LISTSERV mailing list manager LISTSERV 16.5

Help for HPS-SVN Archives


HPS-SVN Archives

HPS-SVN Archives


HPS-SVN@LISTSERV.SLAC.STANFORD.EDU


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Proportional Font

LISTSERV Archives

LISTSERV Archives

HPS-SVN Home

HPS-SVN Home

HPS-SVN  October 2016

HPS-SVN October 2016

Subject:

r4551 - /java/trunk/users/src/main/java/org/hps/users/omoreno/SvtHitPerformance.java

From:

[log in to unmask]

Reply-To:

Notification of commits to the hps svn repository <[log in to unmask]>

Date:

Mon, 31 Oct 2016 22:46:31 -0000

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (186 lines)

Author: [log in to unmask]
Date: Mon Oct 31 15:46:29 2016
New Revision: 4551

Log:
Analysis driver used to understand the hit performance of the SVT.

Added:
    java/trunk/users/src/main/java/org/hps/users/omoreno/SvtHitPerformance.java   (with props)

Added: java/trunk/users/src/main/java/org/hps/users/omoreno/SvtHitPerformance.java
 =============================================================================
--- java/trunk/users/src/main/java/org/hps/users/omoreno/SvtHitPerformance.java	(added)
+++ java/trunk/users/src/main/java/org/hps/users/omoreno/SvtHitPerformance.java	Mon Oct 31 15:46:29 2016
@@ -0,0 +1,170 @@
+package org.hps.users.omoreno;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import hep.aida.IHistogramFactory;
+import hep.aida.IAnalysisFactory;
+import hep.aida.IHistogram1D;
+import hep.aida.ITree;
+import hep.aida.ref.rootwriter.RootFileStore;
+
+import org.lcsim.detector.tracker.silicon.HpsSiSensor;
+import org.lcsim.event.EventHeader;
+import org.lcsim.event.RawTrackerHit;
+import org.lcsim.geometry.Detector;
+import org.lcsim.recon.tracking.digitization.sisim.SiTrackerHitStrip1D;
+
+/**
+ *
+ */
+public class SvtHitPerformance extends TriggerFilter {
+
+    //---------------//
+    //   Constants   //
+    //---------------//
+    private static final String SUBDETECTOR_NAME = "Tracker";
+
+    //--------------//
+    //--------------//
+
+    // Container for HPS sensor objects
+    private List<HpsSiSensor> sensors = null;
+    private Map<HpsSiSensor, MutableInt> hitMultiplicityMap     = new HashMap<HpsSiSensor, MutableInt>();
+    private Map<HpsSiSensor, MutableInt> clusterMultiplicityMap = new HashMap<HpsSiSensor, MutableInt>();
+
+    //-----------------//
+    //   Collections   //
+    //-----------------//
+    private static final String RAW_HIT_COLLECTION = "SVTRawTrackerHits";
+    private static final String CLUSTER_COLLECTION = "StripClusterer_SiTrackerHitStrip1D";
+
+    //--------------//
+    //--------------//
+
+    //--------------//
+    //   Plotting   //
+    //--------------//
+    private ITree tree = null; 
+    private IHistogramFactory histogramFactory = null; 
+
+    // Raw hits per sensor 
+    private Map<HpsSiSensor, IHistogram1D> rawHitPlots = new HashMap<HpsSiSensor, IHistogram1D>();
+    
+    // Clusters per sensor
+    private Map<HpsSiSensor, IHistogram1D> clusterMultPlots = new HashMap<HpsSiSensor, IHistogram1D>();
+
+    //--------------//
+    //--------------//
+
+    public void detectorChanged(Detector detector) { 
+
+        // Instantiate the tree and histogram factory
+        tree = IAnalysisFactory.create().createTreeFactory().create();
+        histogramFactory = IAnalysisFactory.create().createHistogramFactory(tree);
+
+        // Get the HpsSiSensor objects from the tracker detector element
+        sensors = detector.getSubdetector(SUBDETECTOR_NAME).getDetectorElement().findDescendants(HpsSiSensor.class);
+
+        // Associate plots with each of the sensors.
+        for (HpsSiSensor sensor : sensors) {
+
+            String sensorName = sensor.getName();
+
+            // Book a histogram of the raw hit multiplicity for each of the sensors. 
+            this.rawHitPlots.put(sensor, 
+                    histogramFactory.createHistogram1D(sensorName + " - Raw Hit Multiplicity", 101, 0, 100));
+            this.clusterMultPlots.put(sensor, 
+                    histogramFactory.createHistogram1D(sensorName + " - Cluster Multiplicity", 101, 0, 100));
+            
+            this.hitMultiplicityMap.put(sensor, new MutableInt());
+            this.clusterMultiplicityMap.put(sensor, new MutableInt());
+        }
+    }
+
+    public void process(EventHeader event) { 
+
+        super.process(event);
+        
+        if (!triggerFound) return; 
+        
+        // If the event doesn't have a collection of raw hits, skip it. This 
+        // should never happen.  If an event doesn't have any raw hits 
+        // from the SVT, an empty collection is still placed into the event.
+        if (!event.hasCollection(RawTrackerHit.class, RAW_HIT_COLLECTION)) return;
+
+        // Get the list of raw hits from the event. 
+        List<RawTrackerHit> rawHits = event.get(RawTrackerHit.class, RAW_HIT_COLLECTION);
+
+        // Reset the map keeping count of the hits per sensor.
+        this.resetMultiplicityMaps();
+
+        // Loop through all of the hits in the event and calculate various quantities.
+        for (RawTrackerHit rawHit : rawHits) { 
+
+            // Get the sensor associated with this hit.
+            HpsSiSensor sensor = (HpsSiSensor) rawHit.getDetectorElement();
+
+            // Increament the hit count on that sensor
+            this.hitMultiplicityMap.get(sensor).increment();
+        }
+
+        // Fill the hit multiplicity plots.
+        for (Map.Entry<HpsSiSensor, MutableInt> entry : this.hitMultiplicityMap.entrySet()) { 
+            rawHitPlots.get(entry.getKey()).fill(entry.getValue().get());
+        }
+        
+        // Check if the event has a collection of clusters.  If not, stop processing
+        // the event.
+        if (!event.hasCollection(SiTrackerHitStrip1D.class, CLUSTER_COLLECTION)) return;
+
+        // Get the collection of clusters from the event.
+        List<SiTrackerHitStrip1D> clusters = event.get(SiTrackerHitStrip1D.class, CLUSTER_COLLECTION);
+        
+        // Loop through all of the clusters in the event and calculate various quantities.
+        for (SiTrackerHitStrip1D cluster : clusters) { 
+
+            // Get the sensor associated with this cluster.
+            HpsSiSensor sensor = (HpsSiSensor) cluster.getRawHits().get(0).getDetectorElement();
+            
+            // Increment the cluster count on that sensor
+            this.clusterMultiplicityMap.get(sensor).increment();
+        }
+        
+        // Fill the cluster multiplicity plots.
+        for (Map.Entry<HpsSiSensor, MutableInt> entry : this.clusterMultiplicityMap.entrySet()) { 
+            clusterMultPlots.get(entry.getKey()).fill(entry.getValue().get());
+        }
+    }
+
+    @Override
+    public void endOfData(){
+        String rootFile = "hit_performance.root";
+        RootFileStore store = new RootFileStore(rootFile);
+        try {
+            store.open();
+            store.add(tree);
+            store.close(); 
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
+
+    private void resetMultiplicityMaps() { 
+        for (Map.Entry<HpsSiSensor, MutableInt> entry : this.hitMultiplicityMap.entrySet()) { 
+            entry.getValue().reset();;
+        }
+        for (Map.Entry<HpsSiSensor, MutableInt> entry : this.clusterMultiplicityMap.entrySet()) { 
+            entry.getValue().reset();;
+        }
+    }
+
+    class MutableInt { 
+        int value = 0; 
+        public void increment() { ++value; }
+        public int get() { return value; }
+        public void reset() { value = 0; }
+    }
+}

Top of Message | Previous Page | Permalink

Advanced Options


Options

Log In

Log In

Get Password

Get Password


Search Archives

Search Archives


Subscribe or Unsubscribe

Subscribe or Unsubscribe


Archives

November 2017
August 2017
July 2017
January 2017
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
December 2013
November 2013

ATOM RSS1 RSS2



LISTSERV.SLAC.STANFORD.EDU

Secured by F-Secure Anti-Virus CataList Email List Search Powered by the LISTSERV Email List Manager

Privacy Notice, Security Notice and Terms of Use