1
2
3
4
5
6 package org.lcsim.geometry.compact.converter.lcdd;
7
8 import org.jdom.Element;
9 import org.jdom.JDOMException;
10
11 import org.lcsim.geometry.compact.converter.lcdd.util.LCDD;
12 import org.lcsim.geometry.compact.converter.lcdd.util.Material;
13 import org.lcsim.geometry.compact.converter.lcdd.util.SensitiveDetector;
14 import org.lcsim.geometry.compact.converter.lcdd.util.Solids;
15 import org.lcsim.geometry.compact.converter.lcdd.util.Structure;
16 import org.lcsim.geometry.compact.converter.lcdd.util.PhysVol;
17 import org.lcsim.geometry.compact.converter.lcdd.util.Polycone;
18 import org.lcsim.geometry.compact.converter.lcdd.util.Volume;
19
20
21
22
23
24
25 public class PolyconeSupport extends LCDDSubdetector {
26
27 private Element node;
28
29
30 public PolyconeSupport(Element node) throws JDOMException {
31 super(node);
32 this.node = node;
33 }
34
35 public void addToLCDD(LCDD lcdd, SensitiveDetector sens) throws JDOMException {
36
37
38 Solids solids = lcdd.getSolids();
39 Structure structure = lcdd.getStructure();
40
41
42 String supportName = node.getAttributeValue("name");
43
44
45 Polycone pc = new Polycone(supportName + "_envelope_polycone", 0, 2. * Math.PI, node);
46 solids.addSolid(pc);
47
48
49 Element matElem = node.getChild("material");
50 if (matElem == null) {
51 throw new JDOMException("Required material element not found.");
52 }
53 Material mat = lcdd.getMaterial(matElem.getAttributeValue("name"));
54
55
56 if (mat == null) {
57 throw new JDOMException("Material not found in compact file.");
58 }
59
60
61 Volume vol = new Volume(supportName + "_envelope_volume");
62 vol.setMaterial(mat);
63 vol.setSolid(pc);
64
65
66 setRegion(lcdd, mat, vol);
67
68
69 setVisAttributes(lcdd, node, vol);
70
71
72 structure.addVolume(vol);
73
74
75 Volume motherVolume = lcdd.pickMotherVolume(this);
76
77
78 PhysVol physvol = new PhysVol(vol);
79 motherVolume.addPhysVol(physvol);
80 }
81 }