Print

Print


Commit in java/trunk/recon/src on MAIN
main/java/org/hps/recon/particle/HpsReconParticleDriver.java+17-4605 -> 606
                                /ReconParticleDriver.java+12-4605 -> 606
test/java/org/hps/recon/particle/HpsReconParticleDriverTest.java+30-16605 -> 606
+59-24
3 modified files
Rotate the momentum vector of final state and vertexed particles from the tracking frame to the detector frame.  Update HpsReconParticleDriverTest to reflect the changes.

java/trunk/recon/src/main/java/org/hps/recon/particle
HpsReconParticleDriver.java 605 -> 606
--- java/trunk/recon/src/main/java/org/hps/recon/particle/HpsReconParticleDriver.java	2014-05-19 20:38:26 UTC (rev 605)
+++ java/trunk/recon/src/main/java/org/hps/recon/particle/HpsReconParticleDriver.java	2014-05-19 22:19:40 UTC (rev 606)
@@ -9,15 +9,18 @@
 import java.util.ArrayList;
 import java.util.List;
 
-import org.hps.recon.vertexing.BilliorTrack;
-import org.hps.recon.vertexing.BilliorVertex;
-import org.hps.recon.vertexing.BilliorVertexer;
 import org.lcsim.event.ReconstructedParticle;
 import org.lcsim.event.Track;
 import org.lcsim.event.base.BaseReconstructedParticle;
 import org.lcsim.fit.helicaltrack.HelicalTrackFit;
 import org.lcsim.recon.tracking.seedtracker.SeedTrack;
 
+import org.hps.recon.tracking.CoordinateTransformations;
+import org.hps.recon.vertexing.BilliorTrack;
+import org.hps.recon.vertexing.BilliorVertex;
+import org.hps.recon.vertexing.BilliorVertexer;
+
+
 /**
  * 
  * @author Omar Moreno <[log in to unmask]>
@@ -79,7 +82,8 @@
 				((BaseReconstructedParticle) candidate).setStartVertex(vtxFit);
 				candidate.addParticle(electron);
 				candidate.addParticle(positron);
-				// TODO: This should probably be done within BilliorVertex
+				// TODO: The calculation of the total fitted momentum should be done within 
+				// 		 BilloirVertex
 				((BaseReconstructedParticle) candidate).setMass(vtxFit.getParameters().get("invMass"));
 				Hep3Vector fittedMomentum = new BasicHep3Vector(vtxFit.getParameters().get("p1X"), 
 																vtxFit.getParameters().get("p1Y"), 
@@ -87,6 +91,9 @@
 				fittedMomentum = VecOp.add(fittedMomentum, new BasicHep3Vector(vtxFit.getParameters().get("p2X"), 
 																			   vtxFit.getParameters().get("p2Y"),
 																			   vtxFit.getParameters().get("p2Z")));
+				this.printDebug("Fitted momentum in tracking frame: " + fittedMomentum.toString());
+				fittedMomentum = CoordinateTransformations.transformVectorToDetector(fittedMomentum);
+				this.printDebug("Fitted momentum in detector frame: " + fittedMomentum.toString());
 				HepLorentzVector fourVector = new BasicHepLorentzVector(0, 0, 0, 0); 
     			((BasicHepLorentzVector) fourVector).setV3(fourVector.t(), fittedMomentum);
 				((BaseReconstructedParticle) candidate).set4Vector(fourVector);
@@ -103,6 +110,9 @@
 				fittedMomentum = VecOp.add(fittedMomentum, new BasicHep3Vector(vtxFitCon.getParameters().get("p2X"), 
 																			   vtxFitCon.getParameters().get("p2Y"),
 																			   vtxFitCon.getParameters().get("p2Z")));
+				this.printDebug("Fitted momentum in tracking frame: " + fittedMomentum.toString());
+				fittedMomentum = CoordinateTransformations.transformVectorToDetector(fittedMomentum);
+				this.printDebug("Fitted momentum in detector frame: " + fittedMomentum.toString());
 				fourVector = new BasicHepLorentzVector(0, 0, 0, 0); 
     			((BasicHepLorentzVector) fourVector).setV3(fourVector.t(), fittedMomentum);
 				((BaseReconstructedParticle) candidate).set4Vector(fourVector);
@@ -119,6 +129,9 @@
 				fittedMomentum = VecOp.add(fittedMomentum, new BasicHep3Vector(vtxFitTarget.getParameters().get("p2X"), 
 																			   vtxFitTarget.getParameters().get("p2Y"),
 																			   vtxFitTarget.getParameters().get("p2Z")));
+				this.printDebug("Fitted momentum in tracking frame: " + fittedMomentum.toString());
+				fittedMomentum = CoordinateTransformations.transformVectorToDetector(fittedMomentum);
+				this.printDebug("Fitted momentum in detector frame: " + fittedMomentum.toString());
 				fourVector = new BasicHepLorentzVector(0, 0, 0, 0); 
     			((BasicHepLorentzVector) fourVector).setV3(fourVector.t(), fittedMomentum);
 				((BaseReconstructedParticle) candidate).set4Vector(fourVector);

java/trunk/recon/src/main/java/org/hps/recon/particle
ReconParticleDriver.java 605 -> 606
--- java/trunk/recon/src/main/java/org/hps/recon/particle/ReconParticleDriver.java	2014-05-19 20:38:26 UTC (rev 605)
+++ java/trunk/recon/src/main/java/org/hps/recon/particle/ReconParticleDriver.java	2014-05-19 22:19:40 UTC (rev 606)
@@ -16,6 +16,7 @@
 import org.lcsim.geometry.Detector;
 import org.lcsim.util.Driver;
 import org.hps.recon.ecal.HPSEcalCluster;
+import org.hps.recon.tracking.CoordinateTransformations;
 import org.hps.recon.tracking.TrackUtils;
 
 /**
@@ -186,7 +187,9 @@
     		
     			// Check if the Ecal cluster and track are within the same 
     			// detector volume i.e. both top or bottom
-                    /* TODO:  mg-May 14, 2014 does getTrackStates().get(0).getZ0() really get the z-pos (y in detector frame) @ the ECAL or anywhere other than the POCA??? Where is this calculated*/
+                // TODO:  mg-May 14, 2014 does getTrackStates().get(0).getZ0() 
+    			// really get the z-pos (y in detector frame) @ the ECAL or anywhere
+    			// other than the POCA??? Where is this calculated
     			if(clusterPosition.y()*track.getTrackStates().get(0).getZ0() < 0){
     				this.printDebug("Track and Ecal cluster are in opposite volumes. Track Z0 = " + track.getTrackStates().get(0).getZ0());
     				continue; 
@@ -212,8 +215,7 @@
                 }
     		}
     		
