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 ForwardDetectorTest extends TestCase
20  {
21      Detector det;
22      ForwardDetector fdet;
23      
24      /** Creates a new instance of ForwardDetectorTest */
25      public ForwardDetectorTest()
26      {}
27      
28      protected void setUp() throws java.lang.Exception
29      {
30          InputStream in = this.getClass().getResourceAsStream("/org/lcsim/geometry/subdetector/ForwardDetectorTest.xml");
31          GeometryReader reader = new GeometryReader();
32          det = reader.read(in);
33          
34          assertTrue( det.getSubdetectors().get("LuminosityMonitor") != null );
35          
36          try
37          {
38              fdet = (ForwardDetector) det.getSubdetectors().get("LuminosityMonitor");
39          }
40          catch ( ClassCastException cce )
41          {
42              throw new RuntimeException("Failed cast to ForwardDetector.");
43          }
44      }
45      
46      public static junit.framework.Test suite()
47      {
48          return new TestSuite(ForwardDetectorTest.class);
49      }
50      
51      public void test_dimensions()
52      {
53          double zmax = fdet.getZMax();
54          double zmin = fdet.getZMin();
55          double orad = fdet.getOuterRadius();
56          double irad = fdet.getInnerRadius();  
57                                  
58          assertEquals(zmin, 2000.0);
59          assertEquals(zmax, zmin + fdet.getLayering().getLayers().getTotalThickness() );
60          assertEquals(orad, 800.0);
61          assertEquals(irad, 0.0);
62      }
63      
64      public void test_beampipe()
65      {
66          double crossing_angle = fdet.getCrossingAngle();
67          double incoming_r = fdet.getIncomingRadius();
68          double outgoing_r = fdet.getOutgoingRadius();
69          
70          assertEquals(crossing_angle, 0.2);
71          assertEquals(incoming_r, 10.0);
72          assertEquals(outgoing_r, 20.0);
73      }
74  }