1
2
3
4
5
6
7 package org.lcsim.geometry.subdetector;
8
9 import hep.graphics.heprep.HepRepProvider;
10 import java.io.IOException;
11 import java.io.InputStream;
12 import junit.framework.TestCase;
13 import junit.framework.TestSuite;
14 import org.jdom.JDOMException;
15 import org.lcsim.geometry.Calorimeter;
16 import org.lcsim.geometry.GeometryReader;
17 import org.lcsim.geometry.compact.Detector;
18 import org.lcsim.util.xml.ElementFactory.ElementCreationException;
19
20 import org.lcsim.geometry.layer.Layering;
21
22
23
24
25
26 public class CylindricalCalorimeterTest extends TestCase
27 {
28 Detector detector;
29 CylindricalBarrelCalorimeter barrel;
30 CylindricalEndcapCalorimeter endcap;
31
32
33 public CylindricalCalorimeterTest()
34 {
35 }
36
37 protected void setUp() throws java.lang.Exception
38 {
39 InputStream in = this.getClass().getResourceAsStream("/org/lcsim/geometry/subdetector/CylindricalCalorimeterTest.xml");
40
41 GeometryReader reader = new GeometryReader();
42 Detector det = reader.read(in);
43
44 assertTrue( det.getSubdetectors().get("EMBarrel") != null );
45 assertTrue( det.getSubdetectors().get("EMEndcap") != null );
46
47 org.lcsim.geometry.compact.Subdetector subdetEMBarrel = det.getSubdetectors().get("EMBarrel");
48 org.lcsim.geometry.compact.Subdetector subdetEMEndcap = det.getSubdetectors().get("EMEndcap");
49
50
51
52 if ( subdetEMBarrel == null )
53 {
54 throw new RuntimeException("EMBarrel failed cast to Subdetector.");
55 }
56
57 if (!( subdetEMBarrel instanceof CylindricalBarrelCalorimeter ))
58 {
59 throw new RuntimeException("EMBarrel is not an instance of CylindricalBarrelCalorimeter.");
60 }
61
62 if ( subdetEMEndcap == null )
63 {
64 throw new RuntimeException("EMEndcap failed cast to Subdetector.");
65 }
66
67 if (!(subdetEMEndcap instanceof CylindricalEndcapCalorimeter ))
68 {
69 throw new RuntimeException("EMBarrel is not an instance of CylindricalBarrelCalorimeter.");
70 }
71
72 barrel = (org.lcsim.geometry.subdetector.CylindricalBarrelCalorimeter) subdetEMBarrel;
73
74 if ( barrel == null )
75 {
76 throw new RuntimeException("Failed cast to CylindricalBarrelCalorimeter.");
77 }
78
79 endcap = (org.lcsim.geometry.subdetector.CylindricalEndcapCalorimeter) subdetEMEndcap;
80
81 if ( endcap == null )
82 {
83 throw new RuntimeException("Failed cast to CylindricalEndcapCalorimeter.");
84 }
85
86 return;
87 }
88
89 public static junit.framework.Test suite()
90 {
91 return new TestSuite(CylindricalCalorimeterTest.class);
92 }
93
94 public void testBarrel()
95 {
96 double zmax = barrel.getZMax();
97 double zmin = barrel.getZMin();
98 double orad = barrel.getOuterRadius();
99 double irad = barrel.getInnerRadius();
100
101 assertEquals(zmax,1795.0);
102 assertEquals(zmin,-1795.0);
103 assertEquals(irad,1270.0);
104 assertEquals(orad,1382.5);
105 assertEquals(barrel.getLayering().getLayers().getTotalThickness(), orad - irad);
106 }
107
108 public void testEndcap()
109 {
110 double zmax = endcap.getZMax();
111 double zmin = endcap.getZMin();
112 double orad = endcap.getOuterRadius();
113 double irad = endcap.getInnerRadius();
114
115 assertEquals(zmax,1792.5);
116 assertEquals(zmin,1680.0);
117 assertEquals(orad,1250.0);
118 assertEquals(irad,200.0);
119 assertEquals(endcap.getLayering().getLayers().getTotalThickness(), zmax - zmin);
120
121
122 }
123 }