hps-java/src/main/java/org/lcsim/hps/recon/ecal
diff -u -r1.3 -r1.4
--- HPSEcalReadoutDriver.java 23 Aug 2011 22:08:29 -0000 1.3
+++ HPSEcalReadoutDriver.java 23 Aug 2011 22:18:10 -0000 1.4
@@ -18,7 +18,7 @@
*
* @author Sho Uemura <[log in to unmask]>
*/
-public class HPSEcalReadoutDriver extends Driver {
+public class HPSEcalReadoutDriver extends Driver implements ECalReadout {
HPSEcal ecal;
String ecalCollectionName;
@@ -59,6 +59,8 @@
//initialize clock
clock = 0;
+ //initialize buffers
+ eDepMap = new HashMap<Long, Double>();
}
public void detectorChanged(Detector detector) {
@@ -68,18 +70,34 @@
public void process(EventHeader event) {
//System.out.println(this.getClass().getCanonicalName() + " - process");
- //if at the beginning of a readout cycle, reset readout buffers
- if (clock % triggerCycle == 0) {
- eDepMap = new HashMap<Long, Double>();
- }
-
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!");
+ putHits(hits);
- //fill trigger buffers
+ //if at the end of a readout cycle, write buffers to hits
+ if (clock % triggerCycle == 0) {
+ event.put(ecalRawCollectionName, readHits(), CalorimeterHit.class, 0);
+ }
+ }
+
+ 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 trigger buffers
for (CalorimeterHit hit : hits) {
Double eDep = eDepMap.get(hit.getCellID());
if (eDep == null) {
@@ -88,18 +106,5 @@
eDepMap.put(hit.getCellID(), eDep + hit.getRawEnergy());
}
}
-
- //if at the end of a readout cycle, write buffers to hits
- if (clock % triggerCycle == 0) {
- IDDecoder dec = ecal.getIDDecoder();
- // New CalorimeterHit list to be added to event.
- List<CalorimeterHit> rawHits = new ArrayList<CalorimeterHit>();
- for (Long cellID : eDepMap.keySet()) {
- dec.setID(cellID);
- rawHits.add(new RawCalorimeterHit(eDepMap.get(cellID), dec.getPosition(), 0.0, cellID, hitType, dec));
- }
-
- event.put(ecalRawCollectionName, rawHits, CalorimeterHit.class, 0);
- }
}
}
\ No newline at end of file
hps-java/src/main/java/org/lcsim/hps/recon/ecal
diff -N ECalSimpleReadout.java
--- ECalSimpleReadout.java 23 Aug 2011 17:28:19 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,68 +0,0 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-package org.lcsim.hps.recon.ecal;
-
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Map;
-import java.util.HashMap;
-
-import org.lcsim.event.CalorimeterHit;
-import org.lcsim.geometry.Subdetector;
-import org.lcsim.geometry.IDDecoder;
-
-/**
- * Minimal ECal readout - just integrates energies of all hits,
- * no time evolution
- * @author meeg
- */
-public class ECalSimpleReadout implements ECalReadout {
-
- private static String _NAME = "ECalSimpleDigitizer";
- Subdetector ecal;
- Map<Long, Double> eDepMap = null;
- int hitType = 11;
-
- public String getName() {
- return _NAME;
- }
-
- public ECalSimpleReadout(Subdetector ecal) {
- this.ecal = ecal;
- eDepMap = new HashMap<Long, Double>();
- }
-
- public void setEcal(Subdetector ecal) {
- this.ecal = ecal;
- }
-
- public void setHitType(int hitType) {
- this.hitType = hitType;
- }
-
- 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 trigger 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());
- }
- }
- }
-}