Print

Print


Author: [log in to unmask]
Date: Fri Nov 14 13:06:01 2014
New Revision: 1527

Log:
merge ReconParticleDriverIC changes into ReconParticleDriver

Removed:
    java/trunk/recon/src/main/java/org/hps/recon/particle/HpsReconParticleDriverIC.java
    java/trunk/recon/src/main/java/org/hps/recon/particle/ReconParticleDriverIC.java
Modified:
    java/trunk/ecal-recon/src/main/java/org/hps/recon/ecal/HPSEcalClusterIC.java
    java/trunk/recon/src/main/java/org/hps/recon/particle/ReconParticleDriver.java
    java/trunk/steering-files/src/main/resources/org/hps/steering/recon/HPS2014OfflineNoPileupRecon.lcsim
    java/trunk/steering-files/src/main/resources/org/hps/steering/recon/HPS2014OfflineRecon.lcsim
    java/trunk/steering-files/src/main/resources/org/hps/steering/recon/HPS2014OfflineTruthRecon.lcsim

Modified: java/trunk/ecal-recon/src/main/java/org/hps/recon/ecal/HPSEcalClusterIC.java
 =============================================================================
--- java/trunk/ecal-recon/src/main/java/org/hps/recon/ecal/HPSEcalClusterIC.java	(original)
+++ java/trunk/ecal-recon/src/main/java/org/hps/recon/ecal/HPSEcalClusterIC.java	Fri Nov 14 13:06:01 2014
@@ -21,14 +21,7 @@
     private ArrayList<CalorimeterHit> sharedHitList = new ArrayList<CalorimeterHit>(); 
     private double[] rawPosition = new double[3];
 
-    
-    
-    static final double eCriticalW = 800.0*ECalUtils.MeV/(74+1);
-    static final double radLenW = 8.8; //mm
-    double[] electronPosAtDepth = new double[3];
-    private boolean needsElectronPosCalculation = true;
-    double[] photonPosAtDepth = new double[3];
-    private boolean needsPhotonPosCalculation = true;
+    private int particleID = 0;
     
  // Variables for electron energy corrections
     static final double ELECTRON_ENERGY_A = -0.0027;
@@ -132,21 +125,19 @@
      * @param rawEnergy Raw Energy of the cluster (sum of hits with shared hit distribution)
      * @return Corrected Energy
      */    
-    public double enCorrection(int pdg, double rawEnergy){
-  	   if (pdg == 11) { // Particle is electron  		   
-  		   return energyCorrection(rawEnergy, ELECTRON_ENERGY_A, ELECTRON_ENERGY_B, ELECTRON_ENERGY_C);   
-  	   }
-  	   else if (pdg == -11) { //Particle is positron
-		   return energyCorrection(rawEnergy, POSITRON_ENERGY_A, POSITRON_ENERGY_B, POSITRON_ENERGY_C);   
-  	   }
-  	   else if (pdg == 22) { //Particle is photon
-		   return energyCorrection(rawEnergy, PHOTON_ENERGY_A, PHOTON_ENERGY_B, PHOTON_ENERGY_C);   
-  	   }
-  	   else { //Unknown 
-  		   double corrEnergy = rawEnergy;
-  		   return corrEnergy;}
-  	   
-     }   
+    private double enCorrection(int pdg, double rawEnergy) {
+        switch (pdg) {
+            case 11: // Particle is electron  		   
+                return energyCorrection(rawEnergy, ELECTRON_ENERGY_A, ELECTRON_ENERGY_B, ELECTRON_ENERGY_C);
+            case -11: //Particle is positron
+                return energyCorrection(rawEnergy, POSITRON_ENERGY_A, POSITRON_ENERGY_B, POSITRON_ENERGY_C);
+            case 22: //Particle is photon
+                return energyCorrection(rawEnergy, PHOTON_ENERGY_A, PHOTON_ENERGY_B, PHOTON_ENERGY_C);
+            default: //Unknown 
+                return rawEnergy;
+        }
+
+    }
     
     /**
      * Calculates the energy correction to a cluster given the variables from the fit as per
@@ -155,7 +146,7 @@
      * @param A,B,C from fitting in note
      * @return Corrected Energy
      */   
