View Javadoc

1   /*
2    * PolyconeSupport.java
3    *
4    * Created on May 3, 2005, 2:55 PM
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   * -reorganize and rename 090220 JM
22   * 
23   * @author jeremym
24   */
25  public class PolyconeSupport extends LCDDSubdetector {
26  
27      private Element node;
28  
29      /** Creates a new instance of PolyconeSupport */
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          // Get the lcdd data structures.
38          Solids solids = lcdd.getSolids();
39          Structure structure = lcdd.getStructure();
40  
41          // Name of support structure.
42          String supportName = node.getAttributeValue("name");
43  
44          // polycone solid
45          Polycone pc = new Polycone(supportName + "_envelope_polycone", 0, 2. * Math.PI, node);
46          solids.addSolid(pc);
47  
48          // Material is required.
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          // Material was not found.
56          if (mat == null) {
57              throw new JDOMException("Material not found in compact file.");
58          }
59  
60          // Create the volume.
61          Volume vol = new Volume(supportName + "_envelope_volume");
62          vol.setMaterial(mat);
63          vol.setSolid(pc);
64          
65          // Set region.
66          setRegion(lcdd, mat, vol);
67  
68          // Set the volume display.
69          setVisAttributes(lcdd, node, vol);
70  
71          // Add the volume to lcdd.
72          structure.addVolume(vol);
73  
74          // Let lcdd pick the mother volume.
75          Volume motherVolume = lcdd.pickMotherVolume(this);
76  
77          // Finally, make the physical volume. (supports have no id)
78          PhysVol physvol = new PhysVol(vol);
79          motherVolume.addPhysVol(physvol);
80      }
81  }