hps-java/src/main/java/org/lcsim/hps/analysis/ecal
diff -u -r1.4 -r1.5
--- HPSEcalPlotsDriver.java 27 May 2011 20:43:03 -0000 1.4
+++ HPSEcalPlotsDriver.java 18 Jul 2011 21:02:46 -0000 1.5
@@ -27,7 +27,7 @@
* Diagnostic plots for HPS ECal.
*
* @author Jeremy McCormick <[log in to unmask]>
- * @version $Id: HPSEcalPlotsDriver.java,v 1.4 2011/05/27 20:43:03 jeremy Exp $
+ * @version $Id: HPSEcalPlotsDriver.java,v 1.5 2011/07/18 21:02:46 jeremy Exp $
*/
public class HPSEcalPlotsDriver extends Driver
{
@@ -224,10 +224,10 @@
Collections.sort(fsParticles, new MCParticleEComparator());
// Energy of top two FS particles.
- double e2 = fsParticles.get(0).getEnergy() + fsParticles.get(1).getEnergy();
+ //double e2 = fsParticles.get(0).getEnergy() + fsParticles.get(1).getEnergy();
// Energy of top three FS particles.
- double e3 = e2 + fsParticles.get(2).getEnergy();
+ //double e3 = e2 + fsParticles.get(2).getEnergy();
// Check unique IDs.
Set<Long> ids = new HashSet<Long>();
@@ -375,7 +375,7 @@
clusTotEPlot.fill(clusE);
// Residual of cluster total E and E from top 3 primary particles.
- clusResTop3Plot.fill(clusE - e3);
+ //clusResTop3Plot.fill(clusE - e3);
for (Entry<CalorimeterHit, Integer> clusHit : hitClusMap.entrySet())
{
hps-java/src/main/java/org/lcsim/hps/recon/ecal
diff -u -r1.6 -r1.7
--- HPSEcalClusterer.java 27 May 2011 20:43:03 -0000 1.6
+++ HPSEcalClusterer.java 18 Jul 2011 21:02:46 -0000 1.7
@@ -6,12 +6,16 @@
import java.util.Map;
import java.util.Set;
+import org.lcsim.detector.identifier.IIdentifierHelper;
+import org.lcsim.detector.identifier.Identifier;
import org.lcsim.event.CalorimeterHit;
import org.lcsim.event.Cluster;
import org.lcsim.event.EventHeader;
import org.lcsim.geometry.Detector;
import org.lcsim.geometry.IDDecoder;
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;
@@ -19,10 +23,12 @@
/**
* Creates clusters from CalorimeterHits in the HPSEcal detector.
*
- * Clustering algorithm is from pages 83 and 84 of the HPS Proposal.
+ * The clustering algorithm is from pages 83 and 84 of the HPS Proposal.
*
* @author Jeremy McCormick <[log in to unmask]>
- * @version $Id: HPSEcalClusterer.java,v 1.6 2011/05/27 20:43:03 jeremy Exp $
+ * @author Tim Nelson <[log in to unmask]>
+ *
+ * @version $Id: HPSEcalClusterer.java,v 1.7 2011/07/18 21:02:46 jeremy Exp $
*/
public class HPSEcalClusterer extends Driver
{
@@ -41,7 +47,8 @@
// Odd or even number of crystals in X.
boolean oddX;
- Map<Long,Set<Long>> neighborsMap = null;
+ // Map of crystals to their neighbors.
+ NeighborMap neighborMap = null;
public HPSEcalClusterer()
{}
@@ -79,69 +86,89 @@
if (ecalName == null)
throw new RuntimeException("The parameter ecalName was not set!");
- System.out.println(this.getClass().getCanonicalName());
- System.out.println(" seedEMin="+seedEMin);
- System.out.println(" addEMin="+addEMin);
- System.out.println();
+ //System.out.println(this.getClass().getCanonicalName());
+ //System.out.println(" seedEMin="+seedEMin);
+ //System.out.println(" addEMin="+addEMin);
+ //System.out.println();
}
public void detectorChanged(Detector detector)
{
- ecal = (HPSEcal)detector.getSubdetector(ecalName);
+ //System.out.println(this.getClass().getCanonicalName() + " - detectorChanged");
+
+ ecal = (HPSEcal2)detector.getSubdetector(ecalName);
- neighborsMap = ecal.makeNeighborsMap();
+ neighborMap = ecal.makeNeighborMap();
- 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(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("done with neighbors map");
}
public void process(EventHeader event)
- {
+ {
+ //System.out.println(this.getClass().getCanonicalName() + " - process");
+
+ // 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!");
+
+ HPSEcal2 ecal = (HPSEcal2)event.getMetaData(hits).getIDDecoder().getSubdetector();
+ IIdentifierHelper idhelp = ecal.getDetectorElement().getIdentifierHelper();
+ // Get the decoder for the ECal IDs.
IDDecoder dec = ecal.getIDDecoder();
// Hit map.
Map<Long,CalorimeterHit> hitMap = new HashMap<Long,CalorimeterHit>();
- // Make map of x, y, and side to hit.
- for (CalorimeterHit hit : hits)
- {
- dec.setID(hit.getCellID());
- hitMap.put(hit.getCellID(), hit);
- }
-
- // Cluster list to be added to event.
+ // Make a hit map for quick lookup by ID.
+
+ //System.out.println("HPSEcal hits ...");
+ //for (CalorimeterHit hit : hits)
+ //{
+ // TODO: add unpack(long) method to helper
+ // System.out.println(idhelp.unpack(new Identifier(hit.getCellID())));
+ // dec.setID(hit.getCellID());
+ // hitMap.put(hit.getCellID(), hit);
+ //}
+
+ // New Cluster list to be added to event.
List<Cluster> clusters = new ArrayList<Cluster>();
- // Loop over ECal hits.
+ // Loop over ECal hits to find cluster seeds.
for (CalorimeterHit hit : hits)
{
// Cut on min seed E.
if (hit.getRawEnergy() < seedEMin)
continue;
+ //System.out.println("looking up neighbors for: " + idhelp.unpack(hit.getIdentifier()));
+
// Get neighbor crystal IDs.
- Set<Long> neighbors = ecal.getNeighbors(hit.getCellID());
+ Set<Long> neighbors = neighborMap.get(hit.getCellID());
+
+ if (neighbors == null)
+ throw new RuntimeException("Oops! Set of neighbors is null!");
- // Loop over neighbors.
+ // 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)
{
// Find neighbor hit if it exists.
CalorimeterHit neighborHit = hitMap.get(neighborId);
- // Got a hit?
+ // Was this cell hit?
if (neighborHit != null)
{
- // Neighbor is hotter so skip this hit.
+ // Neighbor cell has more energy so this hit is not a seed.
if (neighborHit.getRawEnergy() > hit.getRawEnergy())
{
isSeed = false;
@@ -149,15 +176,17 @@
}
// 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)
{
- // Make cluster.
+ // Make cluster from hit list.
BasicCluster cluster = new BasicCluster();
cluster.addHit(hit);
for (CalorimeterHit clusHit : neighborHits)
@@ -168,7 +197,8 @@
}
}
- int flag = 1 << LCIOConstants.CLBIT_HITS;
+ // Put Cluster collection into event.
+ int flag = 1 << LCIOConstants.CLBIT_HITS;
event.put(clusterCollectionName, clusters, Cluster.class, flag);
}
}