-    public double energyCorrection(double rawEnergy, double varA, double varB, double varC){
+    private double energyCorrection(double rawEnergy, double varA, double varB, double varC){
     	double corrEnergy = rawEnergy / (varA * rawEnergy + varB / (Math.sqrt(rawEnergy)) + varC);
     	return corrEnergy;
     }
@@ -170,24 +161,24 @@
      * @param rawEnergy Raw energy of the cluster (sum of hits with shared hit distribution)
      * @return Corrected x position
      */
-    public double posCorrection(int pdg, double xPos, double rawEnergy){
-    	double xCl = xPos/10.0;//convert to mm
-    	if (pdg == 11) { //Particle is electron    	
-    		double xCorr = positionCorrection(xCl, rawEnergy, ELECTRON_POS_A, ELECTRON_POS_B, ELECTRON_POS_C, ELECTRON_POS_D, ELECTRON_POS_E);
-    		return xCorr*10.0;
-    	}
-    	else if (pdg == -11) {// Particle is positron   	
-    		double xCorr = positionCorrection(xCl, rawEnergy, POSITRON_POS_A, POSITRON_POS_B, POSITRON_POS_C, POSITRON_POS_D, POSITRON_POS_E);
-    		return xCorr*10.0;
-    	}
-    	else if (pdg == 22) {// Particle is photon  	
-    		double xCorr = positionCorrection(xCl, rawEnergy, PHOTON_POS_A, PHOTON_POS_B, PHOTON_POS_C, PHOTON_POS_D, PHOTON_POS_E);
-    		return xCorr*10.0;
-    	}
-    	else { //Unknown 
-    		double xCorr = xCl;
-    		return xCorr*10.0;}
-    	}
+    private double posCorrection(int pdg, double xPos, double rawEnergy) {
+        double xCl = xPos / 10.0;//convert to mm
+        double xCorr;
+        switch (pdg) {
+            case 11: //Particle is electron    	
+                xCorr = positionCorrection(xCl, rawEnergy, ELECTRON_POS_A, ELECTRON_POS_B, ELECTRON_POS_C, ELECTRON_POS_D, ELECTRON_POS_E);
+                return xCorr * 10.0;
+            case -11:// Particle is positron   	
+                xCorr = positionCorrection(xCl, rawEnergy, POSITRON_POS_A, POSITRON_POS_B, POSITRON_POS_C, POSITRON_POS_D, POSITRON_POS_E);
+                return xCorr * 10.0;
+            case 22: // Particle is photon  	
+                xCorr = positionCorrection(xCl, rawEnergy, PHOTON_POS_A, PHOTON_POS_B, PHOTON_POS_C, PHOTON_POS_D, PHOTON_POS_E);
+                return xCorr * 10.0;
+            default: //Unknown 
+                xCorr = xCl;
+                return xCorr * 10.0;
+        }
+    }
     
     
    /**
@@ -203,382 +194,29 @@
     * @param varE
     * @return
     */    
-    public double positionCorrection(double xCl, double rawEnergy, double varA, double varB, double varC, double varD, double varE){
+    private double positionCorrection(double xCl, double rawEnergy, double varA, double varB, double varC, double varD, double varE){
     	double xCorr = xCl-(varA/Math.sqrt(rawEnergy) + varB )*xCl-
 				(varC*rawEnergy + varD/Math.sqrt(rawEnergy) + varE);
     	return xCorr;
     }
     
-    
- /*   @Override
-    public double[] getPosition() {
-        //Electron by default!?
-        return this.getPositionAtShowerMax(true);
-    }
-        
-    public double[] getPositionAtShowerMax(boolean isElectron) {
-        if( isElectron) {
-            if(needsElectronPosCalculation) {
-                this.calcPositionAtShowerMax(true);
-            }
-            return this.electronPosAtDepth;
-        }
-        else {
-            if(needsPhotonPosCalculation) {
-                this.calcPositionAtShowerMax(false);
-            }
-            return this.photonPosAtDepth;
-        }  
-    }
-        
-    public void calcPositionAtShowerMax(boolean isElectron) {
-        double E = this.getEnergy();
-        double y = E/eCriticalW;
-        double Cj = isElectron ? -0.5 : 0.5;
-        double tmax = Math.log(y) + Cj; //Maximum of dE/dt profile in units of rad. len. 
-//        double dmax = tmax*radLenW; //mm
-        double dmax = 0.0; //Changed this to readout crystal centroid at face
-        if(isElectron) {
-            electronPosAtDepth =  calculatePositionAtDepth(dmax);
-        } else {
-            photonPosAtDepth =  calculatePositionAtDepth(dmax);
-        }
-            
-    }
-    
-    
-    
-    public double[] calculatePositionAtDepth(double dmax) 
-    {
-        return this.calculatePositionAtDepth(this.getCalorimeterHits(), dmax);
-    }    
-    
-    public double[] calculatePositionAtDepth(List<CalorimeterHit> hits, double dmax)
-    {
-        //copy from package org.lcsim.recon.cluster.util.TensorClusterPropertyCalculator;
-
-        double positionErrorLocal[] = new double[6];
-        double directionErrorLocal[] = new double[6];
-        double shapeParametersLocal[] = new double[6];
-        double positionLocal[] = new double[3];
-        double ithetaLocal;
-        double iphiLocal;
-        
-        
-        double[] mm_NE = new double[3];
-        double[] mm_CE = new double[3];
-        double[][] mm_PA = new double[3][3];
-        for(int i=0;i<3;++i)
-        {
-            mm_NE[i] = 0.;
-            mm_CE[i] = 0.;
-            for(int j=0;j<3;++j)
-            {mm_PA[i][j]= 0.;}
-        }
-        double Etot = 0.0;
-        double Exx = 0.0;
-        double Eyy = 0.0;
-        double Ezz = 0.0;
-        double Exy = 0.0;
-        double Eyz = 0.0;
-        double Exz = 0.0;
-        double CEx = 0.0;
-        double CEy = 0.0;
-        double CEz = 0.0;
-        double CEr = 0.0;
-        double E1 = 0.0;
-        double E2 = 0.0;
-        double E3 = 0.0;
-        double NE1 = 0.0;
-        double NE2 = 0.0;
-        double NE3 = 0.0;
-        double Tr = 0.0;
-        double M = 0.0;
-        double Det = 0.0;
-        int nhits = hits.size();
-        for(int i=0;i<hits.size();i++)
-        {
-            CalorimeterHit hit = hits.get(i);
-            //	CalorimeterIDDecoder decoder = hit.getDecoder();
-            //	decoder.setID(hit.getCellID());
-            //	double[] pos = new double[3];
-            //	pos[0] = decoder.getX();
-            //	pos[1] = decoder.getY();
-            //	pos[2] = decoder.getZ();
-            //double[] pos = hit.getPosition();
-            //Find position at shower max
-            IGeometryInfo geom = hit.getDetectorElement().getGeometry();
-            double[] pos = geom.transformLocalToGlobal(VecOp.add(geom.transformGlobalToLocal(geom.getPosition()),(Hep3Vector)new BasicHep3Vector(0,0,dmax-1*((Trd)geom.getLogicalVolume().getSolid()).getZHalfLength()))).v();
-
-
-            
-            
-//            System.out.println("global pos " + global_pos.toString());
-//            System.out.println("local pos " + local_pos.toString());
-//            System.out.println("local pos tmax " + local_pos_tmax.toString());
-//            System.out.println("global pos tmax " + global_pos_tmax.toString());
-//            
-            //pos = global_pos_tmax.v();
-            
-            double E = hit.getCorrectedEnergy();
-            Etot += E;
-            CEx += E*pos[0];
-            CEy += E*pos[1];
-            CEz += E*pos[2];
-            Exx += E*(pos[1]*pos[1] + pos[2]*pos[2]);
-            Eyy += E*(pos[0]*pos[0] + pos[2]*pos[2]);
-            Ezz += E*(pos[1]*pos[1] + pos[0]*pos[0]);
-            Exy -= E*pos[0]*pos[1];
-            Eyz -= E*pos[1]*pos[2];
-            Exz -= E*pos[0]*pos[2];
-        }
-        CEx = CEx/Etot;
-        CEy = CEy/Etot;
-        CEz = CEz/Etot;
-        double CErSq = CEx*CEx + CEy*CEy + CEz*CEz;
-        CEr = Math.sqrt(CErSq);
-        // now go to center of energy coords.
-        if (nhits > 3 )
-        {
-            Exx = Exx - Etot*(CErSq - CEx*CEx);
-            Eyy = Eyy - Etot*(CErSq - CEy*CEy);
-            Ezz = Ezz - Etot*(CErSq - CEz*CEz);
-            Exy = Exy + Etot*CEx*CEy;
-            Eyz = Eyz + Etot*CEy*CEz;
-            Exz = Exz + Etot*CEz*CEx;
-
-            //
-            Tr = Exx + Eyy + Ezz;
-            double Dxx = Eyy*Ezz - Eyz*Eyz;
-            double Dyy = Ezz*Exx - Exz*Exz;
-            double Dzz = Exx*Eyy - Exy*Exy;
-            M = Dxx + Dyy + Dzz;
-            double Dxy = Exy*Ezz - Exz*Eyz;
-            double Dxz = Exy*Eyz - Exz*Eyy;
-            Det = Exx*Dxx - Exy*Dxy + Exz*Dxz;
-            double xt = Tr*Tr - 3*M;
-            double sqrtxt = Math.sqrt(xt);
-            // eqn to solve for eigenvalues is x**3 - x**2*Tr + x*M - Det = 0
-            // crosses y axis at -Det and inflection points are
-
-            double mE1 = 0.;
-            double mE2 = 0.;
-            double mE3 = 0.;
-            double a = (3*M - Tr*Tr)/3.;
-            double b = (-2*Tr*Tr*Tr + 9*Tr*M -27*Det)/27.;
-            double test = b*b/4. + a*a*a/27.;
-            if(test >= 0.01)
-            {
-                //System.out.println("AbstractCluster: Only 1 real root!!!");
-                //System.out.println("  nhits = " + nhits + "\n");
-                //System.out.println(" a,b,test = " + a + " " + b + " " + test + "\n");
-            }
-            else
-            {
-                double temp;
-                if(test >= 0.)temp = 1.;
-                else temp = Math.sqrt(b*b*27./(-a*a*a*4.));
-                if(b > 0.)temp = -temp;
-                double phi = Math.acos(temp);
-                double temp1 = 2.*Math.sqrt(-a/3.);
-                mE1 = Tr/3. + 2.*Math.sqrt(-a/3.)*Math.cos(phi/3.);
-                mE2 = Tr/3. + 2.*Math.sqrt(-a/3.)*Math.cos(phi/3. + 2.*Math.PI/3.);
-                mE3 = Tr/3. + 2.*Math.sqrt(-a/3.)*Math.cos(phi/3. + 4.*Math.PI/3.);
-            }
-            if(mE1 < mE2)
-            {
-                if(mE1 < mE3)
-                {
-                    E1 = mE1;
-                    if(mE2 < mE3)
-                    {
-                        E2 = mE2;
-                        E3 = mE3;
-                    }
-                    else
-                    {
-                        E2 = mE3;
-                        E3 = mE2;
-                    }
-                }
-                else
-                {
-                    E1 = mE3;
-                    E2 = mE1;
-                    E3 = mE2;
-                }
-            }
-            else
-            {
-                if(mE2 < mE3)
-                {
-                    E1 = mE2;
-                    if(mE1 < mE3)
-                    {
-                        E2 = mE1;
-                        E3 = mE3;
-                    }
-                    else
-                    {
-                        E2 = mE3;
-                        E3 = mE1;
-                    }
-                }
-                else
-                {
-                    E1 = mE3;
-                    E2 = mE2;
-                    E3 = mE1;
-                }
-            }
-
-            NE1 = E1/Etot;
-            NE2 = E2/Etot;
-            NE3 = E3/Etot;
-            double[] EV = new double[3];
-            EV[0] = E1;
-            EV[1] = E2;
-            EV[2] = E3;
-            // Now calculate principal axes
-	    // For eigenvalue EV, the axis is (nx, ny, nz) where:
-	    //    (Exx - EV)nx + (Exy)ny + (Exz)nz = 0
-	    //    (Eyx)nx + (Eyy - EV)ny + (Eyz)nz = 0
-	    //    (Ezx)nx + (Ezy)ny + (Ezz - EV)nz = 0
-	    // Setting nx = 1, we have:
-	    //    (Exx - EV) + (Exy)ny + (Exz)nz = 0
-	    //    (Eyx) + (Eyy - EV)ny + (Eyz)nz = 0
-	    //    (Ezx) + (Ezy)ny + (Ezz - EV)nz = 0
-	    // and so
-	    //    (Exy)ny = EV - Exx - (Exz)nz  =>  ny = (EV - Exx - Exz*nz)/Exy
-	    // What if Exy = 0? Then provided Eyz is non-zero we can write:
-	    //    (Ezx) + (Ezy)ny + (Ezz - EV)nz = 0
-	    //    ny = (Exz - (Ezz-EV)*nz)/Eyz
-	    // What if Exy = 0 and Eyz = 0 but (Eyy - EV) is non-zero?
-	    //    (Eyy - EV)ny + (Eyz)nz = 0
-	    //    ny = -(Eyz*nz)/(Eyy-EV)
-
-	    // In the pathological case where Exz = Eyz = Ezz = 0:
-	    //    (Exx - EV)nx + (Exy)ny = 0  =>  ny/nx = -(Exx-EV)/Exy
-	    //    (Eyx)nx + (Eyy - EV)ny = 0  =>  ny/nx = -Eyx/(Eyy-EV)
-	    //    (EV)nz = 0
-	    // so
-	    //     -ny/nx = (EV-Exx)/Exy = Eyx/(EV-Eyy)
-	    // But watch out for order! Recalculate eigenvalues for this pathological case.
-	    //     (EV-Exx)(EV-Eyy) = Eyx*Exy
-	    //     EV^2 - EV(Exx+Eyy) + Exx*Eyy - Eyx*Exy = 0
-	    // 
-	    // In another pathological case, Exz = Exy = 0:
-	    //    (Exx - EV)nx = 0
-	    //    (Eyy - EV)ny + (Eyz)nz = 0 => ny/nz = -(Eyz)/(Eyy-EV)
-	    //    (Ezy)ny + (Ezz - EV)nz = 0 => ny/nz = -(Ezz-EV)/(Ezy)
-	    // so we cannot set nx = 1. Instead, write:
-	    //    -ny/nz = (Eyz)/(Eyy-EV) = (Ezz-EV)/(Ezy)
-	    // Then
-	    //    (Eyz)(Ezy) = (Eyy-EV)(Ezz-EV)
-	    //    (Eyz)^2 = (Eyy)(Ezz) - (Eyy)(EV) - (Ezz)(EV) + (EV)^2
-	    //    EV^2 - EV(Eyy+Ezz) + Eyy*Ezz - Eyz*Eyz = 0
-
-	    // Handle pathological case
-	    if (Exz == 0.0 && Eyz == 0.0) {
-		// Recompute eigenvectors.
-		EV[0] = 0.5*(Exx+Eyy) + 0.5*Math.sqrt((Exx+Eyy)*(Exx+Eyy) + 4.0*Exy*Exy);
-		EV[1] = 0.5*(Exx+Eyy) - 0.5*Math.sqrt((Exx+Eyy)*(Exx+Eyy) + 4.0*Exy*Exy);
-		EV[2] = 0.0;
-		for( int i = 0 ; i < 2 ; i++ ) {
-		    double nx_over_ny = Exy / (Exx-EV[i]);
-		    double nx_unnormalized = nx_over_ny;
-		    double ny_unnormalized = 1.0;
-		    double norm = Math.sqrt(nx_unnormalized*nx_unnormalized + ny_unnormalized*ny_unnormalized);
-		    mm_PA[i][0] = ny_unnormalized/norm;
-		    mm_PA[i][1] = nx_unnormalized/norm;
-		    mm_PA[i][2] = 0.0;
-		}
-		// ... and now set third eigenvector to the z direction:
-		mm_PA[2][0] = 0.0;
-		mm_PA[2][1] = 0.0;
-		mm_PA[2][2] = 1.0;
-	    } else if (Exz == 0.0 && Exy == 0.0) {
-		// Another pathological case
-		EV[0] = 0.5*(Eyy+Ezz) + 0.5*Math.sqrt((Eyy+Ezz)*(Eyy+Ezz) + 4.0*Eyz*Eyz);
-		EV[1] = 0.5*(Eyy+Ezz) - 0.5*Math.sqrt((Eyy+Ezz)*(Eyy+Ezz) + 4.0*Eyz*Eyz);
-		EV[2] = 0.0;
-		for( int i = 0 ; i < 2 ; i++ ) {
-		    double ny_over_nz = Eyz / (Eyy-EV[i]);
-		    double ny_unnormalized = ny_over_nz;
-		    double nz_unnormalized = 1.0;
-		    double norm = Math.sqrt(ny_unnormalized*ny_unnormalized + nz_unnormalized*nz_unnormalized);
-		    mm_PA[i][0] = nz_unnormalized/norm;
-		    mm_PA[i][1] = ny_unnormalized/norm;
-		    mm_PA[i][2] = 0.0;
-		}
-		mm_PA[2][0] = 0.0;
-		mm_PA[2][1] = 0.0;
-		mm_PA[2][2] = 1.0;
-	    } else {
-		for( int i = 0 ; i < 3 ; i++ )
-		    {
-			double[] C = new double[3];
-			C[0] = 1.0;
-			C[2] = (Exy*Exy + (Eyy - EV[i])*(EV[i] - Exx))/
-			    ((Eyy - EV[i])*Exz - Eyz*Exy);
-			C[1] = (EV[i] - Exx - Exz*C[2])/Exy;
-			if (Exy == 0.0) {
-			    // Recompute
-			    if (Eyz != 0.0) {
-				// ny = (Exz - (Ezz-EV)*nz)/Eyz
-				C[1] = (Exz - (Ezz-EV[i])*C[2])/Eyz;
-			    } else {
-				// ny = -(Eyz*nz)/(Eyy-EV)
-				C[1] = -(Eyz*C[2])/(Eyy-EV[i]);
-			    }
-			}
-			double norm = Math.sqrt(C[0]*C[0] + C[1]*C[1] + C[2]*C[2]);
-			mm_PA[i][0] = C[0]/norm;
-			mm_PA[i][1] = C[1]/norm;
-			mm_PA[i][2] = C[2]/norm;
-		    }
-	    }
-        }
-        mm_NE[0] = NE1;
-        mm_NE[1] = NE2;
-        mm_NE[2] = NE3;
-        mm_CE[0] = CEx;
-        mm_CE[1] = CEy;
-        mm_CE[2] = CEz;
-        for(int i=0;i<6;i++)
-        {
-            positionErrorLocal[i] = 0.;
-            directionErrorLocal[i] = 0.;
-            shapeParametersLocal[i] = 0.;
-        }
-        for(int i=0;i<3;i++)
-        {
-            positionLocal[i] = mm_CE[i];
-            shapeParametersLocal[i] = mm_NE[i];
-        }
-        if(nhits > 3)
-        {
-            double dr = Math.sqrt(  (position[0]+mm_PA[0][0])*(position[0]+mm_PA[0][0]) +
-                    (position[1]+mm_PA[0][1])*(position[1]+mm_PA[0][1]) +
-                    (position[2]+mm_PA[0][2])*(position[2]+mm_PA[0][2]) ) -
-                    Math.sqrt(	(position[0])*(position[0]) +
-                    (position[1])*(position[1]) +
-                    (position[2])*(position[2]) ) ;
-            double sign = 1.;
-            if(dr < 0.)sign = -1.;
-            itheta = Math.acos(sign*mm_PA[0][2]);
-            iphi = Math.atan2(sign*mm_PA[0][1],sign*mm_PA[0][0]);
-        }
-        else
-        {
-            itheta = 999.;
-            iphi = 999.;
-        }
-    
-        return positionLocal;
-    }
-    
-  */  
-    
-    
+    private void recalculateForParticleID(int pid) {
+        double rawE = getRawEnergy();
+        double corrE = enCorrection(pid, rawE);
+        setEnergy(corrE);
+        double rawP[] = getPosition();
+        double corrP = posCorrection(pid, rawP[0], rawE);
+        double[] corrPosition = new double[3];
+        corrPosition[0] = corrP;
+        corrPosition[1] = rawP[1];
+        corrPosition[2] = rawP[2];
+        setCorrPosition(corrPosition);
+    }
+    
+    public void setParticleID(int pid) {
+        if (particleID!=pid){
+            particleID = pid;
+            recalculateForParticleID(pid);
+        }
+    }
 }

Modified: java/trunk/recon/src/main/java/org/hps/recon/particle/ReconParticleDriver.java
 =============================================================================
--- java/trunk/recon/src/main/java/org/hps/recon/particle/ReconParticleDriver.java	(original)
+++ java/trunk/recon/src/main/java/org/hps/recon/particle/ReconParticleDriver.java	Fri Nov 14 13:06:01 2014
@@ -4,10 +4,11 @@
 import hep.physics.vec.BasicHepLorentzVector;
 import hep.physics.vec.Hep3Vector;
 import hep.physics.vec.HepLorentzVector;
-
 import java.util.ArrayList;
 import java.util.List;
-
+import org.hps.recon.ecal.HPSEcalClusterIC;
+import org.hps.recon.tracking.CoordinateTransformations;
+import org.hps.recon.tracking.TrackUtils;
 import org.lcsim.event.Cluster;
 import org.lcsim.event.EventHeader;
 import org.lcsim.event.ReconstructedParticle;
@@ -17,178 +18,199 @@
 import org.lcsim.geometry.Detector;
 import org.lcsim.util.Driver;
 
-import org.hps.recon.tracking.CoordinateTransformations;
-import org.hps.recon.tracking.TrackUtils;
-
 /**
- * Driver framework for generating reconstructed particles and matching
- * clusters and tracks.
+ * Driver framework for generating reconstructed particles and matching clusters
+ * and tracks.
  *
  * @author Mathew Graham <[log in to unmask]>
  * @author Omar Moreno <[log in to unmask]>
  * @version $Id$
  */
 public abstract class ReconParticleDriver extends Driver {
-    /**
-     * Sets the name of the LCIO collection for beam spot constrained
-     * V0 candidate particles.
+
+    /**
+     * Sets the name of the LCIO collection for beam spot constrained V0
+     * candidate particles.
+     *
      * @param beamConV0CandidatesColName - The LCIO collection name.
      */
     public void setBeamConV0CandidatesColName(String beamConV0CandidatesColName) {
         this.beamConV0CandidatesColName = beamConV0CandidatesColName;
     }
-    
-    /**
-     * Sets the name of the LCIO collection for beam spot constrained
-     * V0 candidate vertices.
+
+    /**
+     * Sets the name of the LCIO collection for beam spot constrained V0
+     * candidate vertices.
+     *
      * @param beamConV0VerticesColName - The LCIO collection name.
      */
     public void setBeamConV0VerticesColName(String beamConV0VerticesColName) {
         this.beamConV0VerticesColName = beamConV0VerticesColName;
     }
-    
+
     /**
      * Sets the beam size sigma in the x-direction.
+     *
      * @param sigmaX - The standard deviation of the beam width in the
      * x-direction.
      */
-    public void setBeamSigmaX(double sigmaX) { beamSize[1] = sigmaX; }
-    
+    public void setBeamSigmaX(double sigmaX) {
+        beamSize[1] = sigmaX;
+    }
+
     /**
      * Sets the beam size sigma in the y-direction.
+     *
      * @param sigmaY - The standard deviation of the beam width in the
      * y-direction.
      */
-    public void setBeamSigmaY(double sigmaY) { beamSize[2] = sigmaY; }
-    
-    /**
-     * Indicates whether verbose debug text should be written out during
-     * runtime or note. Defaults to <code>false</code>.
-     * @param debug - <code>true</code> indicates that debug text should
-     * be written and <code>false</code> that it should be suppressed.
-     */
-    public void setDebug(boolean debug) { this.debug = debug; }
-    
-    /**
-     * Sets the maximum allowed separation distance between a matched
-     * cluster and track pair.
+    public void setBeamSigmaY(double sigmaY) {
+        beamSize[2] = sigmaY;
+    }
+
+    /**
+     * Indicates whether verbose debug text should be written out during runtime
+     * or note. Defaults to <code>false</code>.
+     *
+     * @param debug - <code>true</code> indicates that debug text should be
+     * written and <code>false</code> that it should be suppressed.
+     */
+    public void setDebug(boolean debug) {
+        this.debug = debug;
+    }
+
+    /**
+     * Sets the maximum allowed separation distance between a matched cluster
+     * and track pair.
+     *
      * @param dxCut - The maximum separation distance in the x-direction.
      */
     public void setDxCut(double dxCut) {
         this.dxCut = dxCut;
     }
-    
-    /**
-     * Sets the maximum allowed separation distance between a matched
-     * cluster and track pair.
+
+    /**
+     * Sets the maximum allowed separation distance between a matched cluster
+     * and track pair.
+     *
      * @param dyCut - The maximum separation distance in the y-direction.
      */
     public void setDyCut(double dyCut) {
         this.dyCut = dyCut;
     }
-    
+
     /**
      * Sets the LCIO collection name for calorimeter cluster data.
+     *
      * @param ecalClustersCollectionName - The LCIO collection name.
      */
     public void setEcalClusterCollectionName(String ecalClustersCollectionName) {
         this.ecalClustersCollectionName = ecalClustersCollectionName;
     }
-    
+
     /**
      * Sets the name of the LCIO collection for reconstructed particles.
+     *
      * @param finalStateParticlesColName - The LCIO collection name.
      */
     public void setFinalStateParticlesColName(String finalStateParticlesColName) {
         this.finalStateParticlesColName = finalStateParticlesColName;
     }
-    
-    /**
-     * Sets the name of the LCIO collection for target constrained V0
-     * candidate particles.
+
+    /**
+     * Sets the name of the LCIO collection for target constrained V0 candidate
+     * particles.
+     *
      * @param targetConV0CandidatesColName - The LCIO collection name.
      */
     public void setTargetConV0CandidatesColName(String targetConV0CandidatesColName) {
         this.targetConV0CandidatesColName = targetConV0CandidatesColName;
     }
-    
-    /**
-     * Sets the name of the LCIO collection for target constrained V0
-     * candidate vertices.
+
+    /**
+     * Sets the name of the LCIO collection for target constrained V0 candidate
+     * vertices.
+     *
      * @param targetConV0VerticesColName - The LCIO collection name.
      */
     public void setTargetConV0VerticesColName(String targetConV0VerticesColName) {
         this.targetConV0VerticesColName = targetConV0VerticesColName;
     }
-    
+
     /**
      * Sets the LCIO collection name for particle track data.
+     *
      * @param tracksCollectionName - The LCIO collection name.
      */
     public void setTracksCollectionName(String tracksCollectionName) {
         this.tracksCollectionName = tracksCollectionName;
     }
-    
-    /**
-     * Sets the name of the LCIO collection for unconstrained V0
-     * candidate particles.
+
+    /**
+     * Sets the name of the LCIO collection for unconstrained V0 candidate
+     * particles.
+     *
      * @param unconstrainedV0CandidatesColName - The LCIO collection name.
      */
     public void setUnconstrainedV0CandidatesColName(String unconstrainedV0CandidatesColName) {
         this.unconstrainedV0CandidatesColName = unconstrainedV0CandidatesColName;
     }
-    
-    /**
-     * Sets the name of the LCIO collection for unconstrained V0
-     * candidate vertices.
+
+    /**
+     * Sets the name of the LCIO collection for unconstrained V0 candidate
+     * vertices.
+     *
      * @param unconstrainedV0VerticesColName - The LCIO collection name.
      */
     public void setUnconstrainedV0VerticesColName(String unconstrainedV0VerticesColName) {
         this.unconstrainedV0VerticesColName = unconstrainedV0VerticesColName;
     }
-    
-    /**
-     * Updates the magnetic field parameters to match the appropriate
-     * values for the current detector settings.
+
+    /**
+     * Updates the magnetic field parameters to match the appropriate values for
+     * the current detector settings.
      */
     @Override
     protected void detectorChanged(Detector detector) {
         // Set the magnetic field parameters to the appropriate values.
         Hep3Vector ip = new BasicHep3Vector(0., 0., 1.);
         bField = detector.getFieldMap().getField(ip).y();
-        if (bField < 0) { flipSign = -1; }
-    }
-    
-    /**
-     * Generates reconstructed V0 candidate particles and vertices from
-     * sets of positrons and electrons. Implementing methods should
-     * place the reconstructed vertices and candidate particles into the
-     * appropriate class variable lists in <code>ReconParticleDriver
+        if (bField < 0) {
+            flipSign = -1;
+        }
+    }
+
+    /**
+     * Generates reconstructed V0 candidate particles and vertices from sets of
+     * positrons and electrons. Implementing methods should place the
+     * reconstructed vertices and candidate particles into the appropriate class
+     * variable lists in <code>ReconParticleDriver
      * </code>.
+     *
      * @param electrons - The list of electrons.
      * @param positrons - The list of positrons.
      */
     protected abstract void findVertices(List<ReconstructedParticle> electrons, List<ReconstructedParticle> positrons);
-    
-    /**
-     * Create the set of final state particles from the event tracks
-     * and clusters. Clusters will be matched with tracks when this
-     * is possible.
+
+    /**
+     * Create the set of final state particles from the event tracks and
+     * clusters. Clusters will be matched with tracks when this is possible.
+     *
      * @param clusters - The list of event clusters.
      * @param tracks - The list of event tracks.
-     * @return Returns a <code>List</code> collection containing all
-     * of the <code>ReconstructedParticle</code> objects generated from
-     * the argument data.
+     * @return Returns a <code>List</code> collection containing all of the
+     * <code>ReconstructedParticle</code> objects generated from the argument
+     * data.
      */
     protected List<ReconstructedParticle> makeReconstructedParticles(List<Cluster> clusters, List<Track> tracks) {
         // Create a list in which to store reconstructed particles.
         List<ReconstructedParticle> particles = new ArrayList<ReconstructedParticle>();
-        
+
         // Create a list of unmatched clusters. A cluster should be
         // removed from the list if a matching track is found.
         //List<Cluster> unmatchedClusters = new ArrayList<Cluster>(clusters);
         java.util.Set<Cluster> unmatchedClusters = new java.util.HashSet<Cluster>(clusters);
-        
+
         // Iterate over all of the tracks and generate reconstructed
         // particles for each one. If possible, match a cluster to the
         // track as well.
@@ -196,33 +218,32 @@
             // Create a reconstructed particle to represent the track.
             ReconstructedParticle particle = new BaseReconstructedParticle();
             HepLorentzVector fourVector = new BasicHepLorentzVector(0, 0, 0, 0);
-            
+
             // Store the track in the particle.
             particle.addTrack(track);
-            
+
             // Store the momentum derived from the track in the particle.
             Hep3Vector momentum = new BasicHep3Vector(track.getTrackStates().get(0).getMomentum());
             momentum = CoordinateTransformations.transformVectorToDetector(momentum);
             ((BasicHepLorentzVector) fourVector).setV3(fourVector.t(), momentum);
-            
+
             // Derive the charge of the particle from the track.
             ((BaseReconstructedParticle) particle).setCharge(track.getCharge() * flipSign);
-            
+
             // Extrapolate the particle ID from the track. Positively
             // charged particles are assumed to be positrons and those
             // with negative charges are assumed to be electrons.
             if (particle.getCharge() > 0) {
                 ((BaseReconstructedParticle) particle).setParticleIdUsed(new SimpleParticleID(-11, 0, 0, 0));
-            }
-            else if (particle.getCharge() < 0) {
+            } else if (particle.getCharge() < 0) {
                 ((BaseReconstructedParticle) particle).setParticleIdUsed(new SimpleParticleID(11, 0, 0, 0));
             }
-            
+
             // Track the best matching cluster for the track. A null
             // value indicates that no cluster matches the track to
             // within the maximum displacement limits.
             Cluster matchedCluster = null;
-            
+
             // Loop through all the unmatched clusters and select the
             // cluster, if any, that best fits with the track.
             clusterLoop:
@@ -231,76 +252,96 @@
                 if (isMatch(cluster, track)) {
                     // Store the matched cluster.
                     matchedCluster = cluster;
-                    
+
                     // Since a match has been found, the loop can be
                     // terminated.
                     break clusterLoop;
                 }
             }
-            
+
             // If a cluster was found that matches the track...
             if (matchedCluster != null) {
+
+                if (matchedCluster instanceof HPSEcalClusterIC) {
+                    int pid = particle.getParticleIDUsed().getPDG();
+                    if (pid != 11) {
+                        ((HPSEcalClusterIC) matchedCluster).setParticleID(pid);
+                    }// End of cluster position/energy corrections. 
+                }
+
                 // Update the reconstructed particle with the data from
                 // the cluster.
                 particle.addCluster(matchedCluster);
                 ((BasicHepLorentzVector) fourVector).setT(matchedCluster.getEnergy());
-                
+
                 // Remove the cluster from the set of unmatched clusters.
                 unmatchedClusters.remove(matchedCluster);
             }
-            
+
             // Store the momentum vector in the reconstructed particle.
             ((BaseReconstructedParticle) particle).set4Vector(fourVector);
-            
+
             // Add the particle to the list of reconstructed particles.
             particles.add(particle);
         }
-        
+
         // If any cluster remain unmatched after the tracks are finished,
         // they should be processed into additional reconstructed particles.
-        if (!unmatchedClusters.isEmpty())
-            // Iterate over the remaining unmatched clusters.
+        if (!unmatchedClusters.isEmpty()) // Iterate over the remaining unmatched clusters.
+        {
             for (Cluster unmatchedCluster : unmatchedClusters) {
                 // Create a reconstructed particle to represent the
                 // unmatched cluster.
                 ReconstructedParticle particle = new BaseReconstructedParticle();
                 HepLorentzVector fourVector = new BasicHepLorentzVector(0, 0, 0, 0);
-                
+
                 // Add the cluster to the particle.
                 particle.addCluster(unmatchedCluster);
-                
+
                 // Set the reconstructed particle properties based on
                 // the cluster properties.
                 ((BasicHepLorentzVector) fourVector).setT(unmatchedCluster.getEnergy());
                 ((BaseReconstructedParticle) particle).setCharge(0);
                 ((BaseReconstructedParticle) particle).set4Vector(fourVector);
-                
+
                 // The particle is assumed to be a photon, since it
                 // did not leave any track.
                 ((BaseReconstructedParticle) particle).setParticleIdUsed(new SimpleParticleID(22, 0, 0, 0));
-                
+
+                if (unmatchedCluster instanceof HPSEcalClusterIC) {
+                    int pid = particle.getParticleIDUsed().getPDG();
+                    if (pid != 11) {
+                        ((HPSEcalClusterIC) unmatchedCluster).setParticleID(pid);
+                    }// End of cluster position/energy corrections. 
+                }
+
                 // Add the particle to the reconstructed particle list.
                 particles.add(particle);
             }
-        
+        }
+
         // Return the list of reconstructed particles.
         return particles;
     }
 
     /**
-     * Prints a message as per <code>System.out.println</code> to the
-     * output stream if the verbose debug output option is enabled.
+     * Prints a message as per <code>System.out.println</code> to the output
+     * stream if the verbose debug output option is enabled.
+     *
      * @param debugMessage - The message to print.
      */
     protected void printDebug(String debugMessage) {
         // If verbose debug mode is enabled, print out the message.
-        if(debug) { System.out.printf("%s :: %s%n", simpleName, debugMessage); }
-    }
-    
+        if (debug) {
+            System.out.printf("%s :: %s%n", simpleName, debugMessage);
+        }
+    }
+
     /**
      * Processes the track and cluster collections in the event into
-     * reconstructed particles and V0 candidate particles and vertices.
-     * These reconstructed particles are then stored in the event.
+     * reconstructed particles and V0 candidate particles and vertices. These
+     * reconstructed particles are then stored in the event.
+     *
      * @param event - The event to process.
      */
     @Override
