Commit in lcsim/src/org/lcsim/contrib/uiowa on MAIN
ReclusterDTreeDriver.java+60-161.54 -> 1.55
make muon particle using newmap

lcsim/src/org/lcsim/contrib/uiowa
ReclusterDTreeDriver.java 1.54 -> 1.55
diff -u -r1.54 -r1.55
--- ReclusterDTreeDriver.java	29 Sep 2008 20:36:15 -0000	1.54
+++ ReclusterDTreeDriver.java	30 Sep 2008 01:13:43 -0000	1.55
@@ -35,7 +35,7 @@
   * in this package, which uses the implementation in
   * org.lcsim.recon.cluster.directedtree developed by NIU).
   *
-  * @version $Id: ReclusterDTreeDriver.java,v 1.54 2008/09/29 20:36:15 mcharles Exp $
+  * @version $Id: ReclusterDTreeDriver.java,v 1.55 2008/09/30 01:13:43 tjkim Exp $
   * @author Mat Charles <[log in to unmask]>
   */
 
@@ -203,6 +203,12 @@
 	// Read in
 	List<Cluster> dTreeClusters = event.get(Cluster.class, m_dTreeClusterListName);
 	List<Track> trackList = event.get(Track.class, m_inputTrackList);
+        Map<Track,Set<Cluster>> newMapTrackToMip = ((Map<Track, Set<Cluster>>)(event.get("newMapTrackToMip")));
+        List<Track> muonTracks = new Vector<Track>();
+        for(Track tr : newMapTrackToMip.keySet()) { muonTracks.add(tr);}
+        boolean sub_muon = trackList.removeAll(muonTracks);
+        if(sub_muon) { System.out.println("track list changed due to the muon list");}
+        else { System.out.println("There is no muon track for this event"); }
 	List<Cluster> photons = event.get(Cluster.class, "PhotonClustersForDTree");
 	List<Cluster> largeClusters = dTreeClusters; // FIXME: NOT IDEAL! Perhaps run MST on DTree clusters?
 	if (trackList == null) { throw new AssertionError("Null track list!"); }
@@ -344,7 +350,6 @@
 	List<Cluster> photonLikePhotons = new Vector<Cluster>();
 	List<Cluster> electronClusters = new Vector<Cluster>();
 	List<Track>   electronTracks   = new Vector<Track>();
-        List<Track>   muonTracks = event.get(Track.class, "MuonList");
 	photonHandling(photons, electronClusters, chargedHadronLikePhotons, modifiedPhotonClusters, photonLikePhotons, trackList, electronTracks, clustersMatchedToTracks, tracksMatchedToClusters);
 
 	// Resume track matching
@@ -1846,7 +1851,7 @@
 	// Outputs
 	makeParticlesAndWriteOut(trackList, tracksSortedByMomentum, unmatchedTracksThatDontReachCalorimeter, mapOrigTrackToTweakedTrack,
 				 tracksMatchedToClusters, clustersMatchedToTracks,
-				 electronTracks, muonTracks, modifiedPhotonClusters,electronClusters, photonLikePhotons, chargedHadronLikePhotons,
+				 electronTracks, newMapTrackToMip, modifiedPhotonClusters,electronClusters, photonLikePhotons, chargedHadronLikePhotons,
 				 seedHadronLikePhotonClusters, nonSeedHadronLikePhotonClusters, nonSeedPhotonLikePhotonClusters,
 				 newMapTrackToShowerComponents, newMapShowerComponentToTrack,
 				 linkableClusters,
@@ -3509,7 +3514,7 @@
 				  List<Track> trackList, List<Track> tracksSortedByMomentum, List<Track> unmatchedTracksThatDontReachCalorimeter,
 				  Map<Track, Track> mapOrigTrackToTweakedTrack,
 				  Map<Track,Cluster> tracksMatchedToClusters, Map<Cluster, List<Track>> clustersMatchedToTracks,
-				  List<Track> electronTracks, List<Track> muonTracks, List<Cluster> modifiedPhotonClusters, List<Cluster> electronClusters, List<Cluster> photonLikePhotons, List<Cluster> chargedHadronLikePhotons,  
+				  List<Track> electronTracks, Map<Track, Set<Cluster>> newMapTrackToMip, List<Cluster> modifiedPhotonClusters, List<Cluster> electronClusters, List<Cluster> photonLikePhotons, List<Cluster> chargedHadronLikePhotons,  
 				  List<Cluster> seedHadronLikePhotonClusters, List<Cluster> nonSeedHadronLikePhotonClusters, List<Cluster> nonSeedPhotonLikePhotonClusters,
 				  Map<Track, Set<Cluster>> newMapTrackToShowerComponents, Map<Cluster, Track> newMapShowerComponentToTrack,
 				  List<Cluster> linkableClusters,
@@ -3674,10 +3679,60 @@
 	}
 
 	// Write out charged particles:
