Commit in lcd/hep/lcd/recon/cluster/MIP on MAIN
AbstractHitType.java+1-11.1 -> 1.2
DoubleHit.java+1-11.1 -> 1.2
Flash.java+23-141.1 -> 1.2
HitCollection.java+1-11.1 -> 1.2
MIPCluster.java+20-11.1 -> 1.2
MIPClusterBuilder.java+33-71.1 -> 1.2
MIPClusterList.java+12-11.1 -> 1.2
MIPClusterProcessor.java+24-31.1 -> 1.2
SingleHit.java+1-11.1 -> 1.2
+116-30
9 modified files

First update of the MIP Cluster Builder based on comments received on the first version.

1) The HitCollection 'Flash.java' was updated to use exclusively the towerID of a CalorimeterHit and not the pointer to the hit (required by the MST)
2) In the recursive MIP Clustering algorithm, MIPs that fork (most likely due to elastic scattering) are reconstructed as one MIP. A flag was introduced which can be read by the user to reject these MIPs.
3) An additional flag was introduced in the MIPClusterProcessor to provide the user with the probability to update the MIPClusterList after a second pass. The default was (and still is) that in a second pass a possibly existing list with the same name is replaced. 

lcd/hep/lcd/recon/cluster/MIP
AbstractHitType.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- AbstractHitType.java	25 Jul 2005 17:19:23 -0000	1.1
+++ AbstractHitType.java	1 Aug 2005 23:48:49 -0000	1.2
@@ -1,4 +1,4 @@
-package hep.lcd.recon.cluster.MIP; 
+package MIP; 
 
 import hep.lcd.geometry.CalorimeterCell; 
 import hep.lcd.event.LCDEvent; 

lcd/hep/lcd/recon/cluster/MIP
DoubleHit.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- DoubleHit.java	25 Jul 2005 17:19:23 -0000	1.1
+++ DoubleHit.java	1 Aug 2005 23:48:49 -0000	1.2
@@ -1,4 +1,4 @@
-package hep.lcd.recon.cluster.MIP; 
+package MIP; 
 
 import hep.lcd.event.LCDEvent; 
 import hep.lcd.event.CalorimeterHit; 

lcd/hep/lcd/recon/cluster/MIP
Flash.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- Flash.java	25 Jul 2005 17:19:23 -0000	1.1
+++ Flash.java	1 Aug 2005 23:48:49 -0000	1.2
@@ -1,29 +1,28 @@
-package hep.lcd.recon.cluster.MIP; 
-
-import java.util.List; 
-import java.util.Vector; 
-import java.util.Enumeration; 
-
+package MIP; 
 
+import java.util.*; 
 import hep.lcd.event.CalorimeterHit; 
 
 /**
-   Standalone Implementation of Hit Collection Flash. Designed for use with 
-   LCDG4 Geant files. (Idea taken from SimpleClusterBuilder by Tony)
+   Implementation of Hit Collection Flash. Designed for use with
+   LCDG4 Geant files 
    
    
+   @author Wolfgang F. Mader ([log in to unmask])
+   @version 1.0
+   
    Modification Log:
    -- 07/22/2004 Version 1.0
 */
 
 public class Flash extends HitCollection {
     public Flash(int size) {
-	flashVector = new Vector(); 
+	flashVector = new Hashtable(); 
 	array = new Object[137*size/50];
     }
 
     void put(CalorimeterHit h) {
-	flashVector.add(h);
+	flashVector.put(new Integer(h.getTowerID()),h);
 	
 	int i = hash(h.getTowerID());
 	if (array[i] == null) 
@@ -66,14 +65,16 @@
 	return null;
     }
     void remove(CalorimeterHit h) {
-	flashVector.removeElement(h); 
+	flashVector.remove(new Integer(h.getTowerID())); 
 	
 	int i = hash(h.getTowerID());
 	if (array[i] == h) array[i] = null;
 	else if (array[i] instanceof Vector)
 	    {
 		Vector v = (Vector) array[i];
-		v.removeElement(h);
+		boolean b = v.removeElement(h);
+		if ( !b )
+		    throw new AssertionError("Hit "+h+" not in HitCollection"); 
 	    }
     }
     int getNumberOfHits(){
@@ -84,7 +85,15 @@
 	return flashVector.elements(); 
     }
     Vector getVector(){
-	return flashVector; 
+	Vector v = new Vector(); 
+	Enumeration e = flashVector.elements(); 
+
+	while ( e.hasMoreElements() ) {
+	    CalorimeterHit hit = (CalorimeterHit) 
+		flashVector.get((Object) e.nextElement()); 
+	    v.add(hit); 
+	}
+	return v; 
     }
     
     private int hash(int i){
@@ -93,6 +102,6 @@
     
     
     private Object[] array;
-    private Vector flashVector;
+    private Hashtable flashVector;
     private int numberOfHits;
 }

lcd/hep/lcd/recon/cluster/MIP
HitCollection.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- HitCollection.java	25 Jul 2005 17:19:23 -0000	1.1
+++ HitCollection.java	1 Aug 2005 23:48:49 -0000	1.2
@@ -1,4 +1,4 @@
-package hep.lcd.recon.cluster.MIP; 
+package MIP; 
 
 import java.util.Vector; 
 import java.util.Enumeration; 

lcd/hep/lcd/recon/cluster/MIP
MIPCluster.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- MIPCluster.java	25 Jul 2005 17:19:23 -0000	1.1
+++ MIPCluster.java	1 Aug 2005 23:48:49 -0000	1.2
@@ -1,4 +1,4 @@
-package hep.lcd.recon.cluster.MIP; 
+package MIP; 
 
 import java.io.*; 
 import java.util.*; 
@@ -41,6 +41,9 @@
     }
 
     public double[] getShowerCoordinates(){
+	/**
+	   returns the 3D Coordinates of the last MIP-Hit	   
+	 */
 	CalorimeterHit hit = (CalorimeterHit) hits.lastElement(); 
 	thisCell.setTowerID(hit.getTowerID()); 
 	
@@ -54,6 +57,20 @@
 	return lIsGoodMIP; 
     }
 
