13 modified files
java/branches/hps_java_trunk_HPSJAVA-251/ecal-recon/src/main/java/org/hps/recon/ecal
--- java/branches/hps_java_trunk_HPSJAVA-251/ecal-recon/src/main/java/org/hps/recon/ecal/CTPEcalClusterer.java 2014-09-12 02:08:45 UTC (rev 1010)
+++ java/branches/hps_java_trunk_HPSJAVA-251/ecal-recon/src/main/java/org/hps/recon/ecal/CTPEcalClusterer.java 2014-09-12 02:32:40 UTC (rev 1011)
@@ -19,6 +19,8 @@
import org.lcsim.util.Driver;
import org.lcsim.lcio.LCIOConstants;
+import org.hps.recon.ecal.HPSEcalCluster;
+
/**
* Creates clusters from CalorimeterHits in the HPSEcal detector.
*
@@ -30,6 +32,8 @@
* @version $Id: CTPEcalClusterer.java,v 1.1 2013/02/25 22:39:24 meeg Exp $
*/
public class CTPEcalClusterer extends Driver {
+
+ Detector detector = null;
// The calorimeter object.
HPSEcal3 ecal;
IDDecoder dec;
@@ -87,6 +91,9 @@
@Override
public void detectorChanged(Detector detector) {
+
+ this.detector = detector;
+
// Get the Subdetector.
ecal = (HPSEcal3) detector.getSubdetector(ecalName);
@@ -116,6 +123,9 @@
clusterCenters.add(cellID);
}
}
+
+ System.out.println("You are using CTPEcalCluster.java with the database conditions.");
+
}
public void process(EventHeader event) {
@@ -127,7 +137,7 @@
// Define a list of clusters to be filled.
List<HPSEcalCluster> clusters;
- // If there is a cluster window, run the clsuter window code. A cluster window is a time
+ // If there is a cluster window, run the cluster window code. A cluster window is a time
// period in nanoseconds during which hits can be applied to the same cluster.
if (clusterWindow >= 0) {
// Create priority queues. These are sorted by the time variable associated with each hit.
@@ -344,17 +354,18 @@
}
// Generate a new cluster seed hit from the above results.
- CalorimeterHit seedHit = new HPSCalorimeterHit(0.0, clusterTime, possibleCluster, hits.get(0).getType());
+ HPSCalorimeterHit seedHit = new HPSCalorimeterHit(0.0, clusterTime, possibleCluster, hits.get(0).getType());
+ seedHit.setDetector(detector);
seedHit.setMetaData(hits.get(0).getMetaData());
// Generate a new cluster from the seed hit.
- HPSEcalCluster cluster = new HPSEcalCluster(seedHit);
-
+ HPSEcalCluster cluster = new HPSEcalCluster();
+ cluster.setDetector(detector);
+ cluster.setSeedHit(seedHit);
// Populate the cluster with each of the chosen neighbors.
for (CalorimeterHit clusterHit : hits) {
cluster.addHit(clusterHit);
}
-
// Add the cluster to the cluster list.
clusters.add(cluster);
}
java/branches/hps_java_trunk_HPSJAVA-251/ecal-recon/src/main/java/org/hps/recon/ecal
--- java/branches/hps_java_trunk_HPSJAVA-251/ecal-recon/src/main/java/org/hps/recon/ecal/ECalUtils.java 2014-09-12 02:08:45 UTC (rev 1010)
+++ java/branches/hps_java_trunk_HPSJAVA-251/ecal-recon/src/main/java/org/hps/recon/ecal/ECalUtils.java 2014-09-12 02:32:40 UTC (rev 1011)
@@ -75,7 +75,6 @@
}
}
-
/*These methods have been added by A. Celentano: they're mostly used in the monitoring drivers related to Ecal:
* however, instead of keeping them in a class "EcalMonitoringUtils", it seems better to have them here.
*/
@@ -99,6 +98,4 @@
}
return ret;
}
-
-
}
java/branches/hps_java_trunk_HPSJAVA-251/ecal-recon/src/main/java/org/hps/recon/ecal
--- java/branches/hps_java_trunk_HPSJAVA-251/ecal-recon/src/main/java/org/hps/recon/ecal/EcalClusterer.java 2014-09-12 02:08:45 UTC (rev 1010)
+++ java/branches/hps_java_trunk_HPSJAVA-251/ecal-recon/src/main/java/org/hps/recon/ecal/EcalClusterer.java 2014-09-12 02:32:40 UTC (rev 1011)
@@ -26,6 +26,8 @@
* @version $Id: EcalClusterer.java,v 1.1 2013/02/25 22:39:24 meeg Exp $
*/
public class EcalClusterer extends Driver {
+
+ Detector detector = null;
HPSEcal3 ecal;
String ecalCollectionName;
@@ -77,6 +79,9 @@
}
public void detectorChanged(Detector detector) {
+
+ this.detector = detector;
+
// Get the Subdetector.
ecal = (HPSEcal3) detector.getSubdetector(ecalName);
@@ -158,7 +163,9 @@
// Did we find a seed?
if (isSeed) {
// Make a cluster from the hit list.
- HPSEcalCluster cluster = new HPSEcalCluster(hit);
+ HPSEcalCluster cluster = new HPSEcalCluster();
+ cluster.setDetector(detector);
+ cluster.setSeedHit(hit);
cluster.addHit(hit);
for (CalorimeterHit clusHit : neighborHits) {
cluster.addHit(clusHit);
java/branches/hps_java_trunk_HPSJAVA-251/ecal-recon/src/main/java/org/hps/recon/ecal
--- java/branches/hps_java_trunk_HPSJAVA-251/ecal-recon/src/main/java/org/hps/recon/ecal/EcalConverterDriver.java 2014-09-12 02:08:45 UTC (rev 1010)
+++ java/branches/hps_java_trunk_HPSJAVA-251/ecal-recon/src/main/java/org/hps/recon/ecal/EcalConverterDriver.java 2014-09-12 02:32:40 UTC (rev 1011)
@@ -2,9 +2,11 @@
import java.util.ArrayList;
import java.util.List;
+
import org.lcsim.event.CalorimeterHit;
import org.lcsim.event.EventHeader;
import org.lcsim.event.RawCalorimeterHit;
+import org.lcsim.geometry.Detector;
import org.lcsim.util.Driver;
import org.lcsim.lcio.LCIOConstants;
@@ -14,6 +16,8 @@
* @version $Id: EcalConverterDriver.java,v 1.1 2013/02/25 22:39:24 meeg Exp $
*/
public class EcalConverterDriver extends Driver {
+
+ Detector detector = null;
String rawCollectionName;
String ecalReadoutName = "EcalHits";
@@ -51,6 +55,11 @@
throw new RuntimeException("The parameter ecalCollectionName was not set!");
}
}
+
+ @Override
+ public void detectorChanged(Detector detector) {
+ this.detector = detector;
+ }
@Override
public void process(EventHeader event) {
@@ -77,7 +86,9 @@
}
private CalorimeterHit HitDtoA(RawCalorimeterHit hit) {
- return new HPSCalorimeterHit(DtoA(hit.getAmplitude(), hit.getCellID()), period * hit.getTimeStamp() + dt, hit.getCellID(), 0);
+ HPSCalorimeterHit h = new HPSCalorimeterHit(DtoA(hit.getAmplitude(), hit.getCellID()), period * hit.getTimeStamp() + dt, hit.getCellID(), 0);
+ h.setDetector(detector);
+ return h;
}
// private RawCalorimeterHit HitAtoD(CalorimeterHit hit) {
java/branches/hps_java_trunk_HPSJAVA-251/ecal-recon/src/main/java/org/hps/recon/ecal
--- java/branches/hps_java_trunk_HPSJAVA-251/ecal-recon/src/main/java/org/hps/recon/ecal/EcalEdepToTriggerConverterDriver.java 2014-09-12 02:08:45 UTC (rev 1010)
+++ java/branches/hps_java_trunk_HPSJAVA-251/ecal-recon/src/main/java/org/hps/recon/ecal/EcalEdepToTriggerConverterDriver.java 2014-09-12 02:32:40 UTC (rev 1011)
@@ -3,20 +3,40 @@
import java.util.ArrayList;
import java.util.List;
-import org.hps.conditions.deprecated.EcalConditions;
+
+//import org.hps.conditions.deprecated.EcalConditions;
+import org.hps.conditions.ConditionsDriver;
+import org.hps.conditions.TableConstants;
+import org.hps.conditions.ecal.EcalChannel.EcalChannelCollection;
+import org.hps.conditions.ecal.EcalChannel.GeometryId;
+import org.hps.conditions.ecal.EcalChannelConstants;
+import org.hps.conditions.ecal.EcalConditions;
+import org.hps.conditions.ecal.EcalConditionsUtil;
+import org.lcsim.conditions.ConditionsManager;
+import org.lcsim.detector.identifier.IIdentifier;
+import org.lcsim.detector.identifier.IIdentifierHelper;
+import org.lcsim.detector.identifier.Identifier;
import org.hps.util.RandomGaussian;
import org.lcsim.event.CalorimeterHit;
import org.lcsim.event.EventHeader;
import org.lcsim.geometry.Detector;
import org.lcsim.util.Driver;
+
/**
*
* @version $Id: HPSEcalRawConverterDriver.java,v 1.2 2012/05/03 00:17:54
* phansson Exp $
*/
public class EcalEdepToTriggerConverterDriver extends Driver {
-
+
+ Detector detector = null;
+ static EcalConditions ecalConditions = null;
+ static IIdentifierHelper helper = null;
+ static EcalChannelCollection channels = null;
+
+ private static boolean isBadChannelLoaded = true;
+
private String ecalReadoutName = "EcalHits";
private String inputCollection = "EcalHits";
private String readoutCollection = "EcalCalHits";
@@ -75,12 +95,31 @@
}
}
+
@Override
public void detectorChanged(Detector detector) {
+
+ //Must be set to use the database conditions
+ this.detector = detector;
+
+ // ECAL combined conditions object.
+ ecalConditions = ConditionsManager.defaultInstance()
+ .getCachedConditions(EcalConditions.class, TableConstants.ECAL_CONDITIONS).getCachedData();
+
+ // List of channels.
+ channels = ecalConditions.getChannelCollection();
+
+ // ID helper.
+ helper = detector.getSubdetector("Ecal").getDetectorElement().getIdentifierHelper();
+
+ System.out.println("You are now using the database conditions for EcalEdepToTriggerConverterDriver.");
}
public boolean isBadCrystal(CalorimeterHit hit) {
- return EcalConditions.badChannelsLoaded() ? EcalConditions.isBadChannel(hit.getCellID()) : false;
+ // Get the channel data.
+ EcalChannelConstants channelData = findChannel(hit.getCellID());
+
+ return isBadChannelLoaded ? channelData.isBadChannel() : false;
}
@Override
@@ -141,7 +180,9 @@
int truncatedIntegral = (int) Math.floor(triggerIntegral / truncateScale);
if (truncatedIntegral > 0) {
- return new HPSCalorimeterHit(truncatedIntegral, hit.getTime(), hit.getCellID(), 0);
+ HPSCalorimeterHit h = new HPSCalorimeterHit(truncatedIntegral, hit.getTime(), hit.getCellID(), 0);
+ h.setDetector(detector);
+ return h ;
}
return null;
}
@@ -151,8 +192,12 @@
return null;
}
+
+ // Get the channel data.
+ EcalChannelConstants channelData = findChannel(hit.getCellID());
+
// double integral = hit.getRawEnergy()/ECalUtils.GeV * gainScale;
- double gain = _gain > 0 ? _gain : EcalConditions.physicalToGain(hit.getCellID());
+ double gain = _gain > 0 ? _gain : channelData.getGain().getGain();
double integral = amplitude * gain * pulseIntegral * gainScale * ECalUtils.MeV / ECalUtils.GeV;
// double thresholdCrossingTime = 0 - hit.getTime();
@@ -176,19 +221,24 @@
// System.out.format("dumb: %f, full: %f\n",hit.getRawEnergy() * 1000.0,readoutIntegral * HPSEcalConditions.physicalToGain(id));
// System.out.format("readout: %f %f\n", amplitude, integral);
- CalorimeterHit h = new HPSCalorimeterHit(integral, hit.getTime(), hit.getCellID(), 0);
+ HPSCalorimeterHit h = new HPSCalorimeterHit(integral, hit.getTime(), hit.getCellID(), 0);
+ h.setDetector(detector);
return h;
}
private double hitAmplitude(CalorimeterHit hit) {
double energyAmplitude = hit.getRawEnergy();
+
+ // Get the channel data.
+ EcalChannelConstants channelData = findChannel(hit.getCellID());
+
if (addNoise) {
//add preamp noise and photoelectron Poisson noise in quadrature
- double noise = Math.sqrt(Math.pow(EcalConditions.physicalToNoise(hit.getCellID()) * EcalConditions.physicalToGain(hit.getCellID()) * ECalUtils.MeV, 2) + hit.getRawEnergy() * ECalUtils.MeV / pePerMeV);
+ double noise = Math.sqrt(Math.pow(channelData.getCalibration().getNoise() * channelData.getGain().getGain() * ECalUtils.MeV, 2) + hit.getRawEnergy() * ECalUtils.MeV / pePerMeV);
energyAmplitude += RandomGaussian.getGaussian(0, noise);
}
- double gain = _gain > 0 ? _gain : EcalConditions.physicalToGain(hit.getCellID());
+ double gain = _gain > 0 ? _gain : channelData.getGain().getGain();
// System.out.format("amplitude: %f %f %f %f\n", hit.getRawEnergy(), energyAmplitude, gain, (energyAmplitude / ECalUtils.MeV) / (gain * pulseIntegral));
return (energyAmplitude / ECalUtils.MeV) / (gain * pulseIntegral);
}
@@ -207,4 +257,25 @@
}
}
}
+
+ /**
+ * Convert physical ID to gain value.
+ * @param cellID (long)
+ * @return channel constants (EcalChannelConstants)
+ */
+ private static EcalChannelConstants findChannel(long cellID) {
+ // Make an ID object from raw hit ID.
+ IIdentifier id = new Identifier(cellID);
+
+ // Get physical field values.
+ int system = helper.getValue(id, "system");
+ int x = helper.getValue(id, "ix");
+ int y = helper.getValue(id, "iy");
+
+ // Create an ID to search for in channel collection.
+ GeometryId geometryId = new GeometryId(helper, new int[] { system, x, y });
+
+ // Get the channel data.
+ return ecalConditions.getChannelConstants(channels.findChannel(geometryId));
+ }
}
java/branches/hps_java_trunk_HPSJAVA-251/ecal-recon/src/main/java/org/hps/recon/ecal
--- java/branches/hps_java_trunk_HPSJAVA-251/ecal-recon/src/main/java/org/hps/recon/ecal/EcalRawConverter.java 2014-09-12 02:08:45 UTC (rev 1010)
+++ java/branches/hps_java_trunk_HPSJAVA-251/ecal-recon/src/main/java/org/hps/recon/ecal/EcalRawConverter.java 2014-09-12 02:32:40 UTC (rev 1011)
@@ -1,10 +1,22 @@
package org.hps.recon.ecal;
-import org.hps.conditions.deprecated.EcalConditions;
+import org.hps.conditions.ConditionsDriver;
+import org.hps.conditions.DatabaseConditionsManager;
+import org.hps.conditions.TableConstants;
+import org.hps.conditions.ecal.EcalChannel.EcalChannelCollection;
+import org.hps.conditions.ecal.EcalChannel.GeometryId;
+import org.hps.conditions.ecal.EcalChannelConstants;
+import org.hps.conditions.ecal.EcalConditions;
+import org.hps.conditions.ecal.EcalConditionsUtil;
+import org.lcsim.conditions.ConditionsManager;
+import org.lcsim.detector.identifier.IIdentifier;
+import org.lcsim.detector.identifier.IIdentifierHelper;
+import org.lcsim.detector.identifier.Identifier;
import org.lcsim.event.CalorimeterHit;
import org.lcsim.event.RawCalorimeterHit;
import org.lcsim.event.RawTrackerHit;
import org.lcsim.event.base.BaseRawCalorimeterHit;
+import org.lcsim.geometry.Detector;
/**
*
@@ -17,8 +29,16 @@
private boolean constantGain = false;
private double gain;
private boolean use2014Gain = true;
+
+ //get the database condition manager
+
+// Detector detector = DatabaseConditionsManager.getInstance().getDetectorObject();
+ Detector detector = null;
+ static EcalConditions ecalConditions = null;
+ static IIdentifierHelper helper = null;
+ static EcalChannelCollection channels = null;
- public EcalRawConverter() {
+ public EcalRawConverter() {
}
public void setGain(double gain) {
@@ -36,7 +56,11 @@
if (debug) {
System.out.println("Summing ADC for hit: " + hit.toString());
}
- double pedestal = EcalConditions.physicalToPedestal(hit.getCellID());
+
+ // Get the channel data.
+ EcalChannelConstants channelData = findChannel(hit.getCellID());
+
+ double pedestal = channelData.getCalibration().getPedestal();
short sum = 0;
short samples[] = hit.getADCValues();
for (int isample = 0; isample < samples.length; ++isample) {
@@ -52,10 +76,12 @@
double time = hit.getTime();
long id = hit.getCellID();
double rawEnergy = adcToEnergy(sumADC(hit), id);
+ HPSCalorimeterHit h1 = new HPSCalorimeterHit(rawEnergy + 0.0000001, time, id, 0);
+ h1.setDetector(detector);
+
// double[] pos = hit.getDetectorElement().getGeometry().getPosition().v();
- CalorimeterHit h = new HPSCalorimeterHit(rawEnergy + 0.0000001, time, id, 0);
//+0.0000001 is a horrible hack to ensure rawEnergy!=BaseCalorimeterHit.UNSET_CORRECTED_ENERGY
- return h;
+ return h1;
}
public CalorimeterHit HitDtoA(RawCalorimeterHit hit, int window, double timeOffset) {
@@ -64,21 +90,26 @@
}
double time = hit.getTimeStamp() / 16.0;
long id = hit.getCellID();
- double adcSum = hit.getAmplitude() - window * EcalConditions.physicalToPedestal(id);
+ // Get the channel data.
+ EcalChannelConstants channelData = findChannel(id);
+ double adcSum = hit.getAmplitude() - window * channelData.getCalibration().getPedestal();
double rawEnergy = adcToEnergy(adcSum, id);
- CalorimeterHit h = new HPSCalorimeterHit(rawEnergy + 0.0000001, time + timeOffset, id, 0);
+ HPSCalorimeterHit h2 = new HPSCalorimeterHit(rawEnergy + 0.0000001, time + timeOffset, id, 0);
+ h2.setDetector(detector);
//+0.0000001 is a horrible hack to ensure rawEnergy!=BaseCalorimeterHit.UNSET_CORRECTED_ENERGY
- return h;
+ return h2;
}
public RawCalorimeterHit HitAtoD(CalorimeterHit hit, int window) {
int time = (int) (Math.round(hit.getTime() / 4.0) * 64.0);
long id = hit.getCellID();
+ // Get the channel data.
+ EcalChannelConstants channelData = findChannel(id);
int amplitude;
if (constantGain) {
- amplitude = (int) Math.round((hit.getRawEnergy() / ECalUtils.MeV) / gain + window * EcalConditions.physicalToPedestal(id));
+ amplitude = (int) Math.round((hit.getRawEnergy() / ECalUtils.MeV) / gain + window * channelData.getCalibration().getPedestal());
} else {
- amplitude = (int) Math.round((hit.getRawEnergy() / ECalUtils.MeV) / EcalConditions.physicalToGain(id) + window * EcalConditions.physicalToPedestal(id));
+ amplitude = (int) Math.round((hit.getRawEnergy() / ECalUtils.MeV) / channelData.getGain().getGain() + window * channelData.getCalibration().getPedestal());
}
RawCalorimeterHit h = new BaseRawCalorimeterHit(id, amplitude, time);
return h;
@@ -88,17 +119,21 @@
* 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;
} else {
- return EcalConditions.physicalToGain(cellID) * adcSum * ECalUtils.gainFactor * ECalUtils.ecalReadoutPeriod; // should not be used for the moment (2014/02)
+ return channelData.getGain().getGain() * adcSum * ECalUtils.gainFactor * ECalUtils.ecalReadoutPeriod; // should not be used for the moment (2014/02)
}
} else {
if (constantGain) {
return gain * adcSum * ECalUtils.MeV;
} else {
- return EcalConditions.physicalToGain(cellID) * adcSum * ECalUtils.MeV; //gain is defined as MeV/integrated ADC
+ return channelData.getGain().getGain() * adcSum * ECalUtils.MeV; //gain is defined as MeV/integrated ADC
}
}
}
@@ -115,4 +150,49 @@
return h;
}
*/
-}
\ No newline at end of file
+ /**
+ * Must be set when an object EcalRawConverter is created.
+ * @param detector (long)
+ */
+ void setDetector(Detector detector) {
+
+// h1.setDetector(detector);
+// h2.setDetector(detector);
+
+ this.detector = detector;
+
+ // ECAL combined conditions object.
+ ecalConditions = ConditionsManager.defaultInstance()
+ .getCachedConditions(EcalConditions.class, TableConstants.ECAL_CONDITIONS).getCachedData();
+
+ // List of channels.
+ channels = ecalConditions.getChannelCollection();
+
+ // ID helper.
+ helper = detector.getSubdetector("Ecal").getDetectorElement().getIdentifierHelper();
+
+ System.out.println("You are now using the database conditions for EcalRawConverter.");
+ }
+
+ /**
+ * Convert physical ID to gain value.
+ * @param cellID (long)
+ * @return channel constants (EcalChannelConstants)
+ */
+ private static EcalChannelConstants findChannel(long cellID) {
+ // Make an ID object from raw hit ID.
+ IIdentifier id = new Identifier(cellID);
+
+ // Get physical field values.
+ int system = helper.getValue(id, "system");
+ int x = helper.getValue(id, "ix");
+ int y = helper.getValue(id, "iy");
+
+ // Create an ID to search for in channel collection.
+ GeometryId geometryId = new GeometryId(helper, new int[] { system, x, y });
+
+ // Get the channel data.
+ return ecalConditions.getChannelConstants(channels.findChannel(geometryId));
+ }
+
+}
java/branches/hps_java_trunk_HPSJAVA-251/ecal-recon/src/main/java/org/hps/recon/ecal
--- java/branches/hps_java_trunk_HPSJAVA-251/ecal-recon/src/main/java/org/hps/recon/ecal/EcalRawConverterDriver.java 2014-09-12 02:08:45 UTC (rev 1010)
+++ java/branches/hps_java_trunk_HPSJAVA-251/ecal-recon/src/main/java/org/hps/recon/ecal/EcalRawConverterDriver.java 2014-09-12 02:32:40 UTC (rev 1011)
@@ -3,7 +3,19 @@
import java.util.ArrayList;
import java.util.List;
-import org.hps.conditions.deprecated.EcalConditions;
+import org.hps.conditions.ConditionsDriver;
+import org.hps.conditions.TableConstants;
+import org.hps.conditions.ecal.EcalChannel.EcalChannelCollection;
+import org.hps.conditions.ecal.EcalChannel.GeometryId;
+import org.hps.conditions.ecal.EcalChannelConstants;
+import org.hps.conditions.ecal.EcalConditions;
+import org.hps.conditions.ecal.EcalConditionsUtil;
+import org.lcsim.conditions.ConditionsManager;
+import org.lcsim.detector.identifier.IIdentifier;
+import org.lcsim.detector.identifier.IIdentifierHelper;
+import org.lcsim.detector.identifier.Identifier;
+import org.hps.conditions.ecal.EcalChannel.EcalChannelCollection;
+import org.lcsim.detector.identifier.IIdentifierHelper;
import org.lcsim.event.CalorimeterHit;
import org.lcsim.event.EventHeader;
import org.lcsim.event.GenericObject;
@@ -20,6 +32,13 @@
*/
public class EcalRawConverterDriver extends Driver {
+ // To import database conditions
+ static EcalConditions ecalConditions = null;
+ static IIdentifierHelper helper = null;
+ static EcalChannelCollection channels = null;
+
+ Detector detector = null;
+
EcalRawConverter converter = null;
String rawCollectionName = "EcalReadoutHits";
String ecalReadoutName = "EcalHits";
@@ -32,9 +51,10 @@
private boolean runBackwards = false;
private boolean useTimestamps = false;
private boolean useTruthTime = false;
+ private static boolean isBadChannelLoaded = true;
public EcalRawConverterDriver() {
- converter = new EcalRawConverter();
+ converter = new EcalRawConverter();
}
public void setUse2014Gain(boolean use2014Gain) {
@@ -94,17 +114,43 @@
@Override
public void detectorChanged(Detector detector) {
+
+ converter.setDetector(detector);
+
+ // set the detector for the converter
+ this.detector = detector;
+
+ // ECAL combined conditions object.
+ ecalConditions = ConditionsManager.defaultInstance()
+ .getCachedConditions(EcalConditions.class, TableConstants.ECAL_CONDITIONS).getCachedData();
+
+ // List of channels.
+ channels = ecalConditions.getChannelCollection();
+
+ // ID helper.
+ helper = detector.getSubdetector("Ecal").getDetectorElement().getIdentifierHelper();
+
+ System.out.println("You are now using the database conditions for EcalRawConverterDriver.");
}
-
- public static boolean isBadCrystal(CalorimeterHit hit) {
- return EcalConditions.badChannelsLoaded() ? EcalConditions.isBadChannel(hit.getCellID()) : false;
+ /**
+ * @return false if the channel is a good one, true if it is a bad one
+ * @param CalorimeterHit
+ */
+ public static boolean isBadCrystal(CalorimeterHit hit) {
+ // Get the channel data.
+ EcalChannelConstants channelData = findChannel(hit.getCellID());
+
+ return isBadChannelLoaded ? channelData.isBadChannel() : false;
}
-
- public static boolean isBadFADC(CalorimeterHit hit) {
- long daqID = EcalConditions.physicalToDaqID(hit.getCellID());
- return (EcalConditions.getCrate(daqID) == 1 && EcalConditions.getSlot(daqID) == 3);
+
+ /**
+ * @return false if the ADC is a good one, true if it is a bad one
+ * @param CalorimeterHit
+ */
+ public boolean isBadFADC(CalorimeterHit hit) {
+ return (getCrate(hit.getCellID()) == 1 && getSlot(hit.getCellID()) == 3);
}
-
+
private static double getTimestamp(int system, EventHeader event) { //FIXME: copied from org.hps.readout.ecal.ReadoutTimestamp
if (event.hasCollection(GenericObject.class, "ReadoutTimestamps")) {
List<GenericObject> timestamps = event.get(GenericObject.class, "ReadoutTimestamps");
@@ -121,6 +167,7 @@
@Override
public void process(EventHeader event) {
+
final int SYSTEM_TRIGGER = 0;
final int SYSTEM_TRACKER = 1;
final int SYSTEM_ECAL = 2;
@@ -136,7 +183,6 @@
timeOffset += ((t0ECal + 250.0) % 500.0) - 250.0;
}
-
int flags = 0;
flags += 1 << LCIOConstants.RCHBIT_TIME; //store hit time
flags += 1 << LCIOConstants.RCHBIT_LONG; //store hit position; this flag has no effect for RawCalorimeterHits
@@ -150,7 +196,11 @@
for (RawTrackerHit hit : hits) {
CalorimeterHit newHit = converter.HitDtoA(hit);
- if (applyBadCrystalMap && isBadCrystal(newHit)) {
+
+ // Get the channel data.
+ EcalChannelConstants channelData = findChannel(newHit.getCellID());
+
+ if (applyBadCrystalMap && channelData.isBadChannel()) {
continue;
}
if (dropBadFADC && isBadFADC(newHit)) {
@@ -206,4 +256,52 @@
}
}
}
+
+
+ /**
+ * Convert physical ID to gain value.
+ * @param cellID (long)
+ * @return channel constants (EcalChannelConstants)
+ */
+ private static EcalChannelConstants findChannel(long cellID) {
+ // Make an ID object from raw hit ID.
+ IIdentifier id = new Identifier(cellID);
+
+ // Get physical field values.
+ int system = helper.getValue(id, "system");
+ int x = helper.getValue(id, "ix");
+ int y = helper.getValue(id, "iy");
+
+ // Create an ID to search for in channel collection.
+ GeometryId geometryId = new GeometryId(helper, new int[] { system, x, y });
+
+ // Get the channel data.
+ return ecalConditions.getChannelConstants(channels.findChannel(geometryId));
+ }
+
+ /**
+ * Return crate number from cellID
+ * @param cellID (long)
+ * @return Crate number (int)
+ */
+ private int getCrate(long cellID) {
+
+ EcalConditionsUtil util = new EcalConditionsUtil();
+
+ // Find the ECAL channel and return the crate number.
+ return util.getCrate(helper, cellID);
+ }
+
+ /**
+ * Return slot number from cellID
+ * @param cellID (long)
+ * @return Slot number (int)
+ */
+ private int getSlot(long cellID) {
+ EcalConditionsUtil util = new EcalConditionsUtil();
+
+ // Find the ECAL channel and return the crate number.
+ return util.getSlot(helper, cellID);
+ }
+
}
java/branches/hps_java_trunk_HPSJAVA-251/ecal-recon/src/main/java/org/hps/recon/ecal
--- java/branches/hps_java_trunk_HPSJAVA-251/ecal-recon/src/main/java/org/hps/recon/ecal/EcalReadoutToTriggerConverterDriver.java 2014-09-12 02:08:45 UTC (rev 1010)
+++ java/branches/hps_java_trunk_HPSJAVA-251/ecal-recon/src/main/java/org/hps/recon/ecal/EcalReadoutToTriggerConverterDriver.java 2014-09-12 02:32:40 UTC (rev 1011)
@@ -3,7 +3,19 @@
import java.util.ArrayList;
import java.util.List;
-import org.hps.conditions.deprecated.EcalConditions;
+import org.hps.conditions.ConditionsDriver;
+import org.hps.conditions.TableConstants;
+import org.hps.conditions.ecal.EcalChannel.EcalChannelCollection;
+import org.hps.conditions.ecal.EcalChannel.GeometryId;
+import org.hps.conditions.ecal.EcalChannelConstants;
+import org.hps.conditions.ecal.EcalConditions;
+import org.hps.conditions.ecal.EcalConditionsUtil;
+import org.lcsim.conditions.ConditionsManager;
+import org.lcsim.detector.identifier.IIdentifier;
+import org.lcsim.detector.identifier.IIdentifierHelper;
+import org.lcsim.detector.identifier.Identifier;
+import org.hps.conditions.ecal.EcalChannel.EcalChannelCollection;
+import org.lcsim.detector.identifier.IIdentifierHelper;
import org.lcsim.event.CalorimeterHit;
import org.lcsim.event.EventHeader;
import org.lcsim.event.base.BaseRawCalorimeterHit;
@@ -17,6 +29,12 @@
*/
public class EcalReadoutToTriggerConverterDriver extends Driver {
+ // To import database conditions
+ static EcalConditions ecalConditions = null;
+ static IIdentifierHelper helper = null;
+ static EcalChannelCollection channels = null;
+ Detector detector = null;
+
String rawCollectionName = "EcalReadoutHits";
String ecalReadoutName = "EcalHits";
String ecalCollectionName = "EcalCalHits";
@@ -31,6 +49,7 @@
private int triggerThreshold = 80;
private double timeShift = 0;
private int truncateScale = 128;
+ private static boolean isBadChannelLoaded = true;
public EcalReadoutToTriggerConverterDriver() {
}
@@ -76,15 +95,30 @@
@Override
public void detectorChanged(Detector detector) {
+ this.detector = detector;
+
+ // ECAL combined conditions object.
+ ecalConditions = ConditionsManager.defaultInstance()
+ .getCachedConditions(EcalConditions.class, TableConstants.ECAL_CONDITIONS).getCachedData();
+
+ // List of channels.
+ channels = ecalConditions.getChannelCollection();
+
+ // ID helper.
+ helper = detector.getSubdetector("Ecal").getDetectorElement().getIdentifierHelper();
+
+ System.out.println("You are now using the database conditions for EcalReadoutToTriggerConverterDriver.");
}
public boolean isBadCrystal(CalorimeterHit hit) {
- return EcalConditions.badChannelsLoaded() ? EcalConditions.isBadChannel(hit.getCellID()) : false;
+ // Get the channel data.
+ EcalChannelConstants channelData = findChannel(hit.getCellID());
+
+ return isBadChannelLoaded ? channelData.isBadChannel() : false;
}
public boolean isBadFADC(CalorimeterHit hit) {
- long daqID = EcalConditions.physicalToDaqID(hit.getCellID());
- return (EcalConditions.getCrate(daqID) == 1 && EcalConditions.getSlot(daqID) == 3);
+ return (getCrate(hit.getCellID()) == 1 && getSlot(hit.getCellID()) == 3);
}
@Override
@@ -112,8 +146,12 @@
}
public CalorimeterHit HitDtoA(BaseRawCalorimeterHit hit, int window) {
+
+ // Get the channel data.
+ EcalChannelConstants channelData = findChannel(hit.getCellID());
+
double integral = tp * Math.E / readoutPeriod;
- double readoutIntegral = (hit.getAmplitude() - window * EcalConditions.physicalToPedestal(hit.getCellID()));
+ double readoutIntegral = (hit.getAmplitude() - window * channelData.getCalibration().getPedestal());
double amplitude = readoutIntegral / integral;
// double time = readoutPeriod * (Math.random() - 1);
@@ -168,7 +206,8 @@
if (truncatedIntegral <= 0) {
truncatedIntegral = 0;
}
- CalorimeterHit h = new HPSCalorimeterHit(truncatedIntegral, hitTime, id, 0);
+ HPSCalorimeterHit h = new HPSCalorimeterHit(truncatedIntegral, hitTime, id, 0);
+ h.setDetector(detector);
// CalorimeterHit h = new HPSRawCalorimeterHit(triggerIntegral + 0.0000001, hit.getPosition(), hitTime, id, 0);
//+0.0000001 is a horrible hack to ensure rawEnergy!=BaseCalorimeterHit.UNSET_CORRECTED_ENERGY
return h;
@@ -188,4 +227,52 @@
}
}
}
+
+ /**
+ * Convert physical ID to gain value.
+ * @param cellID (long)
+ * @return channel constants (EcalChannelConstants)
+ */
+ private static EcalChannelConstants findChannel(long cellID) {
+ // Make an ID object from raw hit ID.
+ IIdentifier id = new Identifier(cellID);
+
+ // Get physical field values.
+ int system = helper.getValue(id, "system");
+ int x = helper.getValue(id, "ix");
+ int y = helper.getValue(id, "iy");
+
+ // Create an ID to search for in channel collection.
+ GeometryId geometryId = new GeometryId(helper, new int[] { system, x, y });
+
+ // Get the channel data.
+ return ecalConditions.getChannelConstants(channels.findChannel(geometryId));
+ }
+
+ /**
+ * Return crate number from cellID
+ * @param cellID (long)
+ * @return Crate number (int)
+ */
+ private int getCrate(long cellID) {
+
+ EcalConditionsUtil util = new EcalConditionsUtil();
+
+ // Find the ECAL channel and return the crate number.
+ return util.getCrate(helper, cellID);
+ }
+
+ /**
+ * Return slot number from cellID
+ * @param cellID (long)
+ * @return Slot number (int)
+ */
+ private int getSlot(long cellID) {
+ EcalConditionsUtil util = new EcalConditionsUtil();
+
+ // Find the ECAL channel and return the crate number.
+ return util.getSlot(helper, cellID);
+ }
+
+
}
java/branches/hps_java_trunk_HPSJAVA-251/ecal-recon/src/main/java/org/hps/recon/ecal
--- java/branches/hps_java_trunk_HPSJAVA-251/ecal-recon/src/main/java/org/hps/recon/ecal/EcalTriggerFilterDriver.java 2014-09-12 02:08:45 UTC (rev 1010)
+++ java/branches/hps_java_trunk_HPSJAVA-251/ecal-recon/src/main/java/org/hps/recon/ecal/EcalTriggerFilterDriver.java 2014-09-12 02:32:40 UTC (rev 1011)
@@ -5,7 +5,18 @@
import java.util.Queue;
import java.util.concurrent.ArrayBlockingQueue;
-import org.hps.conditions.deprecated.EcalConditions;
+import org.hps.conditions.ConditionsDriver;
+import org.hps.conditions.TableConstants;
+import org.hps.conditions.ecal.EcalChannel;
+import org.hps.conditions.ecal.EcalChannel.DaqId;
+import org.hps.conditions.ecal.EcalChannel.EcalChannelCollection;
+import org.hps.conditions.ecal.EcalChannel.GeometryId;
+import org.hps.conditions.ecal.EcalChannelConstants;
+import org.hps.conditions.ecal.EcalConditions;
+import org.hps.conditions.ecal.EcalConditionsUtil;
+import org.lcsim.conditions.ConditionsManager;
+import org.lcsim.detector.identifier.IIdentifier;
+import org.lcsim.detector.identifier.IIdentifierHelper;
import org.lcsim.event.CalorimeterHit;
import org.lcsim.event.EventHeader;
import org.lcsim.geometry.Detector;
@@ -18,6 +29,13 @@
*/
public class EcalTriggerFilterDriver extends Driver {
+ // To import database conditions
+ static EcalConditions ecalConditions = null;
+ static IIdentifierHelper helper = null;
+ static EcalChannelCollection channels = null;
+ int systemId;
+ Detector detector = null;
+
private String ecalReadoutName = "EcalHits";
private String inputCollection = "EcalReadoutHits";
private String outputCollection = "EcalCalHits";
@@ -55,6 +73,22 @@
@Override
public void detectorChanged(Detector detector) {
+
+ this.detector = detector;
+
+ // ECAL combined conditions object.
+ ecalConditions = ConditionsManager.defaultInstance()
+ .getCachedConditions(EcalConditions.class, TableConstants.ECAL_CONDITIONS).getCachedData();
+
+ // List of channels.
+ channels = ecalConditions.getChannelCollection();
+
+ // ID helper.
+ helper = detector.getSubdetector("Ecal").getDetectorElement().getIdentifierHelper();
+
+ systemId = detector.getSubdetector("Ecal").getSystemID();
+
+ System.out.println("You are now using the database conditions for EcalTriggerFilterDriver.");
}
@Override
@@ -85,15 +119,19 @@
}
}
+ /**
+ * This method takes input hits and makes new hits with different ix
+ * @param CalorimeterHit hit
+ * @return new HPSCalorimeterHit
+ */
private CalorimeterHit filterHit(CalorimeterHit hit) {
int ix = hit.getIdentifierFieldValue("ix");
int iy = hit.getIdentifierFieldValue("iy");
- long daqID = EcalConditions.physicalToDaqID(hit.getCellID());
- int crate = EcalConditions.getCrate(daqID);
- short slot = EcalConditions.getSlot(daqID);
- short channel = EcalConditions.getChannel(daqID);
+ int crate = getCrate(hit.getCellID());
+ int slot = getSlot(hit.getCellID());
- int delay = iy>0?topDelay:bottomDelay;
+ int delay = iy>0?topDelay:bottomDelay;
+
// no triggers from crate 1, slot 3
if (crate == 1 && slot == 3) {
return null;
@@ -103,8 +141,43 @@
if (ix > 0 && iy > 0) {
ix = 24 - ix;
}
- long newID = EcalConditions.makePhysicalID(ix, iy);
+
+ int values[] = {systemId, ix, iy};
+ GeometryId geomId = new GeometryId(helper, values);
+ // Creating the new channel from cell id, ix and iy, then reading its ID
+ long newID = geomId.encode();
+
//make new hit; set position to null so it gets recalculated
- return new HPSCalorimeterHit(hit.getRawEnergy(), hit.getTime()+delay*4, newID, hit.getType());
+ HPSCalorimeterHit h = new HPSCalorimeterHit(hit.getRawEnergy(), hit.getTime()+delay*4, newID, hit.getType());
+ h.setDetector(detector);
+ return h;
}
+
+ /**
+ * Return crate number from cellID
+ * @param cellID (long)
+ * @return Crate number (int)
+ */
+ private int getCrate(long cellID) {
+
+ EcalConditionsUtil util = new EcalConditionsUtil();
+
+ // Find the ECAL channel and return the crate number.
+ return util.getCrate(helper, cellID);
+ }
+
+ /**
+ * Return slot number from cellID
+ * @param cellID (long)
+ * @return Slot number (int)
+ */
+ private int getSlot(long cellID) {
+ EcalConditionsUtil util = new EcalConditionsUtil();
+
+ // Find the ECAL channel and return the crate number.
+ return util.getSlot(helper, cellID);
+ }
+
+
+
}
java/branches/hps_java_trunk_HPSJAVA-251/ecal-recon/src/main/java/org/hps/recon/ecal
--- java/branches/hps_java_trunk_HPSJAVA-251/ecal-recon/src/main/java/org/hps/recon/ecal/FADCConverterDriver.java 2014-09-12 02:08:45 UTC (rev 1010)
+++ java/branches/hps_java_trunk_HPSJAVA-251/ecal-recon/src/main/java/org/hps/recon/ecal/FADCConverterDriver.java 2014-09-12 02:32:40 UTC (rev 1011)
@@ -3,7 +3,15 @@
import java.util.ArrayList;
import java.util.List;
-import org.hps.conditions.deprecated.EcalConditions;
+import org.hps.conditions.TableConstants;
+import org.hps.conditions.ecal.EcalChannel.EcalChannelCollection;
+import org.hps.conditions.ecal.EcalChannel.GeometryId;
+import org.hps.conditions.ecal.EcalChannelConstants;
+import org.hps.conditions.ecal.EcalConditions;
+import org.lcsim.conditions.ConditionsManager;
+import org.lcsim.detector.identifier.IIdentifier;
+import org.lcsim.detector.identifier.IIdentifierHelper;
+import org.lcsim.detector.identifier.Identifier;
import org.lcsim.event.EventHeader;
import org.lcsim.event.RawTrackerHit;
import org.lcsim.event.base.BaseRawCalorimeterHit;
@@ -16,6 +24,10 @@
*/
public class FADCConverterDriver extends Driver {
+ EcalConditions ecalConditions = null;
+ IIdentifierHelper helper = null;
+ EcalChannelCollection channels = null;
+ EcalRawConverter converter = null;
String rawCollectionName = "EcalReadoutHits";
String ecalReadoutName = "EcalHits";
String ecalCollectionName = "EcalIntegralHits";
@@ -59,7 +71,18 @@
}
@Override
- public void detectorChanged(Detector detector) {
+ public void detectorChanged(Detector detector) {
+ // ECAL combined conditions object.
+ ecalConditions = ConditionsManager.defaultInstance()
+ .getCachedConditions(EcalConditions.class, TableConstants.ECAL_CONDITIONS).getCachedData();
+
+ // List of channels.
+ channels = ecalConditions.getChannelCollection();
+
+ // ID helper.
+ helper = detector.getSubdetector("Ecal").getDetectorElement().getIdentifierHelper();
+
+ System.out.println("You are now using the database conditions for FADCConverterDriver");
}
@Override
@@ -74,8 +97,12 @@
for (RawTrackerHit hit : hits) {
short[] window = hit.getADCValues();
long id = hit.getCellID();
+
+ // Get the channel data.
+ EcalChannelConstants channelData = findChannel(id);
+
//do DAQ readout
- double crystalThreshold = EcalConditions.physicalToPedestal(id) + threshold;
+ double crystalThreshold = channelData.getCalibration().getPedestal() + threshold;
int adcSum = 0;
int pointerOffset = 0;
int numSamplesToRead = 0;
@@ -100,4 +127,26 @@
int flags = 0;
event.put(ecalCollectionName, readoutHits, BaseRawCalorimeterHit.class, flags, ecalReadoutName);
}
+
+ /**
+ * Convert physical ID to gain value.
+ * @param cellID (long)
+ * @return channel constants (EcalChannelConstants)
+ */
+ private EcalChannelConstants findChannel(long cellID) {
+ // Make an ID object from raw hit ID.
+ IIdentifier id = new Identifier(cellID);
+
+ // Get physical field values.
+ int system = helper.getValue(id, "system");
+ int x = helper.getValue(id, "ix");
+ int y = helper.getValue(id, "iy");
+
+ // Create an ID to search for in channel collection.
+ GeometryId geometryId = new GeometryId(helper, new int[] { system, x, y });
+
+ // Get the channel data.
+ return ecalConditions.getChannelConstants(channels.findChannel(geometryId));
+ }
+
}
java/branches/hps_java_trunk_HPSJAVA-251/ecal-recon/src/main/java/org/hps/recon/ecal
--- java/branches/hps_java_trunk_HPSJAVA-251/ecal-recon/src/main/java/org/hps/recon/ecal/GTPEcalClusterer.java 2014-09-12 02:08:45 UTC (rev 1010)
+++ java/branches/hps_java_trunk_HPSJAVA-251/ecal-recon/src/main/java/org/hps/recon/ecal/GTPEcalClusterer.java 2014-09-12 02:32:40 UTC (rev 1011)
@@ -32,6 +32,9 @@
* @author Sho Uemura
*/
public class GTPEcalClusterer extends Driver {
+ Detector detector = null;
+
+
/**
* <b>calorimeter</b><br/><br/>
* <code>private HPSEcal3 <b>calorimeter</b></code><br/><br/>
@@ -112,6 +115,9 @@
*/
@Override
public void detectorChanged(Detector detector) {
+
+ this.detector = detector;
+
// Get the calorimeter object.
calorimeter = (HPSEcal3) detector.getSubdetector(ecalName);
@@ -153,7 +159,9 @@
// Store the crystals that are part of this potential cluster,
// starting with the cluster seed candidate.
- HPSEcalCluster cluster = new HPSEcalCluster(currentHit);
+ HPSEcalCluster cluster = new HPSEcalCluster();
+ cluster.setDetector(detector);
+ cluster.setSeedHit(currentHit);
cluster.addHit(currentHit);
// Get the set of neighbors for this hit.
java/branches/hps_java_trunk_HPSJAVA-251/ecal-recon/src/main/java/org/hps/recon/ecal
--- java/branches/hps_java_trunk_HPSJAVA-251/ecal-recon/src/main/java/org/hps/recon/ecal/HPSCalorimeterHit.java 2014-09-12 02:08:45 UTC (rev 1010)
+++ java/branches/hps_java_trunk_HPSJAVA-251/ecal-recon/src/main/java/org/hps/recon/ecal/HPSCalorimeterHit.java 2014-09-12 02:32:40 UTC (rev 1011)
@@ -4,11 +4,21 @@
import java.util.Comparator;
-import org.hps.conditions.deprecated.EcalConditions;
+import org.hps.conditions.ConditionsDriver;
+import org.hps.conditions.TableConstants;
+import org.hps.conditions.ecal.EcalChannel.EcalChannelCollection;
+import org.hps.conditions.ecal.EcalChannel.GeometryId;
+import org.hps.conditions.ecal.EcalChannelConstants;
+import org.hps.conditions.ecal.EcalConditions;
+import org.hps.conditions.ecal.EcalConditionsUtil;
+import org.lcsim.conditions.ConditionsManager;
+import org.lcsim.detector.identifier.IIdentifier;
+import org.lcsim.detector.identifier.IIdentifierHelper;
import org.lcsim.detector.IDetectorElement;
import org.lcsim.detector.IDetectorElementContainer;
import org.lcsim.event.CalorimeterHit;
import org.lcsim.event.base.BaseCalorimeterHit;
+import org.lcsim.geometry.Detector;
/**
* An implementation of CalorimeterHit, with a constructor that sets rawEnergy
@@ -19,6 +29,11 @@
*/
public class HPSCalorimeterHit extends BaseCalorimeterHit {
+ Detector detector = null;
+ static EcalConditions ecalConditions = null;
+ static IIdentifierHelper helper = null;
+ static EcalChannelCollection channels = null;
+
/**
* Fully qualified constructor that sets rawEnergy
*
@@ -27,9 +42,53 @@
* @param time Time of energy deposition
* @param id Cell ID
* @param type Type
+ * WARNING: setDetector(detector° must be called after initialization
*/
public HPSCalorimeterHit(double energy, double time, long id, int type) {
this.rawEnergy = energy;
+// if (position != null) {
+// this.positionVec = new BasicHep3Vector(position);
+// } else {
+// positionVec = null;
+// }
+ this.time = time;
+ this.id = id;
+ this.type = type;
+ }
+
+ /**
+ * Fully qualified constructor that sets rawEnergy
+ *
+ * @param energy Raw energy for this cell
+ * @param position Global Cartesian coordinate for this cell
+ * @param time Time of energy deposition
+ * @param id Cell ID
+ * @param type Type
+ * WARNING: setDetector(detector) must be called after initialization
+ */
+ public HPSCalorimeterHit(CalorimeterHit hit) {
+ this.rawEnergy = hit.getRawEnergy();
+// if (position != null) {
+// this.positionVec = new BasicHep3Vector(position);
+// } else {
+// positionVec = null;
+// }
+ this.time = hit.getTime();
+ this.id = hit.getCellID();
+ this.type = hit.getType();
+ }
+
+ /**
+ * Fully qualified constructor that sets rawEnergy
+ *
+ * @param energy Raw energy for this cell
+ * @param position Global Cartesian coordinate for this cell
+ * @param time Time of energy deposition
+ * @param id Cell ID
+ * @param type Type
+ */
+ public void setParameters(double energy, double time, long id, int type) {
+ this.rawEnergy = energy;
// if (position != null) {
// this.positionVec = new BasicHep3Vector(position);
// } else {
@@ -44,7 +103,7 @@
public IDetectorElement getDetectorElement() {
if (de == null) {
// findDetectorElementByPosition();
- IDetectorElementContainer detectorElements = EcalConditions.getSubdetector().getDetectorElement().findDetectorElement(getIdentifier());
+ IDetectorElementContainer detectorElements = detector.getDetectorElement().findDetectorElement(getIdentifier());
if (detectorElements.size() != 1) {
throw new RuntimeException("Expected exactly one DetectorElement matching ID " + getIdentifier() + ", got " + detectorElements.size());
} else {
@@ -72,4 +131,26 @@
return Double.compare(o1.getTime(), o2.getTime());
}
}
+
+ /**
+ * Must be set when an object HPSCalorimeterHit is created.
+ * @param detector (long)
+ */
+ public void setDetector(Detector detector) {
+ this.detector = detector;
+
+ // ECAL combined conditions object.
+ ecalConditions = ConditionsManager.defaultInstance()
+ .getCachedConditions(EcalConditions.class, TableConstants.ECAL_CONDITIONS).getCachedData();
+
+ // List of channels.
+ channels = ecalConditions.getChannelCollection();
+
+ // ID helper.
+ helper = detector.getSubdetector("Ecal").getDetectorElement().getIdentifierHelper();
+
+// System.out.println("You are now using the database conditions for HPSCalorimeterHit.");
+ }
+
+
}
java/branches/hps_java_trunk_HPSJAVA-251/ecal-recon/src/main/java/org/hps/recon/ecal
--- java/branches/hps_java_trunk_HPSJAVA-251/ecal-recon/src/main/java/org/hps/recon/ecal/HPSEcalCluster.java 2014-09-12 02:08:45 UTC (rev 1010)
+++ java/branches/hps_java_trunk_HPSJAVA-251/ecal-recon/src/main/java/org/hps/recon/ecal/HPSEcalCluster.java 2014-09-12 02:32:40 UTC (rev 1011)
@@ -3,12 +3,20 @@
import hep.physics.vec.BasicHep3Vector;
import hep.physics.vec.Hep3Vector;
import hep.physics.vec.VecOp;
+
import java.util.List;
+
+import org.hps.conditions.TableConstants;
+import org.hps.conditions.ecal.EcalConditions;
+import org.hps.conditions.ecal.EcalChannel.EcalChannelCollection;
+import org.lcsim.conditions.ConditionsManager;
import org.lcsim.detector.IGeometryInfo;
+import org.lcsim.detector.identifier.IIdentifierHelper;
import org.lcsim.detector.solids.Trd;
import org.lcsim.event.CalorimeterHit;
import org.lcsim.event.Cluster;
import org.lcsim.event.base.BaseCluster;
+import org.lcsim.geometry.Detector;
/**
* Cluster with position defined by seed hit (for 1-bit trigger)
@@ -17,8 +25,13 @@
* @version $Id: HPSEcalCluster.java,v 1.11 2013/02/25 22:39:24 meeg Exp $
*/
public class HPSEcalCluster extends BaseCluster {
+
+ Detector detector = null;
+ static EcalConditions ecalConditions = null;
+ static IIdentifierHelper helper = null;
+ static EcalChannelCollection channels = null;
- private CalorimeterHit seedHit = null;
+ private HPSCalorimeterHit seedHit = null;
private long cellID;
static final double eCriticalW = 800.0*ECalUtils.MeV/(74+1);
@@ -27,16 +40,41 @@
private boolean needsElectronPosCalculation = true;
double[] photonPosAtDepth = new double[3];
private boolean needsPhotonPosCalculation = true;
+
+ /**
+ * After the declaration, yourHPSEcalCluster.setDetector(detector) must be called
+ * @param cellID (long)
+ */
+ public HPSEcalCluster() {
+ }
+ /**
+ * After the declaration, yourHPSEcalCluster.setDetector(detector) must be called
+ * @param cellID (long)
+ */
public HPSEcalCluster(Long cellID) {
this.cellID = cellID;
}
public HPSEcalCluster(CalorimeterHit seedHit) {
- this.seedHit = seedHit;
+ setSeedHit(seedHit);
+ }
+
+ /**
+ * Before using this method yourHPSEcalCluster.setDetector(detector) must be called
+ * @param CalorimeterHit
+ */
+ public void setSeedHit(CalorimeterHit seedHit) {
+ this.seedHit = new HPSCalorimeterHit(seedHit);
+ ((HPSCalorimeterHit) seedHit).setDetector(detector);
this.cellID = seedHit.getCellID();
}
+ /**
+ *
+ * @param
+ * @return CalorimeterHit
+ */
public CalorimeterHit getSeedHit() {
if (seedHit == null) {
CalorimeterHit hit = hits.get(0);
@@ -44,16 +82,25 @@
throw new RuntimeException("HPSEcalCluster has no hits");
}
seedHit = new HPSCalorimeterHit(0.0, 0.0, cellID, hit.getType());
+ seedHit.setDetector(detector);
seedHit.setMetaData(hit.getMetaData());
}
return seedHit;
}
+ /**
+ * Must be set when an object HPSEcalCluster is created.
+ * @param detector (long)
+ */
+ public void setDetector(Detector detector) {
+ this.detector = detector;
+ }
+
/**
* Find highest-energy hit in a cluster. For clusters made by GTPEcalClusterer, HPSEcalCluster.getSeedHit(cluster) should be equivalent to cluster.getSeedHit().
* Since this method doesn't require that the cluster be an HPSEcalCluster, it will work on clusters read from LCIO.
* @param cluster
- * @return
+ * @return CalorimeterHit
*/
public static CalorimeterHit getSeedHit(Cluster cluster) {
CalorimeterHit seedHit = null;
SVNspam 0.1