Print

Print


Author: [log in to unmask]
Date: Tue Dec  9 16:44:29 2014
New Revision: 1666

Log:
remove usage of HPSRawCalorimeterHit in readout simulation, make ECalEvioReader use BaseRawCalorimeterHit for mode 3

Modified:
    java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/FADCEcalReadoutDriver.java
    java/trunk/ecal-recon/src/main/java/org/hps/recon/ecal/HPSRawCalorimeterHit.java
    java/trunk/evio/src/main/java/org/hps/evio/ECalEvioReader.java

Modified: java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/FADCEcalReadoutDriver.java
 =============================================================================
--- java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/FADCEcalReadoutDriver.java	(original)
+++ java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/FADCEcalReadoutDriver.java	Tue Dec  9 16:44:29 2014
@@ -8,6 +8,7 @@
 import static org.hps.recon.ecal.ECalUtils.riseTime;
 
 import java.util.ArrayList;
+import java.util.Comparator;
 import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.List;
@@ -20,7 +21,6 @@
 import org.hps.conditions.ecal.EcalConditions;
 import org.lcsim.conditions.ConditionsManager;
 import org.hps.recon.ecal.ECalUtils;
-import org.hps.recon.ecal.HPSRawCalorimeterHit;
 import org.lcsim.event.CalorimeterHit;
 import org.lcsim.event.EventHeader;
 import org.lcsim.event.RawCalorimeterHit;
@@ -58,7 +58,7 @@
     //buffer for timestamps
     private Map<Long, Integer> timeMap = null;
     //queue for hits to be output to clusterer
-    private PriorityQueue<HPSRawCalorimeterHit> outputQueue = null;
+    private PriorityQueue<RawCalorimeterHit> outputQueue = null;
     //length of ring buffer (in readout cycles)
     private int bufferLength = 100;
     //length of readout pipeline (in readout cycles)
@@ -81,7 +81,7 @@
     private int numSamplesAfter = 30;
 //    private HPSEcalConverter converter = null;
     //output buffer for hits
-    private LinkedList<HPSRawCalorimeterHit> buffer = new LinkedList<HPSRawCalorimeterHit>();
+    private LinkedList<RawCalorimeterHit> buffer = new LinkedList<RawCalorimeterHit>();
     //number of readout periods for which a given hit stays in the buffer
     private int coincidenceWindow = 2;
     //output collection name for hits read out from trigger
@@ -107,7 +107,7 @@
     public FADCEcalReadoutDriver() {
         flags = 0;
         flags += 1 << LCIOConstants.RCHBIT_TIME; //store timestamp
-        hitClass = HPSRawCalorimeterHit.class;
+        hitClass = RawCalorimeterHit.class;
         setReadoutPeriod(ecalReadoutPeriod);
 //        converter = new HPSEcalConverter(null);
     }
@@ -269,19 +269,17 @@
                         sumMap.put(cellID, sum + pipeline.getValue(0));
                     } else if (timeMap.get(cellID) + delay0 <= readoutCounter) {
 //                        System.out.printf("sum = %f\n", sum);
-                        outputQueue.add(new HPSRawCalorimeterHit(cellID,
+                        outputQueue.add(new BaseRawCalorimeterHit(cellID,
                                 (int) Math.round(sum / scaleFactor),
-                                64 * timeMap.get(cellID),
-                                readoutCounter - timeMap.get(cellID) + 1));
+                                64 * timeMap.get(cellID)));
                         sumMap.remove(cellID);
                     }
                 } else {
                     if (pedestalSubtractedValue < triggerThreshold || timeMap.get(cellID) + delay0 == readoutCounter) {
 //					System.out.printf("sum = %f\n",sum);
-                        outputQueue.add(new HPSRawCalorimeterHit(cellID,
+                        outputQueue.add(new BaseRawCalorimeterHit(cellID,
                                 (int) Math.round((sum + pedestalSubtractedValue) / scaleFactor),
-                                64 * timeMap.get(cellID),
-                                readoutCounter - timeMap.get(cellID) + 1));
+                                64 * timeMap.get(cellID)));
                         sumMap.remove(cellID);
                     } else {
                         sumMap.put(cellID, sum + pedestalSubtractedValue);
@@ -468,7 +466,7 @@
         //initialize buffers
         sumMap = new HashMap<Long, Integer>();
         timeMap = new HashMap<Long, Integer>();
-        outputQueue = new PriorityQueue(20, new HPSRawCalorimeterHit.TimeComparator());
+        outputQueue = new PriorityQueue(20, new TimeComparator());
         resetFADCBuffers();
     }
 
@@ -620,4 +618,12 @@
         return ecalConditions.getChannelConstants(ecalConditions.getChannelCollection().findGeometric(cellID));
     }
     
+    
+	public static class TimeComparator implements Comparator<RawCalorimeterHit> {
+
+        @Override
+		public int compare(RawCalorimeterHit o1, RawCalorimeterHit o2) {
+			return o1.getTimeStamp() - o2.getTimeStamp();
+		}
+	}
 }

Modified: java/trunk/ecal-recon/src/main/java/org/hps/recon/ecal/HPSRawCalorimeterHit.java
 =============================================================================
--- java/trunk/ecal-recon/src/main/java/org/hps/recon/ecal/HPSRawCalorimeterHit.java	(original)
+++ java/trunk/ecal-recon/src/main/java/org/hps/recon/ecal/HPSRawCalorimeterHit.java	Tue Dec  9 16:44:29 2014
@@ -1,7 +1,5 @@
 package org.hps.recon.ecal;
 
