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

HPS-SVN December 2014

Subject:

r1650 - in /java/trunk/users/src/main/java/org/hps/users/jeremym: EcalADCProfilePlotsDriver.java EcalADCSignalPlotsDriver.java EcalCosmicClusterDriver.java EcalCosmicClusterPlotsDriver.java EcalCosmicHitSelectionDriver.java

From:

[log in to unmask]

Reply-To:

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

Date:

Fri, 5 Dec 2014 01:25:34 -0000

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (333 lines)

Author: [log in to unmask]
Date: Thu Dec  4 17:25:29 2014
New Revision: 1650

Log:
Updates from work on ECAL cosmics analysis.

Added:
    java/trunk/users/src/main/java/org/hps/users/jeremym/EcalADCProfilePlotsDriver.java
    java/trunk/users/src/main/java/org/hps/users/jeremym/EcalCosmicClusterPlotsDriver.java
    java/trunk/users/src/main/java/org/hps/users/jeremym/EcalCosmicHitSelectionDriver.java
Removed:
    java/trunk/users/src/main/java/org/hps/users/jeremym/EcalADCSignalPlotsDriver.java
Modified:
    java/trunk/users/src/main/java/org/hps/users/jeremym/EcalCosmicClusterDriver.java

Added: java/trunk/users/src/main/java/org/hps/users/jeremym/EcalADCProfilePlotsDriver.java
 =============================================================================
--- java/trunk/users/src/main/java/org/hps/users/jeremym/EcalADCProfilePlotsDriver.java	(added)
+++ java/trunk/users/src/main/java/org/hps/users/jeremym/EcalADCProfilePlotsDriver.java	Thu Dec  4 17:25:29 2014
@@ -0,0 +1,62 @@
+package org.hps.users.jeremym;
+
+import hep.aida.IAnalysisFactory;
+import hep.aida.IProfile1D;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.hps.conditions.database.TableConstants;
+import org.hps.conditions.ecal.EcalChannel;
+import org.hps.conditions.ecal.EcalChannel.EcalChannelCollection;
+import org.hps.conditions.ecal.EcalConditions;
+import org.lcsim.conditions.ConditionsManager;
+import org.lcsim.event.EventHeader;
+import org.lcsim.event.RawTrackerHit;
+import org.lcsim.geometry.Detector;
+import org.lcsim.util.Driver;
+import org.lcsim.util.aida.AIDA;
+
+/**
+ * @author Jeremy McCormick <[log in to unmask]>
+ */
+public class EcalADCProfilePlotsDriver extends Driver {
+
+    EcalConditions conditions = null;
+    EcalChannelCollection channels = null;
+    Map<EcalChannel, IProfile1D> adcProfiles = new HashMap<EcalChannel, IProfile1D>();       
+    AIDA aida = AIDA.defaultInstance();
+    IAnalysisFactory analysisFactory = aida.analysisFactory();
+    String inputHitsCollectionName = "EcalReadoutHits";
+    
+    public void setInputHitsCollectionName(String inputHitsCollectionName) {
+        this.inputHitsCollectionName = inputHitsCollectionName;
+    }
+
+    public void detectorChanged(Detector detector) {
+        conditions = ConditionsManager.defaultInstance().getCachedConditions(EcalConditions.class, TableConstants.ECAL_CONDITIONS).getCachedData();
+        channels = conditions.getChannelCollection();
+        for (EcalChannel channel : conditions.getChannelCollection()) {            
+            adcProfiles.put(channel, aida.profile1D(inputHitsCollectionName + "/ : ADC Values : " + String.format("%03d", channel.getChannelId()), 100, 0, 100));
+        }
+    }
+
+    public void process(EventHeader event) {                       
+        if (event.hasCollection(RawTrackerHit.class, inputHitsCollectionName)) {
+            List<RawTrackerHit> hits = event.get(RawTrackerHit.class, inputHitsCollectionName);
+            for (RawTrackerHit hit : hits) {
+                EcalChannel channel = channels.findGeometric(hit.getCellID());                
+                if (channel != null) {                    
+                    IProfile1D profile = adcProfiles.get(channel);                                        
+                    for (int adcIndex = 0; adcIndex < hit.getADCValues().length; adcIndex++) {
+                        // Fill the Profile1D with ADC value.
+                        profile.fill(adcIndex, hit.getADCValues()[adcIndex]);
+                    }                    
+                } else {
+                    System.err.println("EcalChannel not found for cell ID 0x" + String.format("%08d", Long.toHexString(hit.getCellID())));
+                }
+            }
+        }
+    }
+}

