Print

Print


Commit in hps-java/src/main/java/org/lcsim/hps/recon/tracking on MAIN
DataTrackerFakeHitDriver.java+122-431.3 -> 1.4
Added ability to create SimTrackerHits

hps-java/src/main/java/org/lcsim/hps/recon/tracking
DataTrackerFakeHitDriver.java 1.3 -> 1.4
diff -u -r1.3 -r1.4
--- DataTrackerFakeHitDriver.java	17 Oct 2012 22:53:35 -0000	1.3
+++ DataTrackerFakeHitDriver.java	9 Nov 2012 01:42:13 -0000	1.4
@@ -17,15 +17,20 @@
 import org.lcsim.detector.identifier.IIdentifier;
 import org.lcsim.detector.tracker.silicon.*;
 import org.lcsim.event.EventHeader;
+import org.lcsim.event.MCParticle;
 import org.lcsim.event.RawTrackerHit;
 import org.lcsim.event.SimTrackerHit;
 import org.lcsim.event.base.BaseRawTrackerHit;
+import org.lcsim.event.base.BaseSimTrackerHit;
 import org.lcsim.fit.helicaltrack.HelicalTrackFit;
 import org.lcsim.fit.helicaltrack.HelicalTrackHit;
 import org.lcsim.fit.helicaltrack.HelixUtils;
 import org.lcsim.fit.helicaltrack.HitIdentifier;
+import org.lcsim.fit.helicaltrack.HitUtils;
 import org.lcsim.geometry.Detector;
 import org.lcsim.geometry.subdetector.BarrelEndcapFlag;
+import org.lcsim.hps.recon.tracking.apv25.SvtReadout;
+import org.lcsim.hps.users.omoreno.SimpleSvtTrigger;
 import org.lcsim.hps.users.phansson.WTrack;
 import org.lcsim.hps.users.phansson.WTrackUtils;
 import org.lcsim.recon.tracking.digitization.sisim.SiTrackerHit;
@@ -52,19 +57,28 @@
     TrackerHitType trackerType = new TrackerHitType(TrackerHitType.CoordinateSystem.GLOBAL, TrackerHitType.MeasurementType.STRIP_1D);
     CoordinateSystem coordinate_system =  trackerType.getCoordinateSystem();
     private HitIdentifier _ID = new HitIdentifier();
+    
     private boolean _doHth = false;
-    private String trackCollectionName = "MCParticle_HelicalTrackFit";
+    boolean createSimTrackerHits = false;
 
-    
+    // Collections
+    List<SimTrackerHit> simHits    = null;
+    List<SiTrackerHit> stripHits1D = null;
+    List<HelicalTrackHit> hths     = null;
+    String trackCollectionName = "MCParticle_HelicalTrackFit";
+    String stripHitOutputCollectionName = "StripClusterer_SiTrackerHitStrip1D";
+    String hthOutputCollectionName = "RotatedHelicalTrackHits";
+    String simTrackerHitCollectionName = "FakeTrackerHits";
+   
     // Subdetector name.
     private String subdetectorName = "Tracker";
-    // Name of StripHit1D output collection.
-    private String stripHitOutputCollectionName = "StripClusterer_SiTrackerHitStrip1D";
-    private String hthOutputCollectionName = "RotatedHelicalTrackHits";
+
+    
     // Various data lists required by digitization.
     private List<String> processPaths = new ArrayList<String>();
     private List<IDetectorElement> processDEs = new ArrayList<IDetectorElement>();
     private Set<SiSensor> processSensors = new HashSet<SiSensor>();
+
     
     //Visualization
     private boolean hideFrame = false;
@@ -99,6 +113,13 @@
     public void setDoHth(boolean debug) {
         this._doHth = debug;
     }
+    
+    /**
+     *  Enable/disable the creation of SimTrackerHits 
+     */
+    public void setCreateSimTrackerHits(boolean createSimTrackerHits){
+        this.createSimTrackerHits = createSimTrackerHits;
+    }
 
 //    public void setReadoutCollectionName(String readoutCollectionName) {
 //        this.readoutCollectionName = readoutCollectionName;
@@ -156,12 +177,8 @@
 
         for (IDetectorElement detectorElement : processDEs) {
             processSensors.addAll(detectorElement.findDescendants(SiSensor.class));
-            
-        
         }
 
-       
-
         // Set the detector to process.
         processPaths.add(subdetectorName);
         
