lcsim/src/org/lcsim/recon/ganging
diff -u -r1.1 -r1.2
--- GangCalorimeterHits.java 20 Oct 2006 11:58:16 -0000 1.1
+++ GangCalorimeterHits.java 20 Oct 2006 20:53:18 -0000 1.2
@@ -20,7 +20,7 @@
public List<CalorimeterHit> GangCollection(EventHeader event,String coll,int ngang)
{
// Create empty output list
- List<CalorimeterHit>newList = new ArrayList<CalorimeterHit>();
+ Map<Long,CalorimeterHit>newMap = new HashMap<Long,CalorimeterHit>();
// Get a list of CalorimeterHit lists from event
List<List<CalorimeterHit>> clists = event.get(CalorimeterHit.class);
// Loop over list of lists
@@ -40,27 +40,21 @@
// Create a new ganged hit from this hit
GangedSimCalorimeterHit gh =
new GangedSimCalorimeterHit((SimCalorimeterHit) h,ngang);
+ Long lid = new Long(gh.getCellID());
// Find out if we've already created a hit with this ID
- boolean gotit = false;
- for(CalorimeterHit nh:newList)
+ if(newMap.containsKey(lid))
{
- if(nh.getCellID() == gh.getCellID())
- {
-// Found the same ID, so combine the hits
- gotit = true;
- ((GangedSimCalorimeterHit)nh).addHit(gh);
- }
+ ( (GangedSimCalorimeterHit)newMap.get(lid)).addHit(gh);
}
-// If no hit found with this ID, add the hit to the output list
- if(!gotit)
+ else
{
- newList.add(gh);
+ newMap.put(lid, gh);
}
}
}
}
// Return the new list of ganged hits
- return newList;
+ return new ArrayList(newMap.values());
}
lcsim/src/org/lcsim/recon/ganging
diff -u -r1.1 -r1.2
--- GangedCalorimeterIDDecoder.java 20 Oct 2006 11:58:16 -0000 1.1
+++ GangedCalorimeterIDDecoder.java 20 Oct 2006 20:53:18 -0000 1.2
@@ -26,8 +26,8 @@
long id;
// For now, assume we know the relevant field names from the Barrel/Endcap flag
String[] fields;
- String[] BarFields = {"phi","z"};
- String[] ECFields = {"x","y"};
+ static String[] BarFields = {"phi","z"};
+ static String[] ECFields = {"x","y"};
//
/** Creates a new instance of GangedCalorimeterIDDecoder */
public GangedCalorimeterIDDecoder(IDDecoder old, int gang)
lcsim/src/org/lcsim/recon/ganging
diff -u -r1.1 -r1.2
--- GangedSimCalorimeterHit.java 20 Oct 2006 11:58:16 -0000 1.1
+++ GangedSimCalorimeterHit.java 20 Oct 2006 20:53:18 -0000 1.2
@@ -57,8 +57,7 @@
}
decoder = new GangedCalorimeterIDDecoder(h.getIDDecoder(),gang);
cellID = ((GangedCalorimeterIDDecoder)decoder).gangedCellID(h.getCellID());
- decoder.setID(cellID);
- pos = decoder.getPosition();
+ pos = null;
}
public void addHit(SimCalorimeterHit h)
{
@@ -140,6 +139,13 @@
public double getTime()
{return time;}
public double[] getPosition()
- {return pos;}
+ {
+ if(pos == null)
+ {
+ decoder.setID(cellID);
+ pos = decoder.getPosition();
+ }
+ return pos;
+ }
}