@@ -310,27 +351,28 @@
         if (!event.hasCollection(Cluster.class, ecalClustersCollectionName)) {
             return;
         }
-        
+
         // VERBOSE :: Note that a new event is being read.
         printDebug("\nProcessing Event...");
-        
+
         // Otherwise, get the list of calorimeter clusters.
         List<Cluster> clusters = event.get(Cluster.class, ecalClustersCollectionName);
-        
+
         // VERBOSE :: Output the number of clusters in the event.
         printDebug("Clusters :: " + clusters.size());
-        
+
         // Get the set of tracks from the event. If no such collection
         // exists, initialize an empty list instead.
         List<Track> tracks;
-        if(event.hasCollection(Track.class, tracksCollectionName)) {
+        if (event.hasCollection(Track.class, tracksCollectionName)) {
             tracks = event.get(Track.class, tracksCollectionName);
-        }
-        else { tracks = new ArrayList<Track>(0); }
-        
+        } else {
+            tracks = new ArrayList<Track>(0);
+        }
+
         // VERBOSE :: Output the number of tracks in the event.
         printDebug("Tracks :: " + tracks.size());
-        
+
         // Instantiate new lists to store reconstructed particles and
         // V0 candidate particles and vertices.
         finalStateParticles = new ArrayList<ReconstructedParticle>();
