Print

Print


Author: [log in to unmask]
Date: Wed Apr 22 12:44:22 2015
New Revision: 2785

Log:
updated cluster property corrections use after reconclusterer

Modified:
    java/trunk/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/ClusterEnergyCorrection.java
    java/trunk/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/ClusterPositionCorrection.java
    java/trunk/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/ReconClusterPropertyCalculator.java

Modified: java/trunk/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/ClusterEnergyCorrection.java
 =============================================================================
--- java/trunk/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/ClusterEnergyCorrection.java	(original)
+++ java/trunk/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/ClusterEnergyCorrection.java	Wed Apr 22 12:44:22 2015
@@ -4,8 +4,12 @@
 import org.lcsim.event.base.BaseCluster;
 
 /**
- * Cluster energy correction algorithm extracted from <code>HPSEcalClusterIC</code> class.
+ * This is the cluster energy correction requiring the particle id 
+ * uncorrected cluster energy. This is not accurate for edge crystals
+ * and should be used after cluster-track matching and after position
+ * corrections.
  * 
+ * @author Holly Vance <[log in to unmask]>
  * @author Jeremy McCormick <[log in to unmask]>
  */
 public final class ClusterEnergyCorrection {
@@ -71,12 +75,13 @@
     /**
      * Calculates the energy correction to a cluster given the variables from the fit as per
      * <a href="https://misportal.jlab.org/mis/physics/hps_notes/index.cfm?note_year=2014">HPS Note 2014-001</a>
+     * Note that this is correct as there is a typo in the formula print in the note. 
      * @param rawEnergy Raw energy of the cluster
      * @param A,B,C from fitting in note
      * @return Corrected Energy
      */   
     private static double computeCorrectedEnergy(double rawEnergy, double varA, double varB, double varC){
-        double corrEnergy = rawEnergy / (varA * rawEnergy + varB / (Math.sqrt(rawEnergy)) + varC);
+        double corrEnergy = rawEnergy / (varA / rawEnergy + varB / (Math.sqrt(rawEnergy)) + varC);
         return corrEnergy;
     }                   
 }

Modified: java/trunk/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/ClusterPositionCorrection.java
 =============================================================================
--- java/trunk/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/ClusterPositionCorrection.java	(original)
+++ java/trunk/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/ClusterPositionCorrection.java	Wed Apr 22 12:44:22 2015
@@ -4,36 +4,37 @@
 import org.lcsim.event.base.BaseCluster;
 
 /**
- * <p>
- * Cluster position corrections taken from the <code>HPSEcalClusterIC</code> class.
- * <p>
- * This should be used before the energy is corrected on the Cluster.
+ * This uses the uncorrected cluster energy to correct the position of the cluster.
+ * This should be used before the energy is corrected on the Cluster and after
+ * cluster-track matching.
  * 
+ * @author Holly Vance <[log in to unmask]>
  * @author Jeremy McCormick <[log in to unmask]>
  */
 public final class ClusterPositionCorrection {
            
     // Variables for electron position corrections.
-    static final double ELECTRON_POS_A = 0.0066;
-    static final double ELECTRON_POS_B = -0.03;
-    static final double ELECTRON_POS_C = 0.028;
-    static final double ELECTRON_POS_D = -0.45;
-    static final double ELECTRON_POS_E = 0.465;
+    static final double ELECTRON_POS_A1 = 0.0066;
+    static final double ELECTRON_POS_A2 = -0.03;
+    static final double ELECTRON_POS_B1 = 0.028;
+    static final double ELECTRON_POS_B2 = -0.451;
+    static final double ELECTRON_POS_B3 = 0.465;
     
     // Variables for positron position corrections.
-    static final double POSITRON_POS_A = 0.0072;
-    static final double POSITRON_POS_B = -0.031;
-    static final double POSITRON_POS_C = 0.007;
-    static final double POSITRON_POS_D = 0.342;
-    static final double POSITRON_POS_E = 0.108;
+    static final double POSITRON_POS_A1 = 0.0072;
+    static final double POSITRON_POS_A2 = -0.031;
+    static final double POSITRON_POS_B1 = 0.007;
+    static final double POSITRON_POS_B2 = 0.342;
+    static final double POSITRON_POS_B3 = 0.108;
     
     // Variables for photon position corrections.
-    static final double PHOTON_POS_A = 0.005;
-    static final double PHOTON_POS_B = -0.032;
-    static final double PHOTON_POS_C = 0.011;
-    static final double PHOTON_POS_D = -0.037;
-    static final double PHOTON_POS_E = 0.294;
+    static final double PHOTON_POS_A1 = 0.005;
+    static final double PHOTON_POS_A2 = -0.032;
+    static final double PHOTON_POS_B1 = 0.011;
+    static final double PHOTON_POS_B2 = -0.037;
+    static final double PHOTON_POS_B3 = 0.294;
     
+  
     public static double[] calculateCorrectedPosition(Cluster cluster) {
         double clusterPosition[] = cluster.getPosition();                
         double correctedPosition = computeCorrectedPosition(cluster.getParticleId(), clusterPosition[0], cluster.getEnergy());
@@ -58,17 +59,17 @@
      * @return Corrected x position
      */
     private static double computeCorrectedPosition(int pdg, double xPos, double rawEnergy) {
-        double xCl = xPos / 10.0;//convert to mm
+        double xCl = xPos / 10.0;//convert to cm
         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);
+                xCorr = positionCorrection(xCl, rawEnergy, ELECTRON_POS_A1, ELECTRON_POS_A2, ELECTRON_POS_B1, ELECTRON_POS_B2, ELECTRON_POS_B3);
                 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);
+                xCorr = positionCorrection(xCl, rawEnergy, POSITRON_POS_A1, POSITRON_POS_A2, POSITRON_POS_B1, POSITRON_POS_B2, POSITRON_POS_B3);
                 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);
