View Javadoc

1   /*
2    * Main driver for setting up the hit digitization and clustering
3    *
4    */
5   package org.lcsim.recon.tracking.seedtracker.trackingdrivers.sidloi2;
6   
7   import java.util.ArrayList;
8   import java.util.HashSet;
9   import java.util.List;
10  import java.util.Set;
11  
12  import org.lcsim.detector.IDetectorElement;
13  import org.lcsim.detector.tracker.silicon.SiSensor;
14  import org.lcsim.detector.tracker.silicon.SiTrackerModule;
15  import org.lcsim.event.EventHeader;
16  import org.lcsim.event.RawTrackerHit;
17  import org.lcsim.geometry.Detector;
18  import org.lcsim.recon.tracking.digitization.sisim.CDFSiSensorSim;
19  import org.lcsim.recon.tracking.digitization.sisim.GenericReadoutChip;
20  import org.lcsim.recon.tracking.digitization.sisim.NearestNeighbor;
21  import org.lcsim.recon.tracking.digitization.sisim.PixelHitMaker;
22  import org.lcsim.recon.tracking.digitization.sisim.RawTrackerHitMaker;
23  import org.lcsim.recon.tracking.digitization.sisim.SiDigitizer;
24  import org.lcsim.recon.tracking.digitization.sisim.SiSensorSim;
25  import org.lcsim.recon.tracking.digitization.sisim.SiTrackerHit;
26  import org.lcsim.recon.tracking.digitization.sisim.SiTrackerHitPixel;
27  import org.lcsim.recon.tracking.digitization.sisim.SiTrackerHitStrip1D;
28  import org.lcsim.recon.tracking.digitization.sisim.StripHitMaker;
29  import org.lcsim.recon.tracking.digitization.sisim.config.SimTrackerHitReadoutDriver;
30  import org.lcsim.util.Driver;
31  import org.lcsim.lcio.LCIOConstants;
32  
33  /**
34   *
35   * @author Richard Partridge
36   */
37  public class TrackerHitDriver_sidloi2 extends Driver {
38  
39      List<String> _readouts = new ArrayList<String>();
40      List<String> _process_paths = new ArrayList<String>();
41      List<IDetectorElement> _process_de = new ArrayList<IDetectorElement>();
42      Set<SiSensor> _process_sensors = new HashSet<SiSensor>();
43      Set<SiTrackerModule> _process_modules = new HashSet<SiTrackerModule>();
44      SiDigitizer _strip_digitizer;
45      SiDigitizer _pixel_digitizer;
46      StripHitMaker _strip_clusterer;
47      PixelHitMaker _pixel_clusterer;
48      String _digitizer_name;
49      int _nev = 0;
50  
51      /**
52       * Creates a new instance of TrackerHitDriver
53       */
54      public TrackerHitDriver_sidloi2() {
55  
56          //  Instantiate the sensor simulation classes and set the thresholds
57          SiSensorSim strip_simulation = new CDFSiSensorSim();
58          SiSensorSim pixel_simulation = new CDFSiSensorSim();
59  
60          //  Instantiate the readout chips and set the noise parameters
61          GenericReadoutChip strip_readout = new GenericReadoutChip();
62          strip_readout.setNoiseIntercept(800.);
63          strip_readout.setNoiseSlope(0.);
64          strip_readout.setNoiseThreshold(4000.);
65          strip_readout.setNeighborThreshold(4000.);
66          GenericReadoutChip pixel_readout = new GenericReadoutChip();
67          pixel_readout.setNoiseIntercept(80.);
68          pixel_readout.setNoiseSlope(0.);
69          pixel_readout.setNoiseThreshold(400.);
70          pixel_readout.setNeighborThreshold(400.);
71  
72          //  Instantiate the digitizer that produces the raw hits
73          _strip_digitizer = new RawTrackerHitMaker(strip_simulation, strip_readout);
74          _pixel_digitizer = new RawTrackerHitMaker(pixel_simulation, pixel_readout);
75          _digitizer_name = _strip_digitizer.getName();
76  
77          //  Instantiate a nearest neighbor clustering algorithm for the pixels
78          NearestNeighbor strip_clustering = new NearestNeighbor();
79          strip_clustering.setSeedThreshold(4000.);
80          strip_clustering.setNeighborThreshold(2000.);
81  
82          //  Instantiate a nearest neighbor clustering algorithm for the pixels
83          NearestNeighbor pixel_clustering = new NearestNeighbor();
84          pixel_clustering.setSeedThreshold(400.);
85          pixel_clustering.setNeighborThreshold(400.);
86  
87          //  Instantiate the clusterers and set hit-making parameters
88          _strip_clusterer = new StripHitMaker(strip_simulation, strip_readout, strip_clustering);
89          _strip_clusterer.setMaxClusterSize(10);
90          _strip_clusterer.setCentralStripAveragingThreshold(4);
91          _strip_clusterer.SetOneClusterErr(1 / Math.sqrt(12.));
92          _strip_clusterer.SetTwoClusterErr(1 / 5.0);
93          _strip_clusterer.SetThreeClusterErr(1 / 3.0);
94          _strip_clusterer.SetFourClusterErr(1 / 2.0);
95          _strip_clusterer.SetFiveClusterErr(1 / 1.0);
96          
97          _pixel_clusterer = new PixelHitMaker(pixel_simulation, pixel_readout, pixel_clustering);
98          _pixel_clusterer.SetOneClusterErr(1 / Math.sqrt(12.));
99          _pixel_clusterer.SetTwoClusterErr(1 / 5.0);
100         _pixel_clusterer.SetThreeClusterErr(1 / 3.0);
101         _pixel_clusterer.SetFourClusterErr(1 / 2.0);
102         _pixel_clusterer.SetFiveClusterErr(1 / 1.0);
103 
104         //  Specify the readouts to process
105         _readouts.add("SiVertexBarrelHits");
106         _readouts.add("SiVertexEndcapHits");
107         _readouts.add("SiTrackerBarrelHits");
108         _readouts.add("SiTrackerEndcapHits");
109         _readouts.add("SiTrackerForwardHits");
110 
111         //  Specify the detectors to process
112         _process_paths.add("SiVertexBarrel");
113         _process_paths.add("SiVertexEndcap");
114         _process_paths.add("SiTrackerBarrel");
115         _process_paths.add("SiTrackerEndcap");
116         _process_paths.add("SiTrackerForward");
117 
118     }
119 
120     /**
121      * Initialize whenever we have a new detector
122      * 
123      * @param detector
124      */
125     public void detectorChanged(Detector detector) {
126 
127         super.detectorChanged(detector);
128 
129         // Process detectors specified by path, otherwise process entire detector
130         IDetectorElement detector_de = detector.getDetectorElement();
131         for (String de_path : _process_paths) {
132             _process_de.add(detector_de.findDetectorElement(de_path));
133         }
134 
135         if (_process_de.size() == 0) {
136             _process_de.add(detector_de);
137         }
138 
139         for (IDetectorElement detector_element : _process_de) {
140             _process_sensors.addAll(detector_element.findDescendants(SiSensor.class));
141             _process_modules.addAll(detector_element.findDescendants(SiTrackerModule.class));
142         }
143 
144     }
145 
146     /**
147      * Setup readouts
148      */
149     public void startOfData() {
150         // If readouts not already set, set them up
151         if (_readouts.size() != 0) {
152             super.add(new SimTrackerHitReadoutDriver(_readouts));
153         }
154 
155         super.startOfData();
156         _readouts.clear();
157         _nev = 0;
158     }
159 
160     /**
161      * Main digitization driver.  Creates raw hits, forms clusters, and makes
162      * tracker hits using the sisim package.
163      *
164      * @param event
165      */
166     public void process(EventHeader event) {
167         super.process(event);
168 
169         //  Print out the event number
170 //        System.out.println("TrackerHitDriver processing event " + _nev);
171         _nev++;
172 
173         // Lists of hits
174         List<RawTrackerHit> raw_hits = new ArrayList<RawTrackerHit>();
175         List<SiTrackerHit> hits_strip1D = new ArrayList<SiTrackerHit>();
176         List<SiTrackerHit> hits_pixel = new ArrayList<SiTrackerHit>();
177 
178         for (SiSensor sensor : _process_sensors) {
179  
180             if (sensor.hasStrips()) {
181                 raw_hits.addAll(_strip_digitizer.makeHits(sensor));
182                 hits_strip1D.addAll(_strip_clusterer.makeHits(sensor));
183             }
184 
185 
186             if (sensor.hasPixels()) {
187                 raw_hits.addAll(_pixel_digitizer.makeHits(sensor));
188                 hits_pixel.addAll(_pixel_clusterer.makeHits(sensor));
189             }
190 
191         }
192 
193         //int flag = (1 << LCIOConstants.RTHBIT_HITS | 1 << LCIOConstants.TRAWBIT_ID1); //correct flag for persistence 
194         int flag = (1 << LCIOConstants.TRAWBIT_ID1); //correct flag for persistence 
195         event.put(getRawHitsName(), raw_hits, RawTrackerHit.class, flag, toString());
196         event.put(getStripHits1DName(), hits_strip1D, SiTrackerHitStrip1D.class, 0, toString());
197         event.put(getPixelHitsName(), hits_pixel, SiTrackerHitPixel.class, 0, toString());
198 
199     }
200 
201     /**
202      * Return the name of the raw hits collection
203      *
204      * @return name of raw hits collection
205      */
206     public String getRawHitsName() {
207         return _digitizer_name + "_RawTrackerHits";
208     }
209 
210     /**
211      * Return the name of the strip hits collection
212      *
213      * @return name of strip hits collection
214      */
215     public String getStripHits1DName() {
216         return _strip_clusterer.getName() + "_SiTrackerHitStrip1D";
217     }
218 
219     /**
220      * Return the name of the pixel hits collection
221      *
222      * @return name of pixel hits collection
223      */
224     public String getPixelHitsName() {
225         return _pixel_clusterer.getName() + "_SiTrackerHitPixel";
226     }
227 }