@@ -342,35 +384,37 @@
         unconstrainedV0Vertices = new ArrayList<Vertex>();
         beamConV0Vertices = new ArrayList<Vertex>();
         targetConV0Vertices = new ArrayList<Vertex>();
-        
+
         // Generate the reconstructed particles.
         finalStateParticles = makeReconstructedParticles(clusters, tracks);
-        
+
         // VERBOSE :: Output the number of reconstructed particles.
         printDebug("Final State Particles :: " + finalStateParticles.size());
-        
+
         // Store the reconstructed particles collection.
         event.put(finalStateParticlesColName, finalStateParticles, ReconstructedParticle.class, 0);
-        
+
         // Separate the reconstructed particles into electrons and
         // positrons so that V0 candidates can be generated from them.
         for (ReconstructedParticle finalStateParticle : finalStateParticles) {
             // If the charge is positive, assume an electron.
-            if(finalStateParticle.getCharge() > 0) { positrons.add(finalStateParticle); }
-            
-            // Otherwise, assume the particle is a positron.
-            else if(finalStateParticle.getCharge() < 0) { electrons.add(finalStateParticle); }
-        }
-        
+            if (finalStateParticle.getCharge() > 0) {
+                positrons.add(finalStateParticle);
+            } // Otherwise, assume the particle is a positron.
+            else if (finalStateParticle.getCharge() < 0) {
+                electrons.add(finalStateParticle);
+            }
+        }
+
         // VERBOSE :: Output the number of reconstructed positrons
         // and electrons.
         printDebug("Number of Electrons: " + electrons.size());
         printDebug("Number of Positrons: " + positrons.size());
