Print

Print


Commit in hps-java/src/main/java/org/lcsim/hps/recon/particle on MAIN
ReconParticleDriver.java+85-661.2 -> 1.3
Removed some assumptions; Small changes

hps-java/src/main/java/org/lcsim/hps/recon/particle
ReconParticleDriver.java 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- ReconParticleDriver.java	13 Mar 2013 19:24:20 -0000	1.2
+++ ReconParticleDriver.java	21 Mar 2013 17:33:31 -0000	1.3
@@ -6,6 +6,7 @@
 import java.util.List;
 import org.lcsim.event.EventHeader;
 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.hps.recon.ecal.HPSEcalCluster;
@@ -18,21 +19,37 @@
 import org.lcsim.util.Driver;
 
 /**
-
- @author mgraham
+ * Driver that matches SVT Tracks and Ecal Clusters and creates
+ * ReconstructedParticles.
+ *
+ * @author Mathew Graham <[log in to unmask]>
+ * @author Omar Moreno <[log in to unmask]>
+ * @version $Id: ReconParticleDriver.java,v 1.3 2013/03/21 17:33:31 omoreno Exp $ 
  */
 public class ReconParticleDriver extends Driver {
 
+	SvtTrackExtrapolator extrapolator = new SvtTrackExtrapolator();
+	
+	// Reconstructed particle collections
+	List<ReconstructedParticle> reconParticles;
+    List<ReconstructedParticle> aprimeCands;
+    List<ReconstructedParticle> aprimeCandsCon;
+    List<ReconstructedParticle> aprimeCandsTarget;
+    List<ReconstructedParticle> electrons;
+    List<ReconstructedParticle> positrons;
+
+	
     double maxXTrackClusterMatchResidual = 100; // [mm]
     double maxYTrackClusterMatchResidual = 100; // [mm]
+    
     // Collections
-    String ecalClustersCollectionName = "EcalClusters";
-    String tracksCollectionName = "MatchedTracks";
-    String finalStateParticlesCollectionName = "FinalStateParticles";
-    String aprimeCandidatesName = "APrimeUnconstrained";
-    String aprimeCandidatesConstrainedName = "APrimeBeamspotConstrained";
-    String aprimeCandidatesTargetName = "APrimeTargetConstrained";
-    SvtTrackExtrapolator extrapolator = new SvtTrackExtrapolator();
+    String ecalClustersCollectionName 			= "EcalClusters";
+    String tracksCollectionName       			= "MatchedTracks";
+    String finalStateParticlesCollectionName 	= "FinalStateParticles";
+    String aprimeCandidatesName 				= "APrimeUnconstrained";
+    String aprimeCandidatesConstrainedName 		= "APrimeBeamspotConstrained";
+    String aprimeCandidatesTargetName 			= "APrimeTargetConstrained";
+    
     double[] beamsize = {0.001, 0.2, 0.02};
     // flipSign is a kludge...
 //  HelicalTrackFitter doesn't deal with B-fields in -ive Z correctly
@@ -73,76 +90,78 @@
     }
 
     public void process(EventHeader event) {
-        Hep3Vector IP = new BasicHep3Vector(0., 0., 1.);
+        
+    	Hep3Vector IP = new BasicHep3Vector(0., 0., 1.);
         double bfield = event.getDetector().getFieldMap().getField(IP).y();
-        if (bfield < 0) {
-            flipSign = -1;
-        }
+        if (bfield < 0) flipSign = -1;
+        
         // If the event does not have Ecal clusters, skip the event
-        if (!event.hasCollection(HPSEcalCluster.class, ecalClustersCollectionName))
-            return;
+        if (!event.hasCollection(HPSEcalCluster.class, ecalClustersCollectionName)) return;
+        
         // Get the clusters in the event
         List<HPSEcalCluster> clusters = event.get(HPSEcalCluster.class, ecalClustersCollectionName);
+        
         // Get the tracks in the event
-        List<SeedTrack> tracks = event.get(SeedTrack.class, tracksCollectionName);
+        List<Track> tracks = event.get(Track.class, tracksCollectionName);
 
-        List<ReconstructedParticle> reconParticles = new ArrayList<ReconstructedParticle>();
-        List<ReconstructedParticle> aprimeCands = new ArrayList<ReconstructedParticle>();
-        List<ReconstructedParticle> aprimeCandsCon = new ArrayList<ReconstructedParticle>();
-        List<ReconstructedParticle> aprimeCandsTarget = new ArrayList<ReconstructedParticle>();
-
-        List<ReconstructedParticle> electrons = new ArrayList<ReconstructedParticle>();
-        List<ReconstructedParticle> positrons = new ArrayList<ReconstructedParticle>();
+        reconParticles	= new ArrayList<ReconstructedParticle>();
+        aprimeCands 	= new ArrayList<ReconstructedParticle>();
+        aprimeCandsCon 	= new ArrayList<ReconstructedParticle>();
+        aprimeCandsTarget	= new ArrayList<ReconstructedParticle>();
+        electrons = new ArrayList<ReconstructedParticle>();
+        positrons = new ArrayList<ReconstructedParticle>();
 
         // Match tracks to clusters
         if (!tracks.isEmpty()) {
 
-            // If the event only contains a single cluster and a single track then they are most
-            // likely associated with each other
-            if (clusters.size() == 1 && tracks.size() == 1) {
-
+            // Loop over all tracks and find the associated EcalCluster
+        	for(Track track : tracks){
+        		
+        		// Set the track to extrapolate
+        		extrapolator.setTrack(track);
+        		
+        		// Get the track position at the Ecal
+        		Hep3Vector positionAtEcal = extrapolator.getTrackPositionAtEcal();
+        		
+        		// Iterate over all Ecal clusters and find the cluster which is
+        		// closest to the track
+                double rMax = 1000;
+                HPSEcalCluster matchedCluster = null;
+        		for(HPSEcalCluster cluster : clusters){
+        			
+        			// Get the cluster position
+        			Hep3Vector clusterPosition = new BasicHep3Vector(cluster.getPosition());
+        			
+        			double xDiff = positionAtEcal.x() - clusterPosition.x();
+                    double yDiff = positionAtEcal.y() - clusterPosition.y();
+                    double r = Math.sqrt(xDiff * xDiff + yDiff * yDiff);
+                    
+                    // TODO:  Also need to check if r is less than some maximum optimized value
+                    if (r < rMax) {
+                        rMax = r;
+                        matchedCluster = cluster;
+                    }
+        		}
+        		
+        		// Remove the matched Ecal cluster from the collection of clusters so 
+        		// its not matched to another track
+        		clusters.remove(matchedCluster);
+        		
+        		// Create a reconstructed particle and add it to collection of 
+        		// reconstructed particles
                 ReconstructedParticle particle = new BaseReconstructedParticle();
-                particle.addCluster(clusters.get(0));
-                particle.addTrack(tracks.get(0));
+                particle.addCluster(matchedCluster);
+                particle.addTrack(track);
                 reconParticles.add(particle);
-                clusters.clear();
-            } else {
 
-                // Loop over all tracks and find the associated cluster 
-                for (SeedTrack track : tracks) {
-                    extrapolator.setTrack(track);
-
-                    ReconstructedParticle particle = new BaseReconstructedParticle();
-                    particle.addTrack(track);
-
-                    Hep3Vector positionEcal = extrapolator.getTrackPositionAtEcal();
-                    System.out.println(this.getClass().getSimpleName() + ": Position at Ecal: " + positionEcal.toString());
-
-
-                    double rMax = 1000;
-                    HPSEcalCluster matchedCluster = null;
-                    for (HPSEcalCluster cluster : clusters) {
-                        Hep3Vector clusterPosition = new BasicHep3Vector(cluster.getPosition());
-                        System.out.println(this.getClass().getSimpleName() + ": Cluster position: " + clusterPosition.toString());
-
-                        double xDiff = positionEcal.x() - clusterPosition.x();
-                        double yDiff = positionEcal.y() - clusterPosition.y();
-                        double r = Math.sqrt(xDiff * xDiff + yDiff * yDiff);
-                        if (r < rMax) {
-                            rMax = r;
-                            matchedCluster = cluster;
-                        }
-                    }
-                    clusters.remove(matchedCluster);
-                    particle.addCluster(matchedCluster);
-                    reconParticles.add(particle);
-
-                    if (track.getCharge() * flipSign > 0)
-                        positrons.add(particle);
-                    else
-                        electrons.add(particle);
+                // Add the particle to either the collection of possible
+                // electrons or positrons
+                if (track.getCharge() * flipSign > 0){
+                	positrons.add(particle);
+                } else {
+                	electrons.add(particle);
                 }
-            }
+        	}
         }
 
         if (!clusters.isEmpty()) {
@@ -153,9 +172,9 @@
             }
         }
 
+        // 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);
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