hps-java/src/main/java/org/lcsim/hps/recon/tracking
diff -u -r1.13 -r1.14
--- SimpleSvtReadout.java 24 Apr 2013 19:19:15 -0000 1.13
+++ SimpleSvtReadout.java 24 Apr 2013 20:04:08 -0000 1.14
@@ -30,7 +30,7 @@
/**
*
* @author Sho Uemura <[log in to unmask]>
- * @version $Id: SimpleSvtReadout.java,v 1.13 2013/04/24 19:19:15 meeg Exp $
+ * @version $Id: SimpleSvtReadout.java,v 1.14 2013/04/24 20:04:08 meeg Exp $
*/
public class SimpleSvtReadout extends TriggerableDriver {
@@ -40,7 +40,7 @@
private Map<SiSensor, PriorityQueue<StripHit>[]> hitMap = new HashMap<>();
//readout period time offset in ns
private double readoutOffset = 0.0;
- private double readoutLatencyT = 240.0;
+ private double readoutLatency = 240.0;
private String readout = "TrackerHits";
private double timeOffset = 30.0;
private boolean noPileup = false;
@@ -124,6 +124,19 @@
hitQueues[channel].add(stripHit);
}
+ // dump stale hits
+ for (SiSensor sensor : SvtUtils.getInstance().getSensors()) {
+ 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
+// System.out.format("Time %f: Dump stale hit with time %f\n",ClockSingleton.getTime(),hitQueues[i].peek().time);
+ hitQueues[i].poll();
+ }
+ }
+ }
+ }
+
// If an ECal trigger is received, make hits from pipelines
checkTrigger(event);
} else {
@@ -152,15 +165,16 @@
long cell_id = SvtUtils.makeCellID(sensor, channel);
- RawTrackerHit hit = new BaseRawTrackerHit(0, cell_id, samples, null, sensor);
+ RawTrackerHit hit = new BaseRawTrackerHit(0, cell_id, samples, new ArrayList<>(stripHit.simHits), sensor);
// System.out.println("Making RTH");
if (readoutCuts(hit)) {
- System.out.println("RTH passed cuts");
+// System.out.println("RTH passed cuts");
hits.add(hit);
}
}
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");
}
@@ -280,7 +294,7 @@
// Create a list to hold the analog data
List<RawTrackerHit> hits = new ArrayList<>();
// Calculate time of first sample
- double firstSample = Math.floor((ClockSingleton.getTime() - readoutLatencyT - readoutOffset) / Apv25Constants.SAMPLING_INTERVAL) * Apv25Constants.SAMPLING_INTERVAL + readoutOffset;
+ 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);
@@ -288,7 +302,6 @@
if (!addNoise && (hitQueues[channel] == null || hitQueues[channel].isEmpty())) {
continue;
}
- short[] samples = new short[6];
double[] signal = new double[6];
for (int i = 0; i < 6; i++) {
signal[i] = HPSSVTCalibrationConstants.getPedestal(sensor, channel);
@@ -297,16 +310,25 @@
addNoise(sensor, channel, signal);
}
+ 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;
- signal[i] += hit.amplitude * pulseAmplitude(sampleTime - hit.time, HPSSVTCalibrationConstants.getTShaping(sensor, channel));
+ 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);
+ }
}
}
}
+ short[] samples = new short[6];
for (int i = 0; i < 6; i++) {
samples[i] = (short) Math.round(signal[i]);
}
@@ -316,7 +338,7 @@
// }
// }
long cell_id = SvtUtils.makeCellID(sensor, channel);
- RawTrackerHit hit = new BaseRawTrackerHit(0, cell_id, samples, null, sensor);
+ RawTrackerHit hit = new BaseRawTrackerHit(0, cell_id, samples, simHits, sensor);
if (readoutCuts(hit)) {
hits.add(hit);
}
@@ -324,6 +346,7 @@
}
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");
}
@@ -334,7 +357,7 @@
double triggerTime = ClockSingleton.getTime() + triggerDelay;
int cycle = (int) Math.floor((triggerTime - readoutOffset + ClockSingleton.getDt()) / Apv25Constants.SAMPLING_INTERVAL);
// Calculate time of first sample
- double firstSample = Math.floor((triggerTime - readoutLatencyT - readoutOffset) / Apv25Constants.SAMPLING_INTERVAL) * Apv25Constants.SAMPLING_INTERVAL + readoutOffset;
+ double firstSample = Math.floor((triggerTime - readoutLatency - readoutOffset) / Apv25Constants.SAMPLING_INTERVAL) * Apv25Constants.SAMPLING_INTERVAL + readoutOffset;
return firstSample;
}