+	// Write out muon particles:
+        for (Track tr : newMapTrackToMip.keySet()) {
+            List<Cluster> clustersOfTrack = new Vector<Cluster>();
+            for (Cluster clus : newMapTrackToMip.get(tr)) { clustersOfTrack.add(clus); }
+            // Make ReconstructedParticle. May be more than one if MultipleTrackTrack.
+            List<BaseReconstructedParticle> particles = new Vector<BaseReconstructedParticle>();
+            if (tr instanceof MultipleTrackTrack) {
+                for (Track subtrack : tr.getTracks()) {
+                    BaseReconstructedParticle part = new BaseReconstructedParticle();
+                    part.addTrack(subtrack);
+                    particles.add(part);
+                }
+            } else {
+                BaseReconstructedParticle part = new BaseReconstructedParticle();
+                part.addTrack(tr);
+                particles.add(part);
+            }
+
+            if (particles.size() < 1) { throw new AssertionError("Book-keeping error"); }
+            // Assign clusters to first particle in list
+            for (Cluster clus : clustersOfTrack) {
+                particles.get(0).addCluster(clus);
+            }
+            // Make particles properly
+            for (BaseReconstructedParticle part : particles) {
+                if (part.getTracks().size() != 1) { throw new AssertionError("Book-keeping error"); }
+                Track trackOfThisParticle = part.getTracks().get(0);
+                part.setCharge(trackOfThisParticle.getCharge());
+                Hep3Vector trackMomentum = momentum(trackOfThisParticle);
+                double trackMomentumMag = trackMomentum.magnitude();
+                double currentParticleMass = mass_muon;
+                double trackEnergySq = trackMomentumMag*trackMomentumMag + currentParticleMass*currentParticleMass;
+                HepLorentzVector fourMomentum = new BasicHepLorentzVector(Math.sqrt(trackEnergySq), trackMomentum);
+                part.set4Vector(fourMomentum);
+                part.setMass(currentParticleMass);
+                part.setReferencePoint(new BasicHep3Vector(trackOfThisParticle.getReferencePoint()));
+                if (part.getCharge()>0) {
+                    part.addParticleID(pid_muplus);
+                    part.setParticleIdUsed(pid_muplus);
+                } else {
+                    part.addParticleID(pid_muminus);
+                    part.setParticleIdUsed(pid_muminus);
+                }
+            }
+
+            outputParticleList.addAll(particles);
+            outputChargedParticleList.addAll(particles);
+            outputChargedParticleListWithEoverPveto.addAll(particles);
+            outputChargedParticleListWithEoverPveto_pass.addAll(particles);
+        }
+
 	// FIXME: Break up MultipleTrackTrack tracks.
 	for (Track tr : tracksSortedByMomentum) {
 	    boolean isElectron = electronTracks.contains(tr); // includes positrons
-            boolean isMuon = muonTracks.contains(tr);
 	    // WARNING: Clusters may be entirely wrong for jets!
 	    List<Cluster> clustersOfTrack = new Vector<Cluster>();
 	    Set<Cluster> showerComponents = newMapTrackToShowerComponents.get(tr);
@@ -3713,9 +3768,6 @@
 		if (isElectron) {
 		    currentParticleMass = mass_electron;
 		}
-                else if (isMuon) {
-                    currentParticleMass = mass_muon;
-                }
 		double trackEnergySq = trackMomentumMag*trackMomentumMag + currentParticleMass*currentParticleMass;
 		HepLorentzVector fourMomentum = new BasicHepLorentzVector(Math.sqrt(trackEnergySq), trackMomentum);
 		part.set4Vector(fourMomentum);
@@ -3729,14 +3781,6 @@
 			part.addParticleID(pid_electron);
 			part.setParticleIdUsed(pid_electron);			
 		    }
-		} else if(isMuon) {
-                    if (part.getCharge()>0) {
-                        part.addParticleID(pid_muplus);
-                        part.setParticleIdUsed(pid_muplus);
-                    } else {
-                        part.addParticleID(pid_muminus);
-                        part.setParticleIdUsed(pid_muminus);
-                    }
                 } else {
 		    if (part.getCharge()>0) {
 			part.addParticleID(pid_piplus);
CVSspam 0.2.8