View Javadoc

1   /*
2    * LTrack_Test.java
3    *
4    * Created on July 24, 2007, 4:29 PM
5    *
6    * $Id: LTrack_Test.java,v 1.1.1.1 2010/04/08 20:38:00 jeremy Exp $
7    */
8   
9   package org.lcsim.recon.tracking.trflayer;
10  
11  import junit.framework.TestCase;
12  import org.lcsim.recon.tracking.trfbase.ETrack;
13  import org.lcsim.recon.tracking.trfbase.SurfTest;
14  import org.lcsim.recon.tracking.trfutil.Assert;
15  
16  /**
17   *
18   * @author Norman Graf
19   */
20  public class LTrack_Test extends TestCase
21  {
22      private boolean debug;
23      /** Creates a new instance of LTrack_Test */
24      public void testLTrack()
25      {
26          String component = "LTrack";
27          String ok_prefix = component + " (I): ";
28          String error_prefix = component + " test (E): ";
29          
30          if(debug) System.out.println( ok_prefix
31                  + "---------- Testing component " + component
32                  + ". ----------" );
33          
34          //********************************************************************
35          
36          if(debug) System.out.println( ok_prefix + "Test constructor." );
37          SurfTest stst = new SurfTest(1.0);
38          ETrack tre = new ETrack( stst.newPureSurface() );
39          if(debug) System.out.println("tre= "+tre);
40          Layer ltst = new TLayer();
41          LayerStat lstat = new LayerStat(ltst);
42          lstat.setState(2);
43          //  LTrack trl1 = new LTrack();
44          LTrack trl1 = new LTrack(tre, lstat);
45          if(debug) System.out.println("trl1= "+trl1);
46          //fetch reference to the Etrack...
47          ETrack tmp = trl1.track();
48          if(debug) System.out.println("tmp= "+tmp);
49          //Set this reference to a real Etrack...
50          tmp = tre;
51          if(debug) System.out.println("tmp= "+tmp);
52          trl1.pushStatus(lstat);
53          if(debug) System.out.println( "trl1= "+trl1 );
54          // trl1 should now point to a real track... but it doesn't!
55          LTrack trl2 = new LTrack(trl1);
56          if(debug) System.out.println( "trl2= "+trl2 );
57          
58          //********************************************************************
59          
60          if(debug) System.out.println( ok_prefix + "Test access." );
61          if(debug) System.out.println("\n ***trl1.get_track()= \n"+trl1.track());
62          if(debug) System.out.println("\n ***trl2.get_track()= \n"+trl2.track());
63          Assert.assertTrue( trl1.track().equals(trl2.track()) );
64          LayerStatChain lsc = trl1.statusChain();
65          if(debug) System.out.println("***lsc= \n"+lsc);
66          if(debug) System.out.println("\n "+trl1.status().state() );
67          Assert.assertTrue( trl1.status().state() == 2 );
68          
69          //********************************************************************
70          
71          if(debug) System.out.println( ok_prefix + "Test status manipulation." );
72          Assert.assertTrue( trl1.atValidStatus() );
73          Assert.assertTrue( trl1.status().state() == 2 );
74          if(debug) System.out.println( trl1 );
75          trl1.status().setState(1);
76          if(debug) System.out.println( trl1 );
77          Assert.assertTrue( trl1.status().state() == 1 );
78          // insert 2nd status
79          lstat.setState(2);
80          trl1.pushStatus(lstat);
81          if(debug) System.out.println( trl1 );
82          Assert.assertTrue( trl1.status().state() == 2 );
83          Assert.assertTrue( trl1.setPreviousStatus() );
84          // insert 3rd status
85          lstat.setState(3);
86          trl1.pushStatus(lstat);
87          Assert.assertTrue( ! trl1.atTopStatus() );
88          Assert.assertTrue( trl1.status().state() == 3 );
89          // step up to 2nd status
90          Assert.assertTrue( trl1.setPreviousStatus() );
91          if(debug) System.out.println(trl1.status().state());
92          if(debug) System.out.println("lsc= "+trl1.statusChain());
93          Assert.assertTrue( trl1.status().state() == 2 );
94          // step up to 1st status
95          Assert.assertTrue( trl1.setPreviousStatus() );
96          Assert.assertTrue( ! trl1.setPreviousStatus() );
97          Assert.assertTrue( trl1.atTopStatus() );
98          Assert.assertTrue( trl1.status().state() == 1 );
99          // step down
100         Assert.assertTrue( trl1.setNextStatus() );
101         if(debug) System.out.println("get_state()= "+trl1.status().state());
102         Assert.assertTrue( trl1.status().state() == 2 );
103         Assert.assertTrue( trl1.setNextStatus() );
104         Assert.assertTrue( trl1.status().state() == 3 );
105         Assert.assertTrue( ! trl1.setNextStatus() );
106         // pop last status -- should leave us positioned at 2nd
107         Assert.assertTrue( trl1.popStatus() );
108         Assert.assertTrue( trl1.status().state() == 2 );
109         
110         //********************************************************************
111         
112         if(debug) System.out.println( ok_prefix + "Test propagator status" );
113         Assert.assertTrue( ! trl2.propStat().success() );
114         trl2.propStat().setForward();
115         Assert.assertTrue( trl2.propStat().success() );
116         double s = 123.4;
117         trl2.propStat().setPathDistance(s);
118         Assert.assertTrue( trl2.propStat().pathDistance() == s );
119         
120         if(debug) System.out.println( ok_prefix
121                 + "------------- All tests passed. -------------" );
122         
123         //********************************************************************
124     }
125     
126 }