View Javadoc

1   package org.lcsim.geometry.compact.converter.lcdd;
2   
3   import java.util.Iterator;
4   import org.jdom.Attribute;
5   import org.jdom.Element;
6   import org.jdom.JDOMException;
7   import org.lcsim.geometry.compact.converter.lcdd.util.LCDD;
8   import org.lcsim.geometry.compact.converter.lcdd.util.Material;
9   import org.lcsim.geometry.compact.converter.lcdd.util.PhysVol;
10  import org.lcsim.geometry.compact.converter.lcdd.util.SensitiveDetector;
11  import org.lcsim.geometry.compact.converter.lcdd.util.Solids;
12  import org.lcsim.geometry.compact.converter.lcdd.util.Structure;
13  import org.lcsim.geometry.compact.converter.lcdd.util.Tube;
14  import org.lcsim.geometry.compact.converter.lcdd.util.Volume;
15  
16  /**
17   *
18   * @author tonyj
19   */
20  class MultiLayerTracker extends LCDDSubdetector
21  {  
22      MultiLayerTracker(Element node) throws JDOMException
23      {
24          super(node); 
25      }
26  
27      public void addToLCDD(LCDD lcdd, SensitiveDetector sens) throws JDOMException
28      {
29          int id = -1;
30          if (node.getAttribute("id") != null)
31              id = node.getAttribute("id").getIntValue();
32          String detectorName = node.getAttributeValue("name");
33  
34          Material air = lcdd.getMaterial("Air");      
35          Solids solids = lcdd.getSolids();
36          Structure structure = lcdd.getStructure();
37  
38          Volume trackingVolume = lcdd.pickMotherVolume(this);
39  
40          int n = 0;
41          for (Iterator i = node.getChildren("layer").iterator(); i.hasNext(); n++)
42          {
43              Element layer = (Element) i.next();
44              String name1 = detectorName+"_layer"+n;
45              Tube tube1 = new Tube(name1);        
46              Volume volume1 = new Volume(name1+"_volume");
47              volume1.setMaterial(air);
48              volume1.setSolid(tube1);
49  
50              int m = 0;
51              double z = layer.getAttribute("outer_z").getDoubleValue();
52              double rmin = layer.getAttribute("inner_r").getDoubleValue();
53              double r = rmin;
54  
55              for (Iterator j = layer.getChildren("slice").iterator(); j.hasNext(); m++)
56              {
57                  Element slice = (Element) j.next();
58                  double w = slice.getAttribute("thickness").getDoubleValue();
59                  Attribute s = slice.getAttribute("sensitive");
60                  boolean sensitive = s != null && s.getBooleanValue();
61  
62                  String name = detectorName+"_layer"+n+"_slice"+m;
63                  Tube tube = new Tube(name);
64                  tube.setZ(2*z);
65                  tube.setRMin(r);
66                  r += w;
67                  tube.setRMax(r);
68                  tube.setDeltaPhi(Math.PI*2);
69                  solids.addContent(tube);
70  
71                  Volume volume = new Volume(name+"_volume");
72                  volume.setMaterial(lcdd.getMaterial(slice.getAttributeValue("material")));
73                  volume.setSolid(tube);
74                  if (sensitive) volume.setSensitiveDetector(sens);
75  
76                  // Set region of slice.
77                  setRegion(lcdd, slice, volume);
78                  
79                  // Set limits of slice.
80                  setLimitSet(lcdd, slice, volume);            
81                  
82                  // Set vis attributes of slice.
83                  setVisAttributes(lcdd, node, volume);
84  
85                  structure.addContent(volume);
86                  PhysVol physvol = new PhysVol(volume);
87                  physvol.addPhysVolID("layer",n);
88                  volume1.addPhysVol(physvol);
89              }
90  
91              // Set vis attributes of individual layers.
92              this.setVisAttributes(lcdd, layer, volume1);
93              
94              tube1.setZ(2*z);
95              tube1.setRMin(rmin);
96              tube1.setRMax(r);
97              tube1.setDeltaPhi(Math.PI*2);
98              PhysVol physvol = new PhysVol(volume1);
99              physvol.addPhysVolID("system",id);
100             /* barrel is 0 from SubdetectorIDDecoder.BARREL */
101             physvol.addPhysVolID("barrel",0);
102             trackingVolume.addPhysVol(physvol);
103             solids.addSolid(tube1);
104 
105             structure.addVolume(volume1);
106         }
107 
108         setCombineHits(node, sens);
109     }
110     
111     public boolean isTracker()
112     {
113         return true;
114     }
115 }