@@ -175,33 +192,43 @@
     @Override
     public void process(EventHeader event) {
         
-        
-        //Make new tracks based on the MC particles
-        List<HelicalTrackFit> tracks = new ArrayList<HelicalTrackFit>();
-        
-        if(event.hasCollection(HelicalTrackFit.class, trackCollectionName)) {
-            tracks = event.get(HelicalTrackFit.class, trackCollectionName);
+        // Obtain the tracks from the event
+        if(!event.hasCollection(HpsHelicalTrackFit.class, trackCollectionName)){
+            this.printDebug("No HpsHelicalTrackFits were found, skipping event");
+            simHits = null;
+            return;
         }
-        
-        
+        List<HpsHelicalTrackFit> tracks = event.get(HpsHelicalTrackFit.class, trackCollectionName);
         
         if(debug) System.out.println(this.getClass().getSimpleName() + ": found " + tracks.size() + " tracks (" + this.trackCollectionName + ")");
+
+        // Instantiate the list of interest 
+        if(this._doHth){
+            this.printDebug("Creating HelicalTrackHits...");
+            hths = new ArrayList<HelicalTrackHit>();
+        } else if(createSimTrackerHits){
+            this.printDebug("Creating SimTrackerHits...");
+            simHits = new ArrayList<SimTrackerHit>();
+        } else { 
+            // Create StripHit1Ds by default
+            this.printDebug("Creating StripHit1D...");
+            stripHits1D = new ArrayList<SiTrackerHit>();
+        }
         
-        //if(tracks.isEmpty()) return;
-        
-        // Make new lists for output.
+        /*// Make new lists for output.
         List<SiTrackerHit> stripHits1D = new ArrayList<SiTrackerHit>();
-        List<HelicalTrackHit> hths = new ArrayList<HelicalTrackHit>();
+        List<HelicalTrackHit> hths = new ArrayList<HelicalTrackHit>(); */
 
         if(debug) System.out.println(this.getClass().getSimpleName() + ": Add hits for " + tracks.size() + " tracks (" + this.trackCollectionName + ")");
-
         
-        for(HelicalTrackFit helix : tracks) {
+        for(HpsHelicalTrackFit helix : tracks) {
             if(debug) System.out.println(this.getClass().getSimpleName() + ": trying to add hits for this track");
 
-            List<SiTrackerHit> stripHits1D_for_track = new ArrayList<SiTrackerHit>();
-            List<HelicalTrackHit> hths_for_track = new ArrayList<HelicalTrackHit>();
+            //List<SiTrackerHit> stripHits1D_for_track = new ArrayList<SiTrackerHit>();
+            //List<HelicalTrackHit> hths_for_track = new ArrayList<HelicalTrackHit>();
 
+            // Get the MC Particle associated with this track
+            MCParticle mcParticle = helix.getMCParticle();
             
             if(debug) {
                 System.out.println(this.getClass().getSimpleName() + helix.toString());
@@ -230,21 +257,23 @@
             
                 if(debug) System.out.println(this.getClass().getSimpleName() + ": add hits to sensor " + sensor.getName() + " at position " + sensor.getGeometry().getPosition().toString());
                 
+                // When creating stereo hits, skip the even sensors
                 if(this._doHth && _ID.getLayer(sensor)%2==0) {
                     if(debug) System.out.println(this.getClass().getSimpleName() + ": this was an even sensor -> skip for HTH production");
                     continue;
                 }
                 
+                // Get the sensor position along the z direction
                 double zposition = sensor.getGeometry().getPosition().z();
 
+                // Extrapolate the track to the sensor
                 Hep3Vector trackPosAtSensor = extrapolator.extrapolateTrack(zposition);
                 
                 if(debug) {
                     System.out.println(this.getClass().getSimpleName() + ": track position at sensor ( z= " + zposition + ") = " + trackPosAtSensor.toString());
                 }
-                
-                
-                
+
+                // Check if the track lies within the sensor
                 boolean isHit = trackUtils.sensorContainsTrack(trackPosAtSensor, sensor);
                 
                 
@@ -259,16 +288,19 @@
                         isBotTrack=true;
                     }
                     if(this._doHth) {
-                        hths_for_track.add(this.makeHelicalTrackHit(sensor, wtrack));
+                        hths.add(this.makeHelicalTrackHit(sensor, wtrack));
+                    } else if(createSimTrackerHits){
+                        // Create a SimTrackerHit at the intersect between a track and a sensor
+                        simHits.add(this.makeSimTrackerHit(sensor, trackPosAtSensor.v(), mcParticle));
                     } else {
-                        stripHits1D_for_track.add(this.makeTrackerHit(sensor, wtrack));             
-                        
+
+                        this.printDebug("Creating a SimTrackerHit at position: " + trackPosAtSensor);
+                        stripHits1D.add(this.makeTrackerHit(sensor, wtrack));             
                     }
                 } else {
                     if(debug) System.out.println(this.getClass().getSimpleName() + ": this helix didn't pass within the sensor so no hit was added");
                 }
                 
-                
             }
                 
             if(isTopTrack) this._h_nstriphits_top.fill(n_hits_top);
@@ -278,22 +310,39 @@
                 System.exit(1);
             }
             
+            /*
             stripHits1D.addAll(stripHits1D_for_track);
             hths.addAll(hths_for_track);
+            */
         }
 
         