Modified: java/trunk/users/src/main/java/org/hps/users/jeremym/EcalCosmicClusterDriver.java
 =============================================================================
--- java/trunk/users/src/main/java/org/hps/users/jeremym/EcalCosmicClusterDriver.java	(original)
+++ java/trunk/users/src/main/java/org/hps/users/jeremym/EcalCosmicClusterDriver.java	Thu Dec  4 17:25:29 2014
@@ -26,9 +26,10 @@
  * @author Jeremy McCormick <[log in to unmask]>
  * @author Tim "THammer" Nelson <[log in to unmask]>
  */
+// TODO: Add output collection of RawTrackerHits.
 public class EcalCosmicClusterDriver extends Driver {
 
-    String inputHitCollectionName = "SelectedEcalCalHits";
+    String inputHitCollectionName = "EcalCosmicCalHits";
     String outputClusterCollectionName = "EcalCosmicClusters";
     String ecalName = "Ecal";
     HPSEcal3 ecal = null;
@@ -91,7 +92,7 @@
             if (clusterCollection.size() > 0) {
                 int flags = 1 << LCIOConstants.CLBIT_HITS;                
                 event.put(outputClusterCollectionName, clusterCollection, Cluster.class, flags);
-                //System.out.println("added cluster to " + outputClusterCollectionName + " with size " + clusterCollection.size());
+                //System.out.println("added " + clusterCollection.size() + " clusters to " + outputClusterCollectionName);
             } else {
                 throw new NextEventException();
             }

Added: java/trunk/users/src/main/java/org/hps/users/jeremym/EcalCosmicClusterPlotsDriver.java
 =============================================================================
--- java/trunk/users/src/main/java/org/hps/users/jeremym/EcalCosmicClusterPlotsDriver.java	(added)
+++ java/trunk/users/src/main/java/org/hps/users/jeremym/EcalCosmicClusterPlotsDriver.java	Thu Dec  4 17:25:29 2014
@@ -0,0 +1,87 @@
+package org.hps.users.jeremym;
+
+import hep.aida.IAnalysisFactory;
+import hep.aida.IProfile1D;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.hps.conditions.database.TableConstants;
+import org.hps.conditions.ecal.EcalChannel;
+import org.hps.conditions.ecal.EcalChannel.EcalChannelCollection;
+import org.hps.conditions.ecal.EcalConditions;
+import org.lcsim.conditions.ConditionsManager;
+import org.lcsim.event.CalorimeterHit;
+import org.lcsim.event.Cluster;
+import org.lcsim.event.EventHeader;
+import org.lcsim.event.RawTrackerHit;
+import org.lcsim.geometry.Detector;
+import org.lcsim.util.Driver;
+import org.lcsim.util.aida.AIDA;
+
+/**
+ * Create ADC value plots from the cosmic clusters.
+ * @author Jeremy McCormick <[log in to unmask]>
+ */
+public class EcalCosmicClusterPlotsDriver extends Driver {
+
+    EcalConditions conditions = null;
+    EcalChannelCollection channels = null;
+    Map<EcalChannel, IProfile1D> adcProfiles = new HashMap<EcalChannel, IProfile1D>();
+    AIDA aida = AIDA.defaultInstance();
+    IAnalysisFactory analysisFactory = aida.analysisFactory();
+    String inputClusterCollectionName = "EcalCosmicClusters";
+    String rawHitsCollectionName = "EcalCosmicReadoutHits";
+
+    public void setInputHitsCollectionName(String inputClusterCollectionName) {
+        this.inputClusterCollectionName = inputClusterCollectionName;
+    }
+    
+    public void setRawHitsCollectionName(String rawHitsCollectionName) {
+        this.rawHitsCollectionName = rawHitsCollectionName;
+    }
+
+    public void detectorChanged(Detector detector) {
+        conditions = ConditionsManager.defaultInstance().getCachedConditions(EcalConditions.class, TableConstants.ECAL_CONDITIONS).getCachedData();
+        channels = conditions.getChannelCollection();
+        for (EcalChannel channel : conditions.getChannelCollection()) {
+            adcProfiles.put(channel, aida.profile1D(inputClusterCollectionName + "/ADC Values : " + String.format("%03d", channel.getChannelId()), 100, 0, 100));
+        }
+    }
+
+    public void process(EventHeader event) {
+        if (event.hasCollection(Cluster.class, inputClusterCollectionName)) {
+            if (event.hasCollection(RawTrackerHit.class, rawHitsCollectionName)) {
+                Map<Long, RawTrackerHit> rawHitMap = createRawHitMap(event.get(RawTrackerHit.class, rawHitsCollectionName));
+                List<Cluster> clusters = event.get(Cluster.class, inputClusterCollectionName);
+                for (Cluster cluster : clusters) {
+                    for (CalorimeterHit calHit : cluster.getCalorimeterHits()) {
+                        RawTrackerHit rawHit = rawHitMap.get(calHit.getCellID());
+                        EcalChannel channel = channels.findGeometric(rawHit.getCellID());
+                        if (channel != null) {
+                            IProfile1D profile = adcProfiles.get(channel);
+                            for (int adcIndex = 0; adcIndex < rawHit.getADCValues().length; adcIndex++) {
+                                // Fill the Profile1D with ADC value.
+                                profile.fill(adcIndex, rawHit.getADCValues()[adcIndex]);
+                            }
+                        } else {
+                            throw new RuntimeException("EcalChannel not found for cell ID 0x" + String.format("%08d", Long.toHexString(rawHit.getCellID())));
+                        }
+                    }
+                }
+            } else {
+                throw new RuntimeException("Missing raw hit collection: " + rawHitsCollectionName);
+            }                       
+        }
+    }
+    
+    Map<Long, RawTrackerHit> createRawHitMap(List<RawTrackerHit> rawHits) {
+        Map<Long, RawTrackerHit> rawHitMap = new HashMap<Long, RawTrackerHit>();
+        for (RawTrackerHit hit : rawHits) {
+            rawHitMap.put(hit.getCellID(), hit);
+        }
+        return rawHitMap;
+    }
+
+}

Added: java/trunk/users/src/main/java/org/hps/users/jeremym/EcalCosmicHitSelectionDriver.java
 =============================================================================
--- java/trunk/users/src/main/java/org/hps/users/jeremym/EcalCosmicHitSelectionDriver.java	(added)
+++ java/trunk/users/src/main/java/org/hps/users/jeremym/EcalCosmicHitSelectionDriver.java	Thu Dec  4 17:25:29 2014
@@ -0,0 +1,124 @@
+package org.hps.users.jeremym;
+
+import hep.aida.IAnalysisFactory;
+
+import java.util.ArrayList;
+import java.util.List;
+
+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.event.EventHeader;
+import org.lcsim.event.RawTrackerHit;
+import org.lcsim.geometry.Detector;
+import org.lcsim.geometry.subdetector.HPSEcal3;
+import org.lcsim.util.Driver;
+import org.lcsim.util.aida.AIDA;
+
+/**
+ * This Driver will process ECAL raw mode (window) data and extract hits 
+ * that look like signal, by requiring a certain number of ADC samples
+ * in a row that are above a sigma threshold.  For events with number
+ * of hits greater than a minimum (5 by default), it will convert
+ * the raw data into CalorimeterHits and write them to an output
+ * collection.
+ * @author Jeremy McCormick <[log in to unmask]>
+ */
+public class EcalCosmicHitSelectionDriver extends Driver {
+
+    EcalConditions conditions = null;
+    EcalChannelCollection channels = null;
+        
+    AIDA aida = AIDA.defaultInstance();
+    IAnalysisFactory analysisFactory = aida.analysisFactory();
+    double sigmaThreshold = 2.5;
+    
+    int minimumSelectedSamples = 3;
+    int minimumNumberOfHits = 3;
+    int minNeighbors = 2;
+    String outputHitsCollectionName = "EcalCosmicReadoutHits";
+    String inputHitsCollectionName = "EcalReadoutHits";
+    HPSEcal3 ecal = null;
+    static String ecalName = "Ecal";
+
+    /**
+     * Set the sigma threshold for an ADC value.
+     * @param sigmaThreshold The sigma threshold.
+     */
+    public void setSigmaThreshold(double sigmaThreshold) {
+        this.sigmaThreshold = sigmaThreshold;
+    }
+
+    /**
+     * Set the number of hits in a row which must be above threshold for the ADC values to be 
+     * saved for the event.
+     * @param selectedHits The minimum number of hits above threshold.
+     */
+    public void setMinimumSelectedSamples(int minimumSelectedSamples) {
+        this.minimumSelectedSamples = minimumSelectedSamples;
+    }
+    
+    public void setMinimumNumberOfHits(int minimumNumberOfHits) {
+        this.minimumNumberOfHits = minimumNumberOfHits;
+    }
+    
+    public void setOutputHitsCollectionName(String outputHitsCollectionName) {
+        this.outputHitsCollectionName = outputHitsCollectionName;
+    }
+
+    public void detectorChanged(Detector detector) {
+        ecal = (HPSEcal3)detector.getSubdetector(ecalName);
+        conditions = ConditionsManager.defaultInstance().getCachedConditions(EcalConditions.class, TableConstants.ECAL_CONDITIONS).getCachedData();
+        channels = conditions.getChannelCollection();
+    }
+
+    public void process(EventHeader event) {
+        if (event.hasCollection(RawTrackerHit.class, inputHitsCollectionName)) {
+            List<RawTrackerHit> hits = event.get(RawTrackerHit.class, inputHitsCollectionName);
+            List<RawTrackerHit> selectedHitsList = new ArrayList<RawTrackerHit>();
+            for (RawTrackerHit hit : hits) {
+                EcalChannel channel = channels.findGeometric(hit.getCellID());
+                if (channel != null) {
+                    int nSelectedHits = 0;
+                    boolean saveHit = false;
+                    EcalChannelConstants channelConstants = conditions.getChannelConstants(channel);
+                    double pedestal = channelConstants.getCalibration().getPedestal();
+                    double noise = channelConstants.getCalibration().getNoise();
+                    double threshold = pedestal + sigmaThreshold * noise;
+                    adcThresholdLoop: for (int adcIndex = 0; adcIndex < hit.getADCValues().length; adcIndex++) {
+                        short adcValue = hit.getADCValues()[adcIndex];
+                        if (adcValue > threshold) {
+                            ++nSelectedHits;
+                            if (nSelectedHits >= minimumSelectedSamples) {
+                                saveHit = true;
+                                break adcThresholdLoop;
+                            }
+                        } else {
+                            nSelectedHits = 0;
+                        }                        
+                    }
+                    
+                    if (saveHit) {
+                        // Add hit to output list.
+                        selectedHitsList.add(hit);
+                    }                   
+                } else {
+                    System.err.println("EcalChannel not found for cell ID 0x" + String.format("%08d", Long.toHexString(hit.getCellID())));
+                }
+            }
+                             
+            // Is number of hits above minimum?
+            if (selectedHitsList.size() >= this.minimumNumberOfHits) {
+                // Save selected hits list to event.
+                //getLogger().info("writing " + selectedHitsList.size() + " hits into " + outputHitsCollectionName);
+                event.put(outputHitsCollectionName, selectedHitsList, RawTrackerHit.class, event.getMetaData(hits).getFlags(), ecal.getReadout().getName());
+            } else {
+                // Skip this event so LCIODriver does not write this event.
+                throw new NextEventException();
+            }                                   
+        }
+    }
+}

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