Commit in hps-java/src/main/java/org/lcsim/hps on MAIN | |||
evio/SVTHitWriter.java | +12 | -13 | 1.3 -> 1.4 |
recon/tracking/SimpleSvtReadout.java | +60 | -46 | 1.14 -> 1.15 |
+72 | -59 |
save SimTrackerHit associations as LCRelations
diff -u -r1.3 -r1.4 --- SVTHitWriter.java 2 Apr 2013 01:11:11 -0000 1.3 +++ SVTHitWriter.java 25 Apr 2013 21:33:41 -0000 1.4 @@ -1,14 +1,11 @@
package org.lcsim.hps.evio; import java.util.ArrayList;
-import java.util.Collection;
import java.util.HashMap; import java.util.List; import java.util.Map; import static org.lcsim.hps.evio.EventConstants.SVT_BANK_NUMBER; import static org.lcsim.hps.evio.EventConstants.SVT_BANK_TAG;
-import static org.lcsim.hps.evio.EventConstants.SVT_TOTAL_NUMBER_FPGAS; -
import org.jlab.coda.jevio.DataType; import org.jlab.coda.jevio.EventBuilder;
@@ -16,6 +13,7 @@
import org.jlab.coda.jevio.EvioException; import org.lcsim.detector.tracker.silicon.SiSensor; import org.lcsim.event.EventHeader;
+import org.lcsim.event.LCRelation;
import org.lcsim.event.RawTrackerHit; import org.lcsim.hps.recon.tracking.FpgaData; import org.lcsim.hps.recon.tracking.HPSSVTConstants;
@@ -26,13 +24,14 @@
/** * * @author Sho Uemura <[log in to unmask]>
- * @version $Id: SVTHitWriter.java,v 1.3 2013/04/02 01:11:11 meeg Exp $
+ * @version $Id: SVTHitWriter.java,v 1.4 2013/04/25 21:33:41 meeg Exp $
*/ public class SVTHitWriter implements HitWriter { boolean debug = false; private String hitCollectionName = "SVTRawTrackerHits"; private String fpgaDataCollectionName = "FPGAData";
+ private String relationCollectionName = "SVTTrueHitRelations";
String readoutName = "TrackerHits"; public SVTHitWriter() {
@@ -48,14 +47,14 @@
} //make some dummy FpgaData to use in case there isn't any real FpgaData
- private static Map<Integer,FpgaData> makeFpgaData() {
+ private static Map<Integer, FpgaData> makeFpgaData() {
double[] temps = new double[HPSSVTConstants.TOTAL_HYBRIDS_PER_FPGA * HPSSVTConstants.TOTAL_TEMPS_PER_HYBRID]; for (int i = 0; i < HPSSVTConstants.TOTAL_HYBRIDS_PER_FPGA * HPSSVTConstants.TOTAL_TEMPS_PER_HYBRID; i++) { temps[i] = 23.0; }
- Map<Integer,FpgaData> fpgaData = new HashMap<Integer, FpgaData>();
+ Map<Integer, FpgaData> fpgaData = new HashMap<>();
for (Integer fpgaNumber : SvtUtils.getInstance().getFpgaNumbers()) {
- fpgaData.put(fpgaNumber,new FpgaData(fpgaNumber, temps, 0));
+ fpgaData.put(fpgaNumber, new FpgaData(fpgaNumber, temps, 0));
} return fpgaData;
@@ -65,15 +64,15 @@
public void writeData(EventHeader event, EventBuilder builder) { List<RawTrackerHit> hits = event.get(RawTrackerHit.class, hitCollectionName);
- Map<Integer,FpgaData> fpgaData = makeFpgaData();
+ Map<Integer, FpgaData> fpgaData = makeFpgaData();
System.out.println("Writing " + hits.size() + " SVT hits"); System.out.println("Writing " + fpgaData.size() + " FPGA data");
- Map<Integer, List<int[]>> fpgaHits = new HashMap<Integer, List<int[]>>();
+ Map<Integer, List<int[]>> fpgaHits = new HashMap<>();
for (Integer fpgaNumber : SvtUtils.getInstance().getFpgaNumbers()) {
- fpgaHits.put(fpgaNumber,new ArrayList<int[]>());
+ fpgaHits.put(fpgaNumber, new ArrayList<int[]>());
} for (RawTrackerHit hit : hits) {
@@ -143,13 +142,13 @@
@Override public void writeData(EventHeader event, EventHeader toEvent) { List<RawTrackerHit> rawTrackerHits = event.get(RawTrackerHit.class, hitCollectionName);
- - -
System.out.println("Writing " + rawTrackerHits.size() + " SVT hits"); int flags = 1 << LCIOConstants.TRAWBIT_ID1; toEvent.put(hitCollectionName, rawTrackerHits, RawTrackerHit.class, flags, readoutName);
+ List<LCRelation> trueHitRelations = event.get(LCRelation.class, relationCollectionName); + toEvent.put(relationCollectionName, trueHitRelations, LCRelation.class, 0); +
List<FpgaData> fpgaData = new ArrayList(makeFpgaData().values()); System.out.println("Writing " + fpgaData.size() + " FPGA data");
diff -u -r1.14 -r1.15 --- SimpleSvtReadout.java 24 Apr 2013 20:04:08 -0000 1.14 +++ SimpleSvtReadout.java 25 Apr 2013 21:33:41 -0000 1.15 @@ -12,8 +12,10 @@
import org.lcsim.detector.tracker.silicon.ChargeCarrier; import org.lcsim.detector.tracker.silicon.SiSensor; import org.lcsim.event.EventHeader;
+import org.lcsim.event.LCRelation;
import org.lcsim.event.RawTrackerHit; import org.lcsim.event.SimTrackerHit;
+import org.lcsim.event.base.BaseLCRelation;
import org.lcsim.event.base.BaseRawTrackerHit; import org.lcsim.geometry.Detector; import org.lcsim.hps.readout.ecal.TriggerableDriver;
@@ -30,17 +32,19 @@
/** * * @author Sho Uemura <[log in to unmask]>
- * @version $Id: SimpleSvtReadout.java,v 1.14 2013/04/24 20:04:08 meeg Exp $
+ * @version $Id: SimpleSvtReadout.java,v 1.15 2013/04/25 21:33:41 meeg Exp $
*/ public class SimpleSvtReadout extends TriggerableDriver { private SimTrackerHitReadoutDriver readoutDriver = new SimTrackerHitReadoutDriver(); private SiSensorSim siSimulation = new CDFSiSensorSim(); private String outputCollection = "SVTRawTrackerHits";
+ private String relationCollection = "SVTTrueHitRelations";
private Map<SiSensor, PriorityQueue<StripHit>[]> hitMap = new HashMap<>(); //readout period time offset in ns private double readoutOffset = 0.0; private double readoutLatency = 240.0;
+ private double pileupCutoff = 300.0;
private String readout = "TrackerHits"; private double timeOffset = 30.0; private boolean noPileup = false;
@@ -129,7 +133,7 @@
PriorityQueue<StripHit>[] hitQueues = hitMap.get(sensor); for (int i = 0; i < hitQueues.length; i++) { if (hitQueues[i] != null) {
- while (!hitQueues[i].isEmpty() && hitQueues[i].peek().time < ClockSingleton.getTime() - 500.0) { //TODO: more intelligent time cut
+ while (!hitQueues[i].isEmpty() && hitQueues[i].peek().time < ClockSingleton.getTime() - (readoutLatency + pileupCutoff)) {
// System.out.format("Time %f: Dump stale hit with time %f\n",ClockSingleton.getTime(),hitQueues[i].peek().time); hitQueues[i].poll(); }
@@ -288,74 +292,84 @@
@Override protected void processTrigger(EventHeader event) {
- if (!noPileup) {
+ if (noPileup) { + return; + }
// System.out.println("Got trigger");
- // Create a list to hold the analog data - List<RawTrackerHit> hits = new ArrayList<>(); - // Calculate time of first sample - double firstSample = Math.floor((ClockSingleton.getTime() - readoutLatency - readoutOffset) / Apv25Constants.SAMPLING_INTERVAL) * Apv25Constants.SAMPLING_INTERVAL + readoutOffset;
+ // Create a list to hold the analog data + List<RawTrackerHit> hits = new ArrayList<>(); + List<LCRelation> trueHitRelations = new ArrayList<>(); + // Calculate time of first sample + double firstSample = Math.floor((ClockSingleton.getTime() - readoutLatency - readoutOffset) / Apv25Constants.SAMPLING_INTERVAL) * Apv25Constants.SAMPLING_INTERVAL + readoutOffset;
- for (SiSensor sensor : SvtUtils.getInstance().getSensors()) { - PriorityQueue<StripHit>[] hitQueues = hitMap.get(sensor); - for (int channel = 0; channel < hitQueues.length; channel++) { - if (!addNoise && (hitQueues[channel] == null || hitQueues[channel].isEmpty())) { - continue; - } - double[] signal = new double[6]; - for (int i = 0; i < 6; i++) { - signal[i] = HPSSVTCalibrationConstants.getPedestal(sensor, channel); - } - if (addNoise) { - addNoise(sensor, channel, signal); - }
+ for (SiSensor sensor : SvtUtils.getInstance().getSensors()) { + PriorityQueue<StripHit>[] hitQueues = hitMap.get(sensor); + for (int channel = 0; channel < hitQueues.length; channel++) { + if (!addNoise && (hitQueues[channel] == null || hitQueues[channel].isEmpty())) { + continue; + } + double[] signal = new double[6]; + for (int i = 0; i < 6; i++) { + signal[i] = HPSSVTCalibrationConstants.getPedestal(sensor, channel); + } + if (addNoise) { + addNoise(sensor, channel, signal); + }
- List<SimTrackerHit> simHits = new ArrayList<>();
+ List<SimTrackerHit> simHits = new ArrayList<>();
- if (hitQueues[channel] != null) { - for (StripHit hit : hitQueues[channel]) { - double totalContrib = 0; - for (int i = 0; i < 6; i++) { - double sampleTime = firstSample + i * Apv25Constants.SAMPLING_INTERVAL; - double signalAtTime = hit.amplitude * pulseAmplitude(sampleTime - hit.time, HPSSVTCalibrationConstants.getTShaping(sensor, channel)); - totalContrib += signalAtTime; - signal[i] += signalAtTime;
+ if (hitQueues[channel] != null) { + for (StripHit hit : hitQueues[channel]) { + double totalContrib = 0; + for (int i = 0; i < 6; i++) { + double sampleTime = firstSample + i * Apv25Constants.SAMPLING_INTERVAL; + double signalAtTime = hit.amplitude * pulseAmplitude(sampleTime - hit.time, HPSSVTCalibrationConstants.getTShaping(sensor, channel)); + totalContrib += signalAtTime; + signal[i] += signalAtTime;
// System.out.format("new value of signal[%d] = %f\n", i, signal[i]);
- if (totalContrib > 4.0 * HPSSVTCalibrationConstants.getNoise(sensor, channel)) { - simHits.addAll(hit.simHits); - } - }
+ } + if (totalContrib > 4.0 * HPSSVTCalibrationConstants.getNoise(sensor, channel)) { +// System.out.format("adding %d simHits\n", hit.simHits.size()); + simHits.addAll(hit.simHits);
} }
+ }
- short[] samples = new short[6]; - for (int i = 0; i < 6; i++) { - samples[i] = (short) Math.round(signal[i]); - }
+ short[] samples = new short[6]; + for (int i = 0; i < 6; i++) { + samples[i] = (short) Math.round(signal[i]); + }
// if (hitQueues[channel] != null && !hitQueues[channel].isEmpty()) { // for (int i = 0; i < 6; i++) { // System.out.format("samples[%d] = %d\n", i, samples[i]); // } // }
- long cell_id = SvtUtils.makeCellID(sensor, channel); - RawTrackerHit hit = new BaseRawTrackerHit(0, cell_id, samples, simHits, sensor); - if (readoutCuts(hit)) { - hits.add(hit);
+ long cell_id = SvtUtils.makeCellID(sensor, channel); + RawTrackerHit hit = new BaseRawTrackerHit(0, cell_id, samples, simHits, sensor); + if (readoutCuts(hit)) { + hits.add(hit); +// System.out.format("simHits: %d\n", simHits.size()); + for (SimTrackerHit simHit : hit.getSimTrackerHits()) { + LCRelation hitRelation = new BaseLCRelation(hit, simHit); + trueHitRelations.add(hitRelation);
} } }
+ }
- int flags = 1 << LCIOConstants.TRAWBIT_ID1;
+ int flags = 1 << LCIOConstants.TRAWBIT_ID1;
// flags += 1 << LCIOConstants.RTHBIT_HITS;
- event.put(outputCollection, hits, RawTrackerHit.class, flags, readout); - System.out.println("Made " + hits.size() + " RawTrackerHits"); - }
+ event.put(outputCollection, hits, RawTrackerHit.class, flags, readout); + event.put(relationCollection, trueHitRelations, LCRelation.class, 0); + System.out.println("Made " + hits.size() + " RawTrackerHits"); + System.out.println("Made " + trueHitRelations.size() + " LCRelations");
} @Override public double readoutDeltaT() { double triggerTime = ClockSingleton.getTime() + triggerDelay;
- int cycle = (int) Math.floor((triggerTime - readoutOffset + ClockSingleton.getDt()) / Apv25Constants.SAMPLING_INTERVAL);
+// int cycle = (int) Math.floor((triggerTime - readoutOffset + ClockSingleton.getDt()) / Apv25Constants.SAMPLING_INTERVAL);
// Calculate time of first sample double firstSample = Math.floor((triggerTime - readoutLatency - readoutOffset) / Apv25Constants.SAMPLING_INTERVAL) * Apv25Constants.SAMPLING_INTERVAL + readoutOffset;
Use REPLY-ALL to reply to list
To unsubscribe from the LCD-CVS list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=LCD-CVS&A=1