hps-java/src/main/resources/org/lcsim/hps/steering
diff -u -r1.2 -r1.3
--- ecal_example.lcsim 23 Aug 2011 22:35:12 -0000 1.2
+++ ecal_example.lcsim 23 Aug 2011 23:46:12 -0000 1.3
@@ -15,6 +15,7 @@
</classpath>
<execute>
<driver name="EventMarkerDriver"/>
+ <driver name="EcalReadout"/>
<driver name="EcalClusterer"/>
<driver name="EcalPlots"/>
<driver name="Writer"/>
@@ -25,8 +26,8 @@
type="org.lcsim.util.loop.LCIODriver">
<outputFilePath>${inputFile}_ecalClusters</outputFilePath>
</driver>
- <driver name="HPSEcalReadoutDriver"
- type="org.lcsim.hps.recon.ecal.HPSEcalReadoutDriver">
+ <driver name="EcalReadout"
+ type="org.lcsim.hps.recon.ecal.HPSEcalSimpleReadoutDriver">
<readoutCycle>1</readoutCycle>
<ecalName>HPSEcalTest</ecalName>
<ecalCollectionName>EcalHits</ecalCollectionName>
hps-java/src/main/java/org/lcsim/hps/recon/ecal
diff -N HPSEcalTimeEvolutionReadoutDriver.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ HPSEcalTimeEvolutionReadoutDriver.java 23 Aug 2011 23:46:13 -0000 1.1
@@ -0,0 +1,69 @@
+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.RingBuffer;
+
+/**
+ * Performs readout of ECal hits.
+ * Simulates time evolution of preamp output pulse.
+ *
+ * @author Sho Uemura <[log in to unmask]>
+ */
+public class HPSEcalTimeEvolutionReadoutDriver extends HPSEcalReadoutDriver {
+ //buffer for deposited energy
+ Map<Long, RingBuffer> eDepMap = null;
+ //length of ring buffer (in readout cycles)
+ int bufferLength = 1;
+ //minimum readout value to write a hit
+ double threshold = 0.0;
+
+ public HPSEcalTimeEvolutionReadoutDriver() {
+ }
+
+ public void setBufferLength(int bufferLength) {
+ this.bufferLength = bufferLength;
+ }
+
+ public void setThreshold(double threshold) {
+ this.threshold = threshold;
+ }
+
+ public List<CalorimeterHit> readHits() {
+ IDDecoder dec = ecal.getIDDecoder();
+ List<CalorimeterHit> hitList = new ArrayList<CalorimeterHit>();
+ for (Long cellID : eDepMap.keySet()) {
+ RingBuffer eDepBuffer = eDepMap.get(cellID);
+ if (eDepBuffer.currentValue() > threshold) {
+ dec.setID(cellID);
+ hitList.add(new RawCalorimeterHit(eDepBuffer.currentValue(), dec.getPosition(), 0.0, cellID, hitType, dec));
+ }
+ eDepBuffer.step();
+ }
+ return hitList;
+ }
+
+ public void putHits(List<CalorimeterHit> hits) {
+ //fill the readout buffers
+ for (CalorimeterHit hit : hits) {
+ RingBuffer eDepBuffer = eDepMap.get(hit.getCellID());
+ if (eDepBuffer == null) {
+ eDepBuffer = new RingBuffer(bufferLength);
+ eDepMap.put(hit.getCellID(), eDepBuffer);
+ }
+ eDepBuffer.addToCell(0, hit.getRawEnergy()); //TODO: put actual pulse shape here
+ }
+ }
+
+ public void initReadout() {
+ //initialize clock
+ clock = 0;
+ //initialize buffers
+ eDepMap = new HashMap<Long, RingBuffer>();
+ }
+}
\ No newline at end of file
hps-java/src/main/java/org/lcsim/hps/recon/ecal
diff -N HPSEcalSimpleReadoutDriver.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ HPSEcalSimpleReadoutDriver.java 23 Aug 2011 23:46:13 -0000 1.1
@@ -0,0 +1,51 @@
+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;
+
+/**
+ * Performs readout of ECal hits.
+ * No time evolution - this just integrates all hits in a cycle.
+ *
+ * @author Sho Uemura <[log in to unmask]>
+ */
+public class HPSEcalSimpleReadoutDriver extends HPSEcalReadoutDriver {
+ //buffer for deposited energy
+ Map<Long, Double> eDepMap = null;
+
+ public List<CalorimeterHit> readHits() {
+ IDDecoder dec = ecal.getIDDecoder();
+ List<CalorimeterHit> hitList = new ArrayList<CalorimeterHit>();
+ for (Long cellID : eDepMap.keySet()) {
+ dec.setID(cellID);
+ hitList.add(new RawCalorimeterHit(eDepMap.get(cellID), dec.getPosition(), 0.0, cellID, hitType, dec));
+ }
+ //reset hit integration
+ eDepMap = new HashMap<Long, Double>();
+ return hitList;
+ }
+
+ public void putHits(List<CalorimeterHit> hits) {
+ //fill the readout buffers
+ for (CalorimeterHit hit : hits) {
+ Double eDep = eDepMap.get(hit.getCellID());
+ if (eDep == null) {
+ eDepMap.put(hit.getCellID(), hit.getRawEnergy());
+ } else {
+ eDepMap.put(hit.getCellID(), eDep + hit.getRawEnergy());
+ }
+ }
+ }
+
+ public void initReadout() {
+ //initialize clock
+ clock = 0;
+ //initialize buffers
+ eDepMap = new HashMap<Long, Double>();
+ }
+}
\ No newline at end of file
hps-java/src/main/java/org/lcsim/hps/recon/ecal
diff -u -r1.6 -r1.7
--- HPSEcalReadoutDriver.java 23 Aug 2011 22:35:13 -0000 1.6
+++ HPSEcalReadoutDriver.java 23 Aug 2011 23:46:13 -0000 1.7
@@ -1,14 +1,10 @@
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.event.EventHeader;
import org.lcsim.geometry.Detector;
-import org.lcsim.geometry.IDDecoder;
import org.lcsim.geometry.Subdetector;
import org.lcsim.util.Driver;
@@ -17,14 +13,12 @@
*
* @author Sho Uemura <[log in to unmask]>
*/
-public class HPSEcalReadoutDriver extends Driver implements ECalReadout {
+public abstract class HPSEcalReadoutDriver extends Driver {
Subdetector ecal;
String ecalCollectionName;
String ecalName;
String ecalRawCollectionName = "EcalRawHits";
- //buffer for deposited energy
- Map<Long, Double> eDepMap = null;
int hitType = 11;
//counts bunches for readout clock
int clock;
@@ -68,12 +62,12 @@
public void process(EventHeader event) {
//System.out.println(this.getClass().getCanonicalName() + " - process");
clock++;
-
+
// Get the list of ECal hits.
List<CalorimeterHit> hits = event.get(CalorimeterHit.class, ecalCollectionName);
if (hits == null)
throw new RuntimeException("Event is missing ECal hits collection!");
-
+
//write hits into buffers
putHits(hits);
@@ -83,34 +77,12 @@
}
}
- public List<CalorimeterHit> readHits() {
- IDDecoder dec = ecal.getIDDecoder();
- List<CalorimeterHit> hitList = new ArrayList<CalorimeterHit>();
- for (Long cellID : eDepMap.keySet()) {
- dec.setID(cellID);
- hitList.add(new RawCalorimeterHit(eDepMap.get(cellID), dec.getPosition(), 0.0, cellID, hitType, dec));
- }
- //reset hit integration
- eDepMap = new HashMap<Long, Double>();
- return hitList;
- }
+ //read analog signal out of buffers and make hits; reset buffers
+ public abstract List<CalorimeterHit> readHits();
- public void putHits(List<CalorimeterHit> hits) {
- //fill the readout buffers
- for (CalorimeterHit hit : hits) {
- Double eDep = eDepMap.get(hit.getCellID());
- if (eDep == null) {
- eDepMap.put(hit.getCellID(), hit.getRawEnergy());
- } else {
- eDepMap.put(hit.getCellID(), eDep + hit.getRawEnergy());
- }
- }
- }
+ //add deposited energy to buffers
+ public abstract void putHits(List<CalorimeterHit> hits);
- public void initReadout() {
- //initialize clock
- clock = 0;
- //initialize buffers
- eDepMap = new HashMap<Long, Double>();
- }
+ //initialize buffers
+ public abstract void initReadout();
}
\ No newline at end of file