Commit in hps-java/src/main/java/org/lcsim/hps/recon/tracking on MAIN | |||
TrackerDigiDriver.java | +194 | added 1.1 |
first iteration of standalone SVT digi driver for HPS
diff -N TrackerDigiDriver.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ TrackerDigiDriver.java 18 Jan 2012 00:19:21 -0000 1.1 @@ -0,0 +1,194 @@
+package org.lcsim.hps.recon.tracking; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.lcsim.detector.IDetectorElement; +import org.lcsim.detector.tracker.silicon.SiSensor; +import org.lcsim.detector.tracker.silicon.SiTrackerModule; +import org.lcsim.event.EventHeader; +import org.lcsim.event.RawTrackerHit; +import org.lcsim.geometry.Detector; +import org.lcsim.recon.tracking.digitization.sisim.BasicReadoutChip; +import org.lcsim.recon.tracking.digitization.sisim.CDFSiSensorSim; +import org.lcsim.recon.tracking.digitization.sisim.NearestNeighborRMS; +import org.lcsim.recon.tracking.digitization.sisim.RawTrackerHitMaker; +import org.lcsim.recon.tracking.digitization.sisim.SiDigitizer; +import org.lcsim.recon.tracking.digitization.sisim.SiTrackerHit; +import org.lcsim.recon.tracking.digitization.sisim.SiTrackerHitStrip1D; +import org.lcsim.recon.tracking.digitization.sisim.StripHitMaker; +import org.lcsim.recon.tracking.digitization.sisim.config.SimTrackerHitReadoutDriver; +import org.lcsim.util.Driver; + +/** + * + * @author jeremym + */ +public class TrackerDigiDriver extends Driver +{ + // Collections required by digi algo. + private List<String> readouts = new ArrayList<String>(); + private List<String> processPaths = new ArrayList<String>(); + private List<IDetectorElement> processDEs = new ArrayList<IDetectorElement>(); + private Set<SiSensor> processSensors = new HashSet<SiSensor>(); + private Set<SiTrackerModule> processModules = new HashSet<SiTrackerModule>(); + + // Digi class objects. + private SiDigitizer stripDigitizer; + private StripHitMaker stripClusterer; + private String digitizerName; + + // Collection name parameter. + private String readoutCollectionName = "TrackerHits"; + + // Subdetector name parameter. + private String subdetectorName = "Tracker"; + + // Readout parameters. + private double readoutNoiseIntercept = 270.0; + private double readoutNoiseSlope = 36.0; + private double readoutNoiseThreshold = 4.0; + private double readoutNeighborThreshold = 4.0; + private int readoutNBits = 10; + private int readoutDynamicRange = 40; + + // Clustering parameters. + private double clusterSeedThreshold = 4.0; + private double clusterNeighborThreshold = 3.0; + private double clusterThreshold = 4.0; + private int clusterMaxSize = 10; + private int clusterCentralStripAveragingThreshold = 4; + + // Clustering error parameters. + private static final double clusterErrorMultiplier = 1.0; + private double oneClusterErr = clusterErrorMultiplier / Math.sqrt(12.); + private double twoClusterErr = clusterErrorMultiplier / 5.0; + private double threeClusterErr = clusterErrorMultiplier / 3.0; + private double fourClusterErr = clusterErrorMultiplier / 2.0; + private double fiveClusterErr = clusterErrorMultiplier / 1.0; + + // TODO: All parameters with default arguments above should have setters. + + /** + * Creates a new instance of TrackerHitDriver + */ + public TrackerDigiDriver() + { + // TODO: Move all of this constructor code to startOfData(). + + // Create the sensor simulation. + CDFSiSensorSim stripSim = new CDFSiSensorSim(); + + // Create the readout chips and set the noise parameters. + BasicReadoutChip stripReadout = new BasicReadoutChip(); + stripReadout.setNoiseIntercept(readoutNoiseIntercept); + stripReadout.setNoiseSlope(readoutNoiseSlope); + stripReadout.setNoiseThreshold(readoutNoiseThreshold); + stripReadout.setNeighborThreshold(readoutNeighborThreshold); + stripReadout.setNbits(readoutNBits); + stripReadout.setDynamicRange(readoutDynamicRange); + + // Create the digitizer that produces the raw hits + stripDigitizer = new RawTrackerHitMaker(stripSim, stripReadout); + digitizerName = stripDigitizer.getName(); + + // Create Strip clustering algorithm. + NearestNeighborRMS stripClusteringAlgo = new NearestNeighborRMS(); + stripClusteringAlgo.setSeedThreshold(clusterSeedThreshold); + stripClusteringAlgo.setNeighborThreshold(clusterNeighborThreshold); + stripClusteringAlgo.setClusterThreshold(clusterThreshold); + + // Create the clusterers and set hit-making parameters. + stripClusterer = new StripHitMaker(stripSim, stripReadout, stripClusteringAlgo); + stripClusterer.setMaxClusterSize(clusterMaxSize); + stripClusterer.setCentralStripAveragingThreshold(clusterCentralStripAveragingThreshold); + + // Set the cluster errors. + stripClusterer.SetOneClusterErr(oneClusterErr); + stripClusterer.SetTwoClusterErr(twoClusterErr); + stripClusterer.SetThreeClusterErr(threeClusterErr); + stripClusterer.SetFourClusterErr(fourClusterErr); + stripClusterer.SetFiveClusterErr(fiveClusterErr); + + // Set the readout to process. + readouts.add(readoutCollectionName); + + // Set the detector to process. + processPaths.add(subdetectorName); + } + + public void detectorChanged(Detector detector) + { + System.out.println(detector.getName()); + super.detectorChanged(detector); + + // Process detectors specified by path, otherwise process entire detector + IDetectorElement deDetector = detector.getDetectorElement(); + //System.out.println("detector_de Name =" + deDetector.getName()); + + for (String path : processPaths) { + processDEs.add(deDetector.findDetectorElement(path)); + } + + if (processDEs.size() == 0) { + processDEs.add(deDetector); + } + + for (IDetectorElement detectorElement : processDEs) { + processSensors.addAll(detectorElement.findDescendants(SiSensor.class)); + System.out.println("added " + processSensors.size() + " sensors"); + processModules.addAll(detectorElement.findDescendants(SiTrackerModule.class)); + System.out.println("added " + processModules.size() + " modules"); + } + } + + public void startOfData() + { + // If readouts not already set, set them up. + if (readouts.size() != 0) { + System.out.println("Adding SimTrackerHitIdentifierReadoutDriver with readouts: " + readouts); + super.add(new SimTrackerHitReadoutDriver(readouts)); + } + super.startOfData(); + readouts.clear(); + } + + public void process(EventHeader event) + { + super.process(event); + + List<RawTrackerHit> rawHits = new ArrayList<RawTrackerHit>(); + List<SiTrackerHit> stripHits1D = new ArrayList<SiTrackerHit>(); + + for (SiSensor sensor : processSensors) { + rawHits.addAll(stripDigitizer.makeHits(sensor)); + } + + System.out.println(this.getClass().getSimpleName() + " got " + rawHits.size() + " rawHits"); + + for (SiSensor sensor : processSensors) { + stripHits1D.addAll(stripClusterer.makeHits(sensor)); + } + + System.out.println(this.getClass().getSimpleName() + " got " + stripHits1D.size() + " stripHits"); + + // Put hits into collection. + int flag = 0; + event.put(getRawHitsName(), rawHits, RawTrackerHit.class, flag, toString()); + event.put(getStripHits1DName(), stripHits1D, SiTrackerHitStrip1D.class, 0, toString()); + } + + // TODO: Make this a user parameter. + public String getRawHitsName() + { + return digitizerName + "_RawTrackerHits"; + } + + // TODO: Make this a user parameter. + public String getStripHits1DName() + { + return stripClusterer.getName() + "_SiTrackerHitStrip1D"; + } +}
Use REPLY-ALL to reply to list
To unsubscribe from the LCD-CVS list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=LCD-CVS&A=1