-        
+
         // Form V0 candidate particles and vertices from the electron
         // and positron reconstructed particles.
         findVertices(electrons, positrons);
-        
+
         // Store the V0 candidate particles and vertices for each type
         // of constraint in the appropriate collection in the event,
         // as long as a collection name is defined.
@@ -399,43 +443,65 @@
             event.put(targetConV0VerticesColName, targetConV0Vertices, Vertex.class, 0);
         }
     }
-    
-    /**
-     * Sets the LCIO collection names to their default values if they
-     * are not already defined.
+
+    /**
+     * Sets the LCIO collection names to their default values if they are not
+     * already defined.
      */
     @Override
     protected void startOfData() {
         // If any of the LCIO collection names are not properly defined, define them now.
-        if(ecalClustersCollectionName == null) { ecalClustersCollectionName = "EcalClusters"; }
-        if(tracksCollectionName == null) { tracksCollectionName = "MatchedTracks"; }
-        if(finalStateParticlesColName == null) { finalStateParticlesColName = "FinalStateParticles"; }
-        if(unconstrainedV0CandidatesColName == null) { unconstrainedV0CandidatesColName = "UnconstrainedV0Candidates"; }
-        if(beamConV0CandidatesColName == null) { beamConV0CandidatesColName = "BeamspotConstrainedV0Candidates"; }
-        if(targetConV0CandidatesColName == null) { targetConV0CandidatesColName = "TargetConstrainedV0Candidates"; }
-        if(unconstrainedV0VerticesColName == null) { unconstrainedV0VerticesColName = "UnconstrainedV0Vertices"; }
-        if(beamConV0VerticesColName == null) { beamConV0VerticesColName = "BeamspotConstrainedV0Vertices"; }
-        if(targetConV0VerticesColName == null) { targetConV0VerticesColName = "TargetConstrainedV0Vertices"; }
-    }
-    
-    /**
-     * Determines if a cluster is a potential match for a given track.
-     * If it is, returns the distance between the extrapolation of the
-     * track to the z-position of the cluster and the cluster position.
-     * Otherwise, returns <code>null</code> to indicate that the pair
-     * is not a valid match.
+        if (ecalClustersCollectionName == null) {
+            ecalClustersCollectionName = "EcalClusters";
+        }
+        if (tracksCollectionName == null) {
+            tracksCollectionName = "MatchedTracks";
+        }
+        if (finalStateParticlesColName == null) {
+            finalStateParticlesColName = "FinalStateParticles";
+        }
+        if (unconstrainedV0CandidatesColName == null) {
+            unconstrainedV0CandidatesColName = "UnconstrainedV0Candidates";
+        }
+        if (beamConV0CandidatesColName == null) {
+            beamConV0CandidatesColName = "BeamspotConstrainedV0Candidates";
+        }
+        if (targetConV0CandidatesColName == null) {
+            targetConV0CandidatesColName = "TargetConstrainedV0Candidates";
+        }
+        if (unconstrainedV0VerticesColName == null) {
+            unconstrainedV0VerticesColName = "UnconstrainedV0Vertices";
+        }
+        if (beamConV0VerticesColName == null) {
+            beamConV0VerticesColName = "BeamspotConstrainedV0Vertices";
+        }
+        if (targetConV0VerticesColName == null) {
+            targetConV0VerticesColName = "TargetConstrainedV0Vertices";
+        }
+    }
+
+    /**
+     * Determines if a cluster is a potential match for a given track. If it is,
+     * returns the distance between the extrapolation of the track to the
+     * z-position of the cluster and the cluster position. Otherwise, returns
+     * <code>null</code> to indicate that the pair is not a valid match.
+     *
      * @param cluster - The cluster to check.
      * @param track - The track to check.
-     * @return Returns the distance between the cluster and extrapolated
-     * track position in millimeters as a <code>Double</code> if the
-     * pair is a potential match. Returns <code>null</code> otherwise.
+     * @return Returns the distance between the cluster and extrapolated track
+     * position in millimeters as a <code>Double</code> if the pair is a
+     * potential match. Returns <code>null</code> otherwise.
      */
     private boolean isMatch(Cluster cluster, Track track) {
         // Get the position of the cluster and extrapolate the position
         // of the track at the z-position of the cluster.
+
         Hep3Vector clusterPosition = new BasicHep3Vector(cluster.getPosition());
+        if (cluster instanceof HPSEcalClusterIC) {
+            clusterPosition = new BasicHep3Vector(((HPSEcalClusterIC) cluster).getCorrPosition());
+        }
         Hep3Vector trackPosAtEcal = TrackUtils.extrapolateTrack(track, clusterPosition.z());
-        
+
         // TODO: There are some track whose extrapolated coordinates
         //       are NaN. The problem seems to be that the y-coordinate
         //       of the extrapolated helix is found to be non-real. This
@@ -451,12 +517,12 @@
             // Return false to indicate that the pair do not match.
             return false;
         }
