View Javadoc

1   /*
2    * Propagator_Test.java
3    *
4    * Created on July 24, 2007, 12:01 PM
5    *
6    * $Id: Propagator_Test.java,v 1.1.1.1 2010/04/08 20:38:00 jeremy Exp $
7    */
8   
9   package org.lcsim.recon.tracking.trfbase;
10  
11  import junit.framework.TestCase;
12  import org.lcsim.recon.tracking.trfutil.Assert;
13  
14  /**
15   *
16   * @author Norman Graf
17   */
18  public class Propagator_Test extends TestCase
19  {
20      private boolean debug;
21      /** Creates a new instance of Propagator_Test */
22      public void testPropagator()
23      {
24          String ok_prefix = "Propagator test (I): ";
25          String error_prefix = "Propagator test (E): ";
26          
27          if(debug) System.out.println("------- Testing component Propagator. -------" );
28          
29          //********************************************************************
30          
31          if(debug) System.out.println("Test constructor."  );
32          
33          TestProp tprop = new TestProp();
34          if(debug) System.out.println(tprop );
35          
36          //********************************************************************
37          
38          if(debug) System.out.println("Test default VTrack propagation."  );
39          Surface ptsrf1= new SurfTest(1) ;
40          Surface ptsrf2= new SurfTest(2) ;
41          VTrack trv1 = new VTrack(ptsrf1);
42          VTrack trv2 = new VTrack(trv1);
43          
44          Assert.assertTrue( trv2.surface().equals(ptsrf1) );
45          Assert.assertTrue(! trv2.surface().equals(ptsrf2) );
46          Assert.assertTrue( trv2.vector().equals(trv1.vector()) );
47          if(debug) System.out.println(trv2 );
48          
49          tprop.vecProp(trv2,ptsrf2);
50          if(debug) System.out.println(trv2 );
51          
52          Assert.assertTrue( trv2.surface().equals(ptsrf2) );
53          if(debug) System.out.println(trv2.vector().get(1)+", "+ trv1.vector().get(1));
54          Assert.assertTrue( trv2.vector().get(1) > trv1.vector().get(1) );
55          
56          
57          //********************************************************************
58          
59          if(debug) System.out.println("Test backward VTrack propagation."  );
60          Surface ptsrf3 = new SurfTest(3);
61          VTrack trv3 = new VTrack(trv2);
62          if(debug) System.out.println(trv3 );
63          
64          tprop.vecDirProp(trv3,ptsrf3,PropDir.BACKWARD);
65          if(debug) System.out.println(trv3 );
66          
67          Assert.assertTrue( trv3.surface().equals(ptsrf3) );
68          Assert.assertTrue( trv3.vector().get(1) < trv2.vector().get(1) );
69          
70          
71          //********************************************************************
72          
73          if(debug) System.out.println("Test default ETrack propagation."  );
74          ETrack tre1 = new ETrack(ptsrf1);
75          TrackError err = new TrackError();
76          err.set(0,0,0.01);
77          err.set(1,1,0.02);
78          err.set(2,2,0.03);
79          err.set(3,3,0.04);
80          err.set(4,4,0.05);
81          tre1.setError(err);
82          ETrack tre2 = new ETrack(tre1);
83          tre2.setError(err);
84          
85          Assert.assertTrue( tre2.surface().equals(ptsrf1) );
86          Assert.assertTrue( !tre2.surface().equals(ptsrf2) );
87          Assert.assertTrue( tre2.vector().equals(tre1.vector()) );
88          if(debug) System.out.println(tre2 );
89          tprop.errProp(tre2,ptsrf2);
90          if(debug) System.out.println(tre2 );
91          Assert.assertTrue( tre2.surface().equals(ptsrf2) );
92          Assert.assertTrue( tre2.vector().get(1) > tre1.vector().get(1) );
93          
94          //********************************************************************
95          
96          if(debug) System.out.println("Test backward ETrack propagation."  );
97          ETrack tre3 = new ETrack(tre2);
98          if(debug) System.out.println(tre3 );
99          tprop.errDirProp(tre3,ptsrf3,PropDir.BACKWARD);
100         if(debug) System.out.println(tre3 );
101         Assert.assertTrue( tre3.surface().equals(ptsrf3) );
102         Assert.assertTrue( tre3.vector().get(1) < tre2.vector().get(1) );
103         
104         //********************************************************************
105         
106         if(debug) System.out.println("Test direction reduction." );
107         boolean stat;
108         PropDir dir = PropDir.FORWARD_MOVE;
109         if(debug) System.out.println(dir);
110         dir = Propagator.reduce(dir);
111         if(debug) System.out.println(dir);
112         //  Assert.assertTrue( Propagator.reduce_direction(dir) );
113         //  if(debug) System.out.println(dir);
114         Assert.assertTrue( dir.equals(PropDir.FORWARD) );
115         //  Assert.assertTrue( ! Propagator.reduce_direction(dir) );
116         Assert.assertTrue( dir.equals(PropDir.FORWARD) );
117         dir = PropDir.BACKWARD_MOVE;
118         Assert.assertTrue( Propagator.reduceDirection(dir) );
119         dir = Propagator.reduce(dir);
120         Assert.assertTrue( dir.equals(PropDir.BACKWARD) );
121         Assert.assertTrue( ! Propagator.reduceDirection(dir) );
122         Assert.assertTrue( dir.equals(PropDir.BACKWARD) );
123         dir = PropDir.NEAREST_MOVE;
124         Assert.assertTrue( Propagator.reduceDirection(dir) );
125         dir = Propagator.reduce(dir);
126         Assert.assertTrue( dir.equals(PropDir.NEAREST) );
127         Assert.assertTrue( ! Propagator.reduceDirection(dir) );
128         Assert.assertTrue( dir.equals(PropDir.NEAREST) );
129         
130         //********************************************************************
131         
132         if(debug) System.out.println(ok_prefix+ "------------- All tests passed. -------------" );
133         
134         //********************************************************************        
135     }
136     
137 }