Print

Print


Commit in lcsim/src/org/lcsim/recon/cluster/directedtree on MAIN
DirectedTreeClusterer.java+287-2871.10 -> 1.11
JM: indentation

lcsim/src/org/lcsim/recon/cluster/directedtree
DirectedTreeClusterer.java 1.10 -> 1.11
diff -u -r1.10 -r1.11
--- DirectedTreeClusterer.java	22 May 2007 22:42:40 -0000	1.10
+++ DirectedTreeClusterer.java	26 Jun 2008 18:40:41 -0000	1.11
@@ -25,263 +25,263 @@
 
     public DirectedTreeClusterer(){
         _rcp = new RunControlParameters();
-	_loader = LoadMyCalorimeterHit.getInstance();
-	_clusBuilder= new ClusterBuilder(_rcp);
+        _loader = LoadMyCalorimeterHit.getInstance();
+        _clusBuilder= new ClusterBuilder(_rcp);
     }
 
     public DirectedTreeClusterer(RunControlParameters rcp) {
-	_rcp = rcp;
-	_loader = LoadMyCalorimeterHit.getInstance();
-	_clusBuilder= new ClusterBuilder(_rcp);
+        _rcp = rcp;
+        _loader = LoadMyCalorimeterHit.getInstance();
+        _clusBuilder= new ClusterBuilder(_rcp);
     }
 
     public List<Cluster> createClusters(List<CalorimeterHit> hits) {
-	Map<Long,CalorimeterHit> hitmap = new HashMap<Long,CalorimeterHit>();
-	for(CalorimeterHit hit : hits) {
-	    long cellid = hit.getCellID();
+        Map<Long,CalorimeterHit> hitmap = new HashMap<Long,CalorimeterHit>();
+        for(CalorimeterHit hit : hits) {
+            long cellid = hit.getCellID();
             double density = _loader.getDensity( cellid );
-	    if(density>=_minDensity) hitmap.put( cellid, hit );
-	}
+            if(density>=_minDensity) hitmap.put( cellid, hit );
+        }
 
-	List<Cluster> result = doClustering(hitmap);
-	hitmap.clear();
-	return result;
+        List<Cluster> result = doClustering(hitmap);
+        hitmap.clear();
+        return result;
     }
 
     public List<Cluster> createClusters(Map<Long,CalorimeterHit> inputmap) {
-	// rebuild hitmap considering minDensity
-	Map<Long,CalorimeterHit> hitmap = new HashMap<Long,CalorimeterHit>();
-	for(Long cellid : inputmap.keySet()) {
-	    CalorimeterHit hit = inputmap.get(cellid);
+        // rebuild hitmap considering minDensity
+        Map<Long,CalorimeterHit> hitmap = new HashMap<Long,CalorimeterHit>();
+        for(Long cellid : inputmap.keySet()) {
+            CalorimeterHit hit = inputmap.get(cellid);
             double density = _loader.getDensity( cellid );
-	    if(density>=_minDensity) hitmap.put( cellid, hit );
-	}
+            if(density>=_minDensity) hitmap.put( cellid, hit );
+        }
 
-	List<Cluster> result = doClustering(hitmap);
-	hitmap.clear();
-	return result;
+        List<Cluster> result = doClustering(hitmap);
+        hitmap.clear();
+        return result;
     }
 
     public List<Cluster> doClustering(Map<Long,CalorimeterHit> hitmap) {
-	List<List<CalorimeterHit>> trees = makeTree(hitmap);
+        List<List<CalorimeterHit>> trees = makeTree(hitmap);
 
-	List<Cluster> recoClusColl = new ArrayList<Cluster>();
-	if(trees.size()>0)
-	    recoClusColl = _clusBuilder.makeClusters( trees );
-
-	// cleanup
-	for(List<CalorimeterHit> hits : trees) {
-	    hits.clear();
-	}
-	trees.clear();
+        List<Cluster> recoClusColl = new ArrayList<Cluster>();
+        if(trees.size()>0)
+            recoClusColl = _clusBuilder.makeClusters( trees );
+
+        // cleanup
+        for(List<CalorimeterHit> hits : trees) {
+            hits.clear();
+        }
+        trees.clear();
 
-	return recoClusColl;
+        return recoClusColl;
     }
 
     public List<List<CalorimeterHit>> makeTree(Map<Long,CalorimeterHit> cahitmap) {
-	if(_debug>0) {
-	    System.out.println("DTreeClusterer.makeTree(): #hits="+cahitmap.size());
-	}
+        if(_debug>0) {
+            System.out.println("DTreeClusterer.makeTree(): #hits="+cahitmap.size());
+        }
         Map<Long,Long> parentMap = new HashMap<Long,Long>();
         List<CalorimeterHit> rootVec = new ArrayList<CalorimeterHit>();
 
-	// process hits according to raw energy
-	List<CalorimeterHit> sortedHits = new ArrayList<CalorimeterHit>(cahitmap.values());
-	Collections.sort( sortedHits, new CalorimeterHitESort() );
+        // process hits according to raw energy
+        List<CalorimeterHit> sortedHits = new ArrayList<CalorimeterHit>(cahitmap.values());
+        Collections.sort( sortedHits, new CalorimeterHitESort() );
 
         for( CalorimeterHit ihit : sortedHits ) {
             long cellid = ihit.getCellID();
             double idens = _loader.getDensity( cellid );
 
-	    IDDecoder segm = ihit.getIDDecoder();
-	    segm.setID(cellid);
-     	    if(_debug>1) {
-		double mcpE = ((org.lcsim.event.SimCalorimeterHit)ihit).getMCParticle(0).getEnergy();
-		System.out.println("DTree: hit ID="+MyTools.printID(cellid)
-				   +", dens="+idens
-				   +", rawE="+ihit.getRawEnergy()
-				   +", mcpE="+mcpE);
- 	    }
-
-
-	    // Identify calorimeter type for component-specific config
-	    CylindricalCalorimeter cal = (CylindricalCalorimeter)ihit.getSubdetector();
-        // CalorimeterType has been removed.
-        // None of the production compact models
-        // used this feature anyways.  --JM
-	    //CalorimeterType type = cal.getCalorimeterType();
-	    //if( type.isEcal() ) _calType = "EM";
-	    //if( type.isHcal() ) _calType = "HD";
-	    //if( !type.isEcal() && !type.isHcal() ) {
-		// isXcal() is not implemented... use system number for now
-		int sysno = cal.getSystemID();
-		if(sysno==2 || sysno==6) _calType = "EM";
-		else if(sysno==3 || sysno==7) _calType = "HD";
-		else {
-		    assert false : "*** DirectedTreeClusterer: Unexpected sysno="+sysno;
-		//}
-	    }
-// 	    System.out.println("calType="+_calType+", isEcal="+type.isEcal()+", isHcal="+type.isHcal());
-
-	    double maxdensDiff = -999999.;
-	    double parDensity = -1;
-	    long maxdensID = -999999;
+            IDDecoder segm = ihit.getIDDecoder();
+            segm.setID(cellid);
+            if(_debug>1) {
+                double mcpE = ((org.lcsim.event.SimCalorimeterHit)ihit).getMCParticle(0).getEnergy();
+                System.out.println("DTree: hit ID="+MyTools.printID(cellid)
+                        +", dens="+idens
+                        +", rawE="+ihit.getRawEnergy()
+                        +", mcpE="+mcpE);
+            }
+
+
+            // Identify calorimeter type for component-specific config
+            CylindricalCalorimeter cal = (CylindricalCalorimeter)ihit.getSubdetector();
+            // CalorimeterType has been removed.
+            // None of the production compact models
+            // used this feature anyways.  --JM
+            //CalorimeterType type = cal.getCalorimeterType();
+            //if( type.isEcal() ) _calType = "EM";
+            //if( type.isHcal() ) _calType = "HD";
+            //if( !type.isEcal() && !type.isHcal() ) {
+            // isXcal() is not implemented... use system number for now
+            int sysno = cal.getSystemID();
+            if(sysno==2 || sysno==6) _calType = "EM";
+            else if(sysno==3 || sysno==7) _calType = "HD";
+            else {
+                assert false : "*** DirectedTreeClusterer: Unexpected sysno="+sysno;
+            //}
+            }
+//          System.out.println("calType="+_calType+", isEcal="+type.isEcal()+", isHcal="+type.isHcal());
+
+            double maxdensDiff = -999999.;
+            double parDensity = -1;
+            long maxdensID = -999999;
             List<Long> nVec = new ArrayList<Long>();
-	    // changed from !=0
+            // changed from !=0
 
             if(idens>=_rcp.getMinimumDensity() && idens<=_rcp.getMaximumDensity()) {
-	       double[] ipos = ihit.getPosition();
-	       if(_calType=="EM"){
-		 int nLyrOrig = _rcp.getLyrNeighEM();
-		 int nZOrig = _rcp.getZNeighEM();
-		 int nPhiOrig = _rcp.getPhiNeighEM();
-		 int dRegion = emDensityRegion(idens,nLyrOrig,nZOrig,nPhiOrig);
-		 int[] lyrCon = _rcp.getLyrContracEM();
-		 int[] zCon = _rcp.getZContracEM();
-		 int[] phiCon = _rcp.getPhiContracEM();
-//  		 System.out.println("Original Window"+" "+nLyrOrig+" "+nZOrig+" "+nPhiOrig);
-		 if(dRegion==1){
-		     _nLyr = nLyrOrig - lyrCon[0];
-		     _nZ = nZOrig - zCon[0];
-		     _nPhi = nPhiOrig - phiCon[0];
-		 }
-		 if(dRegion==2){
-		     _nLyr = nLyrOrig - lyrCon[1];
-		     _nZ = nZOrig - zCon[1];
-		     _nPhi = nPhiOrig - phiCon[1];
-		 }
-		 if(dRegion==3){
-		     _nLyr = nLyrOrig - lyrCon[2];
-		     _nZ = nZOrig - zCon[2];
-		     _nPhi = nPhiOrig - phiCon[2];
-		 }
-	       }
-	       if(_calType=="HD"){
-		 int nLyrOrig = _rcp.getLyrNeighHD();
-		 int nZOrig = _rcp.getZNeighHD();
-		 int nPhiOrig = _rcp.getPhiNeighHD();
-		 int dRegion = hdDensityRegion(idens,nLyrOrig,nZOrig,nPhiOrig);
-		 int[] lyrCon = _rcp.getLyrContracHD();
-		 int[] zCon = _rcp.getZContracHD();
-		 int[] phiCon = _rcp.getPhiContracHD();
-//  		 System.out.println("Original Window"+" "+nLyrOrig+" "+nZOrig+" "+nPhiOrig);
-		 if(dRegion==0){
-		     _nLyr = nLyrOrig;
-		     _nZ = nZOrig;
-		     _nPhi = nPhiOrig;
-		 }
-		 if(dRegion==1){
-		     _nLyr = nLyrOrig - lyrCon[0];
-		     _nZ = nZOrig - zCon[0];
-		     _nPhi = nPhiOrig - phiCon[0];
-		 }
-		 if(dRegion==2){
-		     _nLyr = nLyrOrig - lyrCon[1];
-		     _nZ = nZOrig - zCon[1];
-		     _nPhi = nPhiOrig - phiCon[1];
-		 }
-		 if(dRegion==3){
-		     _nLyr = nLyrOrig - lyrCon[2];
-		     _nZ = nZOrig - zCon[2];
-		     _nPhi = nPhiOrig - phiCon[2];
-		 }
-	       }
-
-	       // find hit neighbors
-               long neigh[] = segm.getNeighbourIDs(_nLyr, _nZ, _nPhi);
-	       for(int j=0; j<neigh.length; j++){
-		 long jid = neigh[j];
-		 CalorimeterHit jhit = cahitmap.get(jid);
-		 if(jhit==null) continue;
-		 double jdens = _loader.getDensity(jhit);
-		 double[] jpos = jhit.getPosition();
-
-		 _distType = _rcp.getDistanceType();
-		 CalculateDistance calcD = new CalculateDistance();
-		 double distance = calcD.CalculateDistance(_distType,ipos,jpos);
-		 double densDiff = (jdens-idens)/distance;
-
-		 if(densDiff==0.0) nVec.add(jid);
-  		 if(_debug>2) {
-		     System.out.println(" jhit: cellID="+MyTools.printID(jid)
-					+", idens="+idens
-					+", jdens="+jdens
-					+", dist="+distance
-					+", densDiff="+densDiff);
-  		 }
-		 if(densDiff>maxdensDiff){
-		     maxdensDiff = densDiff;
-		     maxdensID = jid;
-		     parDensity = jdens;
-		 }
-		 calcD = null;
-	       }
-
-	       if(maxdensDiff<0.0){
-		   rootVec.add(ihit);
-		   if(_debug>1) System.out.println("Bonafide root");
-	       }
-
-		if(maxdensDiff>0.0){
-// 		   Long key1 = new Long(cellid);
-// 		   Long key2 = new Long(maxdensID);
-// 		   parentMap.put(key1,key2);
-		    parentMap.put(cellid,maxdensID);
-		    if(_debug>1) {
-			System.out.println(" maxdensDiff>0: id="
-					   +MyTools.printID(cellid)
-					   +" --> parent is "
-					   +MyTools.printID(maxdensID)
-					   +", D="+parDensity );
-		    }
-		}
-
-		if(maxdensDiff==0.0){
-		    List<Long> removeItems = new ArrayList<Long>();
-		    for(Long jkey : nVec) {
-			List<Long> temporary = new ArrayList<Long>();
-			Long parent = parentMap.get(jkey);
-
-			while(parent!=null){
-			    temporary.add(parent);
-			    Long lkey = parent;
-			    parent = parentMap.get(lkey);
-			}
-			if(temporary.contains(cellid)){
-			    removeItems.add(jkey);
-			}
-		    }
-		    nVec.removeAll(removeItems);
-
-		    if(nVec.size()==0){
-			rootVec.add(ihit);
-		    }
-		    else{
-		      double dmin = 9999.;
-		      long parentKey = 0;
-		      for(Long jkey : nVec) {
-			CalorimeterHit jhit = cahitmap.get(jkey);
-			double[] jpos = jhit.getPosition();
-			CalculateDistance calcD = new CalculateDistance();
-			double distance = calcD.CalculateDistance(_distType,ipos,jpos);
-			if(distance<dmin){
-			    dmin = distance;
-			    parentKey = jkey;
-			}
-		      }
-		      parentMap.put(cellid,parentKey);
-		      if(_debug>1) System.out.println("Cell is matched to identical density neighbor");
-		    }
-		}
-	    }
-	    else{
-		if(_rcp.getMinimumDensity()==1 && _rcp.getMaximumDensity()==100000) {  // default values
-		    rootVec.add(ihit);
-		    if(_debug>1) System.out.println("Zero density root");
-		}
-	    }
+                double[] ipos = ihit.getPosition();
+                if(_calType=="EM"){
+                    int nLyrOrig = _rcp.getLyrNeighEM();
+                    int nZOrig = _rcp.getZNeighEM();
+                    int nPhiOrig = _rcp.getPhiNeighEM();
+                    int dRegion = emDensityRegion(idens,nLyrOrig,nZOrig,nPhiOrig);
+                    int[] lyrCon = _rcp.getLyrContracEM();
+                    int[] zCon = _rcp.getZContracEM();
+                    int[] phiCon = _rcp.getPhiContracEM();
+//                  System.out.println("Original Window"+" "+nLyrOrig+" "+nZOrig+" "+nPhiOrig);
+                    if(dRegion==1){
+                        _nLyr = nLyrOrig - lyrCon[0];
+                        _nZ = nZOrig - zCon[0];
+                        _nPhi = nPhiOrig - phiCon[0];
+                    }
+                    if(dRegion==2){
+                        _nLyr = nLyrOrig - lyrCon[1];
+                        _nZ = nZOrig - zCon[1];
+                        _nPhi = nPhiOrig - phiCon[1];
+                    }
+                    if(dRegion==3){
+                        _nLyr = nLyrOrig - lyrCon[2];
+                        _nZ = nZOrig - zCon[2];
+                        _nPhi = nPhiOrig - phiCon[2];
+                    }
+                }
+                if(_calType=="HD"){
+                    int nLyrOrig = _rcp.getLyrNeighHD();
+                    int nZOrig = _rcp.getZNeighHD();
+                    int nPhiOrig = _rcp.getPhiNeighHD();
+                    int dRegion = hdDensityRegion(idens,nLyrOrig,nZOrig,nPhiOrig);
+                    int[] lyrCon = _rcp.getLyrContracHD();
+                    int[] zCon = _rcp.getZContracHD();
+                    int[] phiCon = _rcp.getPhiContracHD();
+//                  System.out.println("Original Window"+" "+nLyrOrig+" "+nZOrig+" "+nPhiOrig);
+                    if(dRegion==0){
+                        _nLyr = nLyrOrig;
+                        _nZ = nZOrig;
+                        _nPhi = nPhiOrig;
+                    }
+                    if(dRegion==1){
+                        _nLyr = nLyrOrig - lyrCon[0];
+                        _nZ = nZOrig - zCon[0];
+                        _nPhi = nPhiOrig - phiCon[0];
+                    }
+                    if(dRegion==2){
+                        _nLyr = nLyrOrig - lyrCon[1];
+                        _nZ = nZOrig - zCon[1];
+                        _nPhi = nPhiOrig - phiCon[1];
+                    }
+                    if(dRegion==3){
+                        _nLyr = nLyrOrig - lyrCon[2];
+                        _nZ = nZOrig - zCon[2];
+                        _nPhi = nPhiOrig - phiCon[2];
+                    }
+                }
+
+                // find hit neighbors
+                long neigh[] = segm.getNeighbourIDs(_nLyr, _nZ, _nPhi);
+                for(int j=0; j<neigh.length; j++){
+                    long jid = neigh[j];
+                    CalorimeterHit jhit = cahitmap.get(jid);
+                    if(jhit==null) continue;
+                    double jdens = _loader.getDensity(jhit);
+                    double[] jpos = jhit.getPosition();
+
+                    _distType = _rcp.getDistanceType();
+                    CalculateDistance calcD = new CalculateDistance();
+                    double distance = calcD.CalculateDistance(_distType,ipos,jpos);
+                    double densDiff = (jdens-idens)/distance;
+
+                    if(densDiff==0.0) nVec.add(jid);
+                    if(_debug>2) {
+                        System.out.println(" jhit: cellID="+MyTools.printID(jid)
+                                +", idens="+idens
+                                +", jdens="+jdens
+                                +", dist="+distance
+                                +", densDiff="+densDiff);
+                    }
+                    if(densDiff>maxdensDiff){
+                        maxdensDiff = densDiff;
+                        maxdensID = jid;
+                        parDensity = jdens;
+                    }
+                    calcD = null;
+                }
+
+                if(maxdensDiff<0.0){
+                    rootVec.add(ihit);
+                    if(_debug>1) System.out.println("Bonafide root");
+                }
+
+                if(maxdensDiff>0.0){
+//                  Long key1 = new Long(cellid);
+//                  Long key2 = new Long(maxdensID);
+//                  parentMap.put(key1,key2);
+                    parentMap.put(cellid,maxdensID);
+                    if(_debug>1) {
+                        System.out.println(" maxdensDiff>0: id="
+                                +MyTools.printID(cellid)
+                                +" --> parent is "
+                                +MyTools.printID(maxdensID)
+                                +", D="+parDensity );
+                    }
+                }
+
+                if(maxdensDiff==0.0){
+                    List<Long> removeItems = new ArrayList<Long>();
+                    for(Long jkey : nVec) {
+                        List<Long> temporary = new ArrayList<Long>();
+                        Long parent = parentMap.get(jkey);
+
+                        while(parent!=null){
+                            temporary.add(parent);
+                            Long lkey = parent;
+                            parent = parentMap.get(lkey);
+                        }
+                        if(temporary.contains(cellid)){
+                            removeItems.add(jkey);
+                        }
+                    }
+                    nVec.removeAll(removeItems);
+
+                    if(nVec.size()==0){
+                        rootVec.add(ihit);
+                    }
+                    else{
+                        double dmin = 9999.;
+                        long parentKey = 0;
+                        for(Long jkey : nVec) {
+                            CalorimeterHit jhit = cahitmap.get(jkey);
+                            double[] jpos = jhit.getPosition();
+                            CalculateDistance calcD = new CalculateDistance();
+                            double distance = calcD.CalculateDistance(_distType,ipos,jpos);
+                            if(distance<dmin){
+                                dmin = distance;
+                                parentKey = jkey;
+                            }
+                        }
+                        parentMap.put(cellid,parentKey);
+                        if(_debug>1) System.out.println("Cell is matched to identical density neighbor");
+                    }
+                }
+            }
+            else{
+                if(_rcp.getMinimumDensity()==1 && _rcp.getMaximumDensity()==100000) {  // default values
+                    rootVec.add(ihit);
+                    if(_debug>1) System.out.println("Zero density root");
+                }
+            }
 
-	    nVec.clear();
+            nVec.clear();
         }
 
         List<CalorimeterHit> startingPoints = new ArrayList<CalorimeterHit>();
