Print

Print


Commit in hps-java/src/main/java/org/lcsim/hps/recon/tracking on MAIN
ParticleMaker.java+132added 1.1
Driver to create ReconstructedParticles

hps-java/src/main/java/org/lcsim/hps/recon/tracking
ParticleMaker.java added at 1.1
diff -N ParticleMaker.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ParticleMaker.java	19 Jun 2012 01:44:55 -0000	1.1
@@ -0,0 +1,132 @@
+package org.lcsim.hps.recon.tracking;
+
+//--- java ---//
+import java.util.List;
+import java.util.ArrayList;
+
+//--- org.lcsim ---//
+import org.lcsim.util.Driver;
+import org.lcsim.event.EventHeader;
+import org.lcsim.event.ReconstructedParticle;
+import org.lcsim.event.base.BaseReconstructedParticle;
+import org.lcsim.recon.tracking.seedtracker.SeedTrack;
+
+//--- hps-java ---//
+import org.lcsim.hps.recon.ecal.HPSEcalCluster;
+
+//--- hep ---//
+import hep.physics.vec.BasicHep3Vector;
+import hep.physics.vec.Hep3Vector;
+
+
+/**
+ * 
+ * @author Omar Moreno <[log in to unmask]>
+ * @version $Id: ParticleMaker.java,v 1.1 2012/06/19 01:44:55 omoreno Exp $
+ */
+public class ParticleMaker extends Driver {
+
+    List<ReconstructedParticle> reconParticles = new ArrayList<ReconstructedParticle>();
+
+    double maxXTrackClusterMatchResidual = 100; // [mm]
+    double maxYTrackClusterMatchResidual = 100; // [mm]
+
+    // Collections
+    String ecalClustersCollectionName = "EcalClusters";
+    String tracksCollectionName = "MatchedTracks";
+    String reconParticlesCollectionName = "allRecoParticles";
+
+    SvtTrackExtrapolator extrapolator = new SvtTrackExtrapolator();
+
+    public ParticleMaker() {
+    };
+
+    public void setMaxXTrackClusterMatchResidual(double maxXTrackClusterMatchResidual) {
+        this.maxXTrackClusterMatchResidual = maxXTrackClusterMatchResidual;
+    }
+
+    public void setMaxYTrackClusterMatchResidual(double maxYTrackClusterMatchResidual) {
+        this.maxYTrackClusterMatchResidual = maxYTrackClusterMatchResidual;
+    }
+    
+    public void setEcalClusterCollectionName(String ecalClustersCollectionName){
+        this.ecalClustersCollectionName = ecalClustersCollectionName;
+    }
+
+    public void setTrackCollectoinName(String tracksCollectionName){
+        this.tracksCollectionName = tracksCollectionName;
+    }
+    
+    public void setReconParticlesCollectionName(String reconParticlesCollectionName){
+        this.reconParticlesCollectionName = reconParticlesCollectionName;
+    }
+    
+    public void process(EventHeader event) {
+
+        // If the event does not have Ecal clusters, skip the event
+        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);
+
+        // 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) {
+
+                ReconstructedParticle particle = new BaseReconstructedParticle();
+                particle.addCluster(clusters.get(0));
+                particle.addTrack(tracks.get(0));
+                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(!clusters.isEmpty()){
+            for(HPSEcalCluster cluster : clusters){
+                ReconstructedParticle particle = new BaseReconstructedParticle();
+                particle.addCluster(cluster); 
+            }
+        }
+            
+        event.put(reconParticlesCollectionName, reconParticles, ReconstructedParticle.class, 0);
+    }
+}
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