1 added + 2 modified, total 3 files
hps-java/src/main/java/org/lcsim/hps/recon/ecal
diff -N HPSEcalDiscriminatorReadoutDriver.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ HPSEcalDiscriminatorReadoutDriver.java 2 Sep 2011 23:37:17 -0000 1.1
@@ -0,0 +1,100 @@
+package org.lcsim.hps.recon.ecal;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.lcsim.event.CalorimeterHit;
+import org.lcsim.geometry.IDDecoder;
+import org.lcsim.hps.util.ClockSingleton;
+import org.lcsim.hps.util.RingBuffer;
+
+/**
+ * Performs readout of ECal hits.
+ * Simulates time evolution of preamp output pulse.
+ *
+ * @author Sho Uemura <[log in to unmask]>
+ * @version $Id: HPSEcalDiscriminatorReadoutDriver.java,v 1.1 2011/09/02 23:37:17 meeg Exp $
+ */
+public class HPSEcalDiscriminatorReadoutDriver extends HPSEcalReadoutDriver {
+
+ //buffer for deposited energy
+ Map<Long, RingBuffer> eDepMap = null;
+ //last time we saw a rising edge
+ Map<Long, Double> edgeTimeMap = null;
+ //length of ring buffer (in multiples of bunch spacing)
+ int bufferLength = 200;
+ //shaper time constant in ns
+ double t0 = 18.0;
+ //discriminator output pulse width in ns
+ double outputWidth = 32.0;
+ //output hit "energy" in GeV
+ double outputEnergy = 10.0;
+
+ public HPSEcalDiscriminatorReadoutDriver() {
+ }
+
+ public void setBufferLength(int bufferLength) {
+ this.bufferLength = bufferLength;
+ eDepMap = new HashMap<Long, RingBuffer>();
+ }
+
+ public List<HPSRawCalorimeterHit> readHits() {
+ IDDecoder dec = ecal.getIDDecoder();
+ List<HPSRawCalorimeterHit> hitList = new ArrayList<HPSRawCalorimeterHit>();
+ for (Long cellID : edgeTimeMap.keySet()) {
+ //if there's an output pulse, make a hit
+ if (ClockSingleton.getTime() - edgeTimeMap.get(cellID) < outputWidth) {
+ dec.setID(cellID);
+ hitList.add(new HPSRawCalorimeterHit(outputEnergy, dec.getPosition(), 0.0, cellID, hitType));
+ }
+ }
+ return hitList;
+ }
+
+ public void putHits(List<CalorimeterHit> hits) {
+ //fill the readout buffers
+ for (CalorimeterHit hit : hits) {
+ IDDecoder dec = ecal.getIDDecoder();
+ dec.setID(hit.getCellID());
+// int ix = dec.getValue("ix");
+// int iy = dec.getValue("iy");
+// //temporary hack to disable crystals and flip X coordinate
+// int side = dec.getValue("side");
+// if (iy == 1 && ix * side >= -10 && ix * side <= -2)
+// continue;
+
+ RingBuffer eDepBuffer = eDepMap.get(hit.getCellID());
+ if (eDepBuffer == null) {
+ eDepBuffer = new RingBuffer(bufferLength);
+ eDepMap.put(hit.getCellID(), eDepBuffer);
+ }
+ for (int i = 0; i < bufferLength; i++) {
+ eDepBuffer.addToCell(i, hit.getRawEnergy() * pulseAmplitude(i * ClockSingleton.getDt() - hit.getTime()));
+ }
+ }
+
+ //check for rising edges
+ for (Long cellID : eDepMap.keySet()) {
+ RingBuffer eDepBuffer = eDepMap.get(cellID);
+ //if there's a rising edge between now and the next time step, note the time
+ if ((eDepBuffer.currentValue() < threshold)
+ && (eDepBuffer.getValue(1) > threshold))
+ edgeTimeMap.put(cellID, ClockSingleton.getTime());
+ eDepBuffer.step();
+ }
+ }
+
+ public void initReadout() {
+ //initialize buffers
+ eDepMap = new HashMap<Long, RingBuffer>();
+ edgeTimeMap = new HashMap<Long, Double>();
+ }
+
+ private double pulseAmplitude(double time) {
+ if (time < 0.0)
+ return 0.0;
+ return (time / t0) * Math.exp(1.0 - time / t0);
+ }
+}
\ No newline at end of file
hps-java/src/main/java/org/lcsim/hps/recon/ecal
diff -u -r1.11 -r1.12
--- HPSEcalReadoutDriver.java 30 Aug 2011 22:00:33 -0000 1.11
+++ HPSEcalReadoutDriver.java 2 Sep 2011 23:37:17 -0000 1.12
@@ -15,7 +15,7 @@
* Performs readout of ECal hits.
*
* @author Sho Uemura <[log in to unmask]>
- * @version $Id: HPSEcalReadoutDriver.java,v 1.11 2011/08/30 22:00:33 meeg Exp $
+ * @version $Id: HPSEcalReadoutDriver.java,v 1.12 2011/09/02 23:37:17 meeg Exp $
*/
public abstract class HPSEcalReadoutDriver extends Driver {
@@ -99,6 +99,7 @@
public abstract List<HPSRawCalorimeterHit> readHits();
//add deposited energy to buffers
+ //must be run every event, even if the list is empty
public abstract void putHits(List<CalorimeterHit> hits);
//initialize buffers
hps-java/src/main/java/org/lcsim/hps/util
diff -u -r1.2 -r1.3
--- RingBuffer.java 24 Aug 2011 21:30:14 -0000 1.2
+++ RingBuffer.java 2 Sep 2011 23:37:17 -0000 1.3
@@ -4,7 +4,7 @@
* Ring buffer for storing ECal (and possibly SVT) samples for trigger and readout
*
* @author Sho Uemura <[log in to unmask]>
- * @version $Id: RingBuffer.java,v 1.2 2011/08/24 21:30:14 meeg Exp $
+ * @version $Id: RingBuffer.java,v 1.3 2011/09/02 23:37:17 meeg Exp $
*/
public class RingBuffer {
@@ -25,6 +25,11 @@
public double currentValue() {
return array[ptr];
}
+
+ //return content of specified cell (pos=0 for current cell)
+ public double getValue(int pos) {
+ return array[(ptr+pos)%size];
+ }
/**
* Clear value at current cell and step to the next one
CVSspam 0.2.8