View Javadoc

1   /*
2    * DistSurface_Test.java
3    *
4    * Created on July 24, 2007, 9:59 PM
5    *
6    * $Id: DistSurface_Test.java,v 1.1.1.1 2010/04/08 20:38:00 jeremy Exp $
7    */
8   
9   package org.lcsim.recon.tracking.trfdca;
10  
11  import junit.framework.TestCase;
12  import org.lcsim.recon.tracking.trfbase.Surface;
13  import org.lcsim.recon.tracking.trfcyl.SurfCylinder;
14  import org.lcsim.recon.tracking.trfutil.Assert;
15  import org.lcsim.recon.tracking.trfutil.StatusDouble;
16  
17  /**
18   *
19   * @author Norman Graf
20   */
21  public class DistSurface_Test extends TestCase
22  {
23      private boolean debug;
24      /** Creates a new instance of DistSurface_Test */
25      public void testDistSurface()
26      {
27          String component = "DistSurface";
28          String ok_prefix = component+ " (I): ";
29          String error_prefix = component+ " test (E): ";
30          
31          if(debug) System.out.println( ok_prefix
32                  + "--------------- testing component" + component
33                  + ". -------------");
34          //*******************************************
35          
36          // Test data.
37          
38          double[] x     = {  0.,  0.,  2.,   1.,   2.,   3.  };
39          double[] y     = {  0.,  0.,  3.,   2.,   2.,   0.  };
40          double[] z     = {  0., 10., 10.,   0.,   0.,   0.  };
41          double[] phid  = {  0.,  0.,  0.,   0.,   0.,   0.  };
42          double[] tlam  = {  0.,  0.,  0., 0.75, 0.75, 0.75  };
43          double[] wc    = {  0.,  0.,  0.,   0.,   0.,   0.  };
44          double[] xbeam = {  0.,  1.,  1.,  -1.,  -1.,   0.  };
45          double[] ybeam = {  0.,  2.,  2.,  -2.,  -1.,   0.  };
46          double[] bx    = {  0.,  0.,  0.,   0.,   1.,   0.  };
47          double[] by    = {  0.,  0.,  0.,   0.,   1.,   0.  };
48          double[] s     = {  0.,  1., -1., -2.5, -15., 8.75  };
49          double[] r     = {  0.,  0.,  0.,   0.,   0.,  10.  };
50          
51          int n = x.length;
52          
53          
54          if(debug) System.out.println( ok_prefix+" Test constructor");
55          for(int i=0; i<n; ++i)
56          {
57              Surface srf;
58              if(r[i] == 0.)
59              {
60                  srf = new SurfDCA(xbeam[i], ybeam[i], bx[i], by[i]);
61              }
62              else
63              {
64                  srf = new SurfCylinder(r[i]);
65              }
66              DistSurface dist = new DistSurface(x[i], y[i], z[i], phid[i], tlam[i], wc[i], srf);
67              if(debug) System.out.println(dist);
68              
69              StatusDouble s1 = dist.distance();
70              if(debug) System.out.println( i + "\t" + s[i] + "\t" + s1.value() );
71              Assert.assertTrue(s1.status() == 0);
72              Assert.assertTrue(Math.abs(s[i] - s1.value()) < 1.e-6);
73              
74          }
75          
76          //*******************************************
77          if(debug) System.out.println( ok_prefix
78                  + "-------------------- All tests passed. -------------------");
79          //*******************************************
80      }
81      
82  }