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  November 2014

HPS-SVN November 2014

Subject:

r1599 - /java/trunk/users/src/main/java/org/hps/users/jeremym/EcalRawModeMipAnalysisDriver.java

From:

[log in to unmask]

Reply-To:

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

Date:

Wed, 26 Nov 2014 23:19:50 -0000

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (148 lines)

Author: [log in to unmask]
Date: Wed Nov 26 15:19:47 2014
New Revision: 1599

Log:
Just messing around with MIP analysis of ECAL data.

Added:
    java/trunk/users/src/main/java/org/hps/users/jeremym/EcalRawModeMipAnalysisDriver.java   (with props)

Added: java/trunk/users/src/main/java/org/hps/users/jeremym/EcalRawModeMipAnalysisDriver.java
 =============================================================================
--- java/trunk/users/src/main/java/org/hps/users/jeremym/EcalRawModeMipAnalysisDriver.java	(added)
+++ java/trunk/users/src/main/java/org/hps/users/jeremym/EcalRawModeMipAnalysisDriver.java	Wed Nov 26 15:19:47 2014
@@ -0,0 +1,132 @@
+package org.hps.users.jeremym;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
+import org.hps.conditions.database.TableConstants;
+import org.hps.conditions.ecal.EcalChannel;
+import org.hps.conditions.ecal.EcalChannel.EcalChannelCollection;
+import org.hps.conditions.ecal.EcalChannelConstants;
+import org.hps.conditions.ecal.EcalConditions;
+import org.lcsim.conditions.ConditionsManager;
+import org.lcsim.detector.converter.compact.EcalCrystal;
+import org.lcsim.event.EventHeader;
+import org.lcsim.event.EventHeader.LCMetaData;
+import org.lcsim.event.RawTrackerHit;
+import org.lcsim.geometry.Detector;
+import org.lcsim.geometry.subdetector.HPSEcal3;
+import org.lcsim.util.Driver;
+
+/**
+ * This is an analysis of ECAL cosmics using raw mode (window) data
+ * which has 100 samples of 4 ns.
+ * 
+ * @author Jeremy McCormick <[log in to unmask]>
+ */
+public class EcalRawModeMipAnalysisDriver extends Driver {
+    
+    EcalConditions conditions;
+    EcalChannelCollection channels;
+    double sigmaThreshold = 3;
+    String inputHitCollectionName = "EcalReadoutHits";
+    String ecalName = "Ecal";
+    
+    int maxMipCandidates = Integer.MIN_VALUE;
+    int nMipEvents = 0;
+    HPSEcal3 ecal  = null;
+    
+    public void detectorChanged(Detector detector) {
+        conditions = ConditionsManager.defaultInstance().getCachedConditions(EcalConditions.class, TableConstants.ECAL_CONDITIONS).getCachedData();        
+        channels = conditions.getChannelCollection();
+        ecal = (HPSEcal3)detector.getSubdetector(ecalName);
+        if (ecal == null) {
+            throw new RuntimeException("The ECAL subdetector has the wrong type: " + detector.getSubdetector(ecalName).getClass().getCanonicalName());
+        }
+    }
+    
+    public void setSigmaThreshold(double sigmaThreshold) {
+        this.sigmaThreshold = sigmaThreshold;
+    }
+    
+    public void process(EventHeader event) {
+        
+        if (event.hasCollection(RawTrackerHit.class, inputHitCollectionName)) {
+            
+            List<RawTrackerHit> hits = event.get(RawTrackerHit.class, "EcalReadoutHits");
+            LCMetaData meta = event.getMetaData(hits);                        
+            
+            // Make a map of hits with at least one ADC value above threshold.
+            Map<Long, RawTrackerHit> mipCandidateHits = createMipCandidateHits(hits);
+            System.out.println("found " + mipCandidateHits.size() + " MIP candidate hits");
+            
+            // Filter the hit list based on whether there are neighboring hits.
+            List<RawTrackerHit> mipHits = filterHits(mipCandidateHits);            
+            System.out.println("filtered to " + mipHits.size() + " hits");
+            
+            if (mipCandidateHits.size() > 0) {
+                ++nMipEvents;
+            }
+            if (mipCandidateHits.size() > maxMipCandidates) {
+                maxMipCandidates = mipCandidateHits.size();                 
+            }
+            
+            // Write hits to output collection.
+            event.put(inputHitCollectionName + "_MipHits", mipHits, RawTrackerHit.class, meta.getFlags(), ecal.getReadout().getName());
+        }        
+    }
+    
+    public Map<Long, RawTrackerHit> createMipCandidateHits(List<RawTrackerHit> hitList) {
+        Map<Long, RawTrackerHit> mipCandidateHits = new HashMap<Long, RawTrackerHit>();
+        for (RawTrackerHit hit : hitList) {
+            EcalChannel channel = channels.findGeometric(hit.getCellID());
+            if (channel != null) {
+                EcalChannelConstants channelConstants = conditions.getChannelConstants(channel);
+                double pedestal = channelConstants.getCalibration().getPedestal();
+                double noise = channelConstants.getCalibration().getNoise(); 
+                adcLoop: for (short adcValue : hit.getADCValues()) {
+                    if (adcValue - (pedestal + sigmaThreshold * noise) > 0) {
+                        mipCandidateHits.put(hit.getCellID(), hit);
+                        break adcLoop;
+                    }
+                }
+            }
+        }
+        return mipCandidateHits;
+    }
+    
+    public List<RawTrackerHit> filterHits(Map<Long, RawTrackerHit> mipCandidateHits) {
+        List<RawTrackerHit> hitList = new ArrayList<RawTrackerHit>();
+        for (Entry<Long, RawTrackerHit> entry : mipCandidateHits.entrySet()) {                        
+            RawTrackerHit hit = entry.getValue();
+            EcalCrystal crystal = (EcalCrystal)hit.getDetectorElement();
+            if (crystal == null) {
+                throw new RuntimeException("No crystal geometry object is assigned to hit.");
+            }            
+            Set<Long> neighborHitIDs = findNeighborHitIDs(hit, mipCandidateHits); 
+            if (neighborHitIDs.size() > 0) {
+                hitList.add(hit);
+            }
+        }
+        return hitList;
+    }
+    
+    Set<Long> findNeighborHitIDs(RawTrackerHit hit, Map<Long, RawTrackerHit> mipCandidateHits) {
+        Set<Long> neigbhors = ecal.getNeighborMap().get(hit.getCellID());
+        Set<Long> neighborHitIDs = new HashSet<Long>();
+        for (long neighborID : neigbhors) {
+            if (mipCandidateHits.containsKey(neighborID)) {
+                neighborHitIDs.add(neighborID);
+            }
+        }
+        return neighborHitIDs;
+    }
+    
+    public void endOfData() {
+        System.out.println("maxMipCandidates = " + maxMipCandidates + " @ " + sigmaThreshold + " sigma in " + nMipEvents + " with at least one MIP candidate");
+    }
+}

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