2 added + 1 removed + 5 modified, total 8 files
hps-java/src/main/java/org/lcsim/hps/recon/ecal
diff -N HPSRawCalorimeterHit.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ HPSRawCalorimeterHit.java 29 Aug 2011 23:05:37 -0000 1.1
@@ -0,0 +1,49 @@
+package org.lcsim.hps.recon.ecal;
+
+import org.lcsim.event.base.BaseCalorimeterHit;
+import org.lcsim.geometry.IDDecoder;
+
+/**
+ * An implementation of CalorimeterHit, with a constructor that sets rawEnergy
+ * for use in ECalReadout
+ *
+ * @author Sho Uemura
+ * @version $Id: HPSRawCalorimeterHit.java,v 1.1 2011/08/29 23:05:37 meeg Exp $
+ */
+public class HPSRawCalorimeterHit extends BaseCalorimeterHit {
+
+ /**
+ * Fully qualified constructor that sets rawEnergy
+ *
+ * @param energy Raw energy for this cell
+ * @param position Global Cartesian coordinate for this cell
+ * @param time Time of energy deposition
+ * @param id Cell ID
+ * @param type Type
+ */
+ public HPSRawCalorimeterHit(double energy, double[] position, double time, long id, int type) {
+ this.rawEnergy = energy;
+ this.position = position;
+ this.time = time;
+ this.id = id;
+ this.type = type;
+ }
+
+ public int getQuadrant() {
+ IDDecoder dec = getIDDecoder();
+ dec.setID(id);
+ if (dec.getValue("ix")>0) {
+ if (dec.getValue("side")>0) {
+ return 1;
+ } else {
+ return 4;
+ }
+ } else {
+ if (dec.getValue("side")>0) {
+ return 2;
+ } else {
+ return 3;
+ }
+ }
+ }
+}
\ No newline at end of file
hps-java/src/main/java/org/lcsim/hps/recon/ecal
diff -N HPSEcalCluster.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ HPSEcalCluster.java 29 Aug 2011 23:05:37 -0000 1.1
@@ -0,0 +1,34 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package org.lcsim.hps.recon.ecal;
+
+import org.lcsim.event.CalorimeterHit;
+import org.lcsim.recon.cluster.util.BasicCluster;
+
+/**
+ * Cluster with position defined by seed hit (for 1-bit trigger)
+ * @author Sho Uemura <[log in to unmask]>
+ * @version $Id: HPSEcalCluster.java,v 1.1 2011/08/29 23:05:37 meeg Exp $
+ */
+public class HPSEcalCluster extends BasicCluster {
+
+ CalorimeterHit seedHit = null;
+
+ public void addSeedHit(CalorimeterHit hit) {
+ this.seedHit = hit;
+ addHit(hit);
+ }
+
+ public CalorimeterHit getSeedHit() {
+ if (seedHit == null)
+ return hits.get(0);
+ else
+ return seedHit;
+ }
+
+ public double[] getPosition() {
+ return getSeedHit().getPosition();
+ }
+}
hps-java/src/main/java/org/lcsim/hps/recon/ecal
diff -u -r1.10 -r1.11
--- HPSEcalClusterer.java 24 Aug 2011 17:26:42 -0000 1.10
+++ HPSEcalClusterer.java 29 Aug 2011 23:05:37 -0000 1.11
@@ -1,6 +1,7 @@
package org.lcsim.hps.recon.ecal;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -14,7 +15,7 @@
import org.lcsim.geometry.subdetector.HPSEcal;
import org.lcsim.geometry.subdetector.HPSEcal.NeighborMap;
import org.lcsim.geometry.subdetector.HPSEcal2;
-import org.lcsim.recon.cluster.util.BasicCluster;
+import org.lcsim.recon.cluster.util.Clusterer;
import org.lcsim.util.Driver;
import org.lcsim.util.lcio.LCIOConstants;
@@ -26,164 +27,150 @@
* @author Jeremy McCormick <[log in to unmask]>
* @author Tim Nelson <[log in to unmask]>
*
- * @version $Id: HPSEcalClusterer.java,v 1.10 2011/08/24 17:26:42 meeg Exp $
+ * @version $Id: HPSEcalClusterer.java,v 1.11 2011/08/29 23:05:37 meeg Exp $
*/
-public class HPSEcalClusterer extends Driver
-{
+public class HPSEcalClusterer extends Driver implements Clusterer {
+
HPSEcal ecal;
-
String ecalCollectionName;
String ecalName;
String clusterCollectionName = "EcalClusters";
-
// Minimum E for cluster seed.
double seedEMin = .05;
-
// Minimum E to add hit to cluster.
double addEMin = .03;
-
// Odd or even number of crystals in X.
boolean oddX;
-
// Map of crystals to their neighbors.
NeighborMap neighborMap = null;
-
- public HPSEcalClusterer()
- {}
-
- public void setClusterCollectionName(String clusterCollectionName)
- {
+
+ public HPSEcalClusterer() {
+ }
+
+ public void setClusterCollectionName(String clusterCollectionName) {
this.clusterCollectionName = clusterCollectionName;
}
-
- public void setSeedEMin(double seedEMin)
- {
+
+ public void setSeedEMin(double seedEMin) {
this.seedEMin = seedEMin;
}
-
- public void setAddEMin(double addEMin)
- {
+
+ public void setAddEMin(double addEMin) {
this.addEMin = addEMin;
}
-
- public void setEcalCollectionName(String ecalCollectionName)
- {
+
+ public void setEcalCollectionName(String ecalCollectionName) {
this.ecalCollectionName = ecalCollectionName;
}
-
- public void setEcalName(String ecalName)
- {
+
+ public void setEcalName(String ecalName) {
this.ecalName = ecalName;
}
-
- public void startOfData()
- {
+
+ public void startOfData() {
if (ecalCollectionName == null)
throw new RuntimeException("The parameter ecalCollectionName was not set!");
-
+
if (ecalName == null)
throw new RuntimeException("The parameter ecalName was not set!");
- }
-
- public void detectorChanged(Detector detector)
- {
+ }
+
+ public void detectorChanged(Detector detector) {
// Get the Subdetector.
- ecal = (HPSEcal2)detector.getSubdetector(ecalName);
-
+ ecal = (HPSEcal2) detector.getSubdetector(ecalName);
+
// Cache ref to neighbor map.
neighborMap = ecal.getNeighborMap();
-
+
//System.out.println(ecal.getName());
//System.out.println(" nx="+ecal.nx());
//System.out.println(" ny="+ecal.ny());
//System.out.println(" beamgap="+ecal.beamGap());
//System.out.println(" dface="+ecal.distanceToFace());
-
+
//System.out.println(neighborMap.toString());
- }
-
- public void process(EventHeader event)
- {
+ }
+
+ public void process(EventHeader event) {
//System.out.println(this.getClass().getCanonicalName() + " - process");
-
- // Get the list of ECal hits.
+
+ // Get the list of raw ECal hits.
List<CalorimeterHit> hits = event.get(CalorimeterHit.class, ecalCollectionName);
if (hits == null)
throw new RuntimeException("Event is missing ECal raw hits collection!");
-
- // Get the decoder for the ECal IDs.
- IDDecoder dec = ecal.getIDDecoder();
-
+
+ // Put Cluster collection into event.
+ int flag = 1 << LCIOConstants.CLBIT_HITS;
+ event.put(clusterCollectionName, createClusters(hits), Cluster.class, flag);
+ }
+
+ public List<Cluster> createClusters(List<CalorimeterHit> hits) {
// Hit map.
- Map<Long,CalorimeterHit> hitMap = new HashMap<Long,CalorimeterHit>();
-
+ Map<Long, CalorimeterHit> hitMap = new HashMap<Long, CalorimeterHit>();
+
// Make a hit map for quick lookup by ID.
- for (CalorimeterHit hit : hits)
- {
+ for (CalorimeterHit hit : hits) {
hitMap.put(hit.getCellID(), hit);
}
-
+
+ return createClusters(hitMap);
+ }
+
+ public List<Cluster> createClusters(Map<Long, CalorimeterHit> map) {
+
// New Cluster list to be added to event.
List<Cluster> clusters = new ArrayList<Cluster>();
-
+
+ Collection<CalorimeterHit> hits = map.values();
+
// Loop over ECal hits to find cluster seeds.
- for (CalorimeterHit hit : hits)
- {
+ for (CalorimeterHit hit : hits) {
// Cut on min seed E.
if (hit.getRawEnergy() < seedEMin)
continue;
-
+
// Get neighbor crystal IDs.
Set<Long> neighbors = neighborMap.get(hit.getCellID());
-
+
if (neighbors == null)
throw new RuntimeException("Oops! Set of neighbors is null!");
-
+
// List for neighboring hits.
List<CalorimeterHit> neighborHits = new ArrayList<CalorimeterHit>();
// Loop over neighbors to make hit list for cluster.
boolean isSeed = true;
- for (Long neighborId : neighbors)
- {
+ for (Long neighborId : neighbors) {
// Find the neighbor hit in the event if it exists.
- CalorimeterHit neighborHit = hitMap.get(neighborId);
-
+ CalorimeterHit neighborHit = map.get(neighborId);
+
// Was this neighbor cell hit?
- if (neighborHit != null)
- {
+ if (neighborHit != null) {
// Check if neighbor cell has more energy.
- if (neighborHit.getRawEnergy() > hit.getRawEnergy())
- {
+ if (neighborHit.getRawEnergy() > hit.getRawEnergy()) {
// Neighbor has more energy, so cell is not a seed.
isSeed = false;
break;
- }
-
+ }
+
// Add to cluster if above min E.
- if (neighborHit.getRawEnergy() >= addEMin)
- {
+ if (neighborHit.getRawEnergy() >= addEMin) {
neighborHits.add(neighborHit);
}
- }
+ }
}
-
+
// Did we find a seed?
- if (isSeed)
- {
+ if (isSeed) {
// Make a cluster from the hit list.
- BasicCluster cluster = new BasicCluster();
- cluster.addHit(hit);
- for (CalorimeterHit clusHit : neighborHits)
- {
+ HPSEcalCluster cluster = new HPSEcalCluster();
+ cluster.addSeedHit(hit);
+ for (CalorimeterHit clusHit : neighborHits) {
cluster.addHit(clusHit);
- }
+ }
clusters.add(cluster);
}
}
-
- // Put Cluster collection into event.
- int flag = 1 << LCIOConstants.CLBIT_HITS;
- event.put(clusterCollectionName, clusters, Cluster.class, flag);
- }
+ return clusters;
+ }
}
\ No newline at end of file
hps-java/src/main/java/org/lcsim/hps/recon/ecal
diff -u -r1.3 -r1.4
--- HPSEcalTimeEvolutionReadoutDriver.java 24 Aug 2011 21:30:14 -0000 1.3
+++ HPSEcalTimeEvolutionReadoutDriver.java 29 Aug 2011 23:05:37 -0000 1.4
@@ -7,6 +7,7 @@
import org.lcsim.event.CalorimeterHit;
import org.lcsim.geometry.IDDecoder;
+import org.lcsim.hps.util.ClockSingleton;
import org.lcsim.hps.util.RingBuffer;
/**
@@ -14,18 +15,14 @@
* Simulates time evolution of preamp output pulse.
*
* @author Sho Uemura <[log in to unmask]>
- * @version $Id: HPSEcalTimeEvolutionReadoutDriver.java,v 1.3 2011/08/24 21:30:14 meeg Exp $
+ * @version $Id: HPSEcalTimeEvolutionReadoutDriver.java,v 1.4 2011/08/29 23:05:37 meeg Exp $
*/
public class HPSEcalTimeEvolutionReadoutDriver extends HPSEcalReadoutDriver {
- //buffer for deposited energy
+ //buffer for deposited energy
Map<Long, RingBuffer> eDepMap = null;
//length of ring buffer (in readout cycles)
int bufferLength = 20;
- //minimum readout value to write a hit
- double threshold = 0.0;
- //bunch spacing in ns
- double dt = 2.0;
//shaper time constant in ns
double t0 = 18.0;
@@ -37,22 +34,14 @@
eDepMap = new HashMap<Long, RingBuffer>();
}
- public void setThreshold(double threshold) {
- this.threshold = threshold;
- }
-
- public void setDt(double dt) {
- this.dt = dt;
- }
-
- public List<RawCalorimeterHit> readHits() {
+ public List<HPSRawCalorimeterHit> readHits() {
IDDecoder dec = ecal.getIDDecoder();
- List<RawCalorimeterHit> hitList = new ArrayList<RawCalorimeterHit>();
+ List<HPSRawCalorimeterHit> hitList = new ArrayList<HPSRawCalorimeterHit>();
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));
+ hitList.add(new HPSRawCalorimeterHit(eDepBuffer.currentValue(), dec.getPosition(), 0.0, cellID, hitType));
}
eDepBuffer.step();
}
@@ -62,20 +51,25 @@
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");
+ if (iy == 1 && ix >= -10 && ix <= -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 * dt * readoutCycle - hit.getTime()));
+ eDepBuffer.addToCell(i, hit.getRawEnergy() * pulseAmplitude(i * ClockSingleton.getDt() * readoutCycle - hit.getTime()));
}
}
}
public void initReadout() {
- //initialize clock
- clock = 0;
//initialize buffers
eDepMap = new HashMap<Long, RingBuffer>();
}
@@ -83,6 +77,6 @@
private double pulseAmplitude(double time) {
if (time < 0.0)
return 0.0;
- return (time / t0) * java.lang.Math.exp(1.0 - time / t0);
+ 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.9 -r1.10
--- HPSEcalReadoutDriver.java 24 Aug 2011 21:30:14 -0000 1.9
+++ HPSEcalReadoutDriver.java 29 Aug 2011 23:05:37 -0000 1.10
@@ -7,13 +7,15 @@
import org.lcsim.event.EventHeader;
import org.lcsim.geometry.Detector;
import org.lcsim.geometry.Subdetector;
+import org.lcsim.hps.util.ClockSingleton;
import org.lcsim.util.Driver;
+import org.lcsim.util.lcio.LCIOConstants;
/**
* Performs readout of ECal hits.
*
* @author Sho Uemura <[log in to unmask]>
- * @version $Id: HPSEcalReadoutDriver.java,v 1.9 2011/08/24 21:30:14 meeg Exp $
+ * @version $Id: HPSEcalReadoutDriver.java,v 1.10 2011/08/29 23:05:37 meeg Exp $
*/
public abstract class HPSEcalReadoutDriver extends Driver {
@@ -22,14 +24,19 @@
String ecalName;
String ecalRawCollectionName = "EcalRawHits";
String ecalReadoutName = "EcalHits";
- //hit type as in CalorimeterHitTypeValues
- int hitType = 11;
- //counts bunches for readout clock
- int clock;
+ //hit type as in org.lcsim.recon.calorimetry.CalorimeterHitType
+ int hitType = 0;
//number of bunches in readout cycle
int readoutCycle = 1;
+ //minimum readout value to write a hit
+ double threshold = 0.0;
+ //LCIO flags
+ int flags = 0;
public HPSEcalReadoutDriver() {
+ flags += 1 << LCIOConstants.CHBIT_LONG; //store position
+ flags += 1 << LCIOConstants.RCHBIT_ID1; //store cell ID
+
}
public void setEcalReadoutName(String ecalReadoutName) {
@@ -52,6 +59,10 @@
this.readoutCycle = readoutCycle;
}
+ public void setThreshold(double threshold) {
+ this.threshold = threshold;
+ }
+
public void startOfData() {
if (ecalCollectionName == null)
throw new RuntimeException("The parameter ecalCollectionName was not set!");
@@ -69,8 +80,6 @@
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)
@@ -80,14 +89,14 @@
putHits(hits);
//if at the end of a readout cycle, write buffers to hits
- if (clock % readoutCycle == 0) {
- event.put(ecalRawCollectionName, readHits(), RawCalorimeterHit.class, 0, ecalReadoutName);
+ if (ClockSingleton.getClock() % readoutCycle == 0) {
+ event.put(ecalRawCollectionName, readHits(), HPSRawCalorimeterHit.class, flags, ecalReadoutName);
} else
- event.put(ecalRawCollectionName, new ArrayList<RawCalorimeterHit>(), RawCalorimeterHit.class, 0, ecalReadoutName);
+ event.put(ecalRawCollectionName, new ArrayList<HPSRawCalorimeterHit>(), HPSRawCalorimeterHit.class, flags, ecalReadoutName);
}
//read analog signal out of buffers and make hits; reset buffers
- public abstract List<RawCalorimeterHit> readHits();
+ public abstract List<HPSRawCalorimeterHit> readHits();
//add deposited energy to buffers
public abstract void putHits(List<CalorimeterHit> hits);
hps-java/src/main/java/org/lcsim/hps/recon/ecal
diff -u -r1.12 -r1.13
--- HPSEcal1BitClusterer.java 24 Aug 2011 21:30:14 -0000 1.12
+++ HPSEcal1BitClusterer.java 29 Aug 2011 23:05:37 -0000 1.13
@@ -15,7 +15,6 @@
import org.lcsim.geometry.subdetector.HPSEcal;
import org.lcsim.geometry.subdetector.HPSEcal.NeighborMap;
import org.lcsim.geometry.subdetector.HPSEcal2;
-import org.lcsim.recon.cluster.util.BasicCluster;
import org.lcsim.util.Driver;
import org.lcsim.util.lcio.LCIOConstants;
import org.lcsim.recon.cluster.util.Clusterer;
@@ -28,7 +27,7 @@
* @author Jeremy McCormick <[log in to unmask]>
* @author Tim Nelson <[log in to unmask]>
* @author Sho Uemura <[log in to unmask]>
- * @version $Id: HPSEcal1BitClusterer.java,v 1.12 2011/08/24 21:30:14 meeg Exp $
+ * @version $Id: HPSEcal1BitClusterer.java,v 1.13 2011/08/29 23:05:37 meeg Exp $
*/
public class HPSEcal1BitClusterer extends Driver implements Clusterer {
@@ -302,10 +301,10 @@
if (isCluster) {
//System.out.printf("Cluster: x: %d, y: %d, side:%d, hits: %d\n",x1,y1,side1,hitCount);
- BasicCluster cluster = new BasicCluster();
+ HPSEcalCluster cluster = new HPSEcalCluster();
CalorimeterHit hit = map.get(possibleCluster);
if (hit != null && hit.getRawEnergy() > hitEMin) {
- cluster.addHit(hit);
+ cluster.addSeedHit(hit);
}
for (Long neighborId : neighbors) {
hps-java/src/main/java/org/lcsim/hps/recon/ecal
diff -u -r1.2 -r1.3
--- HPSEcalSimpleReadoutDriver.java 24 Aug 2011 21:30:14 -0000 1.2
+++ HPSEcalSimpleReadoutDriver.java 29 Aug 2011 23:05:37 -0000 1.3
@@ -13,18 +13,24 @@
* No time evolution - this just integrates all hits in a cycle.
*
* @author Sho Uemura <[log in to unmask]>
- * @version $Id: HPSEcalSimpleReadoutDriver.java,v 1.2 2011/08/24 21:30:14 meeg Exp $
+ * @version $Id: HPSEcalSimpleReadoutDriver.java,v 1.3 2011/08/29 23:05:37 meeg Exp $
*/
public class HPSEcalSimpleReadoutDriver extends HPSEcalReadoutDriver {
+
//buffer for deposited energy
Map<Long, Double> eDepMap = null;
- public List<RawCalorimeterHit> readHits() {
+ public List<HPSRawCalorimeterHit> readHits() {
IDDecoder dec = ecal.getIDDecoder();
- List<RawCalorimeterHit> hitList = new ArrayList<RawCalorimeterHit>();
+ List<HPSRawCalorimeterHit> hitList = new ArrayList<HPSRawCalorimeterHit>();
for (Long cellID : eDepMap.keySet()) {
dec.setID(cellID);
- hitList.add(new RawCalorimeterHit(eDepMap.get(cellID), dec.getPosition(), 0.0, cellID, hitType, dec));
+ int ix = dec.getValue("ix");
+ int iy = dec.getValue("iy");
+ if (iy == 1 && ix >= -10 && ix <= -2)
+ continue;
+ if (eDepMap.get(cellID) > threshold)
+ hitList.add(new HPSRawCalorimeterHit(eDepMap.get(cellID), dec.getPosition(), 0.0, cellID, hitType));
}
//reset hit integration
eDepMap = new HashMap<Long, Double>();
@@ -44,8 +50,6 @@
}
public void initReadout() {
- //initialize clock
- clock = 0;
//initialize buffers
eDepMap = new HashMap<Long, Double>();
}
hps-java/src/main/java/org/lcsim/hps/recon/ecal
diff -N RawCalorimeterHit.java
--- RawCalorimeterHit.java 24 Aug 2011 21:30:14 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,38 +0,0 @@
-package org.lcsim.hps.recon.ecal;
-
-import org.lcsim.event.base.BaseCalorimeterHit;
-import org.lcsim.geometry.IDDecoder;
-
-/**
- * An implementation of CalorimeterHit, with a constructor that sets rawEnergy
- * for use in ECalReadout
- *
- * @author Sho Uemura
- * @version $Id: RawCalorimeterHit.java,v 1.2 2011/08/24 21:30:14 meeg Exp $
- */
-public class RawCalorimeterHit extends BaseCalorimeterHit {
-
- IDDecoder idDecoder;
-
- /**
- * Fully qualified constructor that sets rawEnergy
- *
- * @param energy Raw energy for this cell
- * @param position Global Cartesian coordinate for this cell
- * @param time Time of energy deposition
- * @param id Cell ID
- * @param type Type
- */
- public RawCalorimeterHit(double energy, double[] position, double time, long id, int type, IDDecoder idDecoder) {
- this.rawEnergy = energy;
- this.position = position;
- this.time = time;
- this.id = id;
- this.type = type;
- this.idDecoder = idDecoder;
- }
-
- public IDDecoder getIDDecoder() {
- return idDecoder;
- }
-}
\ No newline at end of file
CVSspam 0.2.8