Author: [log in to unmask]
Date: Fri Dec 12 19:40:53 2014
New Revision: 1710
Log:
move the added mode 7 data to GenericObject+LCRelation
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
java/trunk/evio/src/main/java/org/hps/evio/ECalEvioReader.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 Fri Dec 12 19:40:53 2014
@@ -3,19 +3,21 @@
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.hps.recon.ecal.HitExtraData.Mode7Data;
import org.lcsim.conditions.ConditionsManager;
import org.lcsim.event.CalorimeterHit;
+import org.lcsim.event.GenericObject;
import org.lcsim.event.RawCalorimeterHit;
import org.lcsim.event.RawTrackerHit;
import org.lcsim.event.base.BaseRawCalorimeterHit;
import org.lcsim.geometry.Detector;
/**
- * This class is used to convert {@link org.lcsim.event.RawCalorimeterHit} objects
- * to {@link org.lcsim.event.CalorimeterHit} objects with energy information.
- * It has methods to convert pedestal subtracted ADC counts to energy.
- *
+ * This class is used to convert {@link org.lcsim.event.RawCalorimeterHit}
+ * objects to {@link org.lcsim.event.CalorimeterHit} objects with energy
+ * information. It has methods to convert pedestal subtracted ADC counts to
+ * energy.
+ *
* @author Sho Uemura <[log in to unmask]>
* @author Jeremy McCormick <[log in to unmask]>
* @author Andrea Celentano <[log in to unmask]>
@@ -25,10 +27,10 @@
private boolean constantGain = false;
private double gain;
private boolean use2014Gain = true;
-
+
private EcalConditions ecalConditions = null;
- public EcalRawConverter() {
+ public EcalRawConverter() {
}
public void setGain(double gain) {
@@ -41,7 +43,7 @@
}
public short sumADC(RawTrackerHit hit) {
- EcalChannelConstants channelData = findChannel(hit.getCellID());
+ EcalChannelConstants channelData = findChannel(hit.getCellID());
double pedestal = channelData.getCalibration().getPedestal();
short sum = 0;
short samples[] = hit.getADCValues();
@@ -72,54 +74,18 @@
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 CalorimeterHit HitDtoA(RawCalorimeterHit hit, GenericObject mode7Data, int window, double timeOffset) {
+ double time = hit.getTimeStamp() / 16.0; //timestamps use the full 62.5 ps resolution
+ long id = hit.getCellID();
+ // Get the channel data.
+ EcalChannelConstants channelData = findChannel(id);
+ double adcSum = hit.getAmplitude() - window * channelData.getCalibration().getPedestal();
+// double adcSum = hit.getAmplitude() - window * Mode7Data.getAmplLow(mode7Data); //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;
}
public RawCalorimeterHit HitAtoD(CalorimeterHit hit, int window) {
@@ -141,10 +107,10 @@
* return energy (units of GeV) corresponding to the ADC sum and crystal ID
*/
private double adcToEnergy(double adcSum, long cellID) {
-
+
// Get the channel data.
EcalChannelConstants channelData = findChannel(cellID);
-
+
if (use2014Gain) {
if (constantGain) {
return adcSum * ECalUtils.gainFactor * ECalUtils.ecalReadoutPeriod;
@@ -160,22 +126,24 @@
}
}
- /**
+ /**
* Must be set when an object EcalRawConverter is created.
+ *
* @param detector (long)
- */
+ */
public void setDetector(Detector detector) {
// ECAL combined conditions object.
ecalConditions = ConditionsManager.defaultInstance()
.getCachedConditions(EcalConditions.class, TableConstants.ECAL_CONDITIONS).getCachedData();
}
-
- /**
+
+ /**
* Convert physical ID to gain value.
+ *
* @param cellID (long)
* @return channel constants (EcalChannelConstants)
*/
public EcalChannelConstants findChannel(long cellID) {
return ecalConditions.getChannelConstants(ecalConditions.getChannelCollection().findGeometric(cellID));
- }
+ }
}
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 Fri Dec 12 19:40:53 2014
@@ -2,17 +2,20 @@
import java.util.ArrayList;
import java.util.List;
-
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.hps.recon.ecal.HPSRawCalorimeterHit.Mode7Data;
import org.lcsim.conditions.ConditionsManager;
import org.lcsim.event.CalorimeterHit;
import org.lcsim.event.EventHeader;
import org.lcsim.event.GenericObject;
+import org.lcsim.event.LCRelation;
import org.lcsim.event.RawCalorimeterHit;
import org.lcsim.event.RawTrackerHit;
+import org.lcsim.event.RelationalTable;
+import org.lcsim.event.base.BaseRelationalTable;
import org.lcsim.geometry.Detector;
import org.lcsim.lcio.LCIOConstants;
import org.lcsim.util.Driver;
@@ -31,6 +34,10 @@
private String rawCollectionName = "EcalReadoutHits";
private final String ecalReadoutName = "EcalHits";
private String ecalCollectionName = "EcalCalHits";
+
+ private static final String extraDataRelationsName = "EcalReadoutExtraDataRelations";
+// private static final String extraDataCollectionName = "EcalReadoutExtraData";
+
private int integralWindow = 35;
private boolean debug = false;
private double threshold = Double.NEGATIVE_INFINITY;
@@ -101,14 +108,14 @@
@Override
public void detectorChanged(Detector detector) {
-
+
// set the detector for the converter
// FIXME: This method doesn't even need the detector object and does not use it.
converter.setDetector(detector);
// ECAL combined conditions object.
ecalConditions = ConditionsManager.defaultInstance()
- .getCachedConditions(EcalConditions.class, TableConstants.ECAL_CONDITIONS).getCachedData();
+ .getCachedConditions(EcalConditions.class, TableConstants.ECAL_CONDITIONS).getCachedData();
}
/**
@@ -191,30 +198,50 @@
event.put(ecalCollectionName, newHits, CalorimeterHit.class, flags, ecalReadoutName);
}
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;
- 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;
- }
- if (dropBadFADC && isBadFADC(newHit)) {
- continue;
- }
+ if (event.hasCollection(LCRelation.class, extraDataRelationsName)) { // extra information available from mode 7 readout
+ List<LCRelation> extraDataRelations = event.get(LCRelation.class, extraDataRelationsName);
+ for (LCRelation rel : extraDataRelations) {
+ RawCalorimeterHit hit = (RawCalorimeterHit) rel.getFrom();
if (debug) {
- System.out.format("new hit energy %f\n", newHit.getRawEnergy());
- }
- newHits.add(newHit);
+ System.out.format("old hit energy %d\n", hit.getAmplitude());
+ }
+ GenericObject extraData = (GenericObject) rel.getTo();
+ CalorimeterHit newHit;
+ newHit = converter.HitDtoA(hit, extraData, integralWindow, timeOffset);
+ if (newHit.getRawEnergy() > threshold) {
+ if (applyBadCrystalMap && isBadCrystal(newHit)) {
+ continue;
+ }
+ if (dropBadFADC && isBadFADC(newHit)) {
+ continue;
+ }
+ if (debug) {
+ System.out.format("new hit energy %f\n", newHit.getRawEnergy());
+ }
+ newHits.add(newHit);
+ }
+
+ }
+ } else {
+ 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;
+ newHit = converter.HitDtoA(hit, integralWindow, timeOffset);
+ if (newHit.getRawEnergy() > threshold) {
+ if (applyBadCrystalMap && isBadCrystal(newHit)) {
+ continue;
+ }
+ if (dropBadFADC && isBadFADC(newHit)) {
+ continue;
+ }
+ if (debug) {
+ System.out.format("new hit energy %f\n", newHit.getRawEnergy());
+ }
+ newHits.add(newHit);
+ }
}
}
event.put(ecalCollectionName, newHits, CalorimeterHit.class, flags, ecalReadoutName);
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 Fri Dec 12 19:40:53 2014
@@ -9,63 +9,35 @@
*/
public class HPSRawCalorimeterHit implements RawCalorimeterHit {
- long cellID;
- 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;
+ 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;
- }
+ public HPSRawCalorimeterHit(long cellID, int amplitude, int timeStamp, int windowSize) {
+ this.cellID = cellID;
+ this.amplitude = amplitude;
+ this.timeStamp = timeStamp;
+ this.windowSize = windowSize;
+ }
+
@Override
- public int getAmplitude() {
- return amplitude;
- }
+ public long getCellID() {
+ return cellID;
+ }
@Override
- public int getTimeStamp() {
- return timeStamp;
- }
+ public int getAmplitude() {
+ return amplitude;
+ }
- public int getWindowSize() {
- return windowSize;
- }
-
- public int getMode(){
- return mode;
- }
+ @Override
+ public int getTimeStamp() {
+ return timeStamp;
+ }
- public short getAmplLow(){
- return amplLow;
- }
-
- public short getAmplHigh(){
- return amplHigh;
- }
-}
+ public int getWindowSize() {
+ return windowSize;
+ }
+}
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 Fri Dec 12 19:40:53 2014
@@ -14,7 +14,8 @@
import org.hps.conditions.ecal.EcalChannel.GeometryId;
import org.hps.conditions.ecal.EcalConditions;
import org.hps.recon.ecal.FADCGenericHit;
-import org.hps.recon.ecal.HPSRawCalorimeterHit;
+import org.hps.recon.ecal.HitExtraData.Mode7Data;
+import org.hps.recon.ecal.HitExtraData;
import org.jlab.coda.jevio.BaseStructure;
import org.jlab.coda.jevio.BaseStructureHeader;
import org.jlab.coda.jevio.CompositeData;
@@ -24,9 +25,11 @@
import org.lcsim.detector.identifier.IIdentifierHelper;
import org.lcsim.detector.identifier.Identifier;
import org.lcsim.event.EventHeader;
+import org.lcsim.event.LCRelation;
import org.lcsim.event.RawCalorimeterHit;
import org.lcsim.event.RawTrackerHit;
import org.lcsim.event.SimTrackerHit;
+import org.lcsim.event.base.BaseLCRelation;
import org.lcsim.event.base.BaseRawCalorimeterHit;
import org.lcsim.event.base.BaseRawTrackerHit;
import org.lcsim.geometry.Subdetector;
@@ -53,6 +56,12 @@
private static final String genericHitCollectionName = "FADCGenericHits";
private List<FADCGenericHit> genericHits;
+ private static final String extraDataRelationsName = "EcalReadoutExtraDataRelations";
+ private List<LCRelation> extraDataRelations;
+
+ private static final String extraDataCollectionName = "EcalReadoutExtraData";
+ private List<HitExtraData> extraDataList;
+
private static EcalConditions ecalConditions = null;
private static IIdentifierHelper helper = null;
@@ -60,7 +69,7 @@
private final Map<List<Integer>, Integer> genericHitCount = new HashMap<List<Integer>, Integer>();
- private static Logger logger = LogUtil.create(ECalEvioReader.class);
+ private static final Logger logger = LogUtil.create(ECalEvioReader.class);
public ECalEvioReader(int topBankTag, int botBankTag) {
this.topBankTag = topBankTag;
@@ -86,6 +95,8 @@
boolean foundHits = false;
List<Object> hits = new ArrayList<Object>();
genericHits = new ArrayList<FADCGenericHit>();
+ extraDataList = new ArrayList<HitExtraData>();
+ extraDataRelations = new ArrayList<LCRelation>();
hitClass = Object.class;
int flags = 0;
for (BaseStructure bank : event.getChildren()) {
@@ -139,7 +150,7 @@
break;
case EventConstants.ECAL_PULSE_INTEGRAL_HIGHRESTDC_BANK_TAG:
hits.addAll(makeIntegralHitsMode7(cdata, crate));
- hitClass = HPSRawCalorimeterHit.class;
+ hitClass = RawCalorimeterHit.class;
flags = (1 << LCIOConstants.RCHBIT_TIME); //store timestamp
break;
default:
@@ -157,6 +168,10 @@
// String readoutName = ;
lcsimEvent.put(hitCollectionName, hits, hitClass, flags, readoutName);
lcsimEvent.put(genericHitCollectionName, genericHits, FADCGenericHit.class, 0);
+ if (!extraDataList.isEmpty()) {
+ lcsimEvent.put(extraDataCollectionName, extraDataList, Mode7Data.class, 0);
+ lcsimEvent.put(extraDataRelationsName, extraDataRelations, LCRelation.class, 0);
+ }
// for (Object hit : hits) {
// System.out.println(((RawTrackerHit) hit).getIDDecoder().getIDDescription().toString());
// }
@@ -322,7 +337,7 @@
int[] data = {pulseIntegral, pulseTime};
processUnrecognizedChannel(new FADCGenericHit(EventConstants.ECAL_PULSE_INTEGRAL_MODE, crate, slot, channel, data));
} else {
- hits.add(new BaseRawCalorimeterHit(id, pulseIntegral,pulseTime));
+ hits.add(new BaseRawCalorimeterHit(id, pulseIntegral, pulseTime));
}
}
}
@@ -330,10 +345,8 @@
return hits;
}
-
-
- private List<HPSRawCalorimeterHit> makeIntegralHitsMode7(CompositeData cdata, int crate) {
- List<HPSRawCalorimeterHit> hits = new ArrayList<HPSRawCalorimeterHit>();
+ private List<RawCalorimeterHit> makeIntegralHitsMode7(CompositeData cdata, int crate) {
+ List<RawCalorimeterHit> hits = new ArrayList<RawCalorimeterHit>();
if (debug) {
int n = cdata.getNValues().size();
for (int i = 0; i < n; i++) {
@@ -372,18 +385,18 @@
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));
+ RawCalorimeterHit hit = new BaseRawCalorimeterHit(id, pulseIntegral, pulseTime);
+ hits.add(hit);
+ Mode7Data extraData = new Mode7Data(amplLow, amplHigh);
+ extraDataList.add(extraData);
+ extraDataRelations.add(new BaseLCRelation(hit, extraData));
}
}
}
}
return hits;
}
-
-
-
-
-
+
private void processUnrecognizedChannel(FADCGenericHit hit) {
genericHits.add(hit);
|