lcsim/src/org/lcsim/recon/cluster/directedtree
diff -u -r1.7 -r1.8
--- DirectedTreeClusterer.java 1 Jul 2006 21:53:53 -0000 1.7
+++ DirectedTreeClusterer.java 6 Jul 2006 00:30:26 -0000 1.8
@@ -17,7 +17,7 @@
private RunControlParameters _rcp = null;
private int _nLyr, _nZ, _nPhi;
private String _distType,_calType;
-
+
public DirectedTreeClusterer(){
_rcp = new RunControlParameters();
_loader = LoadMyCalorimeterHit.getInstance();
@@ -45,6 +45,12 @@
if(trees.size()>0)
recoClusColl = _clusBuilder.makeClusters( trees );
+ // cleanup
+ for(List<CalorimeterHit> hits : trees) {
+ hits.clear();
+ }
+ trees.clear();
+
return recoClusColl;
}
@@ -155,7 +161,7 @@
}
// find hit neighbors
- long neigh[] = segm.getNeighbourIDs(_nLyr, _nZ, _nPhi);
+ long neigh[] = segm.getNeighbourIDs(_nLyr, _nZ, _nPhi);
for(int j=0; j<neigh.length; j++){
long jid = neigh[j];
CalorimeterHit jhit = cahitmap.get(jid);
@@ -189,56 +195,57 @@
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);
- if(_debug>1) {
- System.out.println(" maxdensDiff>0: id="
- +MyTools.printID(cellid)
- +" --> parent is "
- +MyTools.printID(maxdensID)
- +", D="+parDensity );
- }
- }
+ 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");
- }
- }
+ 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
@@ -246,6 +253,8 @@
if(_debug>1) System.out.println("Zero density root");
}
}
+
+ nVec.clear();
}
List<CalorimeterHit> startingPoints = new ArrayList<CalorimeterHit>();
@@ -300,10 +309,10 @@
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>2) {
+ long tmppID = jhit.getCellID();
+ System.out.println("Branch id="+MyTools.printID(tmppID));
+ }
}
}
}
lcsim/src/org/lcsim/recon/cluster/directedtree
diff -u -r1.2 -r1.3
--- DirectedTreeDriver.java 23 Jun 2006 21:19:51 -0000 1.2
+++ DirectedTreeDriver.java 6 Jul 2006 00:30:26 -0000 1.3
@@ -59,6 +59,7 @@
if(_debug>0) {
System.out.println("Start DirectedTreeDriver, event #"+evtnum);
}
+ _loader.setEvent( event );
if( underUserControl() ) {
// Assumes that collection is a hitmap. Failure otherwise.
@@ -92,7 +93,6 @@
event.put( _outputHitMapName, unusedHits );
usedHits.clear();
- unusedHits.clear(); // maybe wrong, as it was added to event
}
// cleanup
lcsim/src/org/lcsim/recon/cluster/directedtree
diff -u -r1.6 -r1.7
--- LoadMyCalorimeterHit.java 23 Jun 2006 20:43:53 -0000 1.6
+++ LoadMyCalorimeterHit.java 6 Jul 2006 00:30:26 -0000 1.7
@@ -35,13 +35,14 @@
public void setEvent(EventHeader event) {
if( event != _event ) {
+ _event = event;
this.reset();
}
}
public void reset() {
- // clear hit maps for each subdetector collection
- _densityMap.clear();
+ // clear hit maps for each subdetector collection
+ _densityMap.clear();
}
/** assign densities to every hit in the hitmap. No energy cut is
@@ -73,12 +74,14 @@
double nNeigh = 1.0; // count hit itself + neighbors (never zero)
segm.setID(cellid);
- long neigh[] = segm.getNeighbourIDs(_nLyr,_nZ,_nPhi);
+ long[] neigh = segm.getNeighbourIDs(_nLyr,_nZ,_nPhi);
for(int j=0; j<neigh.length; ++j) {
long jid = neigh[j];
CalorimeterHit lhit = hitmap.get(jid);
if(lhit!=null) nNeigh++;
+ neigh[j] = 0;
}
+ neigh = null;
_densityMap.put(cellid,nNeigh);
// AIDA.defaultInstance().cloud1D("density (all)").fill(nNeigh);
@@ -128,7 +131,7 @@
private static LoadMyCalorimeterHit _me = null;
/** Current event */
- private EventHeader _event;
+ private EventHeader _event = null;
private static RunControlParameters _runPar;
private double _thresh;
private int _nLyr;