View Javadoc

1   /*
2    * ForwardDetectorTest.java
3    *
4    * Created on June 16, 2005, 1:50 PM
5    */
6   
7   package org.lcsim.geometry.subdetector;
8   
9   import java.io.InputStream;
10  import junit.framework.TestCase;
11  import junit.framework.TestSuite;
12  import org.lcsim.geometry.GeometryReader;
13  import org.lcsim.geometry.compact.Detector;
14  
15  /**
16   *
17   * @author jeremym
18   */
19  public class TPCTest extends TestCase
20  {
21      Detector det;
22      TPC tpc;
23      
24      /** Creates a new instance of ForwardDetectorTest */
25      public TPCTest()
26      {}
27      
28      protected void setUp() throws java.lang.Exception
29      {
30          InputStream in = this.getClass().getResourceAsStream("/org/lcsim/geometry/subdetector/TPCTest.xml");
31          GeometryReader reader = new GeometryReader();
32          det = reader.read(in);
33          
34          assertTrue( det.getSubdetectors().get("TPCTest") != null );
35          
36          try
37          {
38              tpc = (TPC) det.getSubdetectors().get("TPCTest");
39          }
40          catch ( ClassCastException cce )
41          {
42              throw new RuntimeException("Failed cast to TPC.");
43          }
44      }
45      
46      public static junit.framework.Test suite()
47      {
48          return new TestSuite(TPCTest.class);
49      }
50      
51      public void test_TPC()
52      {
53          double zmax = tpc.getZMax();
54          double zmin = tpc.getZMin();
55          double orad = tpc.getOuterRadius();
56          double irad = tpc.getInnerRadius();
57          
58          /* dimensions */
59          assertEquals(zmax, 1500.0);
60          assertEquals(zmin, -1500.0);
61          assertEquals(irad, 1000.0);
62          assertEquals(orad, 1100.0);
63  
64          /* layering */
65          assertTrue(tpc.getLayering() != null);
66          assertEquals(tpc.getLayering().getLayerCount(), 10);
67          assertEquals(tpc.getLayering().getLayerStack().getLayer(0).getThickness(), 10.0);
68          assertEquals(tpc.getLayering().getDistanceToLayerSensorMid(0), irad + 5.0);
69      }
70  }