Print

Print


Commit in java/branches/hps-java_HPSJAVA-88 on MAIN
distribution/pom.xml+21215 -> 1216
ecal-recon/pom.xml+131215 -> 1216
ecal-recon/src/main/java/org/hps/recon/ecal/EcalClusterIC.java+1-41215 -> 1216
                                           /HPSEcalClusterIC.java+91-251215 -> 1216
integration-tests/pom.xml+11215 -> 1216
integration-tests/src/test/java/org/hps/SimpleMCReconTest.java+71-11215 -> 1216
recon/src/main/java/org/hps/recon/particle/ReconParticleDriverIC.java+5-61215 -> 1216
steering-files/src/main/resources/org/hps/steering/recon/SimpleMCRecon.lcsim+131215 -> 1216
users/pom.xml+11215 -> 1216
+198-36
9 modified files
Merge trunk changes through r1215 into hps-java_HPSJAVA-88.

java/branches/hps-java_HPSJAVA-88/distribution
pom.xml 1215 -> 1216
--- java/branches/hps-java_HPSJAVA-88/distribution/pom.xml	2014-10-16 05:27:54 UTC (rev 1215)
+++ java/branches/hps-java_HPSJAVA-88/distribution/pom.xml	2014-10-16 05:56:05 UTC (rev 1216)
@@ -20,6 +20,7 @@
     </scm>
     <build>              
         <plugins>
+<!--    
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-site-plugin</artifactId>
@@ -29,6 +30,7 @@
                     <skipDeploy>true</skipDeploy>
                 </configuration>
             </plugin>        
+-->            
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-shade-plugin</artifactId>

java/branches/hps-java_HPSJAVA-88/ecal-recon
pom.xml 1215 -> 1216
--- java/branches/hps-java_HPSJAVA-88/ecal-recon/pom.xml	2014-10-16 05:27:54 UTC (rev 1215)
+++ java/branches/hps-java_HPSJAVA-88/ecal-recon/pom.xml	2014-10-16 05:56:05 UTC (rev 1216)
@@ -21,4 +21,17 @@
             <artifactId>hps-conditions</artifactId>
         </dependency>
     </dependencies>
+    <build>
+      <plugins>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-surefire-plugin</artifactId>
+          <configuration>
+            <excludes>
+              <exclude>org/hps/recon/ECalClusterICTest.java</exclude>
+            </excludes>
+          </configuration>
+        </plugin>
+      </plugins>
+    </build>
 </project>

java/branches/hps-java_HPSJAVA-88/ecal-recon/src/main/java/org/hps/recon/ecal
EcalClusterIC.java 1215 -> 1216
--- java/branches/hps-java_HPSJAVA-88/ecal-recon/src/main/java/org/hps/recon/ecal/EcalClusterIC.java	2014-10-16 05:27:54 UTC (rev 1215)
+++ java/branches/hps-java_HPSJAVA-88/ecal-recon/src/main/java/org/hps/recon/ecal/EcalClusterIC.java	2014-10-16 05:56:05 UTC (rev 1216)
@@ -525,10 +525,7 @@
                 // Energy correction for initial guess of electron:
                 int pdg = 11;
                 double corrEnergy = enCorrection(pdg, rawEnergy);
-                if(corrEnergy<1){ //this only happens below threshold
-                	corrEnergy = rawEnergy;
-                }
-              
+
                 seedEnergyCorr.put(entryC.getKey(), corrEnergy);    
             }// end of energy corrections
         

java/branches/hps-java_HPSJAVA-88/ecal-recon/src/main/java/org/hps/recon/ecal
HPSEcalClusterIC.java 1215 -> 1216
--- java/branches/hps-java_HPSJAVA-88/ecal-recon/src/main/java/org/hps/recon/ecal/HPSEcalClusterIC.java	2014-10-16 05:27:54 UTC (rev 1215)
+++ java/branches/hps-java_HPSJAVA-88/ecal-recon/src/main/java/org/hps/recon/ecal/HPSEcalClusterIC.java	2014-10-16 05:56:05 UTC (rev 1216)
@@ -19,7 +19,7 @@
     private CalorimeterHit seedHit = null;
     private long cellID;
     private ArrayList<CalorimeterHit> sharedHitList = new ArrayList<CalorimeterHit>(); 