-import java.util.Comparator;
-import org.lcsim.event.CalorimeterHit;
 import org.lcsim.event.RawCalorimeterHit;
 
 /**
@@ -17,8 +15,6 @@
 	int windowSize;
 	int mode; //A.C. this is the field I use, in case of REAL data, to record which FADC mode was used (ECAL_PULSE_INTEGRAL3_MODE or ECAL_PULSE_INTEGRAL7_MODE)
 	short amplLow,amplHigh;
-	
-	CalorimeterHit analogHit = null;
 
 	public HPSRawCalorimeterHit(long cellID, int amplitude, int timeStamp, int windowSize) { //A.C. I do not change this, since I did not write it!
 		this.cellID = cellID;
@@ -72,20 +68,4 @@
 	public short getAmplHigh(){
 		return amplHigh;
 	}
-	
-	public CalorimeterHit getAnalogHit() {
-		return analogHit;
-	}
-
-	public void setAnalogHit(CalorimeterHit analogHit) {
-		this.analogHit = analogHit;
-	}
-
-	public static class TimeComparator implements Comparator<RawCalorimeterHit> {
-
-        @Override
-		public int compare(RawCalorimeterHit o1, RawCalorimeterHit o2) {
-			return o1.getTimeStamp() - o2.getTimeStamp();
-		}
-	}
 }

Modified: java/trunk/evio/src/main/java/org/hps/evio/ECalEvioReader.java
 =============================================================================
--- java/trunk/evio/src/main/java/org/hps/evio/ECalEvioReader.java	(original)
+++ java/trunk/evio/src/main/java/org/hps/evio/ECalEvioReader.java	Tue Dec  9 16:44:29 2014
@@ -24,6 +24,7 @@
 import org.lcsim.detector.identifier.IIdentifierHelper;
 import org.lcsim.detector.identifier.Identifier;
 import org.lcsim.event.EventHeader;
+import org.lcsim.event.RawCalorimeterHit;
 import org.lcsim.event.RawTrackerHit;
 import org.lcsim.event.SimTrackerHit;
 import org.lcsim.event.base.BaseRawCalorimeterHit;
@@ -133,7 +134,7 @@
                                             break;
                                         case EventConstants.ECAL_PULSE_INTEGRAL_BANK_TAG:
                                             hits.addAll(makeIntegralHitsMode3(cdata, crate));
-                                            hitClass = HPSRawCalorimeterHit.class;
+                                            hitClass = RawCalorimeterHit.class;
                                             flags = (1 << LCIOConstants.RCHBIT_TIME); //store timestamp
                                             break;
                                         case EventConstants.ECAL_PULSE_INTEGRAL_HIGHRESTDC_BANK_TAG:
@@ -246,7 +247,7 @@
                 System.out.println("cdata.type[" + i + "]=" + cdata.getTypes().get(i));
             }
         }
-        while (cdata.index() < cdata.getItems().size()) {
+        while (cdata.index() + 1 < cdata.getItems().size()) { //the +1 is a hack because sometimes an extra byte gets read (padding)
             short slot = cdata.getByte();
             int trigger = cdata.getInt();
             long timestamp = cdata.getLong();
@@ -283,8 +284,8 @@
         return hits;
     }
 
-    private List<HPSRawCalorimeterHit> makeIntegralHitsMode3(CompositeData cdata, int crate) {
-        List<HPSRawCalorimeterHit> hits = new ArrayList<HPSRawCalorimeterHit>();
+    private List<RawCalorimeterHit> makeIntegralHitsMode3(CompositeData cdata, int crate) {
+        List<RawCalorimeterHit> hits = new ArrayList<RawCalorimeterHit>();
         if (debug) {
             int n = cdata.getNValues().size();
             for (int i = 0; i < n; i++) {
@@ -321,7 +322,7 @@
                         int[] data = {pulseIntegral, pulseTime};
                         processUnrecognizedChannel(new FADCGenericHit(EventConstants.ECAL_PULSE_INTEGRAL_MODE, crate, slot, channel, data));
                     } else {
-                        hits.add(new HPSRawCalorimeterHit(id, pulseIntegral,pulseTime,0,(short)0,(short)0,EventConstants.ECAL_PULSE_INTEGRAL_MODE));
+                        hits.add(new BaseRawCalorimeterHit(id, pulseIntegral,pulseTime));
                     }
                 }
             }
@@ -365,10 +366,10 @@
                     short amplLow = cdata.getShort();
                     short amplHigh = cdata.getShort();
                     if (debug) {
-                        System.out.println("    pulseTime=" + pulseTime + "; pulseIntegral=" + pulseIntegral);
+                        System.out.println("    pulseTime=" + pulseTime + "; pulseIntegral=" + pulseIntegral + "; amplLow=" + amplLow + "; amplHigh=" + amplHigh);
                     }
                     if (id == null) {
-                        int[] data = {pulseIntegral, pulseTime};
+                        int[] data = {pulseIntegral, pulseTime, amplLow, amplHigh};
                         processUnrecognizedChannel(new FADCGenericHit(EventConstants.ECAL_PULSE_INTEGRAL_HIGHRESTDC_MODE, crate, slot, channel, data));
                     } else {
                         hits.add(new HPSRawCalorimeterHit(id, pulseIntegral,pulseTime,0,amplLow,amplHigh,EventConstants.ECAL_PULSE_INTEGRAL_HIGHRESTDC_MODE));