Print

Print


Commit in lcsim/src/org/lcsim/contrib/uiowa on MAIN
ReclusterDTreeDriver.java+44-401.30 -> 1.31
MJC: (contrib) Fix bug in PFA output where multiple charged particles with distinct tracks were being merged into a single particle with a fake track

lcsim/src/org/lcsim/contrib/uiowa
ReclusterDTreeDriver.java 1.30 -> 1.31
diff -u -r1.30 -r1.31
--- ReclusterDTreeDriver.java	12 Jul 2008 08:09:28 -0000	1.30
+++ ReclusterDTreeDriver.java	16 Jul 2008 21:04:31 -0000	1.31
@@ -34,7 +34,7 @@
   * in this package, which uses the implementation in
   * org.lcsim.recon.cluster.directedtree developed by NIU).
   *
-  * @version $Id: ReclusterDTreeDriver.java,v 1.30 2008/07/12 08:09:28 mcharles Exp $
+  * @version $Id: ReclusterDTreeDriver.java,v 1.31 2008/07/16 21:04:31 mcharles Exp $
   * @author Mat Charles <[log in to unmask]>
   */
 
@@ -2474,69 +2474,72 @@
 	// FIXME: Break up MultipleTrackTrack tracks.
 	for (Track tr : tracksSortedByMomentum) {
 	    boolean isElectron = electronTracks.contains(tr); // includes positrons
-	    BaseReconstructedParticle part = new BaseReconstructedParticle();
 	    // WARNING: Clusters may be entirely wrong for jets!
+	    List<Cluster> clustersOfTrack = new Vector<Cluster>();
 	    Set<Cluster> showerComponents = newMapTrackToShowerComponents.get(tr);
-	    for (Cluster clus : showerComponents) { part.addCluster(clus); }
+	    for (Cluster clus : showerComponents) { clustersOfTrack.add(clus); }
 	    Cluster sharedHitClus = makeClusterOfSharedHits(showerComponents, allSharedClusters);
-	    if (sharedHitClus.getCalorimeterHits().size()>0) { part.addCluster(sharedHitClus); }
+	    if (sharedHitClus.getCalorimeterHits().size()>0) { clustersOfTrack.add(sharedHitClus); }
+	    // 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);
 	    }
-	    part.setCharge(tr.getCharge());
-	    Hep3Vector trackMomentum = momentum(tr);
-	    double trackMomentumMag = trackMomentum.magnitude();
-	    double currentParticleMass = mass_piplus;
-	    if (isElectron) {
-		currentParticleMass = mass_electron;
-	    }
-	    double trackEnergySq = trackMomentumMag*trackMomentumMag + currentParticleMass*currentParticleMass;
-	    HepLorentzVector fourMomentum = new BasicHepLorentzVector(Math.sqrt(trackEnergySq), trackMomentum);
-	    if (tr instanceof MultipleTrackTrack) {
-		double sumEnergy = 0.0;
-		Hep3Vector sumThreeMomentum = new BasicHep3Vector(0,0,0);
-		for (Track subtr : tr.getTracks()) {
-		    Hep3Vector subTrackMomentum = new BasicHep3Vector(subtr.getMomentum());
-		    double subTrackMomentumMag = subTrackMomentum.magnitude();
-		    double subTrackEnergySq = subTrackMomentumMag*subTrackMomentumMag + mass_piplus*mass_piplus;
-		    sumEnergy += Math.sqrt(subTrackEnergySq);
-		    sumThreeMomentum = VecOp.add(sumThreeMomentum, subTrackMomentum);
-		}
-		HepLorentzVector sumFourMomentum = new BasicHepLorentzVector(sumEnergy, sumThreeMomentum);
-		part.set4Vector(sumFourMomentum);
-		part.setMass(sumFourMomentum.magnitude());
-	    } else {
+	    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_piplus;
+		if (isElectron) {
+		    currentParticleMass = mass_electron;
+		}
+		double trackEnergySq = trackMomentumMag*trackMomentumMag + currentParticleMass*currentParticleMass;
+		HepLorentzVector fourMomentum = new BasicHepLorentzVector(Math.sqrt(trackEnergySq), trackMomentum);
 		part.set4Vector(fourMomentum);
 		part.setMass(mass_piplus);
-	    }
-	    part.setReferencePoint(new BasicHep3Vector(tr.getReferencePoint()));
-	    if (isElectron) {
-		part.addParticleID(pid_electron);
-		part.setParticleIdUsed(pid_electron);
-	    } else {
-		part.addParticleID(pid_piplus);
-		part.setParticleIdUsed(pid_piplus);
+		part.setReferencePoint(new BasicHep3Vector(trackOfThisParticle.getReferencePoint()));
+		if (isElectron) {
+		    part.addParticleID(pid_electron);
+		    part.setParticleIdUsed(pid_electron);
+		} else {
+		    part.addParticleID(pid_piplus);
+		    part.setParticleIdUsed(pid_piplus);
+		}
 	    }
 	    // Write out as charged track
 	    if (trackToTreatAsChargedParticles.contains(tr)) {
-		outputParticleList.add(part);
-		outputChargedParticleList.add(part);
+		outputParticleList.addAll(particles);
+		outputChargedParticleList.addAll(particles);
 	    }
 	    if (trackToTreatAsChargedParticlesWithEoverPveto.contains(tr)) {
-		outputChargedParticleListWithEoverPveto.add(part);
-		outputChargedParticleListWithEoverPveto_pass.add(part);
+		outputChargedParticleListWithEoverPveto.addAll(particles);
+		outputChargedParticleListWithEoverPveto_pass.addAll(particles);
 	    }
 	    // Confusion matrix accounting of calorimeter hits is straightforward
 	    // for non-jet tracks. For tracks in jets, need to be clever to make sure
 	    // each hit appears once and once only.
+	    // FIXME: This is now screwed up for MultipleTrackTracks.
+/*
 	    Set<Track> jet = mapTrackToJet.get(tr);
 	    boolean trackInJet = m_clusterAsJets && jet != null;
 	    if (!trackInJet) {
-		outputParticleListForConfusionMatrix_singleTracks.add(part);
+		outputParticleListForConfusionMatrix_singleTracks.addAll(particles);
 		// Make copy with cluster energy...
 		BaseReconstructedParticle part2 = new BaseReconstructedParticle();
 		BaseReconstructedParticle part3 = new BaseReconstructedParticle();
@@ -2642,6 +2645,7 @@
 		    outputParticleListForConfusionMatrix_jetTracksWithNoClusters.add(partForMatrix);
 		}
 	    }
+*/
 	}
 
 	if (chargedShowersToTreatAsNeutral.size()!=0) {
CVSspam 0.2.8