-    private double[] rawPosition = new double[2];
+    private double[] rawPosition = new double[3];
 
     
     
@@ -30,6 +30,37 @@
     double[] photonPosAtDepth = new double[3];
     private boolean needsPhotonPosCalculation = true;
     
+ // Variables for electron energy corrections
+    static final double ELECTRON_ENERGY_A = -0.0027;
+    static final double ELECTRON_ENERGY_B = -0.06;
+    static final double ELECTRON_ENERGY_C = 0.95;
+    // Variables for positron energy corrections
+    static final double POSITRON_ENERGY_A = -0.0096;
+    static final double POSITRON_ENERGY_B = -0.042;
+    static final double POSITRON_ENERGY_C = 0.94;
+    // Variables for photon energy corrections
+    static final double PHOTON_ENERGY_A = 0.0015;
+    static final double PHOTON_ENERGY_B = -0.047;
+    static final double PHOTON_ENERGY_C = 0.94;
+    // 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;
+    // 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;
+    // 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;
+    
     public HPSEcalClusterIC(Long cellID) {
         this.cellID = cellID;
     }
@@ -95,55 +126,90 @@
     }
     
     /**
-     * Calculates energy correction based on cluster raw energy and particle type as per HPS Note 2014-001
+     * Calculates energy correction based on cluster raw energy and particle type as per 
+     *<a href="https://misportal.jlab.org/mis/physics/hps_notes/index.cfm?note_year=2014">HPS Note 2014-001</a>
      * @param pdg Particle id as per PDG
      * @param rawEnergy Raw Energy of the cluster (sum of hits with shared hit distribution)
      * @return Corrected Energy
      */    
-    public double energyCorrection(int pdg, double rawEnergy){
-  	   if (pdg == 11) { // Particle is electron
-  		   double corrEnergy = rawEnergy / (-0.0027 * rawEnergy - 0.06 / (Math.sqrt(rawEnergy)) + 0.95);
-  		  return corrEnergy;}
+    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
-  		   double corrEnergy = rawEnergy / (-0.0096 * rawEnergy - 0.042 / (Math.sqrt(rawEnergy)) + 0.94);
-  		  return corrEnergy;}
+		   return energyCorrection(rawEnergy, POSITRON_ENERGY_A, POSITRON_ENERGY_B, POSITRON_ENERGY_C);   
+  	   }
   	   else if (pdg == 22) { //Particle is photon
-  		   double corrEnergy = rawEnergy / (0.0015 * rawEnergy - 0.047 / (Math.sqrt(rawEnergy)) + 0.94);
-  		  return corrEnergy;}
+		   return energyCorrection(rawEnergy, PHOTON_ENERGY_A, PHOTON_ENERGY_B, PHOTON_ENERGY_C);   
+  	   }
   	   else { //Unknown 
   		   double corrEnergy = rawEnergy;
-  		  return corrEnergy;}
+  		   return corrEnergy;}
   	   
      }   
     
     /**
+     * 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>
+     * @param rawEnergy Raw energy of the cluster
+     * @param A,B,C from fitting in note
+     * @return Corrected Energy
+     */   
+    public double energyCorrection(double rawEnergy, double varA, double varB, double varC){
+    	double corrEnergy = rawEnergy / (varA * rawEnergy + varB / (Math.sqrt(rawEnergy)) + varC);
+    	return corrEnergy;
+    }
+       
+    
+    /**
      * Calculates position correction based on cluster raw energy, x calculated position, 
-     * and particle type as per HPS Note 2014-001
+     * and particle type as per 
+     * <a href="https://misportal.jlab.org/mis/physics/hps_notes/index.cfm?note_year=2014">HPS Note 2014-001</a>
      * @param pdg Particle id as per PDG
      * @param xCl Calculated x centroid position of the cluster, uncorrected, at face
      * @param rawEnergy Raw energy of the cluster (sum of hits with shared hit distribution)
      * @return Corrected x position
      */
