hps-java/src/main/java/org/lcsim/hps/users/omoreno
diff -N ParticleMaker.java
--- ParticleMaker.java 25 Apr 2013 22:11:14 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,133 +0,0 @@
-package org.lcsim.hps.users.omoreno;
-
-//--- 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;
-import org.lcsim.hps.recon.tracking.SvtTrackExtrapolator;
-
-
-/**
- *
- * @author Omar Moreno <[log in to unmask]>
- * @version $Id: ParticleMaker.java,v 1.1 2013/04/25 22:11:14 meeg 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);
- }
-}