View Javadoc

1   package org.lcsim.recon.tracking.vsegment.geom.segmenters;
2   
3   import java.util.*;
4   
5   import org.lcsim.detector.IDetectorElement;
6   import org.lcsim.detector.IGeometryInfo;
7   import org.lcsim.detector.IPhysicalVolume;
8   import org.lcsim.detector.solids.Tube;
9   
10  import org.lcsim.recon.tracking.vsegment.geom.AbstractSegmenter;
11  
12  /**
13   *
14   *
15   * @author D. Onoprienko
16   * @version $Id: DiskTrackerToWedgesSegmenter.java,v 1.1 2008/12/06 21:53:43 onoprien Exp $
17   */
18  public class DiskTrackerToWedgesSegmenter extends DiskTrackerSegmenter {
19    
20  // -- Constructors :  ----------------------------------------------------------
21    
22    public DiskTrackerToWedgesSegmenter(String subdetectorName) {
23      super(subdetectorName);
24    }
25    
26  // -- Implementing DiskTrackerSegmenter :  -------------------------------------
27    
28    /**
29     * Return <tt>Segmenter</tt> that handles hits in the given <tt>DetectorElement</tt>.
30     */
31    public AbstractSegmenter assignSegmenter(IDetectorElement de) {
32      
33      checkGeometry();
34      
35      int nRadialSlices;
36      if (_radialSlicesBySuperlayer == null) {
37        IGeometryInfo gInfo = de.getGeometry();
38        Tube solid = (Tube) gInfo.getLogicalVolume().getSolid();
39        double radiusInner = solid.getInnerRadius();
40        double radiusOuter = solid.getOuterRadius();
41        nRadialSlices = (int)Math.round((radiusOuter - radiusInner)/_stripLength);
42      } else {
43        nRadialSlices = _radialSlicesBySuperlayer[getSuperlayer(de)];
44      }
45      
46      int nPhiSlices;
47      if (_phiSlicesBySuperlayer == null) {
48        nPhiSlices = _phiSlices;
49      } else {
50        nPhiSlices = _phiSlicesBySuperlayer[getSuperlayer(de)];
51      }
52     
53      double pitch;
54      if (_pitchBySuperlayer == null) {
55        pitch = _pitch;
56      } else {
57        pitch = _pitchBySuperlayer[getSuperlayer(de)];
58      }
59      
60      boolean left = isInner(de);
61      
62      return new DiskToWedgesSegmenter(de, nRadialSlices, nPhiSlices, pitch, left);
63    }
64  
65  // -- Stereo partners :  -------------------------------------------------------
66    
67    /**
68     * Returns a list of <tt>Sensors</tt> that might contain hits that should be combined
69     * with hits in the <tt>Sensor</tt> whose <tt>sensorID</tt> is supplied as an argument
70     * to form stereo pairs. 
71     */
72    public List<Integer> getStereoPartners(int sensorID) {
73      int partnerDisk = getOtherSideIndex(idToDaughterIndex(sensorID));
74      List<Integer> out = new ArrayList<Integer>(1);
75      out.add((partnerDisk << _daughterPostfixLength) | (sensorID & ~_daughterIdMask));
76      return out;
77    }
78  
79  // -- Setters :  ---------------------------------------------------------------
80    
81    /**
82     * Set strip length.
83     * The actual strip length in each disk will be adjusted to create an integral
84     * number of radial slices.
85     */
86    public void setStripLength(double length) {
87      _radialSlicesBySuperlayer = null;
88      _stripLength = length;
89    }
90    
91    /**
92     * Set the number of radial slices in each superlayer.
93     */
94    public void setNumberOfRadialSlices(int[] nRadialSlices) {
95      //_radialSlicesBySuperlayer = Arrays.copyOf(nRadialSlices, nRadialSlices.length); // Need JDK 1.6
96      _radialSlicesBySuperlayer = nRadialSlices;
97    }
98    
99    /**
100    * Set the number of axial slices in all superlayers.
101    */
102   public void setNumberOfPhiSlices(int nPhiSlices) {
103     _phiSlicesBySuperlayer = null;
104     _phiSlices = nPhiSlices;
105   }
106   
107   /**
108    * Set the number of axial slices in each superlayer.
109    */
110   public void setNumberOfPhiSlices(int[] nPhiSlices) {
111     //_phiSlicesBySuperlayer = Arrays.copyOf(nPhiSlices, nPhiSlices.length); // Need JDK 1.6
112     _phiSlicesBySuperlayer = nPhiSlices;
113   }
114   
115   /**
116    * Set the strip width in all superlayers.
117    */
118   public void setStripWidth(double pitch) {
119     _pitchBySuperlayer = null;
120     _pitch = pitch;
121   }
122   
123   /**
124    * Set the strip width in each superlayer.
125    */
126   public void setStripWidth(double[] pitch) {
127     //_pitchBySuperlayer = Arrays.copyOf(pitch, pitch.length); // Need JDK 1.6
128     _pitchBySuperlayer = pitch;
129   }
130   
131 // -- Helpers :  ---------------------------------------------------------------
132   
133   protected void checkGeometry() {
134     int nDisks = _dElements.size()/4;
135     String m1 = "Disk tracker "+_subdName +" contains "+nDisks +" disks in each endcap, but you only supplied ";
136     if (_radialSlicesBySuperlayer != null && _radialSlicesBySuperlayer.length < nDisks ) {
137       throw new RuntimeException(m1 + "number of radial slices for " + _radialSlicesBySuperlayer.length + " superlayers");
138     } else if (_phiSlicesBySuperlayer != null && _phiSlicesBySuperlayer.length < nDisks ) {
139       throw new RuntimeException(m1 + "number of phi slices for " + _radialSlicesBySuperlayer.length + " superlayers");
140     } else if (_pitchBySuperlayer != null && _pitchBySuperlayer.length < nDisks ) {
141       throw new RuntimeException(m1 + "strip widths for " + _radialSlicesBySuperlayer.length + " superlayers");
142     }
143   }
144     
145 // -- Private parts :  ---------------------------------------------------------
146   
147   double _stripLength;
148   int[] _radialSlicesBySuperlayer;
149 
150   int _phiSlices;
151   int[] _phiSlicesBySuperlayer;
152   
153   double _pitch;
154   double[] _pitchBySuperlayer;
155 }