-    public double positionCorrection(int pdg, double xPos, double rawEnergy){
+    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 = xCl-(0.0066/Math.sqrt(rawEnergy)-0.03)*xCl-
-    				(0.028*rawEnergy-0.45/Math.sqrt(rawEnergy)+0.465);
-    		return xCorr*10.0;}
-    	else if (pdg == -11) {// Particle is positron
-    		double xCorr = xCl-(0.0072/Math.sqrt(rawEnergy)-0.031)*xCl-
-    				(0.007*rawEnergy+0.342/Math.sqrt(rawEnergy)+0.108);
-    		return xCorr*10.0;}
-    	else if (pdg == 22) {// Particle is photon
-    		double xCorr = xCl-(0.005/Math.sqrt(rawEnergy)-0.032)*xCl-
-    				(0.011*rawEnergy-0.037/Math.sqrt(rawEnergy)+0.294);
-    		return xCorr*10.0;}
+    	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;}
     	}
     
     
+   /**
+    * Calculates the position correction in cm using the raw energy and variables associated with the fit
+    * of the particle as described in  
+    * <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
+    * @return
+    */    
+    public 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!?

java/branches/hps-java_HPSJAVA-88/integration-tests
pom.xml 1215 -> 1216
--- java/branches/hps-java_HPSJAVA-88/integration-tests/pom.xml	2014-10-16 05:27:54 UTC (rev 1215)
+++ java/branches/hps-java_HPSJAVA-88/integration-tests/pom.xml	2014-10-16 05:56:05 UTC (rev 1216)
@@ -28,6 +28,7 @@
                 <configuration>
                     <excludes>
                         <exclude>org/hps/EtSystemTest.java</exclude>
+                        <exclude>org/hps/TestRunReconTest.java</exclude>
                     </excludes>
                     <redirectTestOutputToFile>true</redirectTestOutputToFile>
                     <trimStackTrace>true</trimStackTrace>

java/branches/hps-java_HPSJAVA-88/integration-tests/src/test/java/org/hps
SimpleMCReconTest.java 1215 -> 1216
--- java/branches/hps-java_HPSJAVA-88/integration-tests/src/test/java/org/hps/SimpleMCReconTest.java	2014-10-16 05:27:54 UTC (rev 1215)
+++ java/branches/hps-java_HPSJAVA-88/integration-tests/src/test/java/org/hps/SimpleMCReconTest.java	2014-10-16 05:56:05 UTC (rev 1216)
@@ -1,13 +1,22 @@
 package org.hps;
 
 import java.io.File;
+import java.io.IOException;
 import java.net.URL;
 
 import junit.framework.TestCase;
 
+import org.lcsim.event.CalorimeterHit;
+import org.lcsim.event.Cluster;
+import org.lcsim.event.EventHeader;
+import org.lcsim.event.ReconstructedParticle;
+import org.lcsim.event.SimCalorimeterHit;
+import org.lcsim.event.Track;
+import org.lcsim.event.TrackerHit;
 import org.lcsim.job.JobControlManager;
 import org.lcsim.util.Driver;
 import org.lcsim.util.cache.FileCache;
