1 package org.lcsim.detector.solids;
2
3 import static org.lcsim.units.clhep.SystemOfUnits.m;
4 import junit.framework.TestCase;
5
6 import org.lcsim.detector.DetectorElement;
7 import org.lcsim.detector.IPhysicalVolume;
8 import org.lcsim.detector.IPhysicalVolumeNavigator;
9 import org.lcsim.detector.IRotation3D;
10 import org.lcsim.detector.ITransform3D;
11 import org.lcsim.detector.ITranslation3D;
12 import org.lcsim.detector.LogicalVolume;
13 import org.lcsim.detector.PhysicalVolume;
14 import org.lcsim.detector.PhysicalVolumeNavigatorStore;
15 import org.lcsim.detector.RotationGeant;
16 import org.lcsim.detector.Transform3D;
17 import org.lcsim.detector.Translation3D;
18 import org.lcsim.detector.converter.heprep.DetectorElementToHepRepConverter;
19 import org.lcsim.detector.material.IMaterial;
20 import org.lcsim.detector.material.MaterialElement;
21 import org.lcsim.util.test.TestUtil.TestOutputFile;
22
23
24
25
26
27
28
29
30 public class TrapTest
31 extends TestCase
32 {
33 private static IMaterial dummymat = new MaterialElement("dummymat",1,1,1.0);
34 IPhysicalVolumeNavigator nav;
35 IPhysicalVolume world;
36
37 public void testTrd() throws Exception
38 {
39 createGeometry();
40 DetectorElementToHepRepConverter.writeHepRep(new TestOutputFile("TrapTest.heprep").getAbsolutePath());
41 }
42
43 public IPhysicalVolume createGeometry()
44 {
45 world = createWorld();
46 nav = PhysicalVolumeNavigatorStore.getInstance().createDefault(world);
47 createSolids(world);
48 return world;
49 }
50
51 public final void createSolids(IPhysicalVolume mom)
52 {
53
54
55
56
57
58
59
60
61
62
63
64
65 double dx1 = 100;
66 double dx2 = 100;
67 double dy1 = 10;
68 double dx3 = 50;
69 double dx4 = 50;
70 double dy2 = 10;
71 double dz = 200;
72 double theta = Math.toRadians(-15);
73 double phi = Math.toRadians(0);
74 double alph1 = Math.toRadians(0);
75 double alph2 = alph1;
76
77
78
79 IRotation3D rotation = new RotationGeant(0,0,0);
80 ITranslation3D translation = new Translation3D(0,0,0);
81 ITransform3D transform = new Transform3D(translation,rotation);
82
83 Trap trap = new Trap("trap",dz,theta,phi,dy1,dx1,dx2,alph1,dy2,dx3,dx4,alph2);
84 LogicalVolume lvTest = new LogicalVolume("lvtrap",trap,dummymat);
85 new PhysicalVolume(
86 transform,
87 "pvtrap",
88 lvTest,
89 mom.getLogicalVolume(),
90 0);
91 new DetectorElement("detrap",null,"/pvtrap");
92
93
94
95 rotation = new RotationGeant(Math.PI/2,0,0);
96 translation = new Translation3D(200,0,0);
97 transform = new Transform3D(translation,rotation);
98
99 new PhysicalVolume(
100 transform,
101 "pvtrap_x",
102 lvTest,
103 mom.getLogicalVolume(),
104 0);
105 new DetectorElement("detrap_x",null,"/pvtrap_x");
106
107
108 rotation = new RotationGeant(Math.PI/2,Math.PI/2,0);
109 translation = new Translation3D(400,0,0);
110 transform = new Transform3D(translation,rotation);
111
112 new PhysicalVolume(
113 transform,
114 "pvtrap_xy",
115 lvTest,
116 mom.getLogicalVolume(),
117 0);
118 new DetectorElement("detrap_xy",null,"/pvtrap_xy");
119
120
121 rotation = new RotationGeant(Math.PI/2,Math.PI/2,Math.PI/2);
122 translation = new Translation3D(600,0,0);
123 transform = new Transform3D(translation,rotation);
124
125 new PhysicalVolume(
126 transform,
127 "pvtrap_xyz",
128 lvTest,
129 mom.getLogicalVolume(),
130 0);
131 new DetectorElement("detrap_xyz",null,"/pvtrap_xyz");
132
133 }
134
135 public final IPhysicalVolume createWorld()
136 {
137 Box boxWorld = new Box(
138 "world_box",
139 10.0*m,
140 10.0*m,
141 10.0*m);
142
143 LogicalVolume lvWorld =
144 new LogicalVolume(
145 "world",
146 boxWorld,
147 dummymat);
148
149 IPhysicalVolume pvTop =
150 new PhysicalVolume(
151 null,
152 "world",
153 lvWorld,
154 null,
155 0);
156
157 return pvTop;
158 }
159 }