View Javadoc

1   package org.lcsim.detector.converter.compact;
2   
3   import org.lcsim.geometry.compact.Detector;
4   import org.lcsim.geometry.compact.Subdetector;
5   import org.lcsim.geometry.subdetector.TubeSegment;
6   import org.lcsim.detector.IPhysicalVolume;
7   import org.lcsim.detector.material.IMaterial;
8   import org.lcsim.detector.ILogicalVolume;
9   import org.lcsim.detector.solids.Tube;
10  import org.lcsim.detector.PhysicalVolume;
11  import org.lcsim.detector.IPhysicalVolumeNavigator;
12  import org.lcsim.detector.PhysicalVolumeNavigatorStore;
13  import org.lcsim.detector.IPhysicalVolumePath;
14  import org.lcsim.detector.DetectorElement;
15  import org.lcsim.detector.LogicalVolume;
16  
17  public class TubeSegmentConverter extends AbstractSubdetectorConverter implements ISubdetectorConverter
18  {
19  
20      public void convert( Subdetector subdet, Detector detector )
21      {
22          // Cast to subtype.
23          TubeSegment tube = ( TubeSegment ) subdet;
24  
25          // Get the world volume.
26          IPhysicalVolume world = detector.getWorldVolume();
27  
28          // Get the world volume fill material.
29          IMaterial matWorld = world.getLogicalVolume().getMaterial();
30  
31          // Create the Subdetector's envelope LogicalVolume.
32          ILogicalVolume envelope = buildEnvelope( tube, matWorld );
33  
34          // Create the PhysicalVolume.
35          new PhysicalVolume( tube.getTransform(), tube.getName(), envelope, world.getLogicalVolume(), subdet
36                  .getSystemID() );
37  
38          // Setup the geometry.
39          IPhysicalVolumeNavigator nav = PhysicalVolumeNavigatorStore.getInstance().getDefaultNavigator();
40          IPhysicalVolumePath path = nav.getPath( tube.getName() );
41  
42          // Create the Subdetector's DetectorElement.
43          if ( tube.getDetectorElement() != null )
44          {
45              ( ( DetectorElement ) tube.getDetectorElement() ).setSupport( path );
46          }
47      }
48  
49      private ILogicalVolume buildEnvelope( TubeSegment tubeSeg, IMaterial material )
50      {
51          Tube tube = new Tube( tubeSeg.getName() + "_envelope_tube",
52                                tubeSeg.getInnerRadius(),
53                                tubeSeg.getOuterRadius(),
54                                tubeSeg.getZHalfLength() );
55  
56          LogicalVolume logvol = new LogicalVolume( tubeSeg.getName() + "_envelope", tube, material );
57  
58          return logvol;
59      }
60  
61      public Class getSubdetectorType()
62      {
63          return TubeSegment.class;
64      }
65  }