Commit in hps-java/src/main/java/org/lcsim/hps/recon/particle on MAIN
TestRunReconParticleDriver.java+52added 1.1
HpsReconParticleDriver.java+104added 1.1
ReconParticleDriver.java+86-1121.5 -> 1.6
+242-112
2 added + 1 modified, total 3 files
Create separate recon particle drivers for the test run and electron run; The test run driver uses TwoTrackVertexer while the electron run driver uses BilliorVertexer

hps-java/src/main/java/org/lcsim/hps/recon/particle
TestRunReconParticleDriver.java added at 1.1
diff -N TestRunReconParticleDriver.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ TestRunReconParticleDriver.java	15 Apr 2013 07:14:32 -0000	1.1
@@ -0,0 +1,52 @@
+package org.lcsim.hps.recon.particle;
+
+//--- java ---//
+import java.util.List;
+
+//--- lcsim ---//
+import org.lcsim.event.ReconstructedParticle;
+import org.lcsim.event.Track;
+import org.lcsim.event.Vertex;
+import org.lcsim.event.base.BaseReconstructedParticle;
+
+//--- hps-java ---//
+import org.lcsim.hps.recon.vertexing.TwoTrackVertexer;
+
+/**
+ * 
+ * @author Omar Moreno <[log in to unmask]>
+ * @version $Id: TestRunReconParticleDriver.java,v 1.1 2013/04/15 07:14:32 omoreno Exp $
+ */
+public class TestRunReconParticleDriver extends ReconParticleDriver {
+
+	public TestRunReconParticleDriver(){}; 
+	
+	@Override
+	protected void startOfData(){
+		candidatesCollectionName = "VertexedReconParticles";
+	}
+	
+	@Override
+	void vertexParticles(List<ReconstructedParticle> electrons, List<ReconstructedParticle> positrons) {
+		
+		TwoTrackVertexer vtxFitter = new TwoTrackVertexer(); 
+	
+		// Loop through both electrons and positrons and try to vertex them
+		for(ReconstructedParticle positron : positrons){
+			for(ReconstructedParticle electron : electrons){
+				
+				// Get the tracks associated with the electrons and positrons
+				Track electronTrack = electron.getTracks().get(0); 
+				Track positronTrack = positron.getTracks().get(0); 
+				
+				Vertex vertex = vtxFitter.fitVertex(electronTrack, positronTrack);
+				
+				ReconstructedParticle candidate = new BaseReconstructedParticle(); 
+				((BaseReconstructedParticle) candidate).setStartVertex(vertex);
+				candidate.addParticle(electron);
+				candidate.addParticle(positron);
+				candidates.add(candidate); 
+			}
+		}
+	}
+}

