1 package org.lcsim.geometry.compact.converter.lcdd;
2
3 import org.jdom.Element;
4 import org.jdom.JDOMException;
5 import org.lcsim.geometry.compact.converter.lcdd.util.LCDD;
6 import org.lcsim.geometry.compact.converter.lcdd.util.Material;
7 import org.lcsim.geometry.compact.converter.lcdd.util.PhysVol;
8 import org.lcsim.geometry.compact.converter.lcdd.util.Position;
9 import org.lcsim.geometry.compact.converter.lcdd.util.Rotation;
10 import org.lcsim.geometry.compact.converter.lcdd.util.SensitiveDetector;
11 import org.lcsim.geometry.compact.converter.lcdd.util.Tube;
12 import org.lcsim.geometry.compact.converter.lcdd.util.Volume;
13
14
15
16
17
18
19
20 public class TubeSegment
21 extends LCDDSubdetector
22 {
23 public TubeSegment(Element node) throws JDOMException
24 {
25 super(node);
26 }
27
28 void addToLCDD(LCDD lcdd, SensitiveDetector sens) throws JDOMException
29 {
30
31 Volume mother = null;
32 if (isInsideTrackingVolume())
33 {
34 mother = lcdd.getTrackingVolume();
35 }
36 else
37 {
38 mother = lcdd.getWorldVolume();
39 }
40
41
42 String name = node.getAttributeValue("name");
43
44
45 int id = -1;
46 if (node.getAttribute("id") != null)
47 id = node.getAttribute("id").getIntValue();
48
49
50 Material material = lcdd.getMaterial(node.getChild("material").getAttributeValue("name"));
51
52
53 Tube tube = null;
54 if (node.getChild("tubs") != null)
55 tube = new Tube(name + "_tube", node.getChild("tubs"));
56 else
57 throw new RuntimeException("TubeSegment " + name + " is missing required tubs element");
58 lcdd.add(tube);
59
60
61 Volume volume = new Volume(name, tube, material);
62 lcdd.add(volume);
63
64
65 Position position;
66 if (node.getChild("position") != null)
67 position = new Position(name + "_position", node.getChild("position"));
68 else
69 position = new Position(name + "_position");
70 lcdd.add(position);
71
72
73 Rotation rotation = null;
74 if (node.getChild("rotation") != null)
75 rotation = new Rotation(name + "_rotation", node.getChild("rotation"));
76 else
77 rotation = new Rotation(name + "_rotation");
78 lcdd.add(rotation);
79
80
81 setVisAttributes(lcdd, node, volume);
82
83
84 PhysVol tubePV = new PhysVol(volume, mother, position, rotation);
85 tubePV.addPhysVolID("id", id);
86 }
87 }