+    public boolean doesFork(){
+	/**
+	   Returns <tt>true</tt> or <tt>false</tt> depending on
+	whether the MIP track forks or not  
+	 */
+	return lFork; 
+    }
+    public void doesFork(boolean b){
+	/**
+	   Sets the <tt>Fork</tt> Flag
+	*/
+	lFork = b; 
+    }
+
     private boolean numberOfHitsInSeedLayers(){
 	int[] nHits = new int[nSeedLayers]; 
 	
@@ -95,5 +112,7 @@
     private int firstLayer = 0; 
     private int nSeedLayers = 4; 
     private int direction = +1; 
+
+    private boolean lFork = false; 
 }
 

lcd/hep/lcd/recon/cluster/MIP
MIPClusterBuilder.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- MIPClusterBuilder.java	25 Jul 2005 17:19:23 -0000	1.1
+++ MIPClusterBuilder.java	1 Aug 2005 23:48:49 -0000	1.2
@@ -1,4 +1,4 @@
-package hep.lcd.recon.cluster.MIP; 
+package MIP; 
 
 import java.io.*;
 import java.text.*; 
@@ -106,13 +106,25 @@
 	    MIPCluster cluster = new MIPCluster(thisCell,
 						nSeedLayers,
 						direction); 
+	    iSingleHitsInLayer = new int[50]; 
 
 	    if ( validate(hit) ){
 		cluster.addHit(hit); 
 		flash.remove(hit); 
 		
 		extend(cluster,hit,flash); 
-		if ( cluster.isGoodMIP() ) vCluster.add(cluster); 
+		if ( cluster.isGoodMIP() ) {
+//
+// See if MIP forks. Criteria is two SingeHits in the same Layer
+//
+		    boolean lFork = false; 
+		    for ( int i=0; i<thisCell.getNumEMLayers(); i++ ){
+			if ( iSingleHitsInLayer[i]>=2 ) lFork = true; 
+		    }
+
+		    cluster.doesFork(lFork); 
+		    vCluster.add(cluster); 
+		}
 	    }
 	}
 //
@@ -126,7 +138,9 @@
 		int i=0; 
 		for ( Enumeration e2 = cluster.getHits(); e2.hasMoreElements(); ){
 		    CalorimeterHit hit = (CalorimeterHit) e2.nextElement(); 
-		    System.out.println("  "+i+":"+hit);
+		    thisCell.setTowerID(hit.getTowerID()); 
+		    
+		    System.out.println("  "+i+":"+hit+" "+thisCell.getLayer()+" "+thisCell.getThetaBin()+" "+thisCell.getPhiBin());
 		    i++;
 		}
 	    }
@@ -135,7 +149,9 @@
 	return ((Vector) vCluster); 
     }
 
