Commit in lcsim/src/org/lcsim/contrib/uiowa on MAIN
MIPReassignmentAlgorithm.java+36-161.2 -> 1.3
fix null point error

lcsim/src/org/lcsim/contrib/uiowa
MIPReassignmentAlgorithm.java 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- MIPReassignmentAlgorithm.java	7 Jul 2008 00:28:06 -0000	1.2
+++ MIPReassignmentAlgorithm.java	8 Jul 2008 17:26:58 -0000	1.3
@@ -46,14 +46,24 @@
     protected double m_angle = 0; 
 	protected double m_degree = 0;
 	protected double m_costheta = 0;
+	protected double m_trans = 0;
 
 	protected ICloud2D m_histo_radian_distance;
 	protected ICloud2D m_histo_degree_distance;
 	protected ICloud2D m_histo_costheta_distance;
-	protected double hcalR=1410.0; //HCAL inner radius for sid01
-	protected double hcalZ=1820.0; //HCAL inner Z for sid01
+	protected ICloud2D m_histo_trans_longi;
+	//sid01
+    protected double ecalRs=1270; //ECAL inner R
+	protected double ecalRe=1410; //ECAL outer R
+    protected double hcalRs=1410; //HCAL inner R
+	protected double hcalRe=2362; //HCAL outer R
+	
+	protected double ecalZs=1680; //ECAL inner Z
+	protected double ecalZe=1820; //ECAL outer Z
+	protected double hcalZs=1820; //HCAL inner Z
+	protected double hcalZe=2772; //HCAL inner Z 
 
-    public MIPReassignmentAlgorithm(double limit, LocalHelixExtrapolator findCluster, Map<Track, Set<Cluster>> newMapTrackToShowerComponents, List<Cluster> mips, Set<CalorimeterHit> allHits, ICloud2D histo1, ICloud2D histo2, ICloud2D histo3 ) {
+    public MIPReassignmentAlgorithm(double limit, LocalHelixExtrapolator findCluster, Map<Track, Set<Cluster>> newMapTrackToShowerComponents, List<Cluster> mips, Set<CalorimeterHit> allHits, ICloud2D histo1, ICloud2D histo2, ICloud2D histo3, ICloud2D histo4) {
 		m_limit = limit;
 		m_findCluster = findCluster;
 		m_newMapTrackToShowerComponents = newMapTrackToShowerComponents;
@@ -62,6 +72,7 @@
 		m_histo_radian_distance = histo1;
 		m_histo_degree_distance = histo2;
 		m_histo_costheta_distance = histo3;
+		m_histo_trans_longi = histo4;
     }
 
 	 
@@ -72,14 +83,9 @@
 		Hep3Vector clusterPosition = new BasicHep3Vector(); //cluster position
 		Hep3Vector displacement = new BasicHep3Vector(); //displacement between cluster and last point
 		Hep3Vector displacementUnit = new BasicHep3Vector();
-	
-		List<Hep3Vector> lastTwoPositions = computePointsOfShower(tr);
-       	Hep3Vector last0pos =  lastTwoPositions.get(0);
-       	Hep3Vector last1pos =  lastTwoPositions.get(1);
-		if(debug) System.out.println("Debug: last0pos= " + last0pos.magnitude() );	
-		if(debug) System.out.println("Debug: last1pos= " + last1pos.magnitude() );	
 		Hep3Vector interceptPoint = m_findCluster.performExtrapolation(tr);		
-	
+		List<Hep3Vector> lastTwoPositions = computePointsOfShower(tr);
+
 		if(lastTwoPositions == null){ //These is no mip close to track.
     		if (interceptPoint != null) {
 	        	tangent = m_findCluster.getTangent(); //tangent obtained using extrapolated track.
@@ -89,6 +95,11 @@
 				displacementUnit = VecOp.unit(displacement);
 			}
 		}else{ //There is a mip attached to track.
+			Hep3Vector last0pos =  lastTwoPositions.get(0);
+			Hep3Vector last1pos =  lastTwoPositions.get(1);
+			if(debug) System.out.println("Debug: last0pos= " + last0pos.magnitude() );
+			if(debug) System.out.println("Debug: last1pos= " + last1pos.magnitude() );
+		
  	      	tangent = VecOp.sub(last0pos, last1pos); //tangent obtained using last two points.
     	    tangentUnit = VecOp.unit(tangent);
         	clusterPosition = new BasicHep3Vector(clus.getPosition());
@@ -104,11 +115,13 @@
 		m_distance=displacement.magnitude()*VecOp.dot(tangentUnit, displacementUnit); //longitudinal distance 
 		m_angle=Math.acos(VecOp.dot(tangentUnit, displacementUnit));
 		m_degree=m_angle*180/3.14;
+		m_trans = displacement.magnitude()*Math.sin(m_angle);
 		m_costheta = VecOp.dot(tangentUnit, displacementUnit);
 		m_histo_radian_distance.fill(m_angle,m_distance);
 		m_histo_degree_distance.fill(m_degree,m_distance);
 		m_histo_costheta_distance.fill(m_costheta,m_distance);
-	
+		m_histo_trans_longi.fill(m_trans, m_distance);
+		
 		if(debug){
 			System.out.println("Debug: Angle= " + m_angle);
 			System.out.println("Debug: Distance= " + m_distance);
@@ -215,7 +228,8 @@
 			double x = id.getPosition()[0];
 			double y = id.getPosition()[1];
 			double z = id.getPosition()[2];
-			double p = Math.sqrt(x*x+y*y+z*z);								
+			double p = Math.sqrt(x*x+y*y+z*z);			
+			double r = Math.sqrt(x*x+y*y);
 			lastlayer = id.getLayer();
 			lastDet = hit.getSubdetector().getName();
 			lastlayer5x5x2 = id.getNeighbourIDs(1, 2, 2);
@@ -233,11 +247,17 @@
                 for (long lastnearID : lastlayer5x5x2 ) nearIDs.add(lastnearID);
 	
 				//use geometric information and layer number to find next hit
-				boolean cond = true;
-				if(lastlayer == 30) cond = hitmag > p && idall.getLayer() == 0; // next layer = 0 since HCAL starts and nearID does not work
-			    else cond = hitmag > p && nearIDs.contains(hitall.getCellID()); //examine in a given area.
+				boolean EcalToHcal= lastlayer == 30 && hitmag > p && idall.getLayer() == 0; 
+			    boolean InSide = hitmag > p && nearIDs.contains(hitall.getCellID()); 
+				boolean EndToBarrelEcal = ((r < ecalRs && r > ecalRs-4) &&  hitmag > p && ((ecalZs < z) || (z < ecalZe)) && (idall.getLayer()==0));   
+				boolean EndToBarrelHcal = ((r < ecalRs && r > ecalRs-4) &&  hitmag > p && ((hcalZs < z) || (z < hcalZe)) && (idall.getLayer()==0));
+				
+		
+				if(debug){
+					if(EndToBarrelEcal || EndToBarrelHcal ) System.out.println("This is a boundary condition");
+				}				
 
-				if(cond){
+				if(EcalToHcal || InSide || EndToBarrelEcal || EndToBarrelHcal){
             			Hep3Vector hitpos = new BasicHep3Vector(xall,yall,zall);
 						Hep3Vector test = VecOp.sub(hitpos, miphit.get(miphit.size()-1));
 						Hep3Vector test_unit = VecOp.unit(test);
CVSspam 0.2.8