+                xCorr = positionCorrection(xCl, rawEnergy, PHOTON_POS_A1, PHOTON_POS_A2, PHOTON_POS_B1, PHOTON_POS_B2, PHOTON_POS_B3);
                 return xCorr * 10.0;
             default: //Unknown 
                 xCorr = xCl;
@@ -82,14 +83,14 @@
     * <a href="https://misportal.jlab.org/mis/physics/hps_notes/index.cfm?note_year=2014">HPS Note 2014-001</a>
     * @param xCl
     * @param rawEnergy
-    * @param varA
-    * @param varB
-    * @param varC
-    * @param varD
-    * @param varE
+    * @param varA1
+    * @param varA2
+    * @param varB1
+    * @param varB2
+    * @param varB3
     * @return
     */    
-    private static double positionCorrection(double xCl, double rawEnergy, double varA, double varB, double varC, double varD, double varE) {
-        return xCl - (varA / Math.sqrt(rawEnergy) + varB ) * xCl - (varC * rawEnergy + varD / Math.sqrt(rawEnergy) + varE);
+    private static double positionCorrection(double xCl, double rawEnergy, double varA1, double varA2, double varB1, double varB2, double varB3) {
+        return ((xCl - (varB1 * rawEnergy + varB2 / Math.sqrt(rawEnergy) + varB3))/(varA1 / Math.sqrt(rawEnergy) + varA2 + 1));
     }
 }

Modified: java/trunk/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/ReconClusterPropertyCalculator.java
 =============================================================================
--- java/trunk/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/ReconClusterPropertyCalculator.java	(original)
+++ java/trunk/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/ReconClusterPropertyCalculator.java	Wed Apr 22 12:44:22 2015
@@ -43,9 +43,10 @@
             EcalCrystal crystal = (EcalCrystal) hit.getDetectorElement();
             Hep3Vector crystalPosition = crystal.getPositionFront();
             
-            eNumX += Math.max(0.0, (w0 + Math.log(hit.getCorrectedEnergy() / cluster.getEnergy()))) * (crystalPosition.x() / 10.0);
-            eNumY += Math.max(0.0, (w0 + Math.log(hit.getCorrectedEnergy() / cluster.getEnergy()))) * (crystalPosition.y() / 10.0);
-            eDen += Math.max(0.0, (w0 + Math.log(hit.getCorrectedEnergy() / cluster.getEnergy())));
+            double wi = Math.max(0.0, (w0 + Math.log(hit.getCorrectedEnergy() / cluster.getEnergy())));
+            eNumX += wi * (crystalPosition.x() / 10.0);
+            eNumY += wi * (crystalPosition.y() / 10.0);
+            eDen += wi;
 
         } // end for iteration through clusterHits