View Javadoc

1   /*
2    * ThinCylMs_Test.java
3    *
4    * Created on July 24, 2007, 7:54 PM
5    *
6    * $Id: ThinCylMs_Test.java,v 1.1.1.1 2010/04/08 20:38:00 jeremy Exp $
7    */
8   
9   package org.lcsim.recon.tracking.trfcyl;
10  
11  import junit.framework.TestCase;
12  import org.lcsim.recon.tracking.trfbase.ETrack;
13  import org.lcsim.recon.tracking.trfbase.Interactor;
14  import org.lcsim.recon.tracking.trfbase.Surface;
15  import org.lcsim.recon.tracking.trfbase.TrackError;
16  import org.lcsim.recon.tracking.trfbase.TrackVector;
17  import org.lcsim.recon.tracking.trfutil.Assert;
18  
19  /**
20   *
21   * @author Norman Graf
22   */
23  public class ThinCylMs_Test extends TestCase
24  {
25      private boolean debug;
26      /** Creates a new instance of ThinCylMs_Test */
27      public void testThinCylMs()
28      {
29           String component = "ThinCylMs";
30          String ok_prefix = component + " (I): ";
31          String error_prefix = component + " test (E): ";
32          
33          if(debug) System.out.println( ok_prefix
34                  + "---------- Testing component " + component
35                  + ". ----------" );
36          if(debug) System.out.println( ok_prefix + "Test constructor." );
37          ThinCylMs scatterIt = new ThinCylMs(1.0);
38          
39          TrackError initialError = new TrackError();
40          initialError.set(2,2 , 0.0);
41          initialError.set(3,3 , 0.0);
42          initialError.set(4,4 , 0.0);
43          initialError.set(4,3 , 0.0);
44          initialError.set(3,4 , 0.0);
45          
46          TrackVector trv = new TrackVector();
47          trv.set(0 , 1.0);
48          trv.set(1 , 1.0);
49          trv.set(2 , 1.0);
50          trv.set(3 , 1.0);
51          trv.set(4 , 1.0);
52          
53          Surface srf = new SurfCylinder( 20.0 );
54          
55          ETrack tmpTrack = new ETrack( srf, trv, initialError );
56          
57          tmpTrack.setError( initialError );
58          scatterIt.interact( tmpTrack );
59          
60          TrackError finalError = tmpTrack.error();
61          double trueLength = 1.0/Math.cos(1.0)*Math.sqrt(1.0 + 1.0);
62          double thetaSqr = (0.0136)*(1.0/Math.cos(Math.atan(1.0)))*Math.sqrt(trueLength)*
63                  (1 + 0.038*Math.log(trueLength));
64          thetaSqr *= thetaSqr;
65          
66          double alfalf = (1.0 + 1.0);
67          double tlamtlam = (alfalf*alfalf);
68          double cc = (1.0);
69          double ctlam = ((1.0)*(1.0 + 1.0));
70          double tlamc = (ctlam);
71          
72          alfalf *= thetaSqr;
73          tlamtlam *= thetaSqr;
74          cc *= thetaSqr;
75          ctlam *= thetaSqr;
76          tlamc *= thetaSqr;
77          
78          Assert.assertTrue(scatterIt.radLength() == 1.0);
79          Assert.assertTrue((finalError.get(2,2)-alfalf)<0.000001);
80          Assert.assertTrue((finalError.get(3,3)-tlamtlam)<0.000001);
81          Assert.assertTrue((finalError.get(4,4)-cc)<0.000001);
82          Assert.assertTrue((finalError.get(3,4)-ctlam)<0.000001);
83          Assert.assertTrue((finalError.get(4,3)-tlamc)<0.000001);
84          
85          //********************************************************************
86          if(debug) System.out.println(ok_prefix + "Testing clone");
87          ETrack tre1 = new ETrack(tmpTrack);
88          ETrack tre2 = new ETrack(tmpTrack);
89          Assert.assertTrue(tre1.equals(tre2));
90          // clone
91          Interactor scatterIt2 = scatterIt.newCopy();
92          // assert they are not the same object
93          Assert.assertTrue( scatterIt2!=scatterIt );
94          // scatter both tracks
95          scatterIt2.interact(tre2);
96          scatterIt.interact(tre1);
97          // assert they're now equal
98          Assert.assertTrue( tre1.equals(tre2) );
99          // assert they're different from the original track
100         Assert.assertTrue( tre1.notEquals(tmpTrack) );
101         //********************************************************************
102         
103         if(debug) System.out.println( ok_prefix
104                 + "------------- All tests passed. -------------" );
105         
106         //********************************************************************      
107     }
108     
109 }