View Javadoc

1   package org.lcsim.geometry.subdetector;
2   
3   import hep.graphics.heprep.HepRep;
4   import hep.graphics.heprep.HepRepFactory;
5   import hep.graphics.heprep.HepRepInstance;
6   import hep.graphics.heprep.HepRepInstanceTree;
7   import hep.graphics.heprep.HepRepType;
8   import hep.graphics.heprep.HepRepTypeTree;
9   import org.jdom.Element;
10  import org.jdom.JDOMException;
11  import org.lcsim.detector.converter.heprep.DetectorElementToHepRepConverter;
12  import org.lcsim.geometry.segmentation.GridXYZ;
13  
14  /**
15   * 
16   * @author Tony Johnson
17   */
18  public class CylindricalEndcapCalorimeter extends CylindricalCalorimeter
19  {
20      CylindricalEndcapCalorimeter( Element node ) throws JDOMException
21      {
22          super( node );
23          build( node );
24      }
25  
26      public boolean isEndcap()
27      {
28          return true;
29      }
30  
31      private void build( Element node ) throws JDOMException
32      {
33          Element dimensions = node.getChild( "dimensions" );
34  
35          /** Define subclass-specific outerR, zmin and zmax. */
36          innerR = dimensions.getAttribute( "inner_r" ).getDoubleValue();
37          outerR = dimensions.getAttribute( "outer_r" ).getDoubleValue();
38          minZ = dimensions.getAttribute( "inner_z" ).getDoubleValue();
39          maxZ = minZ + getLayering().getLayers().getTotalThickness();
40          zlength = maxZ - minZ;
41  
42          getLayering().setOffset( minZ );
43      }
44  
45      public void appendHepRep( HepRepFactory factory, HepRep heprep )
46      {        
47          DetectorElementToHepRepConverter.convert( getDetectorElement(), factory, heprep, 2, true, getVisAttributes().getColor() );
48          /*
49          HepRepInstanceTree instanceTree = heprep.getInstanceTreeTop( "Detector", "1.0" );
50          HepRepTypeTree typeTree = heprep.getTypeTree( "DetectorType", "1.0" );
51          HepRepType endcap = typeTree.getType( "Endcap" );
52  
53          HepRepType type = factory.createHepRepType( endcap, getName() );
54          type.addAttValue( "drawAs", "Cylinder" );
55          //type.addAttValue( "color", getVisAttributes().getColor() );
56  
57          setHepRepColor( type );
58  
59          double flip = 1;
60          for ( ;; )
61          {
62              HepRepInstance instance = factory.createHepRepInstance( instanceTree, type );
63              instance.addAttValue( "radius", getInnerRadius() );
64              factory.createHepRepPoint( instance, 0, 0, flip * getZMin() );
65              factory.createHepRepPoint( instance, 0, 0, flip * getZMax() );
66  
67              HepRepInstance instance2 = factory.createHepRepInstance( instanceTree, type );
68              instance2.addAttValue( "radius", getOuterRadius() );
69              factory.createHepRepPoint( instance2, 0, 0, flip * getZMin() );
70              factory.createHepRepPoint( instance2, 0, 0, flip * getZMax() );
71  
72              if ( !getReflect() || flip < 0 )
73                  break;
74              flip = -1;
75          }
76          */
77      }
78  
79      /**
80       * FIXME: This has an implicit assumption that the localPos is that of the layer.
81       */
82      public double[] transformLocalToGlobal( double[] localPos )
83      {
84          double[] globPos = { localPos[ 0 ], localPos[ 1 ], localPos[ 2 ] };
85          GridXYZ gridSeg = ( GridXYZ ) getReadout().getSegmentation();
86  
87          if ( gridSeg != null )
88          {
89              globPos[ 2 ] += gridSeg.getDistanceToSensitive( gridSeg.getLayer() );
90  
91              // int ecFlag = gridSeg.getValue("barrel");
92              if ( gridSeg.getBarrelEndcapFlag().isEndcapSouth() )
93              {
94                  // if (ecFlag == 2)
95                  // {
96                  globPos[ 2 ] = -globPos[ 2 ];
97              }
98          }
99  
100         return globPos;
101     }
102 
103     public double getZLength()
104     {
105         return this.maxZ - this.minZ;
106     }
107 }