hps-java/src/main/java/org/lcsim/hps/recon/ecal
diff -u -r1.18 -r1.19
--- HPSTriggerDriver.java 26 Sep 2012 23:31:10 -0000 1.18
+++ HPSTriggerDriver.java 27 Sep 2012 00:15:27 -0000 1.19
@@ -1,5 +1,6 @@
package org.lcsim.hps.recon.ecal;
+import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.LinkedList;
@@ -7,11 +8,14 @@
import java.util.Queue;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import org.lcsim.event.EventHeader;
import org.lcsim.hps.recon.tracking.apv25.Apv25Full;
import org.lcsim.hps.recon.tracking.apv25.HPSAPV25;
import org.lcsim.hps.util.ClockSingleton;
import org.lcsim.util.Driver;
+import org.lcsim.util.lcio.LCIOWriter;
/**
* Reads clusters and makes trigger decision using opposite quadrant criterion.
@@ -19,7 +23,7 @@
* Applies SVT trigger latency and sends trigger signal to SVT
*
* @author Sho Uemura <[log in to unmask]>
- * @version $Id: HPSTriggerDriver.java,v 1.18 2012/09/26 23:31:10 meeg Exp $
+ * @version $Id: HPSTriggerDriver.java,v 1.19 2012/09/27 00:15:27 meeg Exp $
*/
public abstract class HPSTriggerDriver extends Driver {
@@ -42,10 +46,16 @@
// trigger bank trigger latency
public static final double triggerTriggerLatency = 50.0; // [ns]
private static boolean triggerBit = false;
+ private String lcioFile = null;
+ LCIOWriter lcioWriter = null;
public HPSTriggerDriver() {
}
+ public void setLcioFile(String lcioFile) {
+ this.lcioFile = lcioFile;
+ }
+
/**
* Set dead time; 0 for no dead time
* @param deadTime Minimum number of clock ticks between triggers
@@ -76,6 +86,14 @@
}
}
+ if (lcioFile != null) {
+ try {
+ lcioWriter = new LCIOWriter(new File(lcioFile));
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
numTriggers = 0;
ecalTriggerTimestamps = new LinkedList<Double>();
@@ -113,6 +131,13 @@
}
}
makeTriggerData(event, "TriggerStatus");
+ if (lcioWriter != null) {
+ try {
+ lcioWriter.write(event);
+ } catch (IOException ex) {
+ Logger.getLogger(HPSTriggerDriver.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
}
// Check if there are any pending SVT triggers to process
@@ -177,6 +202,13 @@
outputStream.printf("Trigger count: %d\n", numTriggers);
outputStream.close();
}
+ if (lcioWriter != null) {
+ try {
+ lcioWriter.close();
+ } catch (IOException ex) {
+ Logger.getLogger(HPSTriggerDriver.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
System.out.printf("Trigger count: %d\n", numTriggers);
}
hps-java/src/main/java/org/lcsim/hps/recon/tracking
diff -u -r1.4 -r1.5
--- SimpleSvtReadout.java 29 Aug 2012 21:02:46 -0000 1.4
+++ SimpleSvtReadout.java 27 Sep 2012 00:15:27 -0000 1.5
@@ -27,26 +27,30 @@
/**
*
* @author Omar Moreno <[log in to unmask]>
- * @version $Id: SimpleSvtReadout.java,v 1.4 2012/08/29 21:02:46 meeg Exp $
+ * @version $Id: SimpleSvtReadout.java,v 1.5 2012/09/27 00:15:27 meeg Exp $
*/
public class SimpleSvtReadout extends Driver {
private SiSensorSim siSimulation = new CDFSiSensorSim();
private String outputCollection = "SVTRawTrackerHits";
private Map<SiSensor, APV25Pipeline[]> pipelineMap = new HashMap<SiSensor, APV25Pipeline[]>();
- //readout period in ns
- private double readoutPeriod = Apv25Constants.SAMPLING_INTERVAL;
//readout period time offset in ns
private double readoutOffset = 0.0;
private String readout = "TrackerHits";
private SimTrackerHitReadoutDriver readoutDriver = new SimTrackerHitReadoutDriver();
private int readoutCycle = 0;
private int samplesAboveThreshold = 3;
+ private boolean noPileup = false;
+ private double timeOffset = 30.0;
public SimpleSvtReadout() {
add(readoutDriver);
}
+ public void setNoPileup(boolean noPileup) {
+ this.noPileup = noPileup;
+ }
+
/**
*
*/
@@ -58,8 +62,11 @@
readoutDriver.setCollections(readouts);
pipelineMap.clear();
- for (SiSensor sensor : SvtUtils.getInstance().getSensors()) {
- pipelineMap.put(sensor, new APV25Pipeline[HPSSVTConstants.TOTAL_STRIPS_PER_SENSOR]);
+
+ if (!noPileup) {
+ for (SiSensor sensor : SvtUtils.getInstance().getSensors()) {
+ pipelineMap.put(sensor, new APV25Pipeline[HPSSVTConstants.TOTAL_STRIPS_PER_SENSOR]);
+ }
}
}
@@ -70,109 +77,178 @@
public void process(EventHeader event) {
super.process(event);
- //if at the end of a readout cycle, step all the pipelines
- while (ClockSingleton.getTime() - readoutTime() + ClockSingleton.getDt() >= readoutPeriod) {
- for (SiSensor sensor : SvtUtils.getInstance().getSensors()) {
- APV25Pipeline[] pipelines = pipelineMap.get(sensor);
- for (int i = 0; i < pipelines.length; i++) {
- if (pipelines[i] != null) {
- pipelines[i].step();
+ if (!noPileup) {
+ //if at the end of a readout cycle, step all the pipelines
+ while (ClockSingleton.getTime() - readoutTime() + ClockSingleton.getDt() >= Apv25Constants.SAMPLING_INTERVAL) {
+ for (SiSensor sensor : SvtUtils.getInstance().getSensors()) {
+ APV25Pipeline[] pipelines = pipelineMap.get(sensor);
+ for (int i = 0; i < pipelines.length; i++) {
+ if (pipelines[i] != null) {
+ pipelines[i].step();
+ }
}
}
+ readoutCycle++;
}
- readoutCycle++;
- }
- for (SiSensor sensor : SvtUtils.getInstance().getSensors()) {
- APV25Pipeline[] pipelines = pipelineMap.get(sensor);
+ for (SiSensor sensor : SvtUtils.getInstance().getSensors()) {
+ APV25Pipeline[] pipelines = pipelineMap.get(sensor);
- // Set the sensor to be used in the charge deposition simulation
- siSimulation.setSensor(sensor);
+ // Set the sensor to be used in the charge deposition simulation
+ siSimulation.setSensor(sensor);
- // Perform the charge deposition simulation
- Map<ChargeCarrier, SiElectrodeDataCollection> electrodeDataMap = siSimulation.computeElectrodeData();
+ // Perform the charge deposition simulation
+ Map<ChargeCarrier, SiElectrodeDataCollection> electrodeDataMap = siSimulation.computeElectrodeData();
- for (ChargeCarrier carrier : ChargeCarrier.values()) {
+ for (ChargeCarrier carrier : ChargeCarrier.values()) {
- // If the sensor is capable of collecting the given charge carrier
- // then obtain the electrode data for the sensor
- if (sensor.hasElectrodesOnSide(carrier)) {
+ // If the sensor is capable of collecting the given charge carrier
+ // then obtain the electrode data for the sensor
+ if (sensor.hasElectrodesOnSide(carrier)) {
- SiElectrodeDataCollection electrodeDataCol = electrodeDataMap.get(carrier);
+ SiElectrodeDataCollection electrodeDataCol = electrodeDataMap.get(carrier);
- // If there is no electrode data available create a new instance of electrode data
- if (electrodeDataCol == null) {
- electrodeDataCol = new SiElectrodeDataCollection();
- }
+ // If there is no electrode data available create a new instance of electrode data
+ if (electrodeDataCol == null) {
+ electrodeDataCol = new SiElectrodeDataCollection();
+ }
- // Loop over all sensor channels
- for (Integer channel : electrodeDataCol.keySet()) {
+ // Loop over all sensor channels
+ for (Integer channel : electrodeDataCol.keySet()) {
- // Get the electrode data for this channel
- SiElectrodeData electrodeData = electrodeDataCol.get(channel);
+ // Get the electrode data for this channel
+ SiElectrodeData electrodeData = electrodeDataCol.get(channel);
- // Get the charge in units of electrons
- double charge = electrodeData.getCharge();
+ // Get the charge in units of electrons
+ double charge = electrodeData.getCharge();
- if (pipelines[channel] == null) {
- pipelines[channel] = new APV25Pipeline();
- }
- double resistorValue = 100; // Ohms
- double inputStageGain = 1.5;
- double amplitude = (charge / Apv25Constants.MIP) * resistorValue * inputStageGain * Math.pow(2, 14) / 2000;
- for (int i = 0; i < 20; i++) {
- pipelines[channel].addToCell(i, amplitude * pulseAmplitude((i + 1) * readoutPeriod + readoutTime() - ClockSingleton.getTime(), HPSSVTCalibrationConstants.getTShaping(sensor, channel)));
+ if (pipelines[channel] == null) {
+ pipelines[channel] = new APV25Pipeline();
+ }
+ double resistorValue = 100; // Ohms
+ double inputStageGain = 1.5;
+ double amplitude = (charge / Apv25Constants.MIP) * resistorValue * inputStageGain * Math.pow(2, 14) / 2000;
+ for (int i = 0; i < 20; i++) {
+ pipelines[channel].addToCell(i, amplitude * pulseAmplitude((i + 1) * Apv25Constants.SAMPLING_INTERVAL + readoutTime() - ClockSingleton.getTime(), HPSSVTCalibrationConstants.getTShaping(sensor, channel)));
+ }
}
}
}
- }
- // Clear the sensors of all deposited charge
- siSimulation.clearReadout();
- }
+ // Clear the sensors of all deposited charge
+ siSimulation.clearReadout();
+ }
- // If an Ecal trigger is received, generate six local triggers in order to read out six
- // samples
- if (HPSAPV25.readoutBit) {
+ // If an Ecal trigger is received, generate six local triggers in order to read out six
+ // samples
+ if (HPSAPV25.readoutBit) {
// System.out.println("Got trigger");
- HPSAPV25.readoutBit = false;
+ HPSAPV25.readoutBit = false;
+
+ // Create a list to hold the analog data
+ List<RawTrackerHit> hits = new ArrayList<RawTrackerHit>();
+
+ for (SiSensor sensor : SvtUtils.getInstance().getSensors()) {
+ APV25Pipeline[] pipelines = pipelineMap.get(sensor);
+ for (int channel = 0; channel < pipelines.length; channel++) {
+ if (pipelines[channel] != null) {
+ short[] samples = new short[6];
+ for (int j = 0; j < 6; j++) {
+ samples[j] = (short) (pipelines[channel].getValue(j) + HPSSVTCalibrationConstants.getPedestal(sensor, channel));
+// System.out.println(samples[j]);
+ }
+// System.out.println();
+
+ // Find the side number (is 1)
+ int sideNumber;
+ if (sensor.hasElectrodesOnSide(ChargeCarrier.HOLE)) {
+ sideNumber = ChargeCarrier.HOLE.charge();
+ } else {
+ sideNumber = ChargeCarrier.ELECTRON.charge();
+ }
+ long cell_id = sensor.makeStripId(channel, sideNumber).getValue();
+
+ RawTrackerHit hit = new BaseRawTrackerHit(0, cell_id, samples, null, sensor);
+// System.out.println("Making RTH");
+ if (samplesAboveThreshold(hit)) {
+ hits.add(hit);
+ }
+ }
+ }
+ }
+ int flags = 1 << LCIOConstants.TRAWBIT_ID1;
+ event.put(outputCollection, hits, RawTrackerHit.class, flags, readout);
+ System.out.println("Made " + hits.size() + " RawTrackerHits");
+ }
+ } else {
// Create a list to hold the analog data
List<RawTrackerHit> hits = new ArrayList<RawTrackerHit>();
for (SiSensor sensor : SvtUtils.getInstance().getSensors()) {
- APV25Pipeline[] pipelines = pipelineMap.get(sensor);
- for (int channel = 0; channel < pipelines.length; channel++) {
- if (pipelines[channel] != null) {
- short[] samples = new short[6];
- for (int j = 0; j < 6; j++) {
- samples[j] = (short) (pipelines[channel].getValue(j) + HPSSVTCalibrationConstants.getPedestal(sensor, channel));
-// System.out.println(samples[j]);
- }
-// System.out.println();
+ // Set the sensor to be used in the charge deposition simulation
+ siSimulation.setSensor(sensor);
+
+ // Perform the charge deposition simulation
+ Map<ChargeCarrier, SiElectrodeDataCollection> electrodeDataMap = siSimulation.computeElectrodeData();
+
+ for (ChargeCarrier carrier : ChargeCarrier.values()) {
+
+ // If the sensor is capable of collecting the given charge carrier
+ // then obtain the electrode data for the sensor
+ if (sensor.hasElectrodesOnSide(carrier)) {
- // Find the side number (is 1)
- int sideNumber;
- if (sensor.hasElectrodesOnSide(ChargeCarrier.HOLE)) {
- sideNumber = ChargeCarrier.HOLE.charge();
- } else {
- sideNumber = ChargeCarrier.ELECTRON.charge();
+ SiElectrodeDataCollection electrodeDataCol = electrodeDataMap.get(carrier);
+
+ // If there is no electrode data available create a new instance of electrode data
+ if (electrodeDataCol == null) {
+ electrodeDataCol = new SiElectrodeDataCollection();
}
- long cell_id = sensor.makeStripId(channel, sideNumber).getValue();
- RawTrackerHit hit = new BaseRawTrackerHit(0, cell_id, samples, null, sensor);
+ // Loop over all sensor channels
+ for (Integer channel : electrodeDataCol.keySet()) {
+ short[] samples = new short[6];
+
+ // Get the electrode data for this channel
+ SiElectrodeData electrodeData = electrodeDataCol.get(channel);
+
+ // Get the charge in units of electrons
+ double charge = electrodeData.getCharge();
+
+ double resistorValue = 100; // Ohms
+ double inputStageGain = 1.5;
+ double amplitude = (charge / Apv25Constants.MIP) * resistorValue * inputStageGain * Math.pow(2, 14) / 2000;
+ for (int i = 0; i < 6; i++) {
+ double time = i * Apv25Constants.SAMPLING_INTERVAL - timeOffset;
+ samples[i] = (short) Math.round(amplitude * pulseAmplitude(time, HPSSVTCalibrationConstants.getTShaping(sensor, channel)) + HPSSVTCalibrationConstants.getPedestal(sensor, channel));
+ }
+
+ int sideNumber;
+ if (sensor.hasElectrodesOnSide(ChargeCarrier.HOLE)) {
+ sideNumber = ChargeCarrier.HOLE.charge();
+ } else {
+ sideNumber = ChargeCarrier.ELECTRON.charge();
+ }
+ long cell_id = sensor.makeStripId(channel, sideNumber).getValue();
+
+ RawTrackerHit hit = new BaseRawTrackerHit(0, cell_id, samples, null, sensor);
// System.out.println("Making RTH");
- if (samplesAboveThreshold(hit)) {
- hits.add(hit);
+ if (samplesAboveThreshold(hit)) {
+ hits.add(hit);
+ }
+
}
}
}
+
+ // Clear the sensors of all deposited charge
+ siSimulation.clearReadout();
}
int flags = 1 << LCIOConstants.TRAWBIT_ID1;
event.put(outputCollection, hits, RawTrackerHit.class, flags, readout);
- System.out.println("Made " + hits.size() + " RawTrackerHits");
+// System.out.println("Made " + hits.size() + " RawTrackerHits");
}
}
@@ -245,6 +321,6 @@
}
private double readoutTime() {
- return readoutCycle * readoutPeriod + readoutOffset;
+ return readoutCycle * Apv25Constants.SAMPLING_INTERVAL + readoutOffset;
}
}