27 modified files
java/branches/hps_java_trunk_HPSJAVA-255/conditions/src/main/java/org/hps/conditions/ecal
--- java/branches/hps_java_trunk_HPSJAVA-255/conditions/src/main/java/org/hps/conditions/ecal/EcalConditionsUtil.java 2014-09-29 21:05:55 UTC (rev 1105)
+++ java/branches/hps_java_trunk_HPSJAVA-255/conditions/src/main/java/org/hps/conditions/ecal/EcalConditionsUtil.java 2014-09-29 22:19:09 UTC (rev 1106)
@@ -61,7 +61,7 @@
* @param cellId The cell ID of the hit.
* @return The crate number of the channel.
*/
- int getCrate(IIdentifierHelper helper, long cellId) {
+ public int getCrate(IIdentifierHelper helper, long cellId) {
return findChannel(helper, cellId).getCrate();
}
@@ -71,7 +71,7 @@
* @param cellId The cell ID of the hit.
* @return The slot number of the channel.
*/
- int getSlot(IIdentifierHelper helper, long cellId) {
+ public int getSlot(IIdentifierHelper helper, long cellId) {
return findChannel(helper, cellId).getSlot();
}
java/branches/hps_java_trunk_HPSJAVA-255/ecal-readout-sim/src/main/java/org/hps/readout/ecal
--- java/branches/hps_java_trunk_HPSJAVA-255/ecal-readout-sim/src/main/java/org/hps/readout/ecal/FADCEcalReadoutDriver.java 2014-09-29 21:05:55 UTC (rev 1105)
+++ java/branches/hps_java_trunk_HPSJAVA-255/ecal-readout-sim/src/main/java/org/hps/readout/ecal/FADCEcalReadoutDriver.java 2014-09-29 22:19:09 UTC (rev 1106)
@@ -15,7 +15,17 @@
import java.util.PriorityQueue;
import java.util.Set;
-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.recon.ecal.ECalUtils;
import org.hps.recon.ecal.HPSRawCalorimeterHit;
import org.lcsim.event.CalorimeterHit;
@@ -45,6 +55,9 @@
private static final int ECAL_PULSE_INTEGRAL_MODE = 3;
String ecalName = "Ecal";
Subdetector ecal;
+ EcalConditions ecalConditions = null;
+ IIdentifierHelper helper = null;
+ EcalChannelCollection channels = null;
//buffer for preamp signals (units of volts, no pedestal)
private Map<Long, RingBuffer> signalMap = null;
//ADC pipeline for readout (units of ADC counts)
@@ -229,9 +242,12 @@
FADCPipeline pipeline = pipelineMap.get(cellID);
pipeline.step();
+
+ // Get the channel data.
+ EcalChannelConstants channelData = findChannel(cellID);
double currentValue = signalBuffer.currentValue() * ((Math.pow(2, nBit) - 1) / maxVolt); //12-bit ADC with maxVolt V range
- int pedestal = (int) Math.round(EcalConditions.physicalToPedestal(cellID));
+ int pedestal = (int) Math.round(channelData.getCalibration().getPedestal());
int digitizedValue = Math.min((int) Math.round(pedestal + currentValue), (int) Math.pow(2, nBit)); //ADC can't return a value larger than 4095; 4096 (overflow) is returned for any input >2V
pipeline.writeValue(digitizedValue);
int pedestalSubtractedValue = digitizedValue - pedestal;
@@ -374,6 +390,10 @@
int pointerOffset = 0;
int numSamplesToRead = 0;
int thresholdCrossing = 0;
+
+ // Get the channel data.
+ EcalChannelConstants channelData = findChannel(cellID);
+
for (int i = 0; i < readoutWindow; i++) {
if (numSamplesToRead != 0) {
adcValues[adcValues.length - numSamplesToRead] = window[i - pointerOffset];
@@ -381,7 +401,7 @@
if (numSamplesToRead == 0) {
hits.add(new BaseRawTrackerHit(cellID, thresholdCrossing, adcValues));
}
- } else if ((i == 0 || window[i - 1] <= EcalConditions.physicalToPedestal(cellID) + readoutThreshold) && window[i] > EcalConditions.physicalToPedestal(cellID) + readoutThreshold) {
+ } else if ((i == 0 || window[i - 1] <= channelData.getCalibration().getPedestal() + readoutThreshold) && window[i] > channelData.getCalibration().getPedestal() + readoutThreshold) {
thresholdCrossing = i;
pointerOffset = Math.min(numSamplesBefore, i);
numSamplesToRead = pointerOffset + Math.min(numSamplesAfter, readoutWindow - i - pointerOffset - 1);
@@ -401,6 +421,10 @@
int pointerOffset = 0;
int numSamplesToRead = 0;
int thresholdCrossing = 0;
+
+ // Get the channel data.
+ EcalChannelConstants channelData = findChannel(cellID);
+
if (window != null) {
for (int i = 0; i < readoutWindow; i++) {
if (numSamplesToRead != 0) {
@@ -412,7 +436,7 @@
if (numSamplesToRead == 0) {
hits.add(new BaseRawCalorimeterHit(cellID, adcSum, 64 * thresholdCrossing));
}
- } else if ((i == 0 || window[i - 1] <= EcalConditions.physicalToPedestal(cellID) + readoutThreshold) && window[i] > EcalConditions.physicalToPedestal(cellID) + readoutThreshold) {
+ } else if ((i == 0 || window[i - 1] <= channelData.getCalibration().getPedestal() + readoutThreshold) && window[i] > channelData.getCalibration().getPedestal() + readoutThreshold) {
thresholdCrossing = i;
pointerOffset = Math.min(numSamplesBefore, i);
numSamplesToRead = pointerOffset + Math.min(numSamplesAfter, readoutWindow - i - pointerOffset - 1);
@@ -430,13 +454,15 @@
for (CalorimeterHit hit : hits) {
RingBuffer eDepBuffer = signalMap.get(hit.getCellID());
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;
if (use2014Gain) {
- noise = Math.sqrt(Math.pow(EcalConditions.physicalToNoise(hit.getCellID()) * EcalConditions.physicalToGain(hit.getCellID()) * ECalUtils.gainFactor * ECalUtils.ecalReadoutPeriod, 2) + hit.getRawEnergy() / (ECalUtils.lightYield * ECalUtils.quantumEff * ECalUtils.surfRatio));
+ noise = Math.sqrt(Math.pow(channelData.getCalibration().getNoise() * channelData.getGain().getGain() * ECalUtils.gainFactor * ECalUtils.ecalReadoutPeriod, 2) + hit.getRawEnergy() / (ECalUtils.lightYield * ECalUtils.quantumEff * ECalUtils.surfRatio));
} else {
- noise = Math.sqrt(Math.pow(EcalConditions.physicalToNoise(hit.getCellID()) * EcalConditions.physicalToGain(hit.getCellID()) * ECalUtils.MeV, 2) + hit.getRawEnergy() * ECalUtils.MeV / pePerMeV);
+ noise = Math.sqrt(Math.pow(channelData.getCalibration().getNoise() * channelData.getGain().getGain() * ECalUtils.MeV, 2) + hit.getRawEnergy() * ECalUtils.MeV / pePerMeV);
}
energyAmplitude += RandomGaussian.getGaussian(0, noise);
}
@@ -459,6 +485,17 @@
public void detectorChanged(Detector detector) {
// Get the Subdetector.
ecal = detector.getSubdetector(ecalName);
+
+ // 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();
+
resetFADCBuffers();
}
@@ -470,20 +507,24 @@
pipelineMap = new HashMap<Long, FADCPipeline>();
Set<Long> cells = ((HPSEcal3) ecal).getNeighborMap().keySet();
for (Long cellID : cells) {
+ EcalChannelConstants channelData = findChannel(cellID);
signalMap.put(cellID, new RingBuffer(bufferLength));
- pipelineMap.put(cellID, new FADCPipeline(pipelineLength, (int) Math.round(EcalConditions.physicalToPedestal(cellID))));
+ pipelineMap.put(cellID, new FADCPipeline(pipelineLength, (int) Math.round(channelData.getCalibration().getPedestal())));
}
return true;
}
private double pulseAmplitude(double time, long cellID) {
+ // Get the channel data.
+ EcalChannelConstants channelData = findChannel(cellID);
+
if (use2014Gain) {
//if fixedGain is set, multiply the default gain by this factor
double corrGain;
if (fixedGain > 0) {
corrGain = fixedGain;
} else {
- corrGain = 1.0 / EcalConditions.physicalToGain(cellID);
+ corrGain = 1.0 / channelData.getGain().getGain();
}
return corrGain * readoutGain * pulseAmplitude(time, pulseShape, tp);
@@ -493,7 +534,7 @@
if (fixedGain > 0) {
gain = readoutPeriod / (fixedGain * ECalUtils.MeV * ((Math.pow(2, nBit) - 1) / maxVolt));
} else {
- gain = readoutPeriod / (EcalConditions.physicalToGain(cellID) * ECalUtils.MeV * ((Math.pow(2, nBit) - 1) / maxVolt));
+ gain = readoutPeriod / (channelData.getGain().getGain() * ECalUtils.MeV * ((Math.pow(2, nBit) - 1) / maxVolt));
}
return gain * pulseAmplitude(time, pulseShape, tp);
@@ -584,4 +625,26 @@
return array[((ptr - pos) % size + size) % size];
}
}
+
+ /**
+ * 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-255/ecal-readout-sim/src/main/java/org/hps/readout/ecal
--- java/branches/hps_java_trunk_HPSJAVA-255/ecal-readout-sim/src/main/java/org/hps/readout/ecal/SimpleEcalReadoutDriver.java 2014-09-29 21:05:55 UTC (rev 1105)
+++ java/branches/hps_java_trunk_HPSJAVA-255/ecal-readout-sim/src/main/java/org/hps/readout/ecal/SimpleEcalReadoutDriver.java 2014-09-29 22:19:09 UTC (rev 1106)
@@ -6,6 +6,7 @@
import org.hps.recon.ecal.HPSCalorimeterHit;
import org.lcsim.event.CalorimeterHit;
+import org.lcsim.geometry.Detector;
/**
* Performs readout of ECal hits.
@@ -17,12 +18,21 @@
public class SimpleEcalReadoutDriver extends EcalReadoutDriver<HPSCalorimeterHit> {
//buffer for deposited energy
Map<Long, Double> eDepMap = null;
+
+ Detector detector = null;
+
+ HPSCalorimeterHit h = null;
public SimpleEcalReadoutDriver() {
hitClass = HPSCalorimeterHit.class;
}
@Override
+ public void detectorChanged(Detector detector) {
+ this.detector = detector;
+ }
+
+ @Override
protected void readHits(List<HPSCalorimeterHit> hits) {
for (Long cellID : eDepMap.keySet()) {
// int ix = dec.getValue("ix");
@@ -32,7 +42,9 @@
// if (iy == 1 && ix*side >= -10 && ix*side <= -2)
// continue;
if (eDepMap.get(cellID) > threshold)
- hits.add(new HPSCalorimeterHit(eDepMap.get(cellID), readoutTime(), cellID, hitType));
+ h = new HPSCalorimeterHit(eDepMap.get(cellID), readoutTime(), cellID, hitType);
+ h.setDetector(detector);
+ hits.add(h);
}
//reset hit integration
eDepMap = new HashMap<Long, Double>();
java/branches/hps_java_trunk_HPSJAVA-255/ecal-readout-sim/src/main/java/org/hps/readout/ecal
--- java/branches/hps_java_trunk_HPSJAVA-255/ecal-readout-sim/src/main/java/org/hps/readout/ecal/TimeEvolutionEcalReadoutDriver.java 2014-09-29 21:05:55 UTC (rev 1105)
+++ java/branches/hps_java_trunk_HPSJAVA-255/ecal-readout-sim/src/main/java/org/hps/readout/ecal/TimeEvolutionEcalReadoutDriver.java 2014-09-29 22:19:09 UTC (rev 1106)
@@ -6,6 +6,7 @@
import org.hps.recon.ecal.HPSCalorimeterHit;
import org.lcsim.event.CalorimeterHit;
+import org.lcsim.geometry.Detector;
/**
* Performs readout of ECal hits.
@@ -16,12 +17,19 @@
*/
public class TimeEvolutionEcalReadoutDriver extends EcalReadoutDriver<HPSCalorimeterHit> {
+ Detector detector = null;
+
//buffer for deposited energy
Map<Long, RingBuffer> eDepMap = null;
//length of ring buffer (in readout cycles)
int bufferLength = 20;
//shaper time constant in ns; negative values generate square pulses of the given width
double t0 = 18.0;
+
+ @Override
+ public void detectorChanged(Detector detector) {
+ this.detector = detector;
+ }
public TimeEvolutionEcalReadoutDriver() {
hitClass = HPSCalorimeterHit.class;
@@ -45,7 +53,9 @@
// int iy = dec.getValue("iy");
// if (iy == 1 && ix == -2)
// System.out.printf("Time %f, output signal %f\n", ClockSingleton.getTime(), eDepBuffer.currentValue());
- hits.add(new HPSCalorimeterHit(eDepBuffer.currentValue(), readoutTime(), cellID, hitType));
+ HPSCalorimeterHit h = new HPSCalorimeterHit(eDepBuffer.currentValue(), readoutTime(), cellID, hitType);
+ h.setDetector(detector);
+ hits.add(h);
}
eDepBuffer.step();
}
java/branches/hps_java_trunk_HPSJAVA-255/ecal-recon/src/main/java/org/hps/recon/ecal
--- java/branches/hps_java_trunk_HPSJAVA-255/ecal-recon/src/main/java/org/hps/recon/ecal/CTPEcalClusterer.java 2014-09-29 21:05:55 UTC (rev 1105)
+++ java/branches/hps_java_trunk_HPSJAVA-255/ecal-recon/src/main/java/org/hps/recon/ecal/CTPEcalClusterer.java 2014-09-29 22:19:09 UTC (rev 1106)
@@ -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-255/ecal-recon/src/main/java/org/hps/recon/ecal
--- java/branches/hps_java_trunk_HPSJAVA-255/ecal-recon/src/main/java/org/hps/recon/ecal/ECalUtils.java 2014-09-29 21:05:55 UTC (rev 1105)
+++ java/branches/hps_java_trunk_HPSJAVA-255/ecal-recon/src/main/java/org/hps/recon/ecal/ECalUtils.java 2014-09-29 22:19:09 UTC (rev 1106)
@@ -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-255/ecal-recon/src/main/java/org/hps/recon/ecal
--- java/branches/hps_java_trunk_HPSJAVA-255/ecal-recon/src/main/java/org/hps/recon/ecal/EcalClusterIC.java 2014-09-29 21:05:55 UTC (rev 1105)
+++ java/branches/hps_java_trunk_HPSJAVA-255/ecal-recon/src/main/java/org/hps/recon/ecal/EcalClusterIC.java 2014-09-29 22:19:09 UTC (rev 1106)
@@ -1,5 +1,10 @@
package org.hps.recon.ecal;
+import hep.physics.vec.BasicHep3Vector;
+import hep.physics.vec.Hep3Vector;
+import hep.physics.vec.VecOp;
+
+import java.awt.Point;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
@@ -11,8 +16,11 @@
import java.util.Map;
import java.util.Set;
+import org.lcsim.detector.IGeometryInfo;
+import org.lcsim.detector.solids.Trd;
import org.lcsim.event.CalorimeterHit;
import org.lcsim.event.EventHeader;
+import org.lcsim.event.MCParticle;
import org.lcsim.geometry.Detector;
import org.lcsim.geometry.subdetector.HPSEcal3;
import org.lcsim.geometry.subdetector.HPSEcal3.NeighborMap;
@@ -153,7 +161,17 @@
this.timeWindow = timeWindow;
}
+ // For storing MC particle list
+ public ArrayList<MCParticle> mcList = new ArrayList<MCParticle>();
+ // Make a map for quick calculation of the x-y position of crystal face
+ public Map<Point, Double[]> correctedPositionMap = new HashMap<Point, Double[]>();
+
+ // MC particle list
+ public void addMCGen(MCParticle genMC){
+ mcList.add(genMC);
+ }
+
public void startOfData() {
// Make sure that the calorimeter hit collection name is defined.
if (ecalCollectionName == null) {
@@ -186,8 +204,15 @@
public void process(EventHeader event) {
// Make sure the current event contains calorimeter hits.
if (event.hasCollection(CalorimeterHit.class, ecalCollectionName)) {
- // Get the list of raw calorimeter hits.
-
+
+ // Get generated hits
+ if (event.hasCollection(MCParticle.class, "MCParticle")) {
+ List<MCParticle> genPart = event.getMCParticles();
+ for(MCParticle m : genPart){
+ mcList.add(m);
+ }
+ }
+
// Generate clusters from the calorimeter hits.
//List<HPSEcalClusterIC> clusterList = null;
try { createClusters(event); }
@@ -374,9 +399,7 @@
}
}
-
-
-
+
// Performs second pass calculations for common hits.
commonHitsLoop:
for (CalorimeterHit clusteredHit : hitSeedMap.keySet()) {
@@ -443,9 +466,7 @@
/*
- * All hits are sorted from above. The next part of the code is for calculating energies. Still
- * needs implementation into new cluster collection so as to preserve shared hit energy
- * distribution within clusters.
+ * All hits are sorted from above. The next part of the code is for calculating energies.
*/
//Create map to contain the total energy of each cluster
@@ -466,9 +487,11 @@
seedEnergy.put(eSeed, eEnergy);
}
- //Distribute common hit energies with clusters
+ // Create a map to contain final uncorrected cluster energies with common hit distributions.
Map<CalorimeterHit, Double> seedEnergyTot = seedEnergy;
+ //Distribute common hit energies with clusters
+
for (Map.Entry<CalorimeterHit, List<CalorimeterHit>> entry1 : commonHits.entrySet()) {
CalorimeterHit commonCell = entry1.getKey();
CalorimeterHit seedA = entry1.getValue().get(0);
@@ -481,11 +504,109 @@
currEnergyB += eFractionB * commonCell.getCorrectedEnergy();
seedEnergyTot.put(seedA, currEnergyA);
- seedEnergyTot.put(seedB, currEnergyB);
+ seedEnergyTot.put(seedB, currEnergyB);
}
+
+
+ // Make mapping to contain clusters with corrected energy.
+ Map<CalorimeterHit, Double> seedEnergyCorr = new HashMap<CalorimeterHit, Double>();
+
+ // Energy Corrections as per HPS Note 2014-001
+ if (mcList.size() > 0) {
+ int pdg = mcList.get(0).getPDGID();
+ // Iterate through known clusters with energies and apply correction.
+ for (Map.Entry<CalorimeterHit, Double> entryC : seedEnergyTot.entrySet()) {
+ double rawEnergy = entryC.getValue();
+ if (pdg == 11) {// electron energy correction
+ double corrEnergy = rawEnergy / (-0.0027 * rawEnergy - 0.06 / (Math.sqrt(rawEnergy)) + 0.95);
+ seedEnergyCorr.put(entryC.getKey(), corrEnergy);
+ } else if (pdg == 22) {// photon energy correction
+ double corrEnergy = rawEnergy / (0.0015 * rawEnergy - 0.047 / (Math.sqrt(rawEnergy)) + 0.94);
+ seedEnergyCorr.put(entryC.getKey(), corrEnergy);
+ } else if (pdg == -11) {// positron energy correction
+ double corrEnergy = rawEnergy / (-0.0096 * rawEnergy - 0.042 / (Math.sqrt(rawEnergy)) + 0.94);
+ seedEnergyCorr.put(entryC.getKey(), corrEnergy);
+ } else {// some other particle, but I have no energy correction for this
+ double corrEnergy = rawEnergy;
+ seedEnergyCorr.put(entryC.getKey(), corrEnergy);
+ }
+ }// end of energy corrections
+ }
+
+ // Cluster Position as per HPS Note 2014-001
+ // Create map with seed as key to position/centroid value
+ Map<CalorimeterHit, Double[]> seedPosition = new HashMap<CalorimeterHit, Double[]>();
+
+ // top level iterates through seeds
+ for (Map.Entry<CalorimeterHit, Double> entryS : seedEnergyTot.entrySet()) {
+ //get the seed for this iteration
+ CalorimeterHit seedP = entryS.getKey();
+
+ double xCl = 0.0; // calculated cluster x position
+ double yCl = 0.0; // calculated cluster y position
+ double eNumX = 0.0;
+ double eNumY = 0.0;
+ double eDen = 0.0;
+ double w0 = 3.1;
+
+ // iterate through hits corresponding to seed
+ for (Map.Entry<CalorimeterHit, CalorimeterHit> entryP : hitSeedMap.entrySet()) {
+ if(entryP.getValue() == seedP){
+ ///////////////////////////////
+ // This block fills a map with crystal to center of face of crystal
+ // Get the hit indices as a Point.
+ int ix = entryP.getKey().getIdentifierFieldValue("ix");
+ int iy = entryP.getKey().getIdentifierFieldValue("iy");
+ Point hitIndex = new Point(ix, iy);
+
+ // Get the corrected position for this index pair.
+ Double[] position = correctedPositionMap.get(hitIndex);
+
+ // If the result is null, it hasn't been calculated yet.
+ if(position == null) {
+ // Calculate the corrected position.
+ IGeometryInfo geom = entryP.getKey().getDetectorElement().getGeometry();
+ double[] pos = geom.transformLocalToGlobal(VecOp.add(geom.transformGlobalToLocal(geom.getPosition()),(Hep3Vector)new BasicHep3Vector(0,0,-1*((Trd)geom.getLogicalVolume().getSolid()).getZHalfLength()))).v();
+
+ // Convert the result to a Double[] array.
+ position = new Double[3];
+ position[0] = pos[0];
+ position[1] = pos[1];
+ position[2] = pos[2];
+
+ // Store the result in the map.
+ correctedPositionMap.put(hitIndex, position);
+ }
+ ///////////////////////////////
+
+ //Use Method 3 weighting scheme described in note:
+ eNumX += Math.max(0.0,(w0+Math.log(entryP.getKey().getCorrectedEnergy()
+ /seedEnergyTot.get(seedP))))*(correctedPositionMap.get(hitIndex)[0]/10.0);
+ eNumY += Math.max(0.0,(w0+Math.log(entryP.getKey().getCorrectedEnergy()
+ /seedEnergyTot.get(seedP))))*(correctedPositionMap.get(hitIndex)[1]/10.0);
+ eDen += Math.max(0.0, (w0+Math.log(entryP.getKey().getCorrectedEnergy()/
+ seedEnergyTot.get(seedP))));
+ }
+
+ }
+
+ xCl = eNumX/eDen;
+ yCl = eNumY/eDen;
+
+ Double[] corrPosition = new Double[2];
+ corrPosition[0] = xCl;
+ corrPosition[1] = yCl;
+ seedPosition.put(seedP, corrPosition);
+
+
+ }// end of cluster position calculation
+
+
+
+
/*
* Prints the results in event display format. Not analyzed
* for efficiency, as this will ultimately not be a part of
@@ -521,11 +642,15 @@
int six = entry2.getKey().getIdentifierFieldValue("ix");
int siy = entry2.getKey().getIdentifierFieldValue("iy");
- double energy = seedEnergyTot.get(entry2.getKey());
// writeHits.append(String.format("Cluster\t%d\t%d\t%f%n", six, siy, energy));
HPSEcalClusterIC cluster = new HPSEcalClusterIC(entry2.getKey());
cluster.addHit(entry2.getKey());
+
+ //can't seem to get this to go into cluster information-------!!!!
+ // cluster.addPositionCorr(seedPosition.get(entry2.getKey()));
+ if (seedEnergyCorr.values().size() > 0)
+ cluster.setEnergy(seedEnergyCorr.get(entry2.getKey()));
for (Map.Entry<CalorimeterHit, CalorimeterHit> entry3 : hitSeedMap.entrySet()) {
if (entry3.getValue() == entry2.getValue()) {
@@ -559,7 +684,6 @@
}
- cluster.setEnergy(energy);
clusterList.add(cluster);
}// End checking thresholds and write out.
}
java/branches/hps_java_trunk_HPSJAVA-255/ecal-recon/src/main/java/org/hps/recon/ecal
--- java/branches/hps_java_trunk_HPSJAVA-255/ecal-recon/src/main/java/org/hps/recon/ecal/EcalClusterICBasic.java 2014-09-29 21:05:55 UTC (rev 1105)
+++ java/branches/hps_java_trunk_HPSJAVA-255/ecal-recon/src/main/java/org/hps/recon/ecal/EcalClusterICBasic.java 2014-09-29 22:19:09 UTC (rev 1106)
@@ -188,7 +188,7 @@
}
if (biggestSeed == null) { //if no neighbors had more energy than this hit, this hit is a seed
hitToSeed.put(hit, hit);
- HPSEcalCluster cluster = new HPSEcalCluster(hit);
+ HPSEcalCluster cluster = new HPSEcalCluster(hit.getCellID());
clusters.add(cluster);
seedToCluster.put(hit, cluster);
} else {
java/branches/hps_java_trunk_HPSJAVA-255/ecal-recon/src/main/java/org/hps/recon/ecal
--- java/branches/hps_java_trunk_HPSJAVA-255/ecal-recon/src/main/java/org/hps/recon/ecal/EcalClusterer.java 2014-09-29 21:05:55 UTC (rev 1105)
+++ java/branches/hps_java_trunk_HPSJAVA-255/ecal-recon/src/main/java/org/hps/recon/ecal/EcalClusterer.java 2014-09-29 22:19:09 UTC (rev 1106)
@@ -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-255/ecal-recon/src/main/java/org/hps/recon/ecal
--- java/branches/hps_java_trunk_HPSJAVA-255/ecal-recon/src/main/java/org/hps/recon/ecal/EcalConverterDriver.java 2014-09-29 21:05:55 UTC (rev 1105)
+++ java/branches/hps_java_trunk_HPSJAVA-255/ecal-recon/src/main/java/org/hps/recon/ecal/EcalConverterDriver.java 2014-09-29 22:19:09 UTC (rev 1106)
@@ -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-255/ecal-recon/src/main/java/org/hps/recon/ecal
--- java/branches/hps_java_trunk_HPSJAVA-255/ecal-recon/src/main/java/org/hps/recon/ecal/EcalEdepToTriggerConverterDriver.java 2014-09-29 21:05:55 UTC (rev 1105)
+++ java/branches/hps_java_trunk_HPSJAVA-255/ecal-recon/src/main/java/org/hps/recon/ecal/EcalEdepToTriggerConverterDriver.java 2014-09-29 22:19:09 UTC (rev 1106)
@@ -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-255/ecal-recon/src/main/java/org/hps/recon/ecal
--- java/branches/hps_java_trunk_HPSJAVA-255/ecal-recon/src/main/java/org/hps/recon/ecal/EcalRawConverter.java 2014-09-29 21:05:55 UTC (rev 1105)
+++ java/branches/hps_java_trunk_HPSJAVA-255/ecal-recon/src/main/java/org/hps/recon/ecal/EcalRawConverter.java 2014-09-29 22:19:09 UTC (rev 1106)
@@ -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,17 @@
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 +57,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 +77,11 @@
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-255/ecal-recon/src/main/java/org/hps/recon/ecal
--- java/branches/hps_java_trunk_HPSJAVA-255/ecal-recon/src/main/java/org/hps/recon/ecal/EcalRawConverterDriver.java 2014-09-29 21:05:55 UTC (rev 1105)
+++ java/branches/hps_java_trunk_HPSJAVA-255/ecal-recon/src/main/java/org/hps/recon/ecal/EcalRawConverterDriver.java 2014-09-29 22:19:09 UTC (rev 1106)
@@ -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";
@@ -34,7 +53,7 @@
private boolean useTruthTime = false;
public EcalRawConverterDriver() {
- converter = new EcalRawConverter();
+ converter = new EcalRawConverter();
}
public void setUse2014Gain(boolean use2014Gain) {
@@ -94,17 +113,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 channelData.isBadChannel();
}
-
- 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");
@@ -150,7 +195,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)) {
@@ -170,6 +219,7 @@
System.out.format("old hit energy %d\n", hit.getAmplitude());
}
CalorimeterHit newHit = converter.HitDtoA(hit, integralWindow, timeOffset);
+
if (newHit.getRawEnergy() > threshold) {
if (applyBadCrystalMap && isBadCrystal(newHit)) {
continue;
@@ -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-255/ecal-recon/src/main/java/org/hps/recon/ecal
--- java/branches/hps_java_trunk_HPSJAVA-255/ecal-recon/src/main/java/org/hps/recon/ecal/EcalReadoutToTriggerConverterDriver.java 2014-09-29 21:05:55 UTC (rev 1105)
+++ java/branches/hps_java_trunk_HPSJAVA-255/ecal-recon/src/main/java/org/hps/recon/ecal/EcalReadoutToTriggerConverterDriver.java 2014-09-29 22:19:09 UTC (rev 1106)
@@ -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-255/ecal-recon/src/main/java/org/hps/recon/ecal
--- java/branches/hps_java_trunk_HPSJAVA-255/ecal-recon/src/main/java/org/hps/recon/ecal/EcalTriggerFilterDriver.java 2014-09-29 21:05:55 UTC (rev 1105)
+++ java/branches/hps_java_trunk_HPSJAVA-255/ecal-recon/src/main/java/org/hps/recon/ecal/EcalTriggerFilterDriver.java 2014-09-29 22:19:09 UTC (rev 1106)
@@ -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-255/ecal-recon/src/main/java/org/hps/recon/ecal
--- java/branches/hps_java_trunk_HPSJAVA-255/ecal-recon/src/main/java/org/hps/recon/ecal/FADCConverterDriver.java 2014-09-29 21:05:55 UTC (rev 1105)
+++ java/branches/hps_java_trunk_HPSJAVA-255/ecal-recon/src/main/java/org/hps/recon/ecal/FADCConverterDriver.java 2014-09-29 22:19:09 UTC (rev 1106)
@@ -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-255/ecal-recon/src/main/java/org/hps/recon/ecal
--- java/branches/hps_java_trunk_HPSJAVA-255/ecal-recon/src/main/java/org/hps/recon/ecal/GTPEcalClusterer.java 2014-09-29 21:05:55 UTC (rev 1105)
+++ java/branches/hps_java_trunk_HPSJAVA-255/ecal-recon/src/main/java/org/hps/recon/ecal/GTPEcalClusterer.java 2014-09-29 22:19:09 UTC (rev 1106)
@@ -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-255/ecal-recon/src/main/java/org/hps/recon/ecal
--- java/branches/hps_java_trunk_HPSJAVA-255/ecal-recon/src/main/java/org/hps/recon/ecal/HPSCalorimeterHit.java 2014-09-29 21:05:55 UTC (rev 1105)
+++ java/branches/hps_java_trunk_HPSJAVA-255/ecal-recon/src/main/java/org/hps/recon/ecal/HPSCalorimeterHit.java 2014-09-29 22:19:09 UTC (rev 1106)
@@ -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-255/ecal-recon/src/main/java/org/hps/recon/ecal
--- java/branches/hps_java_trunk_HPSJAVA-255/ecal-recon/src/main/java/org/hps/recon/ecal/HPSEcalCluster.java 2014-09-29 21:05:55 UTC (rev 1105)
+++ java/branches/hps_java_trunk_HPSJAVA-255/ecal-recon/src/main/java/org/hps/recon/ecal/HPSEcalCluster.java 2014-09-29 22:19:09 UTC (rev 1106)
@@ -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,6 +25,11 @@
* @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 long cellID;
@@ -27,16 +40,37 @@
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) {
+ /**
+ * Before using this method yourHPSEcalCluster.setDetector(detector) must be called
+ * @param CalorimeterHit
+ */
+ public void setSeedHit(CalorimeterHit seedHit) {
this.seedHit = 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 +78,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;
java/branches/hps_java_trunk_HPSJAVA-255/ecal-recon/src/main/java/org/hps/recon/ecal
--- java/branches/hps_java_trunk_HPSJAVA-255/ecal-recon/src/main/java/org/hps/recon/ecal/HPSEcalClusterIC.java 2014-09-29 21:05:55 UTC (rev 1105)
+++ java/branches/hps_java_trunk_HPSJAVA-255/ecal-recon/src/main/java/org/hps/recon/ecal/HPSEcalClusterIC.java 2014-09-29 22:19:09 UTC (rev 1106)
@@ -27,12 +27,15 @@
private ArrayList<CalorimeterHit> sharedHitList = new ArrayList<CalorimeterHit>();
+
+
static final double eCriticalW = 800.0*ECalUtils.MeV/(74+1);
static final double radLenW = 8.8; //mm
double[] electronPosAtDepth = new double[3];
private boolean needsElectronPosCalculation = true;
double[] photonPosAtDepth = new double[3];
private boolean needsPhotonPosCalculation = true;
+ double[] positionCorrection = new double[2];
public HPSEcalClusterIC(Long cellID) {
this.cellID = cellID;
@@ -59,10 +62,17 @@
sharedHitList.add(sharedHit);
}
+
+
public List<CalorimeterHit> getSharedHits() {
return sharedHitList;
}
+ public void addPositionCorr(Double[] posCorr) {
+ this.addPositionCorr(posCorr);
+ }
+
+
// public double[] getPosition() {
// return getSeedHit().getPosition();
// }
java/branches/hps_java_trunk_HPSJAVA-255/evio/src/main/java/org/hps/evio
--- java/branches/hps_java_trunk_HPSJAVA-255/evio/src/main/java/org/hps/evio/ECalEvioReader.java 2014-09-29 21:05:55 UTC (rev 1105)
+++ java/branches/hps_java_trunk_HPSJAVA-255/evio/src/main/java/org/hps/evio/ECalEvioReader.java 2014-09-29 22:19:09 UTC (rev 1106)
@@ -3,18 +3,32 @@
import java.util.ArrayList;
import java.util.List;
-import org.hps.conditions.deprecated.EcalConditions;
+import org.hps.conditions.ecal.EcalChannel.EcalChannelCollection;
+import org.hps.conditions.ConditionsDriver;
+import org.hps.conditions.DatabaseConditionsManager;
+import org.hps.conditions.TableConstants;
+import org.hps.conditions.ecal.EcalChannel;
+import org.hps.conditions.ecal.EcalChannel.DaqId;
+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.IIdentifierHelper;
+import org.lcsim.detector.identifier.Identifier;
+//import org.hps.conditions.deprecated.EcalConditions;
import org.jlab.coda.jevio.BaseStructure;
import org.jlab.coda.jevio.BaseStructureHeader;
import org.jlab.coda.jevio.CompositeData;
import org.jlab.coda.jevio.EvioEvent;
import org.jlab.coda.jevio.EvioException;
-import org.lcsim.detector.identifier.Identifier;
import org.lcsim.event.EventHeader;
import org.lcsim.event.RawTrackerHit;
import org.lcsim.event.SimTrackerHit;
import org.lcsim.event.base.BaseRawCalorimeterHit;
import org.lcsim.event.base.BaseRawTrackerHit;
+import org.lcsim.geometry.Detector;
+import org.lcsim.geometry.Subdetector;
import org.lcsim.lcio.LCIOConstants;
/**
@@ -27,9 +41,35 @@
private int bankTag = EventConstants.ECAL_PULSE_INTEGRAL_BANK_TAG;
private Class hitClass = BaseRawCalorimeterHit.class;
+
+ // FIXME: Hard-coded detector names.
+ private static String readoutName = "EcalHits";
+ private static String subdetectorName = "Ecal";
+ Detector detector;
+ Subdetector subDetector;
+
+ static EcalConditions ecalConditions = null;
+ static IIdentifierHelper helper = null;
+ static EcalChannelCollection channels = null;
public ECalEvioReader() {
hitCollectionName = "EcalReadoutHits";
+
+ detector = DatabaseConditionsManager.getInstance().getDetectorObject();
+ subDetector = detector.getSubdetector(subdetectorName);
+
+ // ECAL combined conditions object.
+ ecalConditions = ConditionsManager.defaultInstance()
+ .getCachedConditions(EcalConditions.class, TableConstants.ECAL_CONDITIONS).getCachedData();
+
+ // List of channels.
+ channels = ecalConditions.getChannelCollection();
+
+ helper = subDetector.getDetectorElement().getIdentifierHelper();
+
+ System.out.println("You are now using the database conditions for ECalEvioReader.java");
+ // ID helper.
+// helper = detector.getSubdetector("Ecal").getDetectorElement().getIdentifierHelper();
}
@Override
@@ -91,7 +131,7 @@
}
}
}
- String readoutName = EcalConditions.getSubdetector().getReadout().getName();
+// String readoutName = ;
lcsimEvent.put(hitCollectionName, hits, hitClass, flags, readoutName);
// for (Object hit : hits) {
// System.out.println(((RawTrackerHit) hit).getIDDecoder().getIDDescription().toString());
@@ -126,22 +166,44 @@
if (debug) {
System.out.println(" channel=" + channel + "; nSamples=" + nSamples);
}
- Long id = EcalConditions.daqToPhysicalID(crate, slot, channel);
+
+ long id = daqToGeometryId(crate, slot, channel);
+// Long id = EcalConditions.daqToPhysicalID(crate, slot, channel);
+
+ System.out.println("The long id is: " + id);
+
short[] adcValues = new short[nSamples];
for (int i = 0; i < nSamples; i++) {
adcValues[i] = cdata.getShort();
}
- if (id == null) {
- System.out.printf("Crate %d, slot %d, channel %d not found in map\n", crate, slot, channel);
- } else {
- hits.add(new BaseRawTrackerHit(0, id, adcValues, new ArrayList<SimTrackerHit>(), EcalConditions.getSubdetector().getDetectorElement().findDetectorElement(new Identifier(id)).get(0)));
- }
+// if (id == null) {
+// System.out.printf("Crate %d, slot %d, channel %d not found in map\n", crate, slot, channel);
+// } else {
+ hits.add(new BaseRawTrackerHit(
+ 0,
+ id,
+ adcValues,
+ new ArrayList<SimTrackerHit>(),
+ subDetector
+ .getDetectorElement().findDetectorElement(new Identifier(id)).get(0)));
+// }
}
}
return hits;
}
+ private long daqToGeometryId(int crate, short slot, short channel) {
+ DaqId daqId = new DaqId(new int[]{crate,slot,channel});
+ EcalChannel ecalChannel = channels.findChannel(daqId);
+ if(ecalChannel == null) throw new RuntimeException("Daq Id not found.");
+ int ix = ecalChannel.getX();
+ int iy = ecalChannel.getY();
+ GeometryId geometryId = new GeometryId(helper, new int[]{subDetector.getSystemID(),ix,iy});
+ long id = geometryId.encode();
+ return id;
+ }
+
private List<BaseRawTrackerHit> makePulseHits(CompositeData cdata, int crate) {
List<BaseRawTrackerHit> hits = new ArrayList<BaseRawTrackerHit>();
if (debug) {
@@ -168,7 +230,7 @@
if (debug) {
System.out.println(" channel=" + channel + "; npulses=" + npulses);
}
- Long id = EcalConditions.daqToPhysicalID(crate, slot, channel);
+ Long id = daqToGeometryId(crate, slot, channel);
for (int k = 0; k < npulses; k++) {
short pulseNum = cdata.getByte();
int sampleCount = cdata.getNValue();
@@ -179,7 +241,7 @@
if (id == null) {
System.out.printf("Crate %d, slot %d, channel %d not found in map\n", crate, slot, channel);
} else {
- hits.add(new BaseRawTrackerHit(pulseNum, id, adcValues, new ArrayList<SimTrackerHit>(), EcalConditions.getSubdetector().getDetectorElement().findDetectorElement(new Identifier(id)).get(0)));
+ hits.add(new BaseRawTrackerHit(pulseNum, id, adcValues, new ArrayList<SimTrackerHit>(), subDetector.getDetectorElement().findDetectorElement(new Identifier(id)).get(0)));
}
}
}
@@ -213,7 +275,7 @@
if (debug) {
System.out.println(" channel=" + channel + "; npulses=" + npulses);
}
- Long id = EcalConditions.daqToPhysicalID(crate, slot, channel);
+ Long id = daqToGeometryId(crate, slot, channel);
for (int k = 0; k < npulses; k++) {
short pulseTime = cdata.getShort();
java/branches/hps_java_trunk_HPSJAVA-255/evio/src/main/java/org/hps/evio
--- java/branches/hps_java_trunk_HPSJAVA-255/evio/src/main/java/org/hps/evio/ECalHitWriter.java 2014-09-29 21:05:55 UTC (rev 1105)
+++ java/branches/hps_java_trunk_HPSJAVA-255/evio/src/main/java/org/hps/evio/ECalHitWriter.java 2014-09-29 22:19:09 UTC (rev 1106)
@@ -5,17 +5,30 @@
import java.util.List;
import java.util.Map;
-import org.hps.conditions.deprecated.EcalConditions;
+import org.hps.conditions.DatabaseConditionsManager;
+import org.hps.conditions.TableConstants;
+import org.hps.conditions.ecal.EcalChannelConstants;
+import org.hps.conditions.ecal.EcalConditions;
+import org.hps.conditions.ecal.EcalConditionsUtil;
+import org.hps.conditions.ecal.EcalChannel.EcalChannelCollection;
+import org.hps.conditions.ecal.EcalChannel.GeometryId;
+//import org.hps.conditions.deprecated.EcalConditions;
import org.jlab.coda.jevio.BaseStructure;
import org.jlab.coda.jevio.CompositeData;
import org.jlab.coda.jevio.DataType;
import org.jlab.coda.jevio.EventBuilder;
import org.jlab.coda.jevio.EvioBank;
import org.jlab.coda.jevio.EvioException;
+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.RawCalorimeterHit;
import org.lcsim.event.RawTrackerHit;
+import org.lcsim.geometry.Detector;
import org.lcsim.geometry.IDDecoder;
+import org.lcsim.geometry.Subdetector;
import org.lcsim.lcio.LCIOConstants;
import static org.hps.evio.EventConstants.*;
@@ -30,8 +43,38 @@
private String hitCollectionName = "EcalReadoutHits";
private int mode = EventConstants.ECAL_PULSE_INTEGRAL_MODE;
- public ECalHitWriter() {
+ // FIXME: Hard-coded detector names.
+ private static String subdetectorName = "Ecal";
+ Detector detector = null;
+ public Subdetector subDetector;
+
+ static EcalConditions ecalConditions = null;
+ static IIdentifierHelper helper = null;
+ static EcalChannelCollection channels = null;
+
+ public ECalHitWriter() {
}
+
+ /**
+ * Must be set when an object EcalHitWriter is created.
+ * @param detector (long)
+ */
+ void setDetector(Detector detector) {
+
+ this.detector = detector;
+ subDetector = detector.getSubdetector(subdetectorName);
+
+ // ECAL combined conditions object.
+ ecalConditions = ConditionsManager.defaultInstance()
+ .getCachedConditions(EcalConditions.class, TableConstants.ECAL_CONDITIONS).getCachedData();
+
+ // List of channels.
+ channels = ecalConditions.getChannelCollection();
+
+ helper = subDetector.getDetectorElement().getIdentifierHelper();
+
+ System.out.println("You are now using the database conditions for ECalHitWriter.java");
+ }
public void setHitCollectionName(String hitCollectionName) {
this.hitCollectionName = hitCollectionName;
@@ -86,8 +129,8 @@
List<Object> topHits = new ArrayList<Object>();
List<Object> bottomHits = new ArrayList<Object>();
for (Object hit : rawCalorimeterHits) {
- Long daqID = EcalConditions.physicalToDaqID(getCellID(hit));
- int crate = EcalConditions.getCrate(daqID);
+// Long daqID = EcalConditions.physicalToDaqID(getCellID(hit));
+ int crate = getCrate(getCellID(hit));
if (crate == ECAL_BOTTOM_BANK_TAG) {
bottomHits.add(hit);
} else {
@@ -150,6 +193,7 @@
private long getCellID(Object hit) {
if (RawCalorimeterHit.class.isInstance(hit)) {
+ System.out.println("hit.getCellID() " + ((RawCalorimeterHit) hit).getCellID());
return ((RawCalorimeterHit) hit).getCellID();
} else if (RawTrackerHit.class.isInstance(hit)) {
return ((RawTrackerHit) hit).getCellID();
@@ -163,7 +207,7 @@
}
// Get the ID decoder.
- IDDecoder dec = EcalConditions.getSubdetector().getIDDecoder();
+ IDDecoder dec = subDetector.getIDDecoder();
// Make a hit map; allow for multiple hits in a crystal.
Map<Long, List<RawCalorimeterHit>> hitMap = new HashMap<Long, List<RawCalorimeterHit>>();
@@ -182,9 +226,9 @@
dec.setID(id);
// System.out.println(dec.getIDDescription());
// System.out.printf("ix = %d, iy = %d\n", dec.getValue("ix"), dec.getValue("iy"));
- Long daqID = EcalConditions.physicalToDaqID(id);
+// Long daqID = EcalConditions.physicalToDaqID(id);
// System.out.printf("physicalID %d, daqID %d\n", id, daqID);
- int slot = EcalConditions.getSlot(daqID);
+ int slot = getSlot(id);
if (slotMap.get(slot) == null) {
slotMap.put(slot, new ArrayList<Long>());
}
@@ -205,7 +249,7 @@
data.addN(nhits); // number of channels
for (Long id : hitIDs) {
dec.setID(id);
- int channel = EcalConditions.getChannel(EcalConditions.physicalToDaqID(id));
+ int channel = getChannel(id);
data.addUchar((byte) channel); // channel #
List<RawCalorimeterHit> channelHits = hitMap.get(id);
data.addN(channelHits.size()); // number of pulses
@@ -236,7 +280,7 @@
}
// Get the ID decoder.
- IDDecoder dec = EcalConditions.getSubdetector().getIDDecoder();
+ IDDecoder dec = subDetector.getIDDecoder();
// Make a hit map; allow for multiple hits in a crystal.
Map<Long, List<RawTrackerHit>> hitMap = new HashMap<Long, List<RawTrackerHit>>();
@@ -255,9 +299,9 @@
dec.setID(id);
// System.out.println(dec.getIDDescription());
// System.out.printf("ix = %d, iy = %d\n", dec.getValue("ix"), dec.getValue("iy"));
- Long daqID = EcalConditions.physicalToDaqID(id);
+// Long daqID = EcalConditions.physicalToDaqID(id);
// System.out.printf("physicalID %d, daqID %d\n", id, daqID);
- int slot = EcalConditions.getSlot(daqID);
+ int slot = getSlot(id);
if (slotMap.get(slot) == null) {
slotMap.put(slot, new ArrayList<Long>());
}
@@ -278,7 +322,7 @@
data.addN(nhits); // number of channels
for (Long id : hitIDs) {
dec.setID(id);
- int channel = EcalConditions.getChannel(EcalConditions.physicalToDaqID(id));
+ int channel = getChannel(id);
data.addUchar((byte) channel); // channel #
List<RawTrackerHit> channelHits = hitMap.get(id);
data.addN(channelHits.size()); // number of pulses
@@ -313,7 +357,7 @@
}
// Get the ID decoder.
- IDDecoder dec = EcalConditions.getSubdetector().getIDDecoder();
+ IDDecoder dec = subDetector.getIDDecoder();
// Make a hit map; allow for multiple hits in a crystal.
Map<Long, RawTrackerHit> hitMap = new HashMap<Long, RawTrackerHit>();
@@ -328,9 +372,9 @@
dec.setID(id);
// System.out.println(dec.getIDDescription());
// System.out.printf("ix = %d, iy = %d\n", dec.getValue("ix"), dec.getValue("iy"));
- Long daqID = EcalConditions.physicalToDaqID(id);
+// Long daqID = EcalConditions.physicalToDaqID(id);
// System.out.printf("physicalID %d, daqID %d\n", id, daqID);
- int slot = EcalConditions.getSlot(daqID);
+ int slot = getSlot(id);
if (slotMap.get(slot) == null) {
slotMap.put(slot, new ArrayList<Long>());
}
@@ -355,7 +399,7 @@
data.addN(nhits); // number of channels
for (Long id : hitIDs) {
dec.setID(id);
- int channel = EcalConditions.getChannel(EcalConditions.physicalToDaqID(id));
+ int channel = getChannel(id);
data.addUchar((byte) channel); // channel #
RawTrackerHit hit = hitMap.get(id);
data.addN(hit.getADCValues().length); // number of samples
@@ -382,7 +426,7 @@
@Override
public void writeData(EventHeader event, EventHeader toEvent) {
- String readoutName = EcalConditions.getSubdetector().getReadout().getName();
+ String readoutName = ((org.lcsim.geometry.compact.Subdetector) subDetector).getReadout().getName();
switch (mode) {
case EventConstants.ECAL_WINDOW_MODE:
case EventConstants.ECAL_PULSE_MODE:
@@ -401,4 +445,49 @@
break;
}
}
+
+
+
+ /**
+ * 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);
+ }
+
+ private int getChannel(long cellID){
+ // Make an ID object from hit ID.
+ IIdentifier idd = new Identifier(cellID);
+
+ // Get physical field values.
+ int system = helper.getValue(idd, "system");
+ int x = helper.getValue(idd, "ix");
+ int y = helper.getValue(idd, "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 channels.findChannel(geometryId).getChannelId();
+
+ }
+
}
java/branches/hps_java_trunk_HPSJAVA-255/evio/src/main/java/org/hps/evio
--- java/branches/hps_java_trunk_HPSJAVA-255/evio/src/main/java/org/hps/evio/TestRunReconToEvio.java 2014-09-29 21:05:55 UTC (rev 1105)
+++ java/branches/hps_java_trunk_HPSJAVA-255/evio/src/main/java/org/hps/evio/TestRunReconToEvio.java 2014-09-29 22:19:09 UTC (rev 1106)
@@ -2,12 +2,16 @@
import java.io.IOException;
+import org.hps.conditions.TableConstants;
+import org.hps.conditions.ecal.EcalConditions;
import org.jlab.coda.jevio.DataType;
import org.jlab.coda.jevio.EventBuilder;
import org.jlab.coda.jevio.EventWriter;
import org.jlab.coda.jevio.EvioBank;
import org.jlab.coda.jevio.EvioException;
+import org.lcsim.conditions.ConditionsManager;
import org.lcsim.event.EventHeader;
+import org.lcsim.geometry.Detector;
import org.lcsim.util.Driver;
/**
@@ -26,9 +30,17 @@
private int eventsWritten = 0;
ECalHitWriter ecalWriter = null;
SVTHitWriter svtWriter = null;
+
+ Detector detector = null;
public TestRunReconToEvio() {
}
+
+ @Override
+ public void detectorChanged(Detector detector) {
+ // set the detector
+ this.detector = detector;
+ }
public void setEvioOutputFile(String evioOutputFile) {
this.evioOutputFile = evioOutputFile;
@@ -49,6 +61,7 @@
}
ecalWriter = new ECalHitWriter();
+ ecalWriter.setDetector(detector);
ecalWriter.setHitCollectionName(rawCalorimeterHitCollectionName);
svtWriter = new SVTHitWriter();
java/branches/hps_java_trunk_HPSJAVA-255/evio/src/main/java/org/hps/evio
--- java/branches/hps_java_trunk_HPSJAVA-255/evio/src/main/java/org/hps/evio/TestRunTriggeredReconToEvio.java 2014-09-29 21:05:55 UTC (rev 1105)
+++ java/branches/hps_java_trunk_HPSJAVA-255/evio/src/main/java/org/hps/evio/TestRunTriggeredReconToEvio.java 2014-09-29 22:19:09 UTC (rev 1106)
@@ -5,8 +5,9 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
+import org.hps.conditions.DatabaseConditionsManager;
import org.hps.conditions.deprecated.CalibrationDriver;
-import org.hps.conditions.deprecated.EcalConditions;
+import org.hps.conditions.ecal.EcalConditions;
import org.hps.readout.ecal.ReadoutTimestamp;
import org.hps.readout.ecal.TriggerDriver;
import org.hps.readout.ecal.TriggerableDriver;
@@ -16,6 +17,7 @@
import org.jlab.coda.jevio.EvioBank;
import org.jlab.coda.jevio.EvioException;
import org.lcsim.event.EventHeader;
+import org.lcsim.geometry.Detector;
import org.lcsim.util.Driver;
/**
@@ -39,10 +41,19 @@
TriggerDataWriter triggerWriter = null;
List<HitWriter> writers = null;
private int ecalMode = EventConstants.ECAL_PULSE_INTEGRAL_MODE;
+
+ Detector detector;
public TestRunTriggeredReconToEvio() {
setTriggerDelay(0);
}
+
+ @Override
+ public void detectorChanged(Detector detector) {
+ //ecalWriter.setDetector(detector);
+ if(detector == null) System.out.println("detectorChanged, Detector == null");
+ else System.out.println("detectorChanged, Detector != null");
+ }
public void setEcalMode(int ecalMode) {
this.ecalMode = ecalMode;
@@ -75,12 +86,17 @@
}
writePrestartEvent();
+ this.detector = DatabaseConditionsManager.getInstance().getDetectorObject();
writers = new ArrayList<HitWriter>();
ecalWriter = new ECalHitWriter();
+ if(detector == null) System.out.println("Detector == null");
+ else System.out.println("Detector != null");
+ //ecalWriter.setDetector(detector);
ecalWriter.setMode(ecalMode);
ecalWriter.setHitCollectionName(rawCalorimeterHitCollectionName);
+ ecalWriter.setDetector(detector);
writers.add(ecalWriter);
svtWriter = new SVTHitWriter();
java/branches/hps_java_trunk_HPSJAVA-255/evio/src/main/java/org/hps/evio
--- java/branches/hps_java_trunk_HPSJAVA-255/evio/src/main/java/org/hps/evio/TestRunTriggeredReconToLcio.java 2014-09-29 21:05:55 UTC (rev 1105)
+++ java/branches/hps_java_trunk_HPSJAVA-255/evio/src/main/java/org/hps/evio/TestRunTriggeredReconToLcio.java 2014-09-29 22:19:09 UTC (rev 1106)
@@ -18,6 +18,7 @@
import org.lcsim.event.MCParticle;
import org.lcsim.event.SimCalorimeterHit;
import org.lcsim.event.SimTrackerHit;
+import org.lcsim.geometry.Detector;
import org.lcsim.lcio.LCIOWriter;
import org.lcsim.util.Driver;
@@ -60,10 +61,18 @@
static final String trackerCollectionName = "TrackerHits";
private String relationCollectionName = "SVTTrueHitRelations";
String ecalScoringPlaneHitsCollectionName = "TrackerHitsECal";
+ Detector detector = null;
public TestRunTriggeredReconToLcio() {
setTriggerDelay(0);
}
+
+ @Override
+ public void detectorChanged(Detector detector) {
+ // set the detector
+ this.detector = detector;
+ ecalWriter.setDetector(detector);
+ }
public void setEcalMode(int ecalMode) {
this.ecalMode = ecalMode;
java/branches/hps_java_trunk_HPSJAVA-255/steering-files/src/main/resources/org/hps/steering/readout
--- java/branches/hps_java_trunk_HPSJAVA-255/steering-files/src/main/resources/org/hps/steering/readout/HPS2014TruthReadoutToLcio.lcsim 2014-09-29 21:05:55 UTC (rev 1105)
+++ java/branches/hps_java_trunk_HPSJAVA-255/steering-files/src/main/resources/org/hps/steering/readout/HPS2014TruthReadoutToLcio.lcsim 2014-09-29 22:19:09 UTC (rev 1106)
@@ -8,6 +8,8 @@
<execute>
<driver name="EventMarkerDriver"/>
+ <driver name="ConditionsDriver"/>
+
<driver name="CalibrationDriver"/>
<driver name="EcalReadout"/>
<driver name="EcalConverter"/>
@@ -28,8 +30,11 @@
<driver name="EventMarkerDriver" type="org.lcsim.job.EventMarkerDriver">
<eventInterval>1000</eventInterval>
</driver>
+ <driver name="ConditionsDriver" type="org.hps.conditions.ConditionsDriver">
+ <loadSvtConditions>false</loadSvtConditions>
+ </driver>
<driver name="CalibrationDriver" type="org.hps.conditions.deprecated.CalibrationDriver">
-<!-- <runNumber>1351</runNumber> -->
+ <!-- <runNumber>1351</runNumber> -->
</driver>
<driver name="TestRunReconToLcio" type="org.hps.evio.TestRunTriggeredReconToLcio">
<outputFile>${outputFile}.slcio</outputFile>
@@ -42,17 +47,17 @@
<ecalCollectionName>EcalHits</ecalCollectionName>
<ecalRawCollectionName>EcalRawHits</ecalRawCollectionName>
<addNoise>true</addNoise>
-<!-- <fixedGain>0.15</fixedGain>-->
-<!-- <debug>true</debug>-->
+ <!-- <fixedGain>0.15</fixedGain>-->
+ <!-- <debug>true</debug>-->
</driver>
<driver name="EcalConverter" type="org.hps.recon.ecal.EcalRawConverterDriver">
<rawCollectionName>EcalRawHits</rawCollectionName>
<ecalCollectionName>EcalCorrectedHits</ecalCollectionName>
-<!-- <gain>0.15</gain>-->
+ <!-- <gain>0.15</gain>-->
<applyBadCrystalMap>false</applyBadCrystalMap>
<use2014Gain>true</use2014Gain>
-<!-- <debug>true</debug>-->
+ <!-- <debug>true</debug>-->
</driver>
<driver name="EcalClusterer" type="org.hps.recon.ecal.GTPEcalClusterer">
@@ -71,7 +76,7 @@
</driver>
<driver name="AidaSaveDriver"
- type="org.lcsim.job.AidaSaveDriver">
+ type="org.lcsim.job.AidaSaveDriver">
<outputFileName>${outputFile}_triggerPlots</outputFileName>
</driver>
java/branches/hps_java_trunk_HPSJAVA-255/steering-files/src/main/resources/org/hps/steering/recon
--- java/branches/hps_java_trunk_HPSJAVA-255/steering-files/src/main/resources/org/hps/steering/recon/HPS2014OfflineTruthRecon.lcsim 2014-09-29 21:05:55 UTC (rev 1105)
+++ java/branches/hps_java_trunk_HPSJAVA-255/steering-files/src/main/resources/org/hps/steering/recon/HPS2014OfflineTruthRecon.lcsim 2014-09-29 22:19:09 UTC (rev 1106)
@@ -7,6 +7,9 @@
xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/lcsim/1.0/lcsim.xsd">
<execute>
<driver name="EventMarkerDriver"/>
+
+ <driver name="ConditionsDriver"/>
+
<driver name="CalibrationDriver"/>
<driver name="RawTrackerHitSensorSetup"/>
<driver name="RawTrackerHitFitterDriver" />
@@ -25,21 +28,27 @@
<driver name="CalibrationDriver" type="org.hps.conditions.deprecated.CalibrationDriver">
<!-- <runNumber>${runNumber}</runNumber>-->
</driver>
+ <driver name="ConditionsDriver" type="org.hps.conditions.ConditionsDriver">
+ <loadSvtConditions>false</loadSvtConditions>
+ </driver>
<driver name="EventMarkerDriver" type="org.lcsim.job.EventMarkerDriver">
<eventInterval>1000</eventInterval>
</driver>
<driver name="RawTrackerHitSensorSetup" type="org.lcsim.recon.tracking.digitization.sisim.config.RawTrackerHitSensorSetup"/>
<driver name="RawTrackerHitFitterDriver" type="org.hps.recon.tracking.RawTrackerHitFitterDriver">
- <fitAlgorithm>Analytic</fitAlgorithm>
+ <fitAlgorithm>Pileup</fitAlgorithm>
<useTimestamps>false</useTimestamps>
<correctT0Shift>false</correctT0Shift>
<useTruthTime>true</useTruthTime>
<subtractTOF>true</subtractTOF>
+ <debug>false</debug>
</driver>
- <driver name="TrackerHitDriver" type="org.hps.recon.tracking.DataTrackerHitDriver" />
+ <driver name="TrackerHitDriver" type="org.hps.recon.tracking.DataTrackerHitDriver">
+ <neighborDeltaT>8.0</neighborDeltaT>
+ </driver>
<driver name="HelicalTrackHitDriver" type="org.hps.recon.tracking.HelicalTrackHitDriver">
<debug>false</debug>
- <clusterTimeCut>16.0</clusterTimeCut>
+ <clusterTimeCut>12.0</clusterTimeCut>
<maxSeperation>20.0</maxSeperation>
<tolerance>1.0</tolerance>
</driver>
SVNspam 0.1