View Javadoc

1   /*
2    * DetectorSimulator_Test.java
3    *
4    * Created on July 24, 2007, 4:32 PM
5    *
6    * $Id: DetectorSimulator_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.trfutil.Assert;
13  
14  /**
15   *
16   * @author Norman Graf
17   */
18  public class DetectorSimulator_Test extends TestCase
19  {
20      private boolean debug;
21      /** Creates a new instance of DetectorSimulator_Test */
22      public void testDetectorSimulator()
23      {
24           String component = "DetectorSimulator";
25          String ok_prefix = component + " (I): ";
26          String error_prefix = component + " test (E): ";
27          
28          if(debug) System.out.println( ok_prefix
29                  +"---------- Testing component " + component
30                  + ". ----------" );
31          
32          //********************************************************************
33          
34          if(debug) System.out.println( ok_prefix +"Check return status." );
35          Assert.assertTrue( DetSimReturnStatus.OK != null);
36          Assert.assertTrue( DetSimReturnStatus.UNKNOWN_NAME != DetSimReturnStatus.OK );
37          Assert.assertTrue( DetSimReturnStatus.LAYER_MISMATCH != DetSimReturnStatus.OK );
38          
39          //********************************************************************
40          
41          if(debug) System.out.println( ok_prefix +"Check constructor." );
42          Layer lyr1 = new LayerTest(1.0);
43          Layer lyr2 = new LayerTest(2.0);
44          Layer lyr3 = new LayerTest(3.0);
45          LayerSimulator lsim1 = new LayerSimulatorTest(lyr1) ;
46          LayerSimulator lsim2 = new LayerSimulatorTest(lyr2) ;
47          LayerSimulator lsim3 = new LayerSimulatorTest(lyr3) ;
48          
49          Detector det12 = new TwoLayerDetectorTest("LYR1",lyr1,"LYR2",lyr2);
50          Detector det3 = new OneLayerDetectorTest("LYR3",lyr3);
51          if(debug) System.out.println( det12 );
52          if(debug) System.out.println( det3 );
53          TwoLayerDetectorSimulatorTest dsim12 = new TwoLayerDetectorSimulatorTest(det12,"LYR1",lsim1,"LYR2",lsim2);
54          OneLayerDetectorSimulatorTest dsim3 = new OneLayerDetectorSimulatorTest(det3,"LYR3",lsim3);
55          if(debug) System.out.println( dsim12 );
56          if(debug) System.out.println( dsim3 );
57          Assert.assertTrue( dsim12.generators().size() == 2 );
58          Assert.assertTrue( dsim3.generators().size() == 1 );
59          
60          //********************************************************************
61          
62          if(debug) System.out.println( ok_prefix +"Combine detector simulators." );
63          Detector det123 = new TwoSubDetectorTest(det12,det3);
64          if(debug) System.out.println( det123 );
65          TwoSubDetectorSimulatorTest dsim123 = new TwoSubDetectorSimulatorTest(det123,dsim12,dsim3);
66          Assert.assertTrue( dsim123.generators().size() == 3 );
67          if(debug) System.out.println( dsim123 );
68          
69          //********************************************************************
70          
71          if(debug) System.out.println( ok_prefix
72                  +"------------- All tests passed. -------------" );
73          
74          //********************************************************************       
75      }
76      
77  }