6 modified files
hps-java/src/main/resources/org/lcsim/hps/steering
diff -u -r1.3 -r1.4
--- ecal_1bit_bkgd.lcsim 7 Oct 2011 23:14:54 -0000 1.3
+++ ecal_1bit_bkgd.lcsim 21 Oct 2011 19:54:08 -0000 1.4
@@ -1,7 +1,7 @@
<!--
Example LCSim steering file to run simple HPS ECal clustering and analysis.
@author Sho Uemura <[log in to unmask]>
- @version $Id: ecal_1bit_bkgd.lcsim,v 1.3 2011/10/07 23:14:54 meeg Exp $
+ @version $Id: ecal_1bit_bkgd.lcsim,v 1.4 2011/10/21 19:54:08 meeg Exp $
-->
<lcsim xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
@@ -41,7 +41,6 @@
</driver>
<driver name="EcalClusterer"
type="org.lcsim.hps.recon.ecal.HPSEcal1BitClusterer">
- <hitEMin>1.0</hitEMin>
<clusterThreshold>0</clusterThreshold>
<ecalName>Ecal</ecalName>
<ecalCollectionName>EcalRawHits</ecalCollectionName>
@@ -49,7 +48,7 @@
<driver name="EcalTrigger"
type="org.lcsim.hps.recon.ecal.HPSTriggerDriver">
<clusterCollectionName>EcalClusters</clusterCollectionName>
- <outputFilePath>${inputFile}_triggers</outputFilePath>
+ <outputFileName>${inputFile}_triggers</outputFileName>
<ecalName>Ecal</ecalName>
</driver>
<driver name="EcalPlots"
hps-java/src/main/resources/org/lcsim/hps/steering
diff -u -r1.2 -r1.3
--- ecal_1bit_ap.lcsim 7 Oct 2011 23:14:54 -0000 1.2
+++ ecal_1bit_ap.lcsim 21 Oct 2011 19:54:08 -0000 1.3
@@ -1,7 +1,7 @@
<!--
Example LCSim steering file to run simple HPS ECal clustering and analysis.
@author Sho Uemura <[log in to unmask]>
- @version $Id: ecal_1bit_ap.lcsim,v 1.2 2011/10/07 23:14:54 meeg Exp $
+ @version $Id: ecal_1bit_ap.lcsim,v 1.3 2011/10/21 19:54:08 meeg Exp $
-->
<lcsim xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/lcsim/1.0/lcsim.xsd">
@@ -36,11 +36,10 @@
<ecalName>Ecal</ecalName>
<ecalCollectionName>EcalHits</ecalCollectionName>
<ecalRawCollectionName>EcalRawHits</ecalRawCollectionName>
- <threshold>0.05</threshold>
+ <threshold>0.2</threshold>
</driver>
<driver name="EcalClusterer"
type="org.lcsim.hps.recon.ecal.HPSEcal1BitClusterer">
- <hitEMin>0.2</hitEMin>
<clusterThreshold>0</clusterThreshold>
<ecalName>Ecal</ecalName>
<ecalCollectionName>EcalRawHits</ecalCollectionName>
@@ -48,7 +47,7 @@
<driver name="EcalTrigger"
type="org.lcsim.hps.recon.ecal.HPSTriggerDriver">
<clusterCollectionName>EcalClusters</clusterCollectionName>
- <outputFilePath>${inputFile}_triggers</outputFilePath>
+ <outputFileName>${inputFile}_triggers</outputFileName>
<ecalName>Ecal</ecalName>
</driver>
<driver name="EcalPlots"
hps-java/src/main/java/org/lcsim/hps/recon/ecal
diff -u -r1.1 -r1.2
--- HPSTriggerDriver.java 7 Oct 2011 23:14:54 -0000 1.1
+++ HPSTriggerDriver.java 21 Oct 2011 19:54:08 -0000 1.2
@@ -16,7 +16,7 @@
* Prints triggers to file if file path specified.
*
* @author Sho Uemura <[log in to unmask]>
- * @version $Id: HPSTriggerDriver.java,v 1.1 2011/10/07 23:14:54 meeg Exp $
+ * @version $Id: HPSTriggerDriver.java,v 1.2 2011/10/21 19:54:08 meeg Exp $
*/
public class HPSTriggerDriver extends Driver {
@@ -24,7 +24,7 @@
String ecalName;
String clusterCollectionName;
IDDecoder dec = null;
- String outputFilePath;
+ String outputFileName;
PrintWriter outputStream = null;
int numTriggers;
@@ -39,8 +39,8 @@
this.ecalName = ecalName;
}
- public void setOutputFilePath(String outputFilePath) {
- this.outputFilePath = outputFilePath;
+ public void setOutputFileName(String outputFileName) {
+ this.outputFileName = outputFileName;
}
public void startOfData() {
@@ -52,9 +52,9 @@
throw new RuntimeException("The parameter ecalName was not set!");
}
- if (outputFilePath != null) {
+ if (outputFileName != null) {
try {
- outputStream = new PrintWriter(outputFilePath);
+ outputStream = new PrintWriter(outputFileName);
} catch (IOException ex) {
throw new RuntimeException("Invalid outputFilePath!");
}
hps-java/src/main/java/org/lcsim/hps/recon/ecal
diff -u -r1.1 -r1.2
--- HPSEcal1BitClusterVetoClusterer.java 13 Oct 2011 19:59:40 -0000 1.1
+++ HPSEcal1BitClusterVetoClusterer.java 21 Oct 2011 19:54:08 -0000 1.2
@@ -1,16 +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 java.util.Set;
import org.lcsim.event.CalorimeterHit;
-import org.lcsim.event.Cluster;
-import org.lcsim.event.EventHeader;
-import org.lcsim.geometry.IDDecoder;
-import org.lcsim.util.lcio.LCIOConstants;
/**
* Creates clusters from CalorimeterHits in the HPSEcal detector.
@@ -20,73 +14,28 @@
* The clustering algorithm is from JLab Hall B 6 GeV DVCS Trigger Design doc.
*
* @author Sho Uemura <[log in to unmask]>
- * @version $Id: HPSEcal1BitClusterVetoClusterer.java,v 1.1 2011/10/13 19:59:40 meeg Exp $
+ * @version $Id: HPSEcal1BitClusterVetoClusterer.java,v 1.2 2011/10/21 19:54:08 meeg Exp $
*/
public class HPSEcal1BitClusterVetoClusterer extends HPSEcal1BitClusterer {
- String vetoCollectionName;
-
public HPSEcal1BitClusterVetoClusterer() {
}
- public void setVetoCollectionName(String vetoCollectionName) {
- this.vetoCollectionName = vetoCollectionName;
- }
-
- public void startOfData() {
- if (ecalCollectionName == null) {
- throw new RuntimeException("The parameter ecalCollectionName was not set!");
- }
-
- if (vetoCollectionName == null) {
- throw new RuntimeException("The parameter vetoCollectionName was not set!");
- }
-
- if (ecalName == null) {
- throw new RuntimeException("The parameter ecalName was not set!");
- }
- }
-
- public void process(EventHeader event) {
- //System.out.println(this.getClass().getCanonicalName() + " - process");
-
- // 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!");
-
- List<CalorimeterHit> vetoHits = event.get(CalorimeterHit.class, vetoCollectionName);
- if (vetoHits == null)
- throw new RuntimeException("Event is missing ECal veto hits collection!");
-
- // Put Cluster collection into event.
- int flag = 1 << LCIOConstants.CLBIT_HITS;
- event.put(clusterCollectionName, createVetoedClusters(hits, vetoHits), Cluster.class, flag);
- }
-
- public List<Cluster> createVetoedClusters(List<CalorimeterHit> hits, List<CalorimeterHit> vetoHits) {
+ public void countHits(List<CalorimeterHit> hits, List<CalorimeterHit> vetoHits) {
// Hit map.
- Map<Long, CalorimeterHit> map = new HashMap<Long, CalorimeterHit>();
-
- // Make a hit map for quick lookup by ID.
- for (CalorimeterHit hit : hits) {
- map.put(hit.getCellID(), hit);
- }
-
- // New Cluster list to be added to event.
- List<Cluster> clusters = new ArrayList<Cluster>();
-
- // Get the decoder for the ECal IDs.
- IDDecoder dec = ecal.getIDDecoder();
-
- Map<Long, Integer> hitCounts = new HashMap<Long, Integer>();
+ hitMap = new HashMap<Long, CalorimeterHit>();
+ hitCounts = new HashMap<Long, Integer>();
// Loop over ECal hits to count hit towers
for (CalorimeterHit hit : hits) {
- // Cut on seed E.
- if (hit.getRawEnergy() < hitEMin || hit.getRawEnergy() > hitEMax) {
- continue;
- }
+ dec.setID(hit.getCellID());
+ int ix = dec.getValue("ix");
+ int iy = dec.getValue("iy");
+ if (ix>0 && ix<=4/* && Math.abs(iy)<=2*/) continue;
+ if (ix<0 && ix>=-5/* && Math.abs(iy)<=2*/) continue;
+ //if (Math.abs(ix)<=2 && Math.abs(iy)<=2) continue;
+ // Make a hit map for quick lookup by ID.
+ hitMap.put(hit.getCellID(), hit);
// Get neighbor crystal IDs.
Set<Long> neighbors = neighborMap.get(hit.getCellID());
@@ -110,183 +59,21 @@
hitCounts.put(neighborId, hitCount + 1);
}
}
-
- // Loop over veto hits to veto clusters
- for (CalorimeterHit hit : vetoHits) {
- // Get neighbor crystal IDs.
- Set<Long> neighbors = neighborMap.get(hit.getCellID());
-
- if (neighbors == null) {
- throw new RuntimeException("Oops! Set of neighbors is null!");
- }
-
- // Veto the hit towers for the vetoed crystal and all neighbors.
- hitCounts.remove(hit.getCellID());
- for (Long neighborId : neighbors) {
- hitCounts.remove(neighborId);
- }
- }
-
- //for each crystal with a nonzero hit count, test for cluster
- for (Long possibleCluster : hitCounts.keySet()) {
- //System.out.printf("%d, %d hits\n",possibleCluster,hitCounts.get(possibleCluster));
- if (hitCounts.get(possibleCluster) <= clusterThreshold) {
- continue;
- }
-
- // Get neighbor crystal IDs.
- Set<Long> neighbors = neighborMap.get(possibleCluster);
-
- if (neighbors == null) {
- throw new RuntimeException("Oops! Set of neighbors is null!");
- }
-
- //Apply peak detector scheme.
- // Set the ID.
- dec.setID(possibleCluster);
- // Get ID field values.
- int x1 = dec.getValue("ix");
- int y1 = dec.getValue("iy");
- Integer hitCount = hitCounts.get(possibleCluster);
-
- //System.out.printf("Possible cluster: x: %d, y: %d, hits: %d\n",x1,y1,hitCount);
- boolean isCluster = true;
- for (Long neighborId : neighbors) {
- // Set the ID.
- dec.setID(neighborId);
- Integer neighborHitCount = hitCounts.get(neighborId);
- if (neighborHitCount == null)
- continue;
- // Get ID field values.
- int x2 = dec.getValue("ix");
- int y2 = dec.getValue("iy");
- if (y1 > 0) {
- if (x1 > 0) {
- //quadrant 1
- if (x1 == 1) {
- //special case: left edge of quadrant
- if (x1 > x2 && y1 < y2) {
- if (hitCount > neighborHitCount)
- continue;
- } else if (x1 > x2) {
- if (hitCount >= neighborHitCount)
- continue;
- } else if (x1 < x2) {
- if (hitCount > neighborHitCount)
- continue;
- } else if (y1 < y2) {
- if (hitCount >= neighborHitCount)
- continue;
- } else {
- if (hitCount > neighborHitCount)
- continue;
- }
- } else {
- if (x1 > x2) {
- if (hitCount >= neighborHitCount)
- continue;
- } else if (x1 < x2) {
- if (hitCount > neighborHitCount)
- continue;
- } else if (y1 < y2) {
- if (hitCount >= neighborHitCount)
- continue;
- } else {
- if (hitCount > neighborHitCount)
- continue;
- }
- }
- } else {
- //quadrant 2
- if (y1 > y2) {
- if (hitCount >= neighborHitCount)
- continue;
- } else if (y1 < y2) {
- if (hitCount > neighborHitCount)
- continue;
- } else if (x1 > x2) {
- if (hitCount >= neighborHitCount)
- continue;
- } else {
- if (hitCount > neighborHitCount)
- continue;
- }
- }
- } else {
- if (x1 < 0) {
- //quadrant 3
- if (x1 == 1) {
- //special case: left edge of quadrant
- if (x1 < x2 && y1 > y2) {
- if (hitCount > neighborHitCount)
- continue;
- } else if (x1 < x2) {
- if (hitCount >= neighborHitCount)
- continue;
- } else if (x1 > x2) {
- if (hitCount > neighborHitCount)
- continue;
- } else if (y1 > y2) {
- if (hitCount >= neighborHitCount)
- continue;
- } else {
- if (hitCount > neighborHitCount)
- continue;
- }
- } else {
- if (x1 < x2) {
- if (hitCount >= neighborHitCount)
- continue;
- } else if (x1 > x2) {
- if (hitCount > neighborHitCount)
- continue;
- } else if (y1 > y2) {
- if (hitCount >= neighborHitCount)
- continue;
- } else {
- if (hitCount > neighborHitCount)
- continue;
- }
- }
- } else {
- //quadrant 4
- if (y1 < y2) {
- if (hitCount >= neighborHitCount)
- continue;
- } else if (y1 > y2) {
- if (hitCount > neighborHitCount)
- continue;
- } else if (x1 < x2) {
- if (hitCount >= neighborHitCount)
- continue;
- } else {
- if (hitCount > neighborHitCount)
- continue;
- }
- }
- }
- isCluster = false;
- break;
- }
-
- if (isCluster) {
- //System.out.printf("Cluster: x: %d, y: %d, side:%d, hits: %d\n",x1,y1,side1,hitCount);
- HPSEcalCluster cluster = new HPSEcalCluster(possibleCluster);
- CalorimeterHit hit = map.get(possibleCluster);
- if (hit != null && hit.getRawEnergy() > hitEMin && hit.getRawEnergy() < hitEMax) {
- cluster.addHit(hit);
- }
-
- for (Long neighborId : neighbors) {
- // Find the neighbor hit in the event if it exists.
- hit = map.get(neighborId);
- if (hit != null && hit.getRawEnergy() > hitEMin && hit.getRawEnergy() < hitEMax) {
- cluster.addHit(hit);
- }
- }
- clusters.add(cluster);
- }
- }
- return clusters;
+ if (vetoHits!=null) {
+ for (CalorimeterHit hit : vetoHits) {
+ //Get neighbor crystal IDs.
+ Set<Long> neighbors = neighborMap.get(hit.getCellID());
+
+ if (neighbors == null) {
+ throw new RuntimeException("Oops! Set of neighbors is null!");
+ }
+
+ // Veto the hit towers for the vetoed crystal and all neighbors.
+ hitCounts.remove(hit.getCellID());
+ for (Long neighborId : neighbors) {
+ hitCounts.remove(neighborId);
+ }
+ }
+ }
}
-}
\ No newline at end of file
+}
hps-java/src/main/java/org/lcsim/hps/recon/ecal
diff -u -r1.17 -r1.18
--- HPSEcal1BitClusterer.java 7 Oct 2011 23:14:54 -0000 1.17
+++ HPSEcal1BitClusterer.java 21 Oct 2011 19:54:08 -0000 1.18
@@ -16,7 +16,6 @@
import org.lcsim.geometry.subdetector.HPSEcal3;
import org.lcsim.util.Driver;
import org.lcsim.util.lcio.LCIOConstants;
-import org.lcsim.recon.cluster.util.Clusterer;
/**
* Creates clusters from CalorimeterHits in the HPSEcal detector.
@@ -26,17 +25,20 @@
* @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.17 2011/10/07 23:14:54 meeg Exp $
+ * @version $Id: HPSEcal1BitClusterer.java,v 1.18 2011/10/21 19:54:08 meeg Exp $
*/
-public class HPSEcal1BitClusterer extends Driver implements Clusterer {
-
+public class HPSEcal1BitClusterer extends Driver {
HPSEcal3 ecal;
+ IDDecoder dec;
String ecalName;
String ecalCollectionName;
+ String vetoCollectionName;
String clusterCollectionName = "EcalClusters";
// Threshold E for discriminator.
- double hitEMin = .05;
- double hitEMax = 100.0;
+ //double hitEMin = .05;
+ //double hitEMax = 100.0;
+ Map<Long, Integer> hitCounts = null;
+ Map<Long, CalorimeterHit> hitMap = null;
// Threshold hit count for cluster. Cluster must have more than this many hits.
int clusterThreshold = 5;
// Map of crystals to their neighbors.
@@ -53,6 +55,11 @@
this.ecalCollectionName = ecalCollectionName;
}
+ public void setVetoCollectionName(String vetoCollectionName) {
+ this.vetoCollectionName = vetoCollectionName;
+ }
+
+ /*
public void setHitEMin(double hitEMin) {
this.hitEMin = hitEMin;
}
@@ -60,6 +67,7 @@
public void setHitEMax(double hitEMax) {
this.hitEMax = hitEMax;
}
+ */
public void setClusterThreshold(int clusterThreshold) {
this.clusterThreshold = clusterThreshold;
@@ -83,6 +91,9 @@
// Get the Subdetector.
ecal = (HPSEcal3) detector.getSubdetector(ecalName);
+ // Get the decoder for the ECal IDs.
+ dec = ecal.getIDDecoder();
+
// Cache ref to neighbor map.
neighborMap = ecal.getNeighborMap();
@@ -102,40 +113,48 @@
List<CalorimeterHit> hits = event.get(CalorimeterHit.class, ecalCollectionName);
if (hits == null)
throw new RuntimeException("Event is missing ECal raw hits collection!");
+ List<CalorimeterHit> vetoHits = null;
+
+ // Get the list of raw ECal hits.
+ if (vetoCollectionName!=null) {
+ vetoHits = event.get(CalorimeterHit.class, vetoCollectionName);
+ if (vetoHits == null)
+ throw new RuntimeException("Event is missing ECal veto hits collection!");
+ }
+
+ countHits(hits, vetoHits);
// Put Cluster collection into event.
int flag = 1 << LCIOConstants.CLBIT_HITS;
- event.put(clusterCollectionName, createClusters(hits), Cluster.class, flag);
+ event.put(clusterCollectionName, createClusters(), Cluster.class, flag);
}
- public List<Cluster> createClusters(List<CalorimeterHit> hits) {
+ public void countHits(List<CalorimeterHit> hits, List<CalorimeterHit> vetoHits) {
// Hit map.
- Map<Long, CalorimeterHit> hitMap = new HashMap<Long, CalorimeterHit>();
+ hitMap = new HashMap<Long, CalorimeterHit>();
+ HashMap<Long, CalorimeterHit> vetoMap = new HashMap<Long, CalorimeterHit>();
- // Make a hit map for quick lookup by ID.
- for (CalorimeterHit hit : hits) {
- hitMap.put(hit.getCellID(), hit);
- }
+ if (vetoHits!=null) {
+ for (CalorimeterHit hit : vetoHits) {
+ vetoMap.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>();
-
- // Get the decoder for the ECal IDs.
- IDDecoder dec = ecal.getIDDecoder();
+ hitCounts = new HashMap<Long, Integer>();
+ // Loop over ECal hits to count hit towers
+ for (CalorimeterHit hit : hits) {
+ if (vetoMap.get(hit.getCellID())!=null)
+ continue;
- Map<Long, Integer> hitCounts = new HashMap<Long, Integer>();
+ dec.setID(hit.getCellID());
+ int ix = dec.getValue("ix");
+ int iy = dec.getValue("iy");
+ if (ix>0 && ix<=4/* && Math.abs(iy)<=2*/) continue;
+ if (ix<0 && ix>=-5/* && Math.abs(iy)<=2*/) continue;
+ //if (Math.abs(ix)<=2 && Math.abs(iy)<=2) continue;
- Collection<CalorimeterHit> hitCollection = map.values();
- // Loop over ECal hits to count hit towers
- for (CalorimeterHit hit : hitCollection) {
- // Cut on seed E.
- if (hit.getRawEnergy() < hitEMin || hit.getRawEnergy() > hitEMax) {
- continue;
- }
+ // Make a hit map for quick lookup by ID.
+ hitMap.put(hit.getCellID(), hit);
// Get neighbor crystal IDs.
Set<Long> neighbors = neighborMap.get(hit.getCellID());
@@ -159,6 +178,11 @@
hitCounts.put(neighborId, hitCount + 1);
}
}
+ }
+
+ public List<Cluster> createClusters() {
+ // New Cluster list to be added to event.
+ List<Cluster> clusters = new ArrayList<Cluster>();
//for each crystal with a nonzero hit count, test for cluster
for (Long possibleCluster : hitCounts.keySet()) {
@@ -305,15 +329,15 @@
if (isCluster) {
//System.out.printf("Cluster: x: %d, y: %d, side:%d, hits: %d\n",x1,y1,side1,hitCount);
HPSEcalCluster cluster = new HPSEcalCluster(possibleCluster);
- CalorimeterHit hit = map.get(possibleCluster);
- if (hit != null && hit.getRawEnergy() > hitEMin && hit.getRawEnergy() < hitEMax) {
+ CalorimeterHit hit = hitMap.get(possibleCluster);
+ if (hit != null /*&& hit.getRawEnergy() > hitEMin && hit.getRawEnergy() < hitEMax*/) {
cluster.addHit(hit);
}
for (Long neighborId : neighbors) {
// Find the neighbor hit in the event if it exists.
- hit = map.get(neighborId);
- if (hit != null && hit.getRawEnergy() > hitEMin && hit.getRawEnergy() < hitEMax) {
+ hit = hitMap.get(neighborId);
+ if (hit != null /*&& hit.getRawEnergy() > hitEMin && hit.getRawEnergy() < hitEMax*/) {
cluster.addHit(hit);
}
}
@@ -322,4 +346,4 @@
}
return clusters;
}
-}
\ No newline at end of file
+}
hps-java/src/main/java/org/lcsim/hps/recon/ecal
diff -u -r1.1 -r1.2
--- HPSEcal1BitEventVetoClusterer.java 13 Oct 2011 19:59:40 -0000 1.1
+++ HPSEcal1BitEventVetoClusterer.java 21 Oct 2011 19:54:08 -0000 1.2
@@ -1,12 +1,10 @@
package org.lcsim.hps.recon.ecal;
-import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Set;
import org.lcsim.event.CalorimeterHit;
-import org.lcsim.event.Cluster;
-import org.lcsim.event.EventHeader;
-import org.lcsim.util.lcio.LCIOConstants;
/**
* Creates clusters from CalorimeterHits in the HPSEcal detector.
@@ -16,50 +14,53 @@
* The clustering algorithm is from JLab Hall B 6 GeV DVCS Trigger Design doc.
*
* @author Sho Uemura <[log in to unmask]>
- * @version $Id: HPSEcal1BitEventVetoClusterer.java,v 1.1 2011/10/13 19:59:40 meeg Exp $
+ * @version $Id: HPSEcal1BitEventVetoClusterer.java,v 1.2 2011/10/21 19:54:08 meeg Exp $
*/
public class HPSEcal1BitEventVetoClusterer extends HPSEcal1BitClusterer {
- String vetoCollectionName;
-
public HPSEcal1BitEventVetoClusterer() {
}
- public void setVetoCollectionName(String vetoCollectionName) {
- this.vetoCollectionName = vetoCollectionName;
- }
-
- public void startOfData() {
- if (ecalCollectionName == null) {
- throw new RuntimeException("The parameter ecalCollectionName was not set!");
- }
-
- if (vetoCollectionName == null) {
- throw new RuntimeException("The parameter vetoCollectionName was not set!");
+ public void countHits(List<CalorimeterHit> hits, List<CalorimeterHit> vetoHits) {
+ // Hit map.
+ hitMap = new HashMap<Long, CalorimeterHit>();
+
+ hitCounts = new HashMap<Long, Integer>();
+ if (vetoHits!=null && !vetoHits.isEmpty()) return;
+
+ // Loop over ECal hits to count hit towers
+ for (CalorimeterHit hit : hits) {
+ dec.setID(hit.getCellID());
+ int ix = dec.getValue("ix");
+ int iy = dec.getValue("iy");
+ if (ix>0 && ix<=4/* && Math.abs(iy)<=2*/) continue;
+ if (ix<0 && ix>=-5/* && Math.abs(iy)<=2*/) continue;
+ //if (Math.abs(ix)<=2 && Math.abs(iy)<=2) continue;
+
+ // Make a hit map for quick lookup by ID.
+ hitMap.put(hit.getCellID(), hit);
+
+ // Get neighbor crystal IDs.
+ Set<Long> neighbors = neighborMap.get(hit.getCellID());
+
+ if (neighbors == null) {
+ throw new RuntimeException("Oops! Set of neighbors is null!");
+ }
+
+ Integer hitCount = hitCounts.get(hit.getCellID());
+ if (hitCount == null)
+ hitCounts.put(hit.getCellID(), 1);
+ else
+ hitCounts.put(hit.getCellID(), hitCount + 1);
+
+ // Loop over neighbors to make hit list for cluster.
+ for (Long neighborId : neighbors) {
+ hitCount = hitCounts.get(neighborId);
+ if (hitCount == null)
+ hitCounts.put(neighborId, 1);
+ else
+ hitCounts.put(neighborId, hitCount + 1);
+ }
}
-
- if (ecalName == null) {
- throw new RuntimeException("The parameter ecalName was not set!");
- }
- }
-
- public void process(EventHeader event) {
- //System.out.println(this.getClass().getCanonicalName() + " - process");
-
- // 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!");
-
- List<CalorimeterHit> vetoHits = event.get(CalorimeterHit.class, vetoCollectionName);
- if (vetoHits == null)
- throw new RuntimeException("Event is missing ECal veto hits collection!");
-
- // Put Cluster collection into event.
- int flag = 1 << LCIOConstants.CLBIT_HITS;
- if (vetoHits.isEmpty())
- event.put(clusterCollectionName, createClusters(hits), Cluster.class, flag);
- else
- event.put(clusterCollectionName, new ArrayList<Cluster>(), Cluster.class, flag);
}
-}
\ No newline at end of file
+}
CVSspam 0.2.8