-    private void extend(MIPCluster c, CalorimeterHit h, HitCollection hc){
+    private void extend(MIPCluster c, 
+			CalorimeterHit h, 
+			HitCollection hc ) {
 	
 	thisCell.setTowerID(h.getTowerID()); 
 	thisCell.setThetaRange(1); 
@@ -145,6 +161,7 @@
 	int[] neighbours = thisCell.getNeighbouringCells(); 
 	Vector vHits = new Vector(); 
 
+	int iNeighboursInNextLayer = 0; 
 	for ( int i=0; i<neighbours.length; i++ ){
 	    CalorimeterHit hit = hc.find(neighbours[i]); 
 
@@ -155,9 +172,10 @@
 		int jLayer = thisCell.getLayer() * direction; 
 
 		if ( jLayer == iLayer+1 ) {
+		    
+		    iNeighboursInNextLayer++; 
+		    if ( validate(hit) ) {
 
-//		    if ( validate(hit) ) vHits.add(hit); 
-		    if ( validate(hit) ){
 			c.addHit(hit); 
 			hc.remove(hit); 
 			extend(c,hit,hc); 
@@ -174,10 +192,17 @@
 	Enumeration e = hitTypes.elements(); 
 	while ( e.hasMoreElements() && !lValidate ){
 	    AbstractHitType aType = (AbstractHitType) e.nextElement(); 
+	    //	    System.out.println("--------------aType"+aType+" "+(aType instanceof SingleHit)); 
+
 	    if ( isInSeedLayer(h) && !aType.useInSeeds() ) continue; 
 	    if ( aType.isValid(h,thisCell,flash) ){
 		lValidate = true; 
 	    }
+	    
+	    if ( lValidate && (aType instanceof SingleHit) ){
+		thisCell.setTowerID(h.getTowerID()); 
+		iSingleHitsInLayer[thisCell.getLayer()]++; 
+	    }
 	}
 	return lValidate; 
     }
@@ -258,11 +283,12 @@
     private int nSeedLayers = 4; 
     private int firstLayer = 0; 
     private int direction = 1; 
+    private int[] iSingleHitsInLayer; 
 
     private Vector vMIP = new Vector();  
     private int depth = 0; 
 
-    private boolean lDebug = true; 
+    private boolean lDebug = false; 
 
     public void setDebugMode(boolean b){
 	lDebug = b; 

lcd/hep/lcd/recon/cluster/MIP
MIPClusterList.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- MIPClusterList.java	25 Jul 2005 17:19:23 -0000	1.1
+++ MIPClusterList.java	1 Aug 2005 23:48:49 -0000	1.2
@@ -1,4 +1,4 @@
-package hep.lcd.recon.cluster.MIP; 
+package MIP; 
 
 import java.io.*; 
 import java.util.*; 
@@ -18,6 +18,17 @@
 	this.vList = vListIn;
     }
     
+    public Vector getVList(){
+	return this.vList; 
+    }
+    public void addVList(Vector v){
+	this.vList.addAll(v); 
+    }
+
+    public void appendList(Vector v){
+	this.vList.addAll(v);
+    }
+
     public int getNClusters() { 
 	return ((int) getNClusters(0)); 
     }

lcd/hep/lcd/recon/cluster/MIP
MIPClusterProcessor.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- MIPClusterProcessor.java	25 Jul 2005 17:19:23 -0000	1.1
+++ MIPClusterProcessor.java	1 Aug 2005 23:48:49 -0000	1.2
@@ -1,4 +1,4 @@
-package hep.lcd.recon.cluster.MIP; 
+package MIP; 
 
 import java.util.*; 
 import java.text.*; 
@@ -54,6 +54,11 @@
     //
     MIPprocessor.setDebugMode(boolean); 
     //
+    // Tell processor to either append (true) or replace (false,
+    // default) any possible existing list with the same name 
+    //
+    MIPprocessor.setAppend(boolean); 
+    //
     // Add the MIPprocessor to the list of processors
     //
     add(MIPprocessor);
@@ -119,8 +124,20 @@
 	if ( lUserNucleii ) clusterBuilder.provideNucleii(nucleii); 
 	clusterBuilder.initialize(); 
 
-	event.put(clusterName, 
-		  new MIPClusterList(clusterBuilder.getMIPClusterList()) );  
+	event.put(clusterName,new MIPClusterList(clusterBuilder.getMIPClusterList())); 
+
+	boolean lKeyExists = false; 
+	Enumeration eKey = (Enumeration) event.keys(); 
+	while ( eKey.hasMoreElements() ){
+	    if ( ((String) eKey.nextElement()).equals(clusterName) ) lKeyExists=true;  
+	}
+	
+	MIPClusterList newList = new MIPClusterList(clusterBuilder.getMIPClusterList()); 
+	if ( lKeyExists && lAppend ){
+	    MIPClusterList existingList = (MIPClusterList) event.get(clusterName); 
+	    newList.addVList(existingList.getVList()); 
+	}
+	event.put(clusterName, newList); 
     }
     
     /**
@@ -158,6 +175,7 @@
     private int direction = 1; 
     private int firstLayer = 0; 
     private boolean lDebug = true; 
+    private boolean lAppend = false; 
     private int nSeedLayers = 4; 
 
     public void setNumberOfSeedLayers(int n){
@@ -191,6 +209,9 @@
     public void setDebugMode(boolean b){
 	lDebug = b; 
     }
+    public void setAppend(boolean b){
+	lAppend = b; 
+    }
 
     private Hashtable hitTypes; 
     public void registerHitTypes(Hashtable hT){

lcd/hep/lcd/recon/cluster/MIP
SingleHit.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- SingleHit.java	25 Jul 2005 17:19:23 -0000	1.1
+++ SingleHit.java	1 Aug 2005 23:48:50 -0000	1.2
@@ -1,4 +1,4 @@
-package hep.lcd.recon.cluster.MIP; 
+package MIP; 
 
 import hep.lcd.geometry.CalorimeterCell; 
 import hep.lcd.event.LCDEvent; 
CVSspam 0.2.8