Commit in hps-java/src/main/java/org/lcsim/hps on MAIN | |||
recon/tracking/SvtUtils.java | +67 | -62 | 1.11 -> 1.12 |
/SimpleSvtReadout.java | +75 | -110 | 1.5 -> 1.6 |
evio/SVTEvioReader_RTH.java | +2 | -9 | 1.2 -> 1.3 |
+144 | -181 |
clean up SimpleSVTReadout
diff -u -r1.11 -r1.12 --- SvtUtils.java 30 Nov 2012 23:08:19 -0000 1.11 +++ SvtUtils.java 1 Mar 2013 01:15:20 -0000 1.12 @@ -17,6 +17,7 @@
import org.lcsim.detector.IDetectorElement; import org.lcsim.detector.identifier.IIdentifier; import org.lcsim.detector.identifier.IIdentifierHelper;
+import org.lcsim.detector.tracker.silicon.ChargeCarrier;
import org.lcsim.detector.tracker.silicon.SiSensor; import org.lcsim.detector.tracker.silicon.SiTrackerIdentifierHelper; import org.lcsim.geometry.Detector;
@@ -24,11 +25,10 @@
//--- hps-java ---// import org.lcsim.hps.util.Pair;
-
/** * * @author Omar Moreno
- * @version $Id: SvtUtils.java,v 1.11 2012/11/30 23:08:19 omoreno Exp $
+ * @version $Id: SvtUtils.java,v 1.12 2013/03/01 01:15:20 meeg Exp $
*/ public class SvtUtils {
@@ -36,40 +36,29 @@
// Set of sensors private Set<SiSensor> sensors = new HashSet<SiSensor>(); // Map from Sensor to Hybrid/FPGA pair
- private Map<SiSensor /* sensor */, Pair<Integer /* FPGA */, Integer /* Hybrid */>> sensorToDaqPair - = new HashMap<SiSensor, Pair<Integer, Integer>>();
+ private Map<SiSensor /* sensor */, Pair<Integer /* FPGA */, Integer /* Hybrid */>> sensorToDaqPair = new HashMap<SiSensor, Pair<Integer, Integer>>();
// Map from Hybrid/FPGA pair
- private Map<Pair<Integer /* FPGA */, Integer /* Hybrid */>, SiSensor /* Sensor*/> daqPairToSensor - = new HashMap<Pair<Integer, Integer>, SiSensor>();
+ private Map<Pair<Integer /* FPGA */, Integer /* Hybrid */>, SiSensor /* Sensor*/> daqPairToSensor = new HashMap<Pair<Integer, Integer>, SiSensor>();
// Map from SVT top layer to Hybrid/FPGA pair
- private Map<Integer /* Layer */, List<Pair<Integer /* FPGA */, Integer /* Hybrid */>>> topLayerDaqMap - = new HashMap<Integer, List<Pair<Integer, Integer>>>();
+ private Map<Integer /* Layer */, List<Pair<Integer /* FPGA */, Integer /* Hybrid */>>> topLayerDaqMap = new HashMap<Integer, List<Pair<Integer, Integer>>>();
// Map from SVT bottom layer to Hybrid/FPGA pair
- private Map<Integer /* Layer # */, List<Pair<Integer /* FPGA */, Integer /* Hybrid */>>> bottomLayerDaqMap - = new HashMap<Integer, List<Pair<Integer, Integer>>>();
+ private Map<Integer /* Layer # */, List<Pair<Integer /* FPGA */, Integer /* Hybrid */>>> bottomLayerDaqMap = new HashMap<Integer, List<Pair<Integer, Integer>>>();
// Map sensor to an SVT top layer
- private Map<SiSensor /* Sensor */, Integer /* Layer */> sensorToTopLayer - = new HashMap<SiSensor, Integer>();
+ private Map<SiSensor /* Sensor */, Integer /* Layer */> sensorToTopLayer = new HashMap<SiSensor, Integer>();
// Map sensor to an SVT bottom layer
- private Map<SiSensor /* Sensor */, Integer /* Layer */> sensorToBottomLayer - = new HashMap<SiSensor, Integer>();
+ private Map<SiSensor /* Sensor */, Integer /* Layer */> sensorToBottomLayer = new HashMap<SiSensor, Integer>();
// Map sensor to descriptor
- private Map<SiSensor /* Sensor */, String /* Description */> sensorToDescriptor - = new HashMap<SiSensor, String>();
+ private Map<SiSensor /* Sensor */, String /* Description */> sensorToDescriptor = new HashMap<SiSensor, String>();
// Map layer to top SVT sensor
- private Map<Integer /* Layer */, List<SiSensor> /* Sensor */> topLayerToSensor - = new HashMap<Integer, List<SiSensor>>();
+ private Map<Integer /* Layer */, List<SiSensor> /* Sensor */> topLayerToSensor = new HashMap<Integer, List<SiSensor>>();
// Map layer to bottom SVT sensor
- private Map<Integer /* Layer */, List<SiSensor> /* Sensor */> bottomLayerToSensor - = new HashMap<Integer, List<SiSensor>>();
+ private Map<Integer /* Layer */, List<SiSensor> /* Sensor */> bottomLayerToSensor = new HashMap<Integer, List<SiSensor>>();
private SiSensor[][] sensorArray; private IIdentifierHelper helper; String subdetectorName = "Tracker"; ConditionsManager manager = ConditionsManager.defaultInstance();
-
int maxModuleNumber = 0; int maxLayerNumber = 0;
-
private boolean isSetup = false; boolean debug = false;
@@ -83,9 +72,9 @@
* */ public static SvtUtils getInstance() {
-
+
// Use lazy instantiation
- if(INSTANCE == null){
+ if (INSTANCE == null) {
INSTANCE = new SvtUtils(); } return INSTANCE;
@@ -210,6 +199,16 @@
return this.sensorToDescriptor.get(sensor); }
+ public static long makeCellID(SiSensor sensor, int channel) { + int sideNumber; + if (sensor.hasElectrodesOnSide(ChargeCarrier.HOLE)) { + sideNumber = ChargeCarrier.HOLE.charge(); + } else { + sideNumber = ChargeCarrier.ELECTRON.charge(); + } + return sensor.makeStripId(channel, sideNumber).getValue(); + } +
/** * */
@@ -220,19 +219,19 @@
} this.printDebug("Detector: " + detector.getDetectorName());
- - BufferedReader reader; -
+ + BufferedReader reader; +
// Load the DAQ Map from the conditions database String filePath = "daqmap/svt_default.daqmap";
- try{
+ try {
reader = new BufferedReader(manager.getRawConditions(filePath).getReader()); this.loadSvtDaqMap(reader);
- } catch(IOException exception){
+ } catch (IOException exception) {
throw new RuntimeException("Unable to load DAQ Map from " + filePath, exception); }
- - sensorArray = new SiSensor[maxModuleNumber+1][maxLayerNumber];
+ + sensorArray = new SiSensor[maxModuleNumber + 1][maxLayerNumber];
// Get the SVT IDetectorElement detectorElement = detector.getDetectorElement().findDetectorElement(subdetectorName);
@@ -258,10 +257,10 @@
int moduleNumber = sensorHelper.getModuleValue(sensorIdent); sensorArray[moduleNumber][layerNumber - 1] = sensor; int listPosition = 0;
- - switch(moduleNumber%2){ - case 0: - listPosition = moduleNumber/2;
+ + switch (moduleNumber % 2) { + case 0: + listPosition = moduleNumber / 2;
this.printDebug("FPGA: " + topLayerDaqMap.get(layerNumber).get(listPosition).getFirstElement() + ", Hybrid: " + topLayerDaqMap.get(layerNumber).get(listPosition).getSecondElement()); sensorToTopLayer.put(sensor, layerNumber);
@@ -277,8 +276,8 @@
this.printDebug("Description: " + description); sensorToDescriptor.put(sensor, description); break;
- case 1: - listPosition = (moduleNumber -1)/2;
+ case 1: + listPosition = (moduleNumber - 1) / 2;
this.printDebug("FPGA: " + bottomLayerDaqMap.get(layerNumber).get(listPosition).getFirstElement() + ", Hybrid: " + bottomLayerDaqMap.get(layerNumber).get(listPosition).getSecondElement()); sensorToBottomLayer.put(sensor, layerNumber);
@@ -294,11 +293,11 @@
this.printDebug("Description: " + description); sensorToDescriptor.put(sensor, description); break;
- default:
+ default:
throw new RuntimeException("Invalid module number: " + moduleNumber); } }
-
+
for (int module = 0; module < 2; module++) { for (int layer = 0; layer < 10; layer++) { if (sensorArray[module][layer] == null) {
@@ -308,65 +307,71 @@
} isSetup = true; }
-
+
/** * Load the SVT DAQ Map from the conditions database */
- private void loadSvtDaqMap(Reader reader){
+ private void loadSvtDaqMap(Reader reader) {
BufferedReader daqMapReader = new BufferedReader(reader); String line = null;
- try{ - while((line = daqMapReader.readLine()) != null){
+ try { + while ((line = daqMapReader.readLine()) != null) {
// If the line is a comment,skip it
- if(line.indexOf("#") != -1) continue;
+ if (line.indexOf("#") != -1) { + continue; + }
StringTokenizer stringTok = new StringTokenizer(line); int listPosition = 0;
- - while(stringTok.hasMoreTokens()){ - int layer = Integer.valueOf(stringTok.nextToken());
+ + while (stringTok.hasMoreTokens()) { + int layer = Integer.valueOf(stringTok.nextToken());
int module = Integer.valueOf(stringTok.nextToken());
- int fpga = Integer.valueOf(stringTok.nextToken());
+ int fpga = Integer.valueOf(stringTok.nextToken());
int hybrid = Integer.valueOf(stringTok.nextToken()); Pair<Integer, Integer> daqPair = new Pair<Integer, Integer>(fpga, hybrid); maxModuleNumber = Math.max(maxModuleNumber, module); maxLayerNumber = Math.max(maxLayerNumber, layer);
- switch(module%2){
+ switch (module % 2) {
case 0:
- listPosition = module/2; - if(!topLayerDaqMap.containsKey(layer))
+ listPosition = module / 2; + if (!topLayerDaqMap.containsKey(layer)) {
topLayerDaqMap.put(layer, new ArrayList<Pair<Integer, Integer>>());
+ }
this.printDebug("Adding FPGA: " + daqPair.getFirstElement() + ", Hybrid: " + daqPair.getSecondElement() + " to position: " + listPosition); topLayerDaqMap.get(layer).add(listPosition, daqPair);
- if(!topLayerToSensor.containsKey(layer)) - topLayerToSensor.put(layer, new ArrayList<SiSensor>());
+ if (!topLayerToSensor.containsKey(layer)) { + topLayerToSensor.put(layer, new ArrayList<SiSensor>()); + }
topLayerToSensor.get(layer).add(null); break;
- case 1: - listPosition = (module - 1)/2; - if(!bottomLayerDaqMap.containsKey(layer))
+ case 1: + listPosition = (module - 1) / 2; + if (!bottomLayerDaqMap.containsKey(layer)) {
bottomLayerDaqMap.put(layer, new ArrayList<Pair<Integer, Integer>>());
+ }
this.printDebug("Adding FPGA: " + daqPair.getFirstElement() + ", Hybrid: " + daqPair.getSecondElement() + " to position: " + listPosition); bottomLayerDaqMap.get(layer).add(listPosition, daqPair);
- if(!bottomLayerToSensor.containsKey(layer))
+ if (!bottomLayerToSensor.containsKey(layer)) {
bottomLayerToSensor.put(layer, new ArrayList<SiSensor>());
+ }
bottomLayerToSensor.get(layer).add(null); break;
- default:
+ default:
throw new RuntimeException("Invalid module number: " + module); } } }
- } catch(IOException exception){
+ } catch (IOException exception) {
throw new RuntimeException("Unable to parse SVT DAQ Map", exception); } }
-
+
/** * Print a debug message * @param debugMessage : message to be printed */
- private void printDebug(String debugMessage){ - if(debug){
+ private void printDebug(String debugMessage) { + if (debug) {
System.out.println(this.getClass().getSimpleName() + ": " + debugMessage); } }
diff -u -r1.5 -r1.6 --- SimpleSvtReadout.java 27 Sep 2012 00:15:27 -0000 1.5 +++ SimpleSvtReadout.java 1 Mar 2013 01:15:20 -0000 1.6 @@ -1,7 +1,6 @@
package org.lcsim.hps.recon.tracking; //--- java ---//
-import org.lcsim.hps.recon.tracking.apv25.*;
import java.util.ArrayList; import java.util.HashMap; import java.util.List;
@@ -14,6 +13,8 @@
import org.lcsim.event.RawTrackerHit; import org.lcsim.event.base.BaseRawTrackerHit; import org.lcsim.geometry.Detector;
+import org.lcsim.hps.recon.tracking.apv25.Apv25Constants; +import org.lcsim.hps.recon.tracking.apv25.HPSAPV25;
import org.lcsim.hps.util.ClockSingleton; import org.lcsim.hps.util.RingBuffer; import org.lcsim.recon.tracking.digitization.sisim.CDFSiSensorSim;
@@ -27,7 +28,7 @@
/** * * @author Omar Moreno <[log in to unmask]>
- * @version $Id: SimpleSvtReadout.java,v 1.5 2012/09/27 00:15:27 meeg Exp $
+ * @version $Id: SimpleSvtReadout.java,v 1.6 2013/03/01 01:15:20 meeg Exp $
*/ public class SimpleSvtReadout extends Driver {
@@ -77,6 +78,51 @@
public void process(EventHeader event) { super.process(event);
+ Map<SiSensor, Map<Integer, Double>> hitMap = new HashMap<SiSensor, Map<Integer, Double>>(); + for (SiSensor sensor : SvtUtils.getInstance().getSensors()) { + Map<Integer, Double> hitsOnSensor = new HashMap<Integer, Double>(); + hitMap.put(sensor, hitsOnSensor); + + // 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)) { + + 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(); + } + + // Loop over all sensor channels + for (Integer channel : electrodeDataCol.keySet()) { + + // 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; + + hitsOnSensor.put(channel, amplitude); + } + } + } + // Clear the sensors of all deposited charge + siSimulation.clearReadout(); + } +
if (!noPileup) { //if at the end of a readout cycle, step all the pipelines while (ClockSingleton.getTime() - readoutTime() + ClockSingleton.getDt() >= Apv25Constants.SAMPLING_INTERVAL) {
@@ -90,57 +136,23 @@
} readoutCycle++; }
+ + for (SiSensor sensor : hitMap.keySet()) { + Map<Integer, Double> hitsOnSensor = hitMap.get(sensor); + for (Integer channel : hitsOnSensor.keySet()) { + Double amplitude = hitsOnSensor.get(channel);
- 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); - - // 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)) { - - 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(); - } - - // Loop over all sensor channels - for (Integer channel : electrodeDataCol.keySet()) { - - // Get the electrode data for this channel - SiElectrodeData electrodeData = electrodeDataCol.get(channel); - - // 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) * Apv25Constants.SAMPLING_INTERVAL + readoutTime() - ClockSingleton.getTime(), HPSSVTCalibrationConstants.getTShaping(sensor, channel))); - } - }
+ APV25Pipeline[] pipelines = pipelineMap.get(sensor); + if (pipelines[channel] == null) { + pipelines[channel] = new APV25Pipeline(); + } + 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();
}
- // If an Ecal trigger is received, generate six local triggers in order to read out six - // samples
+ // If an ECal trigger is received, make hits from pipelines
if (HPSAPV25.readoutBit) { // System.out.println("Got trigger");
@@ -160,14 +172,7 @@
} // 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();
+ long cell_id = SvtUtils.makeCellID(sensor, channel);
RawTrackerHit hit = new BaseRawTrackerHit(0, cell_id, samples, null, sensor); // System.out.println("Making RTH");
@@ -185,65 +190,25 @@
} else { // Create a list to hold the analog data List<RawTrackerHit> hits = new ArrayList<RawTrackerHit>();
+ for (SiSensor sensor : hitMap.keySet()) { + Map<Integer, Double> hitsOnSensor = hitMap.get(sensor); + for (Integer channel : hitsOnSensor.keySet()) { + Double amplitude = hitsOnSensor.get(channel); + short[] samples = new short[6]; + + 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)); + }
- for (SiSensor sensor : SvtUtils.getInstance().getSensors()) { - // 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)) { - - 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(); - } - - // 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();
+ 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, 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;
diff -u -r1.2 -r1.3 --- SVTEvioReader_RTH.java 21 Nov 2012 08:33:18 -0000 1.2 +++ SVTEvioReader_RTH.java 1 Mar 2013 01:15:20 -0000 1.3 @@ -30,7 +30,7 @@
/** * * @author Omar Moreno <[log in to unmask]>
- * @version $Id: SVTEvioReader_RTH.java,v 1.2 2012/11/21 08:33:18 omoreno Exp $
+ * @version $Id: SVTEvioReader_RTH.java,v 1.3 2013/03/01 01:15:20 meeg Exp $
*/ public class SVTEvioReader_RTH extends EvioReader {
@@ -155,15 +155,8 @@
Pair<Integer, Integer> daqPair = new Pair<Integer, Integer>(HPSSVTData.getFPGAAddress(data), HPSSVTData.getHybridNumber(data)); SiSensor sensor = SvtUtils.getInstance().getSensor(daqPair);
- // Find the side number (is 1) - int sideNumber; - if (sensor.hasElectrodesOnSide(ChargeCarrier.HOLE)) { - sideNumber = ChargeCarrier.HOLE.charge(); - } else { - sideNumber = ChargeCarrier.ELECTRON.charge(); - }
int sensorChannel = HPSSVTData.getSensorChannel(data);
- long cell_id = sensor.makeStripId(sensorChannel, sideNumber).getValue();
+ long cell_id = SvtUtils.makeCellID(sensor, sensorChannel);
return new BaseRawTrackerHit(hitTime, cell_id, HPSSVTData.getAllSamples(data), null, sensor); }
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