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  May 2015

HPS-SVN May 2015

Subject:

r3007 - /java/trunk/ecal-recon/src/main/java/org/hps/recon/ecal/EcalRunningPedestalDriver.java

From:

[log in to unmask]

Reply-To:

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

Date:

Wed, 20 May 2015 23:42:08 -0000

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (166 lines)

Author: [log in to unmask]
Date: Wed May 20 16:41:59 2015
New Revision: 3007

Log:
updating ecal running pedestal to work on mode-1

Modified:
    java/trunk/ecal-recon/src/main/java/org/hps/recon/ecal/EcalRunningPedestalDriver.java

Modified: java/trunk/ecal-recon/src/main/java/org/hps/recon/ecal/EcalRunningPedestalDriver.java
 =============================================================================
--- java/trunk/ecal-recon/src/main/java/org/hps/recon/ecal/EcalRunningPedestalDriver.java	(original)
+++ java/trunk/ecal-recon/src/main/java/org/hps/recon/ecal/EcalRunningPedestalDriver.java	Wed May 20 16:41:59 2015
@@ -12,12 +12,15 @@
 import org.lcsim.event.GenericObject;
 import org.lcsim.event.LCRelation;
 import org.lcsim.event.RawCalorimeterHit;
+import org.lcsim.event.RawTrackerHit;
 import org.lcsim.geometry.Detector;
 import org.lcsim.util.Driver;
 
 /**
  * Calculate a running pedestal average for every channel from Mode7 FADCs. Uses
  * pedestals from the database if not available from the data.
+ * 
+ * May 2015:  Updated to also work on Mode1 data.
  * 
  * TODO: Use Logger.
  * 
@@ -49,6 +52,9 @@
     private static final String extraDataRelationsName = "EcalReadoutExtraDataRelations";
     private static final String runningPedestalsName = "EcalRunningPedestals";
 
+    // number of samples from the beginning of the time window used to calculate the pedestal:
+    private static final int nSamples = 4;
+    
     // TODO:  Get this from somewhere else.
     private final int nChannels = 442;
 
@@ -57,7 +63,7 @@
             nChannels);
 
     // recent event-by-event pedestals and timestamps:
-    private Map<EcalChannel, List<Integer>> eventPedestals = new HashMap<EcalChannel, List<Integer>>();
+    private Map<EcalChannel, List<Double>> eventPedestals = new HashMap<EcalChannel, List<Double>>();
     private Map<EcalChannel, List<Long>> eventTimestamps = new HashMap<EcalChannel, List<Long>>();
 
     private boolean debug = false;
@@ -82,7 +88,7 @@
         for (int ii = 0; ii < nChannels; ii++) {
             EcalChannel chan = findChannel(ii + 1);
             runningPedestals.put(chan,getStaticPedestal(chan));
-            eventPedestals.put(chan,new ArrayList<Integer>());
+            eventPedestals.put(chan,new ArrayList<Double>());
             eventTimestamps.put(chan,new ArrayList<Long>());
         }
         if (debug) {
@@ -127,9 +133,21 @@
         System.out.printf("\n");
     }
 
+    private double getNSampleMinimum(short samples[]) {
+        double min=99999999;
+        for (int ii=0; ii<samples.length-nSamples; ii++) {
+            double tmp=0;
+            for (int jj=ii; jj<ii+nSamples; jj++) tmp += samples[jj];
+            tmp /= nSamples;
+            if (tmp < min) min=tmp;
+        }
+        return min;
+    }
+    
     @Override
     protected void process(EventHeader event) {
 
+        // Mode-7 Input Data:
         if (event.hasCollection(RawCalorimeterHit.class, rawCollectionName)) {
             if (event.hasCollection(LCRelation.class, extraDataRelationsName)) {
                 for (LCRelation rel : event.get(LCRelation.class,
@@ -140,7 +158,38 @@
                 }
             }
         }
+        
+        // Mode-1 Input Data:
+        else if (event.hasCollection(RawTrackerHit.class, rawCollectionName)) {
+            List<RawTrackerHit> hits = event.get(RawTrackerHit.class, rawCollectionName);
+            for (RawTrackerHit hit : hits) {
+               short samples[] = hit.getADCValues();
+               if (nSamples > samples.length) {
+                   System.err.println("NOT ENGOUTH SAMPLES FOR ECAL RUNNING PEDETSAL.");
+                   System.exit(0);
+               }
+              
+               //double ped = getNSampleMinimum(samples);
+              
+               boolean good=true;
+               double ped=0;
+               for (int ii=0; ii<nSamples; ii++) {
+                   // reject pulses from pedestal calculation:
+                   if (samples[ii] > getStaticPedestal(findChannel(hit))+12) {
+                       good=false;
+                       break;
+                   }
+                   ped += samples[ii];
+               }
+               if (good) {
+                   ped /= nSamples;
+                   updatePedestal(event,findChannel(hit),ped);
+               }
+            }
+        }
+       
         event.put(runningPedestalsName, runningPedestals);
+        
         if (debug) {
             printPedestals();
         }
@@ -149,7 +198,6 @@
     private void updatePedestal(EventHeader event, RawCalorimeterHit hit,
             GenericObject mode7data) {
 
-        final long timestamp = event.getTimeStamp();
         final int min = ((HitExtraData.Mode7Data) mode7data).getAmplLow();
         final int max = ((HitExtraData.Mode7Data) mode7data).getAmplHigh();
 
@@ -162,7 +210,15 @@
             System.err.println("hit doesn't correspond to ecalchannel");
             return;
         }
-        List<Integer> peds = eventPedestals.get(chan);
+        
+        updatePedestal(event,chan,(double)min);
+    }
+    
+    private void updatePedestal(EventHeader event,EcalChannel chan,double min) {
+
+        final long timestamp = event.getTimeStamp();
+        
+        List<Double> peds = eventPedestals.get(chan);
         List<Long> times = eventTimestamps.get(chan);
 
         if (maxLookbackTime > 0) {
@@ -214,8 +270,8 @@
         } else {
             ped = getStaticPedestal(chan);
         }
+        
         runningPedestals.put(chan, ped);
-
     }
 
     public double getStaticPedestal(EcalChannel chan) {
@@ -227,6 +283,10 @@
         return ecalConditions.getChannelCollection().findChannel(channel_id);
     }
 
+    public EcalChannel findChannel(RawTrackerHit hit) {
+        return ecalConditions.getChannelCollection().findGeometric(
+                hit.getCellID());
+    }
     public EcalChannel findChannel(RawCalorimeterHit hit) {
         return ecalConditions.getChannelCollection().findGeometric(
                 hit.getCellID());

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