hps-java/src/main/java/org/lcsim/hps/recon/particle
HpsReconParticleDriver.java added at 1.1
diff -N HpsReconParticleDriver.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ HpsReconParticleDriver.java	15 Apr 2013 07:14:32 -0000	1.1
@@ -0,0 +1,104 @@
+package org.lcsim.hps.recon.particle;
+
+//--- java ---//
+import java.util.ArrayList;
+import java.util.List;
+
+//--- lcsim ---//
+import org.lcsim.event.ReconstructedParticle;
+import org.lcsim.event.base.BaseReconstructedParticle;
+import org.lcsim.fit.helicaltrack.HelicalTrackFit;
+import org.lcsim.recon.tracking.seedtracker.SeedCandidate;
+import org.lcsim.recon.tracking.seedtracker.SeedTrack;
+
+//--- hps-java ---//
+import org.lcsim.hps.recon.vertexing.BilliorVertexer;
+import org.lcsim.hps.recon.vertexing.BilliorVertex;
+import org.lcsim.hps.recon.vertexing.BilliorTrack;
+
+/**
+ * 
+ * @author Omar Moreno <[log in to unmask]>
+ * @version $Id: HpsReconParticleDriver.java,v 1.1 2013/04/15 07:14:32 omoreno Exp $
+ */
+public class HpsReconParticleDriver extends ReconParticleDriver {
+	
+	public HpsReconParticleDriver(){}
+
+	@Override
+	protected void startOfData(){
+		
+		candidatesCollectionName          = "AprimeUnconstrained";
+		candidatesBeamConCollectionName   = "AprimeBeamspotConstrained";
+		candidatesTargetConCollectionName = "AprimeTargetConstrained";	
+	}
+	
+	@Override
+	void vertexParticles(List<ReconstructedParticle> electrons, List<ReconstructedParticle> positrons) {
+		
+		BilliorVertexer vtxFitter = new BilliorVertexer(bField);
+		vtxFitter.doBeamSpotConstraint(false); 
+		vtxFitter.setBeamSize(beamsize);
+		
+
+		BilliorVertexer vtxFitterCon = new BilliorVertexer(bField);
+		vtxFitterCon.doBeamSpotConstraint(true); 
+		vtxFitterCon.setBeamSize(beamsize);
+		
+		BilliorVertexer vtxFitterTarget = new BilliorVertexer(bField);
+		vtxFitterTarget.doTargetConstraint(true);
+		vtxFitterCon.setBeamSize(beamsize);
+		
+		// Loop through both electrons and positrons and try to vertex them
+		ReconstructedParticle apCand       = null; 
+		for(ReconstructedParticle positron : positrons){
+			for(ReconstructedParticle electron : electrons){
+				
+				// Get the tracks associated with the electron and the positron
+				SeedTrack electronTrack = (SeedTrack) electron.getTracks().get(0); 
+				SeedTrack positronTrack = (SeedTrack) positron.getTracks().get(0); 
+				
+				// Covert the tracks to BilliorTracks used by the vertexer
+				BilliorTrack electronBTrack = this.getBilliorTrack(electronTrack); 
+				BilliorTrack positronBTrack = this.getBilliorTrack(positronTrack);
+			
+				List<BilliorTrack> billiorTracks = new ArrayList<BilliorTrack>();
+				billiorTracks.add(electronBTrack);
+				billiorTracks.add(positronBTrack);
+				
+				BilliorVertex vtxFit = vtxFitter.fitVertex(billiorTracks);
+				BilliorVertex vtxFitCon = vtxFitterCon.fitVertex(billiorTracks);
+				BilliorVertex vtxFitTarget = vtxFitterTarget.fitVertex(billiorTracks);
+				
+				apCand = new BaseReconstructedParticle(); 
+				((BaseReconstructedParticle) apCand).setStartVertex(vtxFit);
+				apCand.addParticle(electron);
+				apCand.addParticle(positron);
+				candidates.add(apCand); 
+				
+				apCand = new BaseReconstructedParticle(); 
+				((BaseReconstructedParticle) apCand).setStartVertex(vtxFitCon);
+				apCand.addParticle(electron);
+				apCand.addParticle(positron);
+				candidatesBeamCon.add(apCand);
+				
+				apCand = new BaseReconstructedParticle(); 
+				((BaseReconstructedParticle) apCand).setStartVertex(vtxFitTarget);
+				apCand.addParticle(electron);
+				apCand.addParticle(positron);
+				candidatesTargetCon.add(apCand);
+				
+			}
+		}
+	}
+
+	/**
+	 * 
+	 */
+    private BilliorTrack getBilliorTrack(SeedTrack seedTrack) {
+    	
+    	SeedCandidate seedCan = seedTrack.getSeedCandidate(); 
+    	HelicalTrackFit trackFit = seedCan.getHelix(); 
+    	return new BilliorTrack(trackFit);
+    }
+}

hps-java/src/main/java/org/lcsim/hps/recon/particle
ReconParticleDriver.java 1.5 -> 1.6
diff -u -r1.5 -r1.6
--- ReconParticleDriver.java	12 Apr 2013 17:25:07 -0000	1.5
+++ ReconParticleDriver.java	15 Apr 2013 07:14:32 -0000	1.6
@@ -14,17 +14,12 @@
 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.SeedCandidate;
-import org.lcsim.recon.tracking.seedtracker.SeedTrack;
+import org.lcsim.geometry.Detector;
 import org.lcsim.util.Driver;
 
 //--- hps-java ---//
 import org.lcsim.hps.recon.ecal.HPSEcalCluster;
 import org.lcsim.hps.recon.tracking.SvtTrackExtrapolator;
-import org.lcsim.hps.recon.vertexing.BilliorTrack;
-import org.lcsim.hps.recon.vertexing.BilliorVertex;
-import org.lcsim.hps.recon.vertexing.BilliorVertexer;
 
 /**
  * Driver that matches SVT Tracks and Ecal Clusters and creates
@@ -32,24 +27,20 @@
  *
  * @author Mathew Graham <[log in to unmask]>
  * @author Omar Moreno <[log in to unmask]>
- * @version $Id: ReconParticleDriver.java,v 1.5 2013/04/12 17:25:07 omoreno Exp $ 
+ * @version $Id: ReconParticleDriver.java,v 1.6 2013/04/15 07:14:32 omoreno Exp $ 
  */
