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.RotationPassiveXYZ;
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 TrdTest
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("TrdTest.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 double x1=760.8757065043884/2;
54 double x2=1272.6157921770439/2;
55 double y1=5544.0/2;
56 double y2=5544.0/2;
57 double z=954.7200000000001/2;
58
59 Trd trd = new Trd("trd",x1,x2,y1,y2,z);
60 LogicalVolume lvTest = new LogicalVolume("lvtrd",trd,dummymat);
61 new PhysicalVolume(
62 new Transform3D(),
63 "pvtrd",
64 lvTest,
65 mom.getLogicalVolume(),
66 0);
67
68 double r=1500;
69 int n = 8;
70
71 for (int i=0; i<n; i++)
72 {
73 double phi=2*Math.PI*((double)i)/n;
74 double zc=-phi-Math.PI/2;
75
76 double x=r*Math.cos(phi);
77 double y=r*Math.sin(phi);
78 ITranslation3D trans = new Translation3D(x,y,0);
79 IRotation3D rotate = new RotationPassiveXYZ(Math.PI/2, 0, zc);
80
81 ITransform3D transform = new Transform3D(trans,rotate);
82
83 String name="pvtrd_rot_"+i;
84 new PhysicalVolume(
85 transform,
86 name,
87 lvTest,
88 mom.getLogicalVolume(),
89 i
90 );
91 new DetectorElement("dummy_"+i,null,nav.getPath("/"+name));
92 }
93 }
94
95 public final IPhysicalVolume createWorld()
96 {
97 Box boxWorld = new Box(
98 "world_box",
99 10.0*m,
100 10.0*m,
101 10.0*m);
102
103 LogicalVolume lvWorld =
104 new LogicalVolume(
105 "world",
106 boxWorld,
107 dummymat);
108
109 IPhysicalVolume pvTop =
110 new PhysicalVolume(
111 null,
112 "world",
113 lvWorld,
114 null,
115 0);
116
117 return pvTop;
118 }
119 }