+import org.lcsim.util.loop.LCSimLoop;
 import org.lcsim.util.test.TestUtil.TestOutputFile;
 
 public class SimpleMCReconTest extends TestCase {
@@ -19,11 +28,72 @@
         FileCache cache = new FileCache();
         File inputFile = cache.getCachedFile(new URL("http://www.lcsim.org/test/hps-java/SimpleMCReconTest.slcio"));
 		
+        // Run the reconstruction.
 		JobControlManager job = new JobControlManager();
         File outputFile = new TestOutputFile(this.getClass().getSimpleName() + File.separator + this.getClass().getSimpleName() + "_recon");
         job.addVariableDefinition("outputFile", outputFile.getPath());
         job.addInputFile(inputFile);
         job.setup("/org/hps/steering/recon/SimpleMCRecon.lcsim");
         job.run();
-	}	
+        
+        // Read in the LCIO event file and print out summary information.
+        System.out.println("Running ReconCheckDriver on output ...");
+        LCSimLoop loop = new LCSimLoop();
+        loop.add(new ReconCheckDriver());
+        try {
+            loop.setLCIORecordSource(new File(outputFile.getPath() + ".slcio"));
+            loop.loop(-1);
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }                
+        System.out.println("Loop processed " + loop.getTotalSupplied() + " events.");        
+        System.out.println("Done!");
+        
+	}
+	
+	static class ReconCheckDriver extends Driver {
+        
+        int nTracks;
+        int nClusters;        
+        int nTrackerHits;
+        int nSimCalorimeterHits;
+        int nCalorimeterHits;
+        int nReconstructedParticles;
+        int nEvents;
+        
+        public void process(EventHeader event) {
+            ++nEvents;
+            if (event.hasCollection(Track.class, "MatchedTracks")) {
+                nTracks += event.get(Track.class, "MatchedTracks").size();
+            }
+            if (event.hasCollection(Cluster.class, "EcalClusters")) {
+                nClusters += event.get(Cluster.class, "EcalClusters").size();
+            }
+            if (event.hasCollection(TrackerHit.class, "RotatedHelicalTrackHits")) {
+                nTrackerHits += event.get(TrackerHit.class, "RotatedHelicalTrackHits").size();
+            }
+            if (event.hasCollection(SimCalorimeterHit.class, "EcalHits")) {
+                nSimCalorimeterHits += event.get(SimCalorimeterHit.class, "EcalHits").size();
+            }
+            if (event.hasCollection(CalorimeterHit.class, "EcalCalHits")) {
+                nCalorimeterHits += event.get(CalorimeterHit.class, "EcalCalHits").size();
+            }
+            if (event.hasCollection(ReconstructedParticle.class, "FinalStateParticles")) {
+                nReconstructedParticles += event.get(ReconstructedParticle.class, "FinalStateParticles").size();
+            }
+        }        
+        
+        public void endOfData() {
+            System.out.println("ReconCheckDriver results ...");
+            System.out.println("  nEvents: " + nEvents);
+            System.out.println("  nTracks: " + nTracks);
+            System.out.println("  nClusters: " + nClusters);
+            System.out.println("  nTrackerHits: " + nTrackerHits);
+            System.out.println("  nSimCalorimeterHits: " + nSimCalorimeterHits);
+            System.out.println("  nCalorimeterHits: " + nCalorimeterHits);
+            System.out.println("  nReconstructedParticles: " + nReconstructedParticles);
+            System.out.println("  nTracks / nEvents = " + (double)nTracks / (double)nEvents);
+            System.out.println("  nClusters / nEvents = " + (double)nClusters / (double)nEvents);
+        }
+    }              
 }
\ No newline at end of file

java/branches/hps-java_HPSJAVA-88/recon/src/main/java/org/hps/recon/particle
ReconParticleDriverIC.java 1215 -> 1216
--- java/branches/hps-java_HPSJAVA-88/recon/src/main/java/org/hps/recon/particle/ReconParticleDriverIC.java	2014-10-16 05:27:54 UTC (rev 1215)
+++ java/branches/hps-java_HPSJAVA-88/recon/src/main/java/org/hps/recon/particle/ReconParticleDriverIC.java	2014-10-16 05:56:05 UTC (rev 1216)
@@ -8,7 +8,7 @@
 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;
@@ -19,7 +19,6 @@
 import org.lcsim.event.base.BaseReconstructedParticle;
 import org.lcsim.geometry.Detector;
 import org.lcsim.util.Driver;