@@ -293,11 +293,11 @@
                 startingPoints.add(ihit);
             }
         }
-	if(_debug>1) {
-	    System.out.println("# starting points = "+startingPoints.size()
-			       +", pars="+parentMap.size()
-			       +", roots="+rootVec.size());
-	}
+        if(_debug>1) {
+            System.out.println("# starting points = "+startingPoints.size()
+                    +", pars="+parentMap.size()
+                    +", roots="+rootVec.size());
+        }
 
         List<List<CalorimeterHit>> branches = new ArrayList<List<CalorimeterHit>>();
         for(int i=0;i<startingPoints.size();i++) {
@@ -307,93 +307,93 @@
             CalorimeterHit ihit = startingPoints.get(i);
             branches.get(i).add(ihit);
             long cellid = ihit.getCellID();
-	    if(_debug>1)
-		System.out.println("Starting point #"+i+": "+MyTools.printID(cellid));
-	    Long key = new Long(cellid);
+            if(_debug>1)
+                System.out.println("Starting point #"+i+": "+MyTools.printID(cellid));
+            Long key = new Long(cellid);
             while(parentMap.containsKey(cellid)){
-		Long jkey = parentMap.get(cellid);
-		CalorimeterHit jhit = cahitmap.get(jkey);
+                Long jkey = parentMap.get(cellid);
+                CalorimeterHit jhit = cahitmap.get(jkey);
                 branches.get(i).add(jhit);
                 cellid = jkey.longValue();
             }
         }
 