-    		// Create a reconstructed particle and add it to the 
-    		// collection of particles
+    		// Create a reconstructed particle and add it to the collection of particles
     		ReconstructedParticle particle = new BaseReconstructedParticle(); 
     		HepLorentzVector fourVector = new BasicHepLorentzVector(0, 0, 0, 0); 
     		particle.addCluster(cluster); 
@@ -221,6 +223,9 @@
     		if(matchedTrack != null){
     			particle.addTrack(matchedTrack);
     			Hep3Vector momentum = new BasicHep3Vector(matchedTrack.getTrackStates().get(0).getMomentum());
+    			this.printDebug("Momentum in tracking frame: " + momentum.toString());
+    			momentum = CoordinateTransformations.transformVectorToDetector(momentum);
+    			this.printDebug("Momentum in detector frame: " + momentum.toString());
     			((BasicHepLorentzVector) fourVector).setV3(fourVector.t(), momentum);
     			((BaseReconstructedParticle) particle).setCharge(matchedTrack.getCharge()*flipSign);
     			if(particle.getCharge() > 0){
@@ -247,6 +252,9 @@
     			
     			particle.addTrack(unmatchedTrack);
     			Hep3Vector momentum = new BasicHep3Vector(unmatchedTrack.getTrackStates().get(0).getMomentum());
+    			this.printDebug("Momentum in tracking frame: " + momentum.toString());
+    			momentum = CoordinateTransformations.transformVectorToDetector(momentum);
+    			this.printDebug("Momentum in detector frame: " + momentum.toString());
     			((BasicHepLorentzVector) fourVector).setV3(momentum.magnitude(), momentum);
     			((BaseReconstructedParticle) particle).setCharge(unmatchedTrack.getCharge()*flipSign);
     			((BaseReconstructedParticle) particle).set4Vector(fourVector);
@@ -266,7 +274,7 @@
      * 
      * @param debugMessage
      */
-    private void printDebug(String debugMessage){
+    protected void printDebug(String debugMessage){
     	if(debug)
     		System.out.println(this.getClass().getSimpleName() + ": " + debugMessage); 
     }

java/trunk/recon/src/test/java/org/hps/recon/particle
HpsReconParticleDriverTest.java 605 -> 606
--- java/trunk/recon/src/test/java/org/hps/recon/particle/HpsReconParticleDriverTest.java	2014-05-19 20:38:26 UTC (rev 605)
+++ java/trunk/recon/src/test/java/org/hps/recon/particle/HpsReconParticleDriverTest.java	2014-05-19 22:19:40 UTC (rev 606)
@@ -14,6 +14,7 @@
 import hep.physics.vec.Hep3Vector;
 
 import org.hps.recon.particle.HpsReconParticleDriver; 
+import org.hps.recon.tracking.CoordinateTransformations;
 import org.hps.recon.ecal.HPSEcalCluster;
 
 
@@ -38,30 +39,30 @@
    		// Create a pair of ideal e+e- tracks in opposite detector volumes.
    		// The e+ track is created on the bottom half of the detector while
    		// the e- track is created on the top half.
-   		BaseTrack topTrack = new BaseTrack(); 
+   		Track electronTrack = new BaseTrack(); 
    		trackParameters[BaseTrack.D0] = 0.41051;
    		trackParameters[BaseTrack.OMEGA] = -2.2584e-4; 
    		trackParameters[BaseTrack.PHI] = 6.2626; 
    		trackParameters[BaseTrack.TANLAMBDA] = 0.046548; 
    		trackParameters[BaseTrack.Z0] = .23732; 
-   		topTrack.setTrackParameters(trackParameters, B_FIELD);
+   		((BaseTrack) electronTrack).setTrackParameters(trackParameters, B_FIELD);
    		
-   		System.out.println("\n[ Track ] Top:  \n" + topTrack.toString());
+   		System.out.println("\n[ Track ] Electron:  \n" + electronTrack.toString());
    		
-   		BaseTrack bottomTrack = new BaseTrack();
+   		Track positronTrack = new BaseTrack();
    		trackParameters[BaseTrack.D0] = 0.19691;
    		trackParameters[BaseTrack.OMEGA] = 1.005e-4; 
    		trackParameters[BaseTrack.PHI] = 6.2447; 
    		trackParameters[BaseTrack.TANLAMBDA] = -0.024134; 
    		trackParameters[BaseTrack.Z0] = -0.040231; 
-   		bottomTrack.setTrackParameters(trackParameters, B_FIELD);
+   		((BaseTrack) positronTrack).setTrackParameters(trackParameters, B_FIELD);
 
-   		System.out.println("\n[ Track ] Bottom: \n" + bottomTrack.toString());
+   		System.out.println("\n[ Track ] Positron: \n" + positronTrack.toString());
 
    		// Add the tracks to the list of tracks that will be used for test
    		// purposes.
-   		tracks.add(topTrack);
-   		tracks.add(bottomTrack);
+   		tracks.add(electronTrack);
+   		tracks.add(positronTrack);
    		
    		System.out.println("\n#=== Creating Ideal Ecal Clusters ===#\n");
    		
@@ -100,7 +101,8 @@
    		clusters.add(topCluster);
    		clusters.add(bottomCluster);
    		
-   		particleDriver = new HpsReconParticleDriver(); 
+   		particleDriver = new HpsReconParticleDriver();
+   		particleDriver.setDebug(true);
    	}
    	
    	public void testMakeReconstructedParticles(){
@@ -139,19 +141,22 @@
     	}
     	
     	//
-    	// Check that the momentum of the ReconstructedParticles was set properly
+    	// Check that the momentum of the ReconstructedParticles was set properly 
+    	// and rotated to the detector frame.
     	//
-    	Hep3Vector topMomentum = new BasicHep3Vector(tracks.get(0).getTrackStates().get(0).getMomentum());
+    	Hep3Vector electronMomentum = new BasicHep3Vector(tracks.get(0).getTrackStates().get(0).getMomentum());
+    	electronMomentum = CoordinateTransformations.transformVectorToDetector(electronMomentum);
     	assertTrue("The momentum of the track and ReconstructedParticle don't match! Top track p = " 
-    				+ topMomentum.toString() + " Recon particle p = " + particleTracks.get(0).getMomentum().toString(),
-    				particleTracks.get(0).getMomentum().equals(topMomentum));
+    				+ electronMomentum.toString() + " Recon particle p = " + particleTracks.get(0).getMomentum().toString(),
+    				particleTracks.get(0).getMomentum().equals(electronMomentum));
     	
     	System.out.println("The momentum of the first ReconstructedParticle: " + particleTracks.get(0).getMomentum().toString());
     	
-    	Hep3Vector bottomMomentum = new BasicHep3Vector(tracks.get(1).getTrackStates().get(0).getMomentum());
+    	Hep3Vector positronMomentum = new BasicHep3Vector(tracks.get(1).getTrackStates().get(0).getMomentum());
+    	positronMomentum = CoordinateTransformations.transformVectorToDetector(positronMomentum);
     	assertTrue("The momentum of track and ReconstructedParticle don't march! Bottom track p = "
-    			    + bottomMomentum.toString() + " Recon particle p = " + particleTracks.get(1).getMomentum().toString(),
-    			    particleTracks.get(1).getMomentum().equals(bottomMomentum));
+    			    + positronMomentum.toString() + " Recon particle p = " + particleTracks.get(1).getMomentum().toString(),
+    			    particleTracks.get(1).getMomentum().equals(positronMomentum));
     	
     	System.out.println("The momentum of the second ReconstructedParticle: " + particleTracks.get(1).getMomentum().toString());
     	
@@ -159,5 +164,14 @@
    	
    	public void testVertexParticles(){
    	
+    	// Create two ReconstructedParticles with tracks only
+    	//List<HPSEcalCluster> emptyClusters = new ArrayList<HPSEcalCluster>(); 
+    	//particleTracks = particleDriver.makeReconstructedParticles(emptyClusters, tracks);
+
+    	//List<ReconstructedParticle> electrons = particleTracks.subList(0, 1);
+   		//List<ReconstructedParticle> positrons = particleTracks.subList(1, 2);
+   	
+   		//particleDriver.vertexParticles(electrons, positrons);
+   		
    	}
 }
SVNspam 0.1