-public class ReconParticleDriver extends Driver {
+public abstract class ReconParticleDriver extends Driver {
 
 	SvtTrackExtrapolator extrapolator = new SvtTrackExtrapolator();
-	
-	// List to contained all tracks which have been matched in an event
-	List<Track> matchedTracks; 	
-	List<HPSEcalCluster> matchedClusters; 
-	
+
 	// Flags
 	boolean debug = false; 
 	
 	// Reconstructed particle collections
 	List<ReconstructedParticle> reconParticles;
-    List<ReconstructedParticle> aprimeCands;
-    List<ReconstructedParticle> aprimeCandsCon;
-    List<ReconstructedParticle> aprimeCandsTarget;
+    List<ReconstructedParticle> candidates;
+    List<ReconstructedParticle> candidatesBeamCon;
+    List<ReconstructedParticle> candidatesTargetCon;
     List<ReconstructedParticle> electrons;
     List<ReconstructedParticle> positrons;
     
@@ -57,13 +48,16 @@
     String ecalClustersCollectionName 			= "EcalClusters";
     String tracksCollectionName       			= "MatchedTracks";
     String finalStateParticlesCollectionName 	= "FinalStateParticles";
-    String aprimeCandidatesName 				= "APrimeUnconstrained";
-    String aprimeCandidatesConstrainedName 		= "APrimeBeamspotConstrained";
-    String aprimeCandidatesTargetName 			= "APrimeTargetConstrained";
+    String candidatesCollectionName 			= null; 
+    String candidatesBeamConCollectionName 		= null;
+    String candidatesTargetConCollectionName	= null;
+    String vertexCandidatesCollectionName       = null;
+    String vertexBeamConsCandidatesName         = null;
     
     // The beamsize array is in the tracking frame
     double[] beamsize = {0.001, 0.2, 0.02};
     double maxTrackClusterDistance = 1000; // [mm] 
+	double bField; 
     
      
     //  flipSign is a kludge...
@@ -105,14 +99,19 @@
     public void setBeamSigmaY(double sigma_y) {
         beamsize[2] = sigma_y;  
     }
+    
+    
+	@Override
+	protected void detectorChanged(Detector detector){
+		
+		Hep3Vector ip = new BasicHep3Vector(0., 0., 1.);
+		bField = detector.getFieldMap().getField(ip).y(); 
+		if(bField < 0) flipSign = -1; 
+	
+	}
 
     public void process(EventHeader event) {
        
-    	// Set the sign of the variable flipSign (See above for details)
-    	Hep3Vector IP = new BasicHep3Vector(0., 0., 1.);
-        double bfield = event.getDetector().getFieldMap().getField(IP).y();
-        if (bfield < 0) flipSign = -1;
-
         // If the event does not have Ecal clusters, skip the event
         if (!event.hasCollection(HPSEcalCluster.class, ecalClustersCollectionName)) return;
         
@@ -121,37 +120,59 @@
         if(clusters.isEmpty()) return; 
         this.printDebug("Number of Ecal clusters: " + clusters.size());
         
-        
         // Get the tracks in the event
         List<Track> tracks = event.get(Track.class, tracksCollectionName);
         this.printDebug("Number of Tracks: " + tracks.size()); 
 
-        
-        
-        // Instantiate the list of matched tracks and clusters. This list 
-        // will be used to check if a track has already been previously matched
-        matchedTracks = new ArrayList<Track>(); 
-        matchedClusters = new ArrayList<HPSEcalCluster>(); 
-        
-        reconParticles	= new ArrayList<ReconstructedParticle>();
-        aprimeCands 	= new ArrayList<ReconstructedParticle>();
-        aprimeCandsCon 	= new ArrayList<ReconstructedParticle>();
-        aprimeCandsTarget	= new ArrayList<ReconstructedParticle>();
-        electrons = new ArrayList<ReconstructedParticle>();
-        positrons = new ArrayList<ReconstructedParticle>();
+        reconParticles		= new ArrayList<ReconstructedParticle>();
+        electrons 			= new ArrayList<ReconstructedParticle>();
+        positrons 			= new ArrayList<ReconstructedParticle>();
+        candidates 			= new ArrayList<ReconstructedParticle>();
+        candidatesBeamCon 	= new ArrayList<ReconstructedParticle>(); 
+        candidatesTargetCon = new ArrayList<ReconstructedParticle>(); 
 
         // If there are clusters and tracks in the event, try to match them
         // to each other
-        if (!tracks.isEmpty() && !clusters.isEmpty()) {
+        if (!tracks.isEmpty() && !clusters.isEmpty()) this.matchTracksToClusters(clusters, tracks);
 
-        	// Loop over all Ecal clusters in the event
-        	HPSEcalCluster matchedCluster = null; 
+        // Put all the reconstructed particles in the event
+        event.put(finalStateParticlesCollectionName, reconParticles, ReconstructedParticle.class, 0);
+
+        // Vertex electron and positron candidates 
+        vertexParticles(electrons, positrons);
+       
+        // If the list exist, put the vertexed candidates into the event
+        if(candidatesCollectionName != null)
+        	event.put(candidatesCollectionName, candidates, ReconstructedParticle.class, 0);
+        if(candidatesBeamConCollectionName != null)
+        	event.put(candidatesBeamConCollectionName, candidatesBeamCon, ReconstructedParticle.class, 0);
+        if(candidatesTargetConCollectionName != null)
+        	event.put(candidatesTargetConCollectionName, candidatesTargetCon, ReconstructedParticle.class, 0);
+    }
+
+    /**
+     * 
+     */
+    abstract void vertexParticles(List<ReconstructedParticle> electrons, List<ReconstructedParticle> positrons);
+    
+    /**
+     * 
+     */
+    private void matchTracksToClusters(List<HPSEcalCluster> clusters, List<Track> tracks){
+    	
+        	// Instantiate the list of matched tracks and clusters. This list 
+        	// will be used to check if a track has already been previously matched
+        	List<Track> matchedTracks = new ArrayList<Track>(); 
+    	    List<HPSEcalCluster> matchedClusters = new ArrayList<HPSEcalCluster>(); 
+        	
+        	// Loop over all clusters 
+    	    HPSEcalCluster matchedCluster = null;
         	for(HPSEcalCluster cluster : clusters){
-        		
+    	
         		// If the cluster has already been matched to a track, continue
         		// on to the next cluster
         		if(matchedClusters.contains(cluster)) continue;
-        		matchedCluster = cluster; 
+        		matchedCluster = cluster; 	
         		
         		// Get the Ecal cluster position
         		Hep3Vector clusterPos = new BasicHep3Vector(cluster.getPosition());
@@ -162,7 +183,7 @@
                 double rMax = Double.MAX_VALUE;
         		// Loop over all tracks in the event
                 for(Track track : tracks){        	
-        		
+                	
                 	// Check if the track has already been matched to another cluster
                 	if(matchedTracks.contains(track)){
                 		this.printDebug("Track has already been matched"); 
@@ -194,8 +215,9 @@
                         matchedTrack = track; 
                         matchedTrackPosition = trkPosAtShowerMax; 
                     }
-        		}
-               
+                }
+                
+                
                 // If a matching track isn't found, continue to the next cluster 
                 // in the event. This will occur when a track is found to have 
                 // NaN coordinate values as explained above or when the distance
@@ -209,13 +231,22 @@
                 // Check if the track is a closer match to any other cluster in
                 // the event
                 for(HPSEcalCluster ecalCluster : clusters){ 
+                	
+                	// Skip the current cluster and any other cluster that has 
+                	// been matched already
                 	if(ecalCluster.equals(cluster) || matchedClusters.contains(ecalCluster)) continue; 
                 	
+                	// Get the Ecal cluster position
                 	Hep3Vector ecalClusterPos = new BasicHep3Vector(ecalCluster.getPosition());
                 	this.printDebug("Ecal cluster position: " + ecalClusterPos.toString());
+                	
+                	// Get the position of the track at the Ecal cluster shower max
                 	extrapolator.setTrack(matchedTrack);
                 	Hep3Vector trkPosAtShowerMax = extrapolator.extrapolateTrack(ecalClusterPos.z());
         			this.printDebug("Track position at shower max: " + trkPosAtShowerMax.toString());
+        			
+        			// Get the distance between the track and the cluster position
+        			// and check if the track has a better cluster match
         			double r = VecOp.sub(trkPosAtShowerMax, ecalClusterPos).magnitude();
         			if(r < rMax && r <= maxTrackClusterDistance){
         				rMax = r; 
@@ -235,15 +266,14 @@
                 particle.addCluster(matchedCluster); 
                 particle.addTrack(matchedTrack); 
                 reconParticles.add(particle);	
-        	        	
+        	
                 // Add the particle to either the collection of possible
                 // electrons or positrons
                 if(matchedTrack.getCharge()*flipSign > 0) positrons.add(particle);
                 else electrons.add(particle); 
-                	
-        	}	
-        } 
-       
+        	
+        	}
+        	
         // After iterating through all tracks, if there still
         // exist some clusters in the list then assign them 
         // to their own reconstructed particles
@@ -254,70 +284,14 @@
                 reconParticles.add(particle);
             }
         }
-
-        // Put all the reconstructed particles in the event
-        event.put(finalStateParticlesCollectionName, reconParticles, ReconstructedParticle.class, 0);
-
-        BilliorVertexer vtxfitter = new BilliorVertexer(bfield);
-        vtxfitter.doBeamSpotConstraint(false);
-        vtxfitter.setBeamSize(beamsize);
-
-        BilliorVertexer vtxfitterCon = new BilliorVertexer(bfield);
-        vtxfitterCon.doBeamSpotConstraint(true);
-        vtxfitterCon.setBeamSize(beamsize);
-
-        BilliorVertexer vtxfitterTarget = new BilliorVertexer(bfield);
-        vtxfitterTarget.doTargetConstraint(true);
-        vtxfitterTarget.setBeamSize(beamsize);
-
-        for (ReconstructedParticle pos : positrons) {
-            for (ReconstructedParticle ele : electrons) {
-                SeedTrack eleTrack=(SeedTrack) ele.getTracks().get(0);
-                SeedTrack posTrack=(SeedTrack) pos.getTracks().get(0);
-                BilliorTrack btEle = getBilliorTrack( eleTrack);
-                BilliorTrack btPos = getBilliorTrack( posTrack);
-                List<BilliorTrack> btlist = new ArrayList<BilliorTrack>();
-                btlist.add(btEle);
-                btlist.add(btPos);
-                BilliorVertex vtxfit = vtxfitter.fitVertex(btlist);
-                BilliorVertex vtxfitCon = vtxfitterCon.fitVertex(btlist);
-                BilliorVertex vtxfitTarget = vtxfitterTarget.fitVertex(btlist);
-
-                BaseReconstructedParticle apCand = new BaseReconstructedParticle();
-                apCand.setStartVertex(vtxfit);
-                apCand.addParticle(ele);
-                apCand.addParticle(pos);
-                aprimeCands.add(apCand);
-
-                BaseReconstructedParticle apCandCon = new BaseReconstructedParticle();
-                apCandCon.setStartVertex(vtxfitCon);
-                apCandCon.addParticle(ele);
-                apCandCon.addParticle(pos);
-                aprimeCandsCon.add(apCandCon);
-
-                BaseReconstructedParticle apCandTarget = new BaseReconstructedParticle();
-                apCandTarget.setStartVertex(vtxfitTarget);
-                apCandTarget.addParticle(ele);
-                apCandTarget.addParticle(pos);
-                aprimeCandsTarget.add(apCandTarget);
-            }
-        }
-
-        event.put(aprimeCandidatesConstrainedName, aprimeCandsCon, ReconstructedParticle.class, 0);
-        event.put(aprimeCandidatesTargetName, aprimeCandsTarget, ReconstructedParticle.class, 0);
-        event.put(aprimeCandidatesName, aprimeCands, ReconstructedParticle.class, 0);
-
     }
-
+       
+    /**
+     * 
+     * @param debugMessage
+     */
     private void printDebug(String debugMessage){
     	if(debug)
     		System.out.println(this.getClass().getSimpleName() + ": " + debugMessage); 
     }
-    
-    private BilliorTrack getBilliorTrack(SeedTrack st) {
-        SeedTrack stEle = (SeedTrack) st;
-        SeedCandidate seedEle = stEle.getSeedCandidate();
-        HelicalTrackFit htEle = seedEle.getHelix();
-        return new BilliorTrack(htEle);
-    }
 }
CVSspam 0.2.12


Use REPLY-ALL to reply to list

To unsubscribe from the LCD-CVS list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=LCD-CVS&A=1