-        
+
         // VERBOSE :: Output the position of the extrapolated track
         //            and the cluster.
         printDebug("\tCluster Position :: " + clusterPosition.toString());
         printDebug("\tTrack Position   :: " + trackPosAtEcal.toString());
-        
+
         // If one of either the cluster or extrapolated track fall on
         // one volume of the detector and the other is in the other
         // volume, then they can not be a match. (i.e. both parts of
@@ -468,7 +534,7 @@
             // Return false to indicate that the pair do not match.
             return false;
         }
-        
+
         // Check to make sure that the x and y displacements between
         // the extrapolated track position and cluster position are
         // within the allowed bounds. If they are not, this pair is
@@ -480,84 +546,139 @@
             // Return false to indicate that the pair do not match.
             return false;
         }
-        
+
         if (Math.abs(trackPosAtEcal.y() - clusterPosition.y()) > dyCut) {
             // VERBOSE :: Indicate the reason for the match failing.
             printDebug("\tFailure :: Pair y-displacement exceeds allowed threshold.");
-            
+
             // Return false to indicate that the pair do not match.
             return false;
         }
-        
+
         // VERBOSE :: Indicate the reason for the match failing.
         printDebug("\tSuccess :: Cluster/track pair match!.");
-        
+
         // A pair that has reached this point is a potential match.
         // Return true to indicate a match.
         return true;
     }
