Print

Print


Commit in lcsim/src/org/lcsim/rpc on MAIN
PadDigiAnalysisDriver.java+135added 1.1
start of histogram analysis on RPC pad digi data

lcsim/src/org/lcsim/rpc
PadDigiAnalysisDriver.java added at 1.1
diff -N PadDigiAnalysisDriver.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ PadDigiAnalysisDriver.java	6 Feb 2013 01:43:09 -0000	1.1
@@ -0,0 +1,135 @@
+package org.lcsim.rpc;
+
+import static java.lang.Math.pow;
+import static java.lang.Math.sqrt;
+import hep.aida.ICloud1D;
+import hep.aida.IHistogram1D;
+import hep.physics.vec.BasicHep3Vector;
+import hep.physics.vec.Hep3Vector;
+
+import java.util.List;
+
+import org.lcsim.event.CalorimeterHit;
+import org.lcsim.event.EventHeader;
+import org.lcsim.event.LCRelation;
+import org.lcsim.event.RelationalTable;
+import org.lcsim.event.SimCalorimeterHit;
+import org.lcsim.event.base.BaseRelationalTable;
+import org.lcsim.geometry.IDDecoder;
+import org.lcsim.util.Driver;
+import org.lcsim.util.aida.AIDA;
+
+/**
+ * @author Jeremy McCormick <[log in to unmask]>
+ * @version $Id: PadDigiAnalysisDriver.java,v 1.1 2013/02/06 01:43:09 jeremy Exp $
+ */
+public class PadDigiAnalysisDriver extends Driver
+{
+    // Collection names with defaults.  These can all be overridden via set methods.
+    private String barrelInputCollection = "HcalBarrelHits";
+    private String endcapInputCollection = "HcalEndcapHits";
+    private static String defaultDigiOutputTag = "_pad_digi";
+    private String barrelOutputCollection = barrelInputCollection + defaultDigiOutputTag;
+    private String endcapOutputCollection = endcapInputCollection + defaultDigiOutputTag;
+    private static String defaultRelationsOutputTag = "_relations";
+    private String barrelRelationCollection = barrelOutputCollection + defaultRelationsOutputTag;
+    private String endcapRelationCollection = endcapOutputCollection + defaultRelationsOutputTag;
+    
+    // Histograms
+    AIDA aida = AIDA.defaultInstance();
+    IHistogram1D barrelOutputHitEnergy; 
+    ICloud1D barrelOutputHitsPerEvent;
+    IHistogram1D barrelSimHitsPerDigiHit;    
+    IHistogram1D barrelDigiHitsPerSimHit;
+    IHistogram1D barrelInputDistanceToPadCenter;
+    
+    public void startOfData() {
+        barrelOutputHitEnergy = aida.histogram1D(barrelOutputCollection + ": Hit Energy", 1000, 0., 2.0);
+        barrelOutputHitsPerEvent = aida.cloud1D(barrelOutputCollection + ": Hits Per Event");
+        barrelSimHitsPerDigiHit = aida.histogram1D(barrelOutputCollection + ": Sim Hits Per Digi Hit", 5, 1., 6.);
+        
+        barrelInputDistanceToPadCenter = aida.histogram1D(barrelInputCollection + ": Contrib Distance to Cell Center", 200, 0., 10.);
+        
+        barrelDigiHitsPerSimHit = aida.histogram1D(barrelInputCollection + ": Digi Hits Per Sim Hit", 20, 1., 21.);
+    }
+
+    public void setBarrelInputCollection(String barrelInputCollection)
+    {
+        this.barrelInputCollection = barrelInputCollection;
+    }
+    
+    public void setEndcapInputCollection(String endcapInputCollection)
+    {
+        this.endcapInputCollection = endcapInputCollection;
+    }
+    
+    public void setBarrelOutputCollection(String barrelOutputCollection)
+    {
+        this.barrelOutputCollection = barrelOutputCollection;
+    }
+    
+    public void setEndcapOutputCollection(String endcapOutputCollection)
+    {
+        this.endcapOutputCollection = endcapOutputCollection;
+    }    
+    
+    public void setBarrelRelationCollection(String barrelOutputRelationCollection)
+    {
+        this.barrelRelationCollection = barrelOutputRelationCollection;
+    }
+    
+    public void setEndcapRelationCollection(String endcapOutputRelationCollection)
+    {
+        this.endcapRelationCollection = endcapOutputRelationCollection;
+    }
+    
+    private static BaseRelationalTable<CalorimeterHit, SimCalorimeterHit> createRelationalTable(List<LCRelation> relations) {
+        BaseRelationalTable<CalorimeterHit, SimCalorimeterHit> table = new BaseRelationalTable<CalorimeterHit, SimCalorimeterHit>();
+        for (LCRelation relation : relations) {
+            table.add((CalorimeterHit)relation.getFrom(), (SimCalorimeterHit)relation.getTo());
+        }
+        return table;
+    }
+    
+    public void process(EventHeader event) 
+    {
+        // Input hit lists.
+        List<SimCalorimeterHit> barrelInputHits = event.get(SimCalorimeterHit.class, barrelInputCollection);
+        List<SimCalorimeterHit> endcapInputHits = event.get(SimCalorimeterHit.class, endcapInputCollection);
+        
+        // Output hit lists with digitized pads.
+        List<CalorimeterHit> barrelOutputHits = event.get(CalorimeterHit.class, barrelOutputCollection);
+        List<CalorimeterHit> endcapOutputHits = event.get(CalorimeterHit.class, endcapOutputCollection);
+        
+        // Output relations connecting digi hits to sim hits.
+        List<LCRelation> barrelRelations = event.get(LCRelation.class, barrelRelationCollection);
+        List<LCRelation> endcapRelations = event.get(LCRelation.class, endcapRelationCollection);
+        
+        RelationalTable<CalorimeterHit, SimCalorimeterHit> barrelRelationalTable = createRelationalTable(barrelRelations);
+        RelationalTable<CalorimeterHit, SimCalorimeterHit> endcapRelationalTable = createRelationalTable(endcapRelations);
+        
+        // Barrel digi hits.
+        barrelOutputHitsPerEvent.fill(barrelOutputHits.size());
+        for (CalorimeterHit hit : barrelOutputHits) {
+            barrelOutputHitEnergy.fill(hit.getCorrectedEnergy());
+            barrelSimHitsPerDigiHit.fill(barrelRelationalTable.allFrom(hit).size());
+        }               
+        
+        // Barrel sim hits.
+        IDDecoder barrelDecoder = event.getMetaData(barrelInputHits).getIDDecoder();
+        for (SimCalorimeterHit hit : barrelInputHits) {
+            int ncontribs = hit.getMCParticleCount();
+            barrelDecoder.setID(hit.getCellID());
+            double[] cellPos = barrelDecoder.getPosition();
+            Hep3Vector p1 = new BasicHep3Vector(cellPos[0], cellPos[1], cellPos[2]);
+            for (int i = 0; i < ncontribs; i++) {
+                float[] stepPos = hit.getStepPosition(i);
+                Hep3Vector p2 = new BasicHep3Vector(stepPos[0], stepPos[1], stepPos[2]);
+                double d = sqrt(pow((p1.x() - p2.x()), 2) + pow((p1.y() - p2.y()), 2) + pow((p1.z() - p2.z()), 2)); 
+                barrelInputDistanceToPadCenter.fill(d);
+            }            
+            barrelDigiHitsPerSimHit.fill(barrelRelationalTable.allTo(hit).size());
+        }
+    }
+    
+}
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