Commit in lcsim/src/org/lcsim/recon/cluster/density on MAIN
LoadMyCalorimeterHit.java+65-591.4 -> 1.5
GL: Now extends from org.lcsim.recon.cluster.util.CalHitMapMgr

lcsim/src/org/lcsim/recon/cluster/density
LoadMyCalorimeterHit.java 1.4 -> 1.5
diff -u -r1.4 -r1.5
--- LoadMyCalorimeterHit.java	7 Dec 2005 18:57:18 -0000	1.4
+++ LoadMyCalorimeterHit.java	12 Dec 2005 05:25:18 -0000	1.5
@@ -7,79 +7,83 @@
 import org.lcsim.util.aida.AIDA;
 import org.lcsim.util.Driver;
 import org.lcsim.event.EventHeader;
-import org.lcsim.event.SimCalorimeterHit;
+import org.lcsim.event.CalorimeterHit;
 import org.lcsim.event.CalorimeterHit;
 import org.lcsim.geometry.segmentation.SegmentationBase;
 import org.lcsim.geometry.compact.Readout;
 import org.lcsim.geometry.Subdetector;
+import org.lcsim.recon.cluster.util.CalHitMapMgr;
+import org.lcsim.geometry.IDDecoder;
 
-public class LoadMyCalorimeterHit {
+public class LoadMyCalorimeterHit extends CalHitMapMgr {
 
-    public static LoadMyCalorimeterHit getInstance(){
-        if(_me==null) {
-            _me = new LoadMyCalorimeterHit();
-        }
-        return _me;
+    public static LoadMyCalorimeterHit getInstance() {
+ 	if(_me==null) {
+ 	    new LoadMyCalorimeterHit();
+	    System.out.println("Constructing a LoadMyCalorimeterHit object at "+_me);
+ 	}
+	assert _me != null : "Problem constructing LoadMyCalorimeterHit.";
+ 	return _me;
     }
 
     private LoadMyCalorimeterHit() {
-        if(_me==null) _me=this;
-	_collMap = new HashMap<String,Map<Long,CalorimeterHit>>();
+	super();
+	if(_me==null) _me=this;
+// 	_collMap = new HashMap<String,Map<Long,CalorimeterHit>>();
 	_densityMap = new HashMap<Long,Double>();
-	_subdet2collMap = new HashMap<Subdetector,Map<Long,CalorimeterHit>>();
+// 	_subdet2collMap = new HashMap<Subdetector,Map<Long,CalorimeterHit>>();
         _runPar = RunControlParameters.getInstance();
     }
 
-    public void process(EventHeader event){
+    public void setEvent(EventHeader event) {
+	super.setEvent(event);
 	if( event != _event ) {
 	    this.reset();
-	    _segmMap = event.getDetector().getReadouts();
-	    _event = event;
+// 	    _segmMap = event.getDetector().getReadouts();
+// 	    _event = event;
 	}
     }
 
     public void reset(){
       // clear hit maps for each subdetector collection
-      for( Map<Long,CalorimeterHit> aHitMap : _collMap.values() ) {
-	aHitMap.clear();
-      }
-      _collMap.clear();
-      _subdet2collMap.clear();
+      System.out.println("LoadMyCalorimeter.reset() called");
+//       _subdet2collMap.clear();
       _densityMap.clear();
-      _segmMap = null;
+//       _segmMap = null;
     }
 
 
-    /**
-     * Returns a hit map, with all hits contained in a given collection.
-     * @param colName name of collection with data to be returned
-     */
-    public final Map<Long,CalorimeterHit> getCollHitMap(final String colName) {
-	Map<Long,CalorimeterHit> retColl = _collMap.get( colName );
-	if(retColl==null) {
-	  // if it does not exist, create it now
-	  retColl = new HashMap<Long,CalorimeterHit>();
-	  _collMap.put(colName, retColl);
-	}
-	assert retColl!=null :
-	    "getCollHitMap: Could not create a new hitmap collection";
-
-	if( retColl.size()==0 ) fillHitMap( colName, retColl );
-	return retColl;
-    }
+//     /**
+//      * Returns a hit map, with all hits contained in a given collection.
+//      * @param colName name of collection with data to be returned
+//      */
+//     public final Map<Long,CalorimeterHit> getCollHitMap(final String colName) {
+// 	Map<Long,CalorimeterHit> retColl = _collMap.get( colName );
+// 	if(retColl==null) {
+// 	  // if it does not exist, create it now
+// 	  retColl = new HashMap<Long,CalorimeterHit>();
+// 	  _collMap.put(colName, retColl);
+// 	}
+// 	assert retColl!=null :
+// 	    "getCollHitMap: Could not create a new hitmap collection";
 
-    /**
-     * Returns a CellID decoder
-     * @param colName name of collection with data to be returned
-     */
-    public final SegmentationBase getSegmentation(final String colName) {
-	return (SegmentationBase)_segmMap.get(colName).getSegmentation();
-    }
+// 	if( retColl.size()==0 ) fillHitMap( colName, retColl );
+// 	return retColl;
+//     }
+
+//     /**
+//      * Returns a CellID decoder
+//      * @param colName name of collection with data to be returned
+//      */
+//     public final SegmentationBase getSegmentation(final String colName) {
+// 	return (SegmentationBase)_segmMap.get(colName).getSegmentation();
+//     }
 
 
     public void fillHitMap(final String colName,
 			   Map<Long,CalorimeterHit> hitmap )
     {
+	System.out.println("Using Loader to fill hitmaps");
       if( colName.contains("Ecal") ) {
 	_weight = _runPar.getEMweight();
 	_mip = _runPar.getEMmip();
@@ -101,9 +105,9 @@
       }
 
       // Get hit collection, if it exist
-      List<SimCalorimeterHit> tmpHits = null;
+      List<CalorimeterHit> tmpHits = null;
       try {
-	tmpHits = _event.getSimCalorimeterHits(colName);
+	tmpHits = _event.get(CalorimeterHit.class, colName);
       }
       catch(Exception e) {
 	// This happens quite frequently, no data from this component
@@ -113,13 +117,14 @@
       if(tmpHits==null) return;
 
       // Fill a hit map from this collection
-      // fill also a subdetector -> hit collection map
-      Subdetector det = null;
-      for( SimCalorimeterHit ihit : tmpHits ) {
-	// Make sure all hits come from same subdetector
-	if(det==null) det=ihit.getSubdetector();
-	else assert det == ihit.getSubdetector()
-		 : "LoadCalorimeterHit: multiple subdets in a collection";
+//       // fill also a subdetector -> hit collection map
+//       Subdetector det = null;
+      System.out.println("LoadMyCalHits: applying energy threshold");
+      for( CalorimeterHit ihit : tmpHits ) {
+// 	// Make sure all hits come from same subdetector
+// 	if(det==null) det=ihit.getSubdetector();
+// 	else assert det == ihit.getSubdetector()
+// 		 : "LoadCalorimeterHit: multiple subdets in a collection";
 
 	double ene = _weight*(ihit.getRawEnergy());
 	// apply energy cut
@@ -131,15 +136,16 @@
 // 	    System.out.println("LoadMyCalhit: rejected hit="+ihit+", id="+MyTools.printID(ihit.getCellID()));
 // 	}
       }
-      // fill map keying hitmap by Subdetector
-      if(det!=null) _subdet2collMap.put( det, hitmap );
+//       // fill map keying hitmap by Subdetector
+//       if(det!=null) _subdet2collMap.put( det, hitmap );
 
       // assign densities to every hit in *new* hitmap,
       // thus density=0 for hits failing energy cut
       for( CalorimeterHit khit : hitmap.values() ) {
 	long cellid = khit.getCellID();
 
-	SegmentationBase segm = (SegmentationBase)_segmMap.get(colName).getSegmentation();
+	IDDecoder decoder = khit.getSubdetector().getIDDecoder();
+	SegmentationBase segm = (SegmentationBase)decoder;	  
 	segm.setID(cellid);
 
 	long neigh[] = segm.getNeighbourIDs(_nLyr,_nZ,_nPhi);
@@ -176,7 +182,7 @@
 
     private static LoadMyCalorimeterHit _me = null;
     /** Current event */
-    private EventHeader _event;
+//     private EventHeader _event;
     private static RunControlParameters _runPar;
     private double _weight;
     private double _mip;
@@ -184,8 +190,8 @@
     private int _nLyr;
     private int _nZ;
     private int _nPhi;
-    private Map<String,Map<Long,CalorimeterHit>> _collMap;
-    private Map<String,Readout> _segmMap;
-    private Map<Subdetector,Map<Long,CalorimeterHit>> _subdet2collMap;
+//     private Map<String,Map<Long,CalorimeterHit>> _collMap;
+//     private Map<String,Readout> _segmMap;
+//     private Map<Subdetector,Map<Long,CalorimeterHit>> _subdet2collMap;
     private Map<Long,Double> _densityMap;
 }
CVSspam 0.2.8