Author: celentan
Date: Tue Dec 9 05:31:07 2014
New Revision: 1661
Log:
Update the Evio Reader to handle FADC mode 7
Modified:
java/trunk/ecal-recon/src/main/java/org/hps/recon/ecal/EcalRawConverter.java
java/trunk/ecal-recon/src/main/java/org/hps/recon/ecal/EcalRawConverterDriver.java
java/trunk/ecal-recon/src/main/java/org/hps/recon/ecal/HPSRawCalorimeterHit.java
Modified: java/trunk/ecal-recon/src/main/java/org/hps/recon/ecal/EcalRawConverter.java
=============================================================================
--- java/trunk/ecal-recon/src/main/java/org/hps/recon/ecal/EcalRawConverter.java (original)
+++ java/trunk/ecal-recon/src/main/java/org/hps/recon/ecal/EcalRawConverter.java Tue Dec 9 05:31:07 2014
@@ -3,6 +3,7 @@
import org.hps.conditions.database.TableConstants;
import org.hps.conditions.ecal.EcalChannelConstants;
import org.hps.conditions.ecal.EcalConditions;
+//import org.hps.evio.EventConstants;
import org.lcsim.conditions.ConditionsManager;
import org.lcsim.event.CalorimeterHit;
import org.lcsim.event.RawCalorimeterHit;
@@ -17,6 +18,7 @@
*
* @author Sho Uemura <[log in to unmask]>
* @author Jeremy McCormick <[log in to unmask]>
+ * @author Andrea Celentano <[log in to unmask]>
*/
public class EcalRawConverter {
@@ -69,6 +71,55 @@
double rawEnergy = adcToEnergy(adcSum, id);
HPSCalorimeterHit h2 = new HPSCalorimeterHit(rawEnergy, time + timeOffset, id, 0);
return h2;
+ }
+
+
+ /**
+ * A.C. This is the method used to handle both the mode3 and mode7 pulse integrals.
+ *
+ * @param hit The raw calorimeter hit
+ * @param timeOffset The time offset
+ * @return The calibrated calorimeter hit
+ *
+ * @TODO Check the pedestal subtraction
+ * @TODO A.C. I am not a maven expert, and I can' import org.hps.evio.EventConstants and use the 2 constants ECAL_PULSE_INTEGRAL_MODE and ECAL_PULSE_INTEGRAL_HIGHRESTDC_MODE.
+ * It seems to me there's a "circular" dependency problem (evio depends on hps-tracking, that depends on ecal-readout-sim, that depends on ecal-recon.
+ * Therefore, ecal-recon can't depend on hps-evio, and I can't import org.hps.evio.EventConstants....
+ */
+ public CalorimeterHit HitDtoA(HPSRawCalorimeterHit hit,double timeOffset) {
+ if (hit.mode==3){ // mode 3
+ if (hit.getTimeStamp() % 64 != 0) {
+ System.out.println("unexpected timestamp " + hit.getTimeStamp());
+ }
+ double time = hit.getTimeStamp() / 16.0;
+ long id = hit.getCellID();
+ // Get the channel data.
+ EcalChannelConstants channelData = findChannel(id);
+ double adcSum = hit.getAmplitude() - hit.windowSize * channelData.getCalibration().getPedestal();
+ double rawEnergy = adcToEnergy(adcSum, id);
+ HPSCalorimeterHit h2 = new HPSCalorimeterHit(rawEnergy, time + timeOffset, id, 0);
+ return h2;
+ }
+ else if (hit.mode==4){ // mode 7
+ double time = hit.getTimeStamp() * 62.5 / 1000; //in mode 7 time is in 62.5 ps units!
+ long id = hit.getCellID();
+ // Get the channel data.
+ EcalChannelConstants channelData = findChannel(id);
+ double adcSum = hit.getAmplitude() - hit.windowSize * channelData.getCalibration().getPedestal(); //A.C. is this the proper way to pedestal subtract in mode 7?
+ //double adcSum = hit.getAmplitude() - hit.windowSize * hit.amplLow; //A.C. is this the proper way to pedestal subtract in mode 7?
+ double rawEnergy = adcToEnergy(adcSum, id);
+ HPSCalorimeterHit h2 = new HPSCalorimeterHit(rawEnergy, time + timeOffset, id, 0);
+ return h2;
+ }
+ else{
+ System.out.println("Unexpected hit type (FADC acq. mode)");
+ long id = hit.getCellID();
+ EcalChannelConstants channelData = findChannel(id);
+ double adcSum = hit.getAmplitude() - hit.windowSize * channelData.getCalibration().getPedestal();
+ double rawEnergy = adcToEnergy(adcSum, id);
+ HPSCalorimeterHit h2 = new HPSCalorimeterHit(rawEnergy, 0, id, 0); //Time=0 since I do not know which time to use (mode3 or mode7?)
+ return h2;
+ }
}
public RawCalorimeterHit HitAtoD(CalorimeterHit hit, int window) {
Modified: java/trunk/ecal-recon/src/main/java/org/hps/recon/ecal/EcalRawConverterDriver.java
=============================================================================
--- java/trunk/ecal-recon/src/main/java/org/hps/recon/ecal/EcalRawConverterDriver.java (original)
+++ java/trunk/ecal-recon/src/main/java/org/hps/recon/ecal/EcalRawConverterDriver.java Tue Dec 9 05:31:07 2014
@@ -6,6 +6,7 @@
import org.hps.conditions.database.TableConstants;
import org.hps.conditions.ecal.EcalChannelConstants;
import org.hps.conditions.ecal.EcalConditions;
+import org.hps.recon.ecal.HPSRawCalorimeterHit;
import org.lcsim.conditions.ConditionsManager;
import org.lcsim.event.CalorimeterHit;
import org.lcsim.event.EventHeader;
@@ -189,15 +190,20 @@
}
event.put(ecalCollectionName, newHits, CalorimeterHit.class, flags, ecalReadoutName);
}
- if (event.hasCollection(RawCalorimeterHit.class, rawCollectionName)) {
+ if (event.hasCollection(RawCalorimeterHit.class, rawCollectionName)) { //A.C. this is the case of the RAW pulse hits
List<RawCalorimeterHit> hits = event.get(RawCalorimeterHit.class, rawCollectionName);
for (RawCalorimeterHit hit : hits) {
if (debug) {
System.out.format("old hit energy %d\n", hit.getAmplitude());
}
- CalorimeterHit newHit = converter.HitDtoA(hit, integralWindow, timeOffset);
-
+ CalorimeterHit newHit;
+ if (hit instanceof HPSRawCalorimeterHit){ //A.C. since (maybe) old reconstructed LCIO data have hits with BaseRawCalorimeterHit
+ newHit = converter.HitDtoA((HPSRawCalorimeterHit)hit,timeOffset);
+ }
+ else{
+ newHit = converter.HitDtoA(hit, integralWindow, timeOffset);
+ }
if (newHit.getRawEnergy() > threshold) {
if (applyBadCrystalMap && isBadCrystal(newHit)) {
continue;
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 05:31:07 2014
@@ -15,15 +15,33 @@
int amplitude;
int timeStamp;
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) {
+ 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;
this.amplitude = amplitude;
this.timeStamp = timeStamp;
this.windowSize = windowSize;
+
+ //A part from init the fields..
+ this.mode = -1;
+ this.amplLow=0;
+ this.amplHigh=0;
}
-
+
+ public HPSRawCalorimeterHit(long cellID, int amplitude, int timeStamp,int windowSize,short amplLow,short amplHigh,int mode) {
+ this.cellID = cellID;
+ this.amplitude = amplitude;
+ this.timeStamp = timeStamp;
+ this.windowSize = 0;
+ this.amplLow = amplLow;
+ this.amplHigh = amplHigh;
+ this.mode = mode;
+ }
+
@Override
public long getCellID() {
return cellID;
@@ -42,7 +60,19 @@
public int getWindowSize() {
return windowSize;
}
+
+ public int getMode(){
+ return mode;
+ }
+ public short getAmplLow(){
+ return amplLow;
+ }
+
+ public short getAmplHigh(){
+ return amplHigh;
+ }
+
public CalorimeterHit getAnalogHit() {
return analogHit;
}
|