-import org.hps.recon.ecal.HPSEcalClusterIC;
 
 
 /**
@@ -277,10 +276,10 @@
             	int pid = particle.getParticleIDUsed().getPDG();
             	if (pid != 11) {
             		double rawE = matchedCluster.getRawEnergy();
-            		double corrE = matchedCluster.energyCorrection(pid, rawE);
+            		double corrE = matchedCluster.enCorrection(pid, rawE);
             		matchedCluster.setEnergy(corrE);
             		double rawP[] = matchedCluster.getPosition();
-            		double corrP = matchedCluster.positionCorrection(pid, rawP[0], rawE);
+            		double corrP = matchedCluster.posCorrection(pid, rawP[0], rawE);
                     double[] corrPosition = new double[3];
                     corrPosition[0] = corrP;
                     corrPosition[1] = rawP[1];
@@ -311,10 +310,10 @@
             	int pid = particle.getParticleIDUsed().getPDG();
             	if (pid != 11) {
             		double rawE = unmatchedCluster.getRawEnergy();
-            		double corrE = unmatchedCluster.energyCorrection(pid, rawE);
+            		double corrE = unmatchedCluster.enCorrection(pid, rawE);
             		unmatchedCluster.setEnergy(corrE);
             		double rawP[] = unmatchedCluster.getPosition();
-            		double corrP = unmatchedCluster.positionCorrection(pid, rawP[0], rawE);
+            		double corrP = unmatchedCluster.posCorrection(pid, rawP[0], rawE);
                     double[] corrPosition = new double[3];
                     corrPosition[0] = corrP;
                     corrPosition[1] = rawP[1];

java/branches/hps-java_HPSJAVA-88/steering-files/src/main/resources/org/hps/steering/recon
SimpleMCRecon.lcsim 1215 -> 1216
--- java/branches/hps-java_HPSJAVA-88/steering-files/src/main/resources/org/hps/steering/recon/SimpleMCRecon.lcsim	2014-10-16 05:27:54 UTC (rev 1215)
+++ java/branches/hps-java_HPSJAVA-88/steering-files/src/main/resources/org/hps/steering/recon/SimpleMCRecon.lcsim	2014-10-16 05:56:05 UTC (rev 1216)
@@ -10,14 +10,23 @@
         <driver name="TrackerDigiDriver"/>
         <driver name="HelicalTrackHitDriver"/>
         <driver name="TrackerReconDriver"/>
+        <!-- FIXME: This should be changed to use the current ECAL clustering algorithm. -->
+        <driver name="SimpleEcalClusterer"/>
+<!--        
         <driver name="EcalRawConverter" />
         <driver name="EcalClusterer" />
+-->        
         <driver name="ReconParticle" />
+<!--        
         <driver name="TrackDataDriver" />
+-->        
         <driver name="GBLDriver"/>
         <driver name="LCIOWriter"/>
     </execute>
     <drivers>
+        <driver name="SimpleEcalClusterer" type="org.hps.recon.ecal.EcalClusterer">
+            <ecalCollectionName>EcalHits</ecalCollectionName>
+        </driver>
         <driver name="CalibrationDriver" type="org.hps.conditions.deprecated.CalibrationDriver"/>
         <driver name="EventMarkerDriver" type="org.lcsim.job.EventMarkerDriver">
             <eventInterval>10</eventInterval>
@@ -39,6 +48,7 @@
             <isMC>false</isMC>
             <gblFileName></gblFileName>
         </driver>
+<!--        
        <driver name="EcalRawConverter" type="org.hps.recon.ecal.EcalRawConverterDriver">
             <ecalCollectionName>EcalCalHits</ecalCollectionName>
             <use2014Gain>false</use2014Gain>
@@ -50,8 +60,11 @@
             <ecalCollectionName>EcalCalHits</ecalCollectionName>
             <timeCut>false</timeCut>
         </driver>
+-->        
         <driver name="ReconParticle" type="org.hps.recon.particle.HpsReconParticleDriver"/>
+<!--        
         <driver name="TrackDataDriver" type="org.hps.recon.tracking.TrackDataDriver" />
+-->        
         <driver name="LCIOWriter" type="org.lcsim.util.loop.LCIODriver">
             <outputFilePath>${outputFile}</outputFilePath>
         </driver>

java/branches/hps-java_HPSJAVA-88/users
pom.xml 1215 -> 1216
--- java/branches/hps-java_HPSJAVA-88/users/pom.xml	2014-10-16 05:27:54 UTC (rev 1215)
+++ java/branches/hps-java_HPSJAVA-88/users/pom.xml	2014-10-16 05:56:05 UTC (rev 1216)
@@ -33,6 +33,7 @@
                     <excludes>
                         <exclude>org/hps/users/jeremym/MockDataChallengeDiagnosticDriverTest.java</exclude>
                         <exclude>org/hps/users/ngraf/NearestNeighborClusterDriverTest.java</exclude>
+			<exclude>org/hps/users/holly/ECalClusterICTest.java</exclude>
                     </excludes>
                 </configuration>
             </plugin>
SVNspam 0.1