+        
         if (debug) {
-            System.out.println(this.getClass().getSimpleName() + ": Produced "  + stripHits1D.size() + " hits for collection " + this.stripHitOutputCollectionName);
-            System.out.println(this.getClass().getSimpleName() + ": Produced "  + hths.size() + " hits for collection " + this.hthOutputCollectionName);
+            if(stripHits1D != null){
+                System.out.println(this.getClass().getSimpleName() + ": Produced "  + stripHits1D.size() + " hits for collection " + this.stripHitOutputCollectionName);
+            }
+            if(hths != null){
+                System.out.println(this.getClass().getSimpleName() + ": Produced "  + hths.size() + " hits for collection " + this.hthOutputCollectionName);
+            }
         }
 
-        // Put output hits into collection.
-        int flag = LCIOUtil.bitSet(0, 31, true); // Turn on 64-bit cell ID.
-//        event.put(this.rawTrackerHitOutputCollectionName, rawHits, RawTrackerHit.class, flag, toString());
-        event.put(this.stripHitOutputCollectionName, stripHits1D, SiTrackerHitStrip1D.class, 0, toString());
-        event.put("RotatedHelicalTrackHits", hths, HelicalTrackHit.class, 0);
+
+        //int flag = LCIOUtil.bitSet(0, 31, true); // Turn on 64-bit cell ID.
+        //event.put(this.rawTrackerHitOutputCollectionName, rawHits, RawTrackerHit.class, flag, toString());
+        // Put the collection of interest into the event
+
+       if(_doHth){
+            event.put(hthOutputCollectionName,      hths,        HelicalTrackHit.class,     0);
+       } else if(createSimTrackerHits){
+            event.put(simTrackerHitCollectionName,  simHits,     SimTrackerHit.class,       0);
+            this.printDebug("SimTrackerHits created: " + simHits.size());
+        } else { 
+            event.put(stripHitOutputCollectionName, stripHits1D, SiTrackerHitStrip1D.class, 0, toString());
+        }
         //event.put("RotatedHelicalTrackHits", rotatedhits, HelicalTrackHit.class, 0);
+        
+       /*
         if (debug) {
             if(event.hasCollection(HelicalTrackHit.class, "RotatedHelicalTrackHits")) {
                 System.out.println(this.getClass().getSimpleName() + ": has hths:");
@@ -310,7 +359,7 @@
                     counts[mod][layer] += SvtUtils.getInstance().getSensor(mod, layer).getReadout().getHits(SiTrackerHit.class).size();
                 }
             }
-        }
+        }*/
     }
     
     
@@ -574,7 +623,27 @@
     }
     
    
-    
+    /**
+     * Create a SimTrackerHit and add it to the corresponding readout
+     * 
+     * @param sensor : sensor on which the hit will be created on
+     * @param trkPositionAtSensor : the position at which the SimTrackerHit will be created at
+     * @param particle : MC particle associated with the track containing the hit
+     * @return SimTrackerHit
+     */
+    private SimTrackerHit makeSimTrackerHit(SiSensor sensor, double[] trkPositionAtSensor, MCParticle particle){
+        
+        double dEdx = 24000/* MIP */*DopedSilicon.ENERGY_EHPAIR;
+        double[] momentum = particle.getMomentum().v();
+        double pathLength = 0;
+        double time = 0;
+        int cellID = (int) TrackerHitUtils.makeSimTrackerHitId(sensor).getValue();
+        // Create a new SimTrackerHit
+        SimTrackerHit simHit = new BaseSimTrackerHit(trkPositionAtSensor, dEdx, momentum, pathLength, time, cellID, particle, null, sensor);
+        // Add it to the sensor readout
+        //sensor.getReadout().addHit(simHit);
+        return simHit;
+    }
     
     
     
@@ -730,11 +799,11 @@
         
         
         plotter_iter = af.createPlotterFactory().create();
-        plotter_iter.createRegions(5,4);
+        plotter_iter.createRegions(6,4);
         plotter_iter.style().dataStyle().fillStyle().setParameter("colorMapScheme", "rainbow");
         plotter_iter.style().statisticsBoxStyle().setVisible(false);
         plotter_itercount = af.createPlotterFactory().create();
-        plotter_itercount.createRegions(5,4);
+        plotter_itercount.createRegions(6,4);
         
         plotter_nstripclusters = af.createPlotterFactory().create();
         plotter_nstripclusters.createRegions(2, 2);
@@ -766,6 +835,16 @@
         }
     }   
     
+    /**
+     * print debug statement
+     * 
+     * @param debugStatement : debug statement
+     */
+    public void printDebug(String debugStatement){
+        if(!debug) return;
+        System.out.println(this.getClass().getSimpleName() + ": " + debugStatement);     
+    }
+    
     
     @Override
     public void endOfData() {
CVSspam 0.2.12


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