-	int nTrivial = 0;
+        int nTrivial = 0;
         int vsiz = rootVec.size();
-	if(_debug>0) System.out.println("no. of roots = "+vsiz);
+        if(_debug>0) System.out.println("no. of roots = "+vsiz);
         List<List<CalorimeterHit>> caTrees = new ArrayList<List<CalorimeterHit>>();
         for(int i=0;i<vsiz;i++) {
             caTrees.add( new ArrayList<CalorimeterHit>() );
         }
 
         for(int i=0;i<vsiz;i++) {
-          CalorimeterHit ihit = rootVec.get(i);
-	  caTrees.get(i).add(ihit);
-	  for(int j=0;j<startingPoints.size();j++) {
-	    List<CalorimeterHit> jbranch = branches.get(j);
-            CalorimeterHit parentHit = jbranch.get( jbranch.size()-1 );
-	    if(parentHit.equals(ihit)) {
-	      for( CalorimeterHit jhit : jbranch ) {
-		if(!caTrees.get(i).contains(jhit)) {
-		  caTrees.get(i).add(jhit);
-		  if(_debug>2) {
-		      long tmppID = jhit.getCellID();
-		      System.out.println("Branch id="+MyTools.printID(tmppID));
-		  }
-		}
-	      }
-	    }
-	  }
-	  if(_debug>0) {
-	      if(caTrees.get(i).size()>0) {
-		  long tmpID = ihit.getCellID();
-		  System.out.println("ROOT id="+MyTools.printID(tmpID)
-				     +", #hits="+caTrees.get(i).size());
-	      }
-// 	      else 	      ++nTrivial;  // for single-hit clusters
-	  }
-        }
-	if(_debug>0) {
-	  System.out.println("*** plus "+nTrivial+" single-hit clusters.");
-	}
-
-// 	for( List<MyCalorimeterHit> rootHits : caTrees ) {
-// 	    System.out.println("ROOT: #hits="+rootHits.size());
-// 	}
-
-	// cleanup
-	parentMap.clear();
-	rootVec.clear();
+            CalorimeterHit ihit = rootVec.get(i);
+            caTrees.get(i).add(ihit);
+            for(int j=0;j<startingPoints.size();j++) {
+                List<CalorimeterHit> jbranch = branches.get(j);
+                CalorimeterHit parentHit = jbranch.get( jbranch.size()-1 );
+                if(parentHit.equals(ihit)) {
+                    for( CalorimeterHit jhit : jbranch ) {
+                        if(!caTrees.get(i).contains(jhit)) {
+                            caTrees.get(i).add(jhit);
+                            if(_debug>2) {
+                                long tmppID = jhit.getCellID();
+                                System.out.println("Branch id="+MyTools.printID(tmppID));
+                            }
+                        }
+                    }
+                }
+            }
+            if(_debug>0) {
+                if(caTrees.get(i).size()>0) {
+                    long tmpID = ihit.getCellID();
+                    System.out.println("ROOT id="+MyTools.printID(tmpID)
+                            +", #hits="+caTrees.get(i).size());
+                }
+//              else 	      ++nTrivial;  // for single-hit clusters
+            }
+        }
+        if(_debug>0) {
+            System.out.println("*** plus "+nTrivial+" single-hit clusters.");
+        }
+
+//      for( List<MyCalorimeterHit> rootHits : caTrees ) {
+//      System.out.println("ROOT: #hits="+rootHits.size());
+//      }
+
+        // cleanup
+        parentMap.clear();
+        rootVec.clear();
         return caTrees;
     }
 
     public int emDensityRegion(double dens,int nl,int nz,int np){
-	int region = 0;
-	//	if(nl==6 && nz==3 && np==3){
-	if(dens<6.) region=1;
-	if(dens>=6. && dens<26.) region=2;
-	if(dens>=26.) region=3;
-	//	}
-	return region;
+        int region = 0;
+        //	if(nl==6 && nz==3 && np==3){
+        if(dens<6.) region=1;
+        if(dens>=6. && dens<26.) region=2;
+        if(dens>=26.) region=3;
+        //	}
+        return region;
     }
 
     public int hdDensityRegion(double dens,int nl,int nz,int np){
-	int region = 0;
-	if(dens<=6.) region=1;
-	if(dens>=6. && dens<26.) region=2;
-	if(dens>=26.) region=3;
-	return region;
+        int region = 0;
+        if(dens<=6.) region=1;
+        if(dens>=6. && dens<26.) region=2;
+        if(dens>=26.) region=3;
+        return region;
     }
 
     /** Set minimum number of hits required for clusters
      */
     public void setMinimumSize(int minsize) {
-	_clusBuilder.setMinimumSize(minsize);
+        _clusBuilder.setMinimumSize(minsize);
     }
 
     /** Set minimum hit density for hits to be used for clustering
      */
     public void setMinimumHitDensity(int mindens) {
-	_minDensity = mindens;
+        _minDensity = mindens;
     }
 }
CVSspam 0.2.8