-    
+
     // ==============================================================
     // ==== Class Variables =========================================
     // ==============================================================
     // Local variables.
-    /** The maximum separation distance in the x-direction beyond which
-     * a cluster and track will be rejected for pairing. */
+    /**
+     * The maximum separation distance in the x-direction beyond which a cluster
+     * and track will be rejected for pairing.
+     */
     private double dxCut = 20.0;
-    /** The maximum separation distance in the y-direction beyond which
-     * a cluster and track will be rejected for pairing. */
+    /**
+     * The maximum separation distance in the y-direction beyond which a cluster
+     * and track will be rejected for pairing.
+     */
     private double dyCut = 20.0;
-    /** Indicates whether debug text should be output or not. */
+    /**
+     * Indicates whether debug text should be output or not.
+     */
     private boolean debug = false;
-    /** The simple name of the class used for debug print statements. */
+    /**
+     * The simple name of the class used for debug print statements.
+     */
     private final String simpleName = getClass().getSimpleName();
-    
+
     // Reconstructed Particle Lists
-    /** Stores reconstructed electron particles. */
+    /**
+     * Stores reconstructed electron particles.
+     */
     private List<ReconstructedParticle> electrons;
-    /** Stores reconstructed positron particles. */
+    /**
+     * Stores reconstructed positron particles.
+     */
     private List<ReconstructedParticle> positrons;
-    /** Stores particles reconstructed from an event. */
+    /**
+     * Stores particles reconstructed from an event.
+     */
     protected List<ReconstructedParticle> finalStateParticles;
-    /** Stores reconstructed V0 candidate particles generated without constraints. */
+    /**
+     * Stores reconstructed V0 candidate particles generated without
+     * constraints.
+     */
     protected List<ReconstructedParticle> unconstrainedV0Candidates;
-    /** Stores reconstructed V0 candidate particles generated with beam spot constraints. */
+    /**
+     * Stores reconstructed V0 candidate particles generated with beam spot
+     * constraints.
+     */
     protected List<ReconstructedParticle> beamConV0Candidates;
-    /** Stores reconstructed V0 candidate particles generated with target constraints. */
+    /**
+     * Stores reconstructed V0 candidate particles generated with target
+     * constraints.
+     */
     protected List<ReconstructedParticle> targetConV0Candidates;
-    /** Stores reconstructed V0 candidate vertices generated without constraints. */
+    /**
+     * Stores reconstructed V0 candidate vertices generated without constraints.
+     */
     protected List<Vertex> unconstrainedV0Vertices;
-    /** Stores reconstructed V0 candidate vertices generated with beam spot constraints. */
+    /**
+     * Stores reconstructed V0 candidate vertices generated with beam spot
+     * constraints.
+     */
     protected List<Vertex> beamConV0Vertices;
-    /** Stores reconstructed V0 candidate vertices generated with target constraints. */
+    /**
+     * Stores reconstructed V0 candidate vertices generated with target
+     * constraints.
+     */
     protected List<Vertex> targetConV0Vertices;
-    
+
     // LCIO Collection Names
-    /** LCIO collection name for calorimeter clusters. */
+    /**
+     * LCIO collection name for calorimeter clusters.
+     */
     private String ecalClustersCollectionName = "EcalClusters";
-    /** LCIO collection name for tracks. */
+    /**
+     * LCIO collection name for tracks.
+     */
     private String tracksCollectionName = "MatchedTracks";
-    /** LCIO collection name for reconstructed particles. */
+    /**
+     * LCIO collection name for reconstructed particles.
+     */
     private String finalStateParticlesColName = "FinalStateParticles";
-    /** LCIO collection name for V0 candidate particles generated without constraints. */
+    /**
+     * LCIO collection name for V0 candidate particles generated without
+     * constraints.
+     */
     protected String unconstrainedV0CandidatesColName = null;
-    /** LCIO collection name for V0 candidate particles generated with beam spot constraints. */
+    /**
+     * LCIO collection name for V0 candidate particles generated with beam spot
+     * constraints.
+     */
     protected String beamConV0CandidatesColName = null;
-    /** LCIO collection name for V0 candidate particles generated with target constraints. */
+    /**
+     * LCIO collection name for V0 candidate particles generated with target
+     * constraints.
+     */
     protected String targetConV0CandidatesColName = null;
-    /** LCIO collection name for V0 candidate vertices generated without constraints. */
+    /**
+     * LCIO collection name for V0 candidate vertices generated without
+     * constraints.
+     */
     protected String unconstrainedV0VerticesColName = null;
-    /** LCIO collection name for V0 candidate vertices generated with beam spot constraints. */
+    /**
+     * LCIO collection name for V0 candidate vertices generated with beam spot
+     * constraints.
+     */
     protected String beamConV0VerticesColName = null;
-    /** LCIO collection name for V0 candidate vertices generated with target constraints. */
+    /**
+     * LCIO collection name for V0 candidate vertices generated with target
+     * constraints.
+     */
     protected String targetConV0VerticesColName = null;
-    
+
     // Beam size variables.
     // The beamsize array is in the tracking frame
     /* TODO  mg-May 14, 2014:  the the beam size from the conditions db...also beam position!  */
     protected double[] beamSize = {0.001, 0.2, 0.02};
     protected double bField;
-    
+
     //  flipSign is a kludge...
     //  HelicalTrackFitter doesn't deal with B-fields in -ive Z correctly
     //  so we set the B-field in +iveZ and flip signs of fitted tracks

Modified: java/trunk/steering-files/src/main/resources/org/hps/steering/recon/HPS2014OfflineNoPileupRecon.lcsim
 =============================================================================
--- java/trunk/steering-files/src/main/resources/org/hps/steering/recon/HPS2014OfflineNoPileupRecon.lcsim	(original)
+++ java/trunk/steering-files/src/main/resources/org/hps/steering/recon/HPS2014OfflineNoPileupRecon.lcsim	Fri Nov 14 13:06:01 2014
@@ -62,7 +62,7 @@
             <ecalCollectionName>EcalCalHits</ecalCollectionName>
             <timeCut>true</timeCut>
         </driver>
-        <driver name="ReconParticle" type="org.hps.recon.particle.HpsReconParticleDriverIC">          
+        <driver name="ReconParticle" type="org.hps.recon.particle.HpsReconParticleDriver">          
         </driver>
         <driver name="TrackDataDriver" type="org.hps.recon.tracking.TrackDataDriver" />
         <driver name="LCIOWriter" type="org.lcsim.util.loop.LCIODriver">

Modified: java/trunk/steering-files/src/main/resources/org/hps/steering/recon/HPS2014OfflineRecon.lcsim
 =============================================================================
--- java/trunk/steering-files/src/main/resources/org/hps/steering/recon/HPS2014OfflineRecon.lcsim	(original)
+++ java/trunk/steering-files/src/main/resources/org/hps/steering/recon/HPS2014OfflineRecon.lcsim	Fri Nov 14 13:06:01 2014
@@ -65,7 +65,7 @@
             <ecalCollectionName>EcalCalHits</ecalCollectionName>
             <timeCut>true</timeCut>
         </driver>
-        <driver name="ReconParticle" type="org.hps.recon.particle.HpsReconParticleDriverIC">          
+        <driver name="ReconParticle" type="org.hps.recon.particle.HpsReconParticleDriver">          
         </driver>
         <driver name="TrackDataDriver" type="org.hps.recon.tracking.TrackDataDriver" />
         <driver name="LCIOWriter" type="org.lcsim.util.loop.LCIODriver">

Modified: java/trunk/steering-files/src/main/resources/org/hps/steering/recon/HPS2014OfflineTruthRecon.lcsim
 =============================================================================
--- java/trunk/steering-files/src/main/resources/org/hps/steering/recon/HPS2014OfflineTruthRecon.lcsim	(original)
+++ java/trunk/steering-files/src/main/resources/org/hps/steering/recon/HPS2014OfflineTruthRecon.lcsim	Fri Nov 14 13:06:01 2014
@@ -67,7 +67,7 @@
             <ecalCollectionName>EcalCalHits</ecalCollectionName>
             <timeCut>true</timeCut>
         </driver>
-        <driver name="ReconParticle" type="org.hps.recon.particle.HpsReconParticleDriverIC">          
+        <driver name="ReconParticle" type="org.hps.recon.particle.HpsReconParticleDriver">          
         </driver>
         <driver name="TrackDataDriver" type="org.hps.recon.tracking.TrackDataDriver" />
         <driver name="LCIOWriter" type="org.lcsim.util.loop.LCIODriver">