Print

Print


Commit in lcsim/src/org/lcsim/contrib/uiowa on MAIN
ReclusterDriver.java+101-991.10 -> 1.11
MJC: Turn off a bunch of debug things by default

lcsim/src/org/lcsim/contrib/uiowa
ReclusterDriver.java 1.10 -> 1.11
diff -u -r1.10 -r1.11
--- ReclusterDriver.java	17 Dec 2007 22:30:44 -0000	1.10
+++ ReclusterDriver.java	17 Dec 2007 23:47:06 -0000	1.11
@@ -30,7 +30,7 @@
   *
   * This version is PRELIMINARY.
   *
-  * @version $Id: ReclusterDriver.java,v 1.10 2007/12/17 22:30:44 mcharles Exp $
+  * @version $Id: ReclusterDriver.java,v 1.11 2007/12/17 23:47:06 mcharles Exp $
   * @author Mat Charles
   */
 
@@ -1230,119 +1230,121 @@
 		totalChiSquared += trackChiSquared;
 	}
 	System.out.println("Total CHI^2 = "+totalChiSquared+" with NDF ~ "+tracksSortedByMomentum.size());
-	System.out.println("Here is a summary of all the energy deposits for each track:");
-	for (Track tr : tracksSortedByMomentum) {
-	    double trackMomentum = (new BasicHep3Vector(tr.getMomentum())).magnitude();
-	    HitMap hitsEcal = ((HitMap)(m_event.get("inputHitMapEcal")));
-	    HitMap hitsHcal = ((HitMap)(m_event.get("inputHitMapHcal")));
-	    List<CalorimeterHit> allTruthHitsInEcal = findHitsFromTruth_T(tr, hitsEcal.values());
-	    List<CalorimeterHit> allTruthHitsInHcal = findHitsFromTruth_T(tr, hitsHcal.values());
-	    int countCoreHitsEcal = 0;
-	    int countCoreHitsHcal = 0;
-	    int countSharedHitsEcal = 0;
-	    int countSharedHitsHcal = 0;
-	    double countWeightedSharedHitsEcal = 0.0;
-	    double countWeightedSharedHitsHcal = 0.0;
-	    int countUnmatchedSharedHitsEcal = 0;
-	    int countUnmatchedSharedHitsHcal = 0;
-	    Set<Cluster> showerComponents = newMapTrackToShowerComponents.get(tr);
-	    Set<Cluster> subClusters = new HashSet<Cluster>();
-	    for (Cluster component : showerComponents) {
-		Set<Cluster> subClustersOfThisComponent = recursivelyFindSubClusters(component);
-		subClusters.addAll(subClustersOfThisComponent);
-	    }
-	    for (Cluster clus : showerComponents) {
-		for (CalorimeterHit hit : clus.getCalorimeterHits()) {
-		    if (allTruthHitsInEcal.contains(hit)) {
-			countCoreHitsEcal++;
-		    } else if (allTruthHitsInHcal.contains(hit)) {
-			countCoreHitsHcal++;
-		    }
+	if (m_debug) {
+	    System.out.println("Here is a summary of all the energy deposits for each track:");
+	    for (Track tr : tracksSortedByMomentum) {
+		double trackMomentum = (new BasicHep3Vector(tr.getMomentum())).magnitude();
+		HitMap hitsEcal = ((HitMap)(m_event.get("inputHitMapEcal")));
+		HitMap hitsHcal = ((HitMap)(m_event.get("inputHitMapHcal")));
+		List<CalorimeterHit> allTruthHitsInEcal = findHitsFromTruth_T(tr, hitsEcal.values());
+		List<CalorimeterHit> allTruthHitsInHcal = findHitsFromTruth_T(tr, hitsHcal.values());
+		int countCoreHitsEcal = 0;
+		int countCoreHitsHcal = 0;
+		int countSharedHitsEcal = 0;
+		int countSharedHitsHcal = 0;
+		double countWeightedSharedHitsEcal = 0.0;
+		double countWeightedSharedHitsHcal = 0.0;
+		int countUnmatchedSharedHitsEcal = 0;
+		int countUnmatchedSharedHitsHcal = 0;
+		Set<Cluster> showerComponents = newMapTrackToShowerComponents.get(tr);
+		Set<Cluster> subClusters = new HashSet<Cluster>();
+		for (Cluster component : showerComponents) {
+		    Set<Cluster> subClustersOfThisComponent = recursivelyFindSubClusters(component);
+		    subClusters.addAll(subClustersOfThisComponent);
 		}
-	    }
-	    // Investigate shared clusters
-	    for (SharedClusterGroup shares : allSharedClusters) {
-		List<SharedCluster> sharedClusters = shares.listAllSharedClusters();
-		for (SharedCluster sharedCluster : sharedClusters) {
-		    // First, check whether this shared cluster has any true hits...
-		    int countTruthHitsEcalInThisSharedCluster = 0;
-		    int countTruthHitsHcalInThisSharedCluster = 0;
-		    for (CalorimeterHit hit : sharedCluster.getCluster().getCalorimeterHits()) {
+		for (Cluster clus : showerComponents) {
+		    for (CalorimeterHit hit : clus.getCalorimeterHits()) {
 			if (allTruthHitsInEcal.contains(hit)) {
-			    countTruthHitsEcalInThisSharedCluster++;
+			    countCoreHitsEcal++;
 			} else if (allTruthHitsInHcal.contains(hit)) {
-			    countTruthHitsHcalInThisSharedCluster++;
+			    countCoreHitsHcal++;
 			}
 		    }
-		    if (countTruthHitsEcalInThisSharedCluster + countTruthHitsHcalInThisSharedCluster > 0) {
-			// There were some truth hits. Check the weight.
-			double sumWeightForThisSharedCluster = 0.0;
-			Set<Cluster> targetsInSharedCluster = sharedCluster.getTargetClusters();
-			for (Cluster targetInSharedCluster : targetsInSharedCluster) {
-			    if (subClusters.contains(targetInSharedCluster)) {
-				sumWeightForThisSharedCluster += sharedCluster.getNormalizedWeight(targetInSharedCluster);
+		}
+		// Investigate shared clusters
+		for (SharedClusterGroup shares : allSharedClusters) {
+		    List<SharedCluster> sharedClusters = shares.listAllSharedClusters();
+		    for (SharedCluster sharedCluster : sharedClusters) {
+			// First, check whether this shared cluster has any true hits...
+			int countTruthHitsEcalInThisSharedCluster = 0;
+			int countTruthHitsHcalInThisSharedCluster = 0;
+			for (CalorimeterHit hit : sharedCluster.getCluster().getCalorimeterHits()) {
+			    if (allTruthHitsInEcal.contains(hit)) {
+				countTruthHitsEcalInThisSharedCluster++;
+			    } else if (allTruthHitsInHcal.contains(hit)) {
+				countTruthHitsHcalInThisSharedCluster++;
 			    }
 			}
-			if (sumWeightForThisSharedCluster > 0.0) {
-			    countSharedHitsEcal += countTruthHitsEcalInThisSharedCluster;
-			    countSharedHitsHcal += countTruthHitsHcalInThisSharedCluster;
-			    countWeightedSharedHitsEcal += ((double)(countTruthHitsEcalInThisSharedCluster)) * sumWeightForThisSharedCluster;
-			    countWeightedSharedHitsHcal += ((double)(countTruthHitsHcalInThisSharedCluster)) * sumWeightForThisSharedCluster;
-			} else {
-			    if (targetsInSharedCluster == null || targetsInSharedCluster.size()==0) {
-				countUnmatchedSharedHitsEcal += countTruthHitsEcalInThisSharedCluster;
-				countUnmatchedSharedHitsHcal += countTruthHitsHcalInThisSharedCluster;
+			if (countTruthHitsEcalInThisSharedCluster + countTruthHitsHcalInThisSharedCluster > 0) {
+			    // There were some truth hits. Check the weight.
+			    double sumWeightForThisSharedCluster = 0.0;
+			    Set<Cluster> targetsInSharedCluster = sharedCluster.getTargetClusters();
+			    for (Cluster targetInSharedCluster : targetsInSharedCluster) {
+				if (subClusters.contains(targetInSharedCluster)) {
+				    sumWeightForThisSharedCluster += sharedCluster.getNormalizedWeight(targetInSharedCluster);
+				}
+			    }
+			    if (sumWeightForThisSharedCluster > 0.0) {
+				countSharedHitsEcal += countTruthHitsEcalInThisSharedCluster;
+				countSharedHitsHcal += countTruthHitsHcalInThisSharedCluster;
+				countWeightedSharedHitsEcal += ((double)(countTruthHitsEcalInThisSharedCluster)) * sumWeightForThisSharedCluster;
+				countWeightedSharedHitsHcal += ((double)(countTruthHitsHcalInThisSharedCluster)) * sumWeightForThisSharedCluster;
+			    } else {
+				if (targetsInSharedCluster == null || targetsInSharedCluster.size()==0) {
+				    countUnmatchedSharedHitsEcal += countTruthHitsEcalInThisSharedCluster;
+				    countUnmatchedSharedHitsHcal += countTruthHitsHcalInThisSharedCluster;
+				}
 			    }
 			}
 		    }
 		}
-	    }
-	    System.out.println("  Track with p="+trackMomentum+" has "+allTruthHitsInEcal.size()+" ECAL + "+allTruthHitsInHcal.size()+" HCAL hits total. Of these, core has "+countCoreHitsEcal+" ECAL + "+countCoreHitsHcal+" HCAL hits and halo has "+countSharedHitsEcal+" ECAL + "+countSharedHitsHcal+" HCAL (weighted to "+countWeightedSharedHitsEcal+" + "+countWeightedSharedHitsHcal+"). Unmatched shared hits: "+countUnmatchedSharedHitsEcal+" ECAL + "+countUnmatchedSharedHitsHcal+" HCAL.");
-	    // MORE DEBUG
-	    System.out.println("Core clusters:");
-	    for (Cluster clus : subClusters) {
-		MCParticle domPart = quoteDominantParticle(clus);
-		System.out.println("   -> "+clus.getCalorimeterHits().size()+" (dominant: "+domPart.getPDGID()+" with p="+domPart.getMomentum().magnitude());
-	    }
-	    // MORE DEBUG
-	    System.out.println("Core contributions:");
-	    Map<MCParticle,Set<CalorimeterHit>> mapTruthToHitSets = new HashMap<MCParticle,Set<CalorimeterHit>>();
-	    for (Cluster clus : subClusters) {
-		for (CalorimeterHit hit : clus.getCalorimeterHits()) {
-		    SimCalorimeterHit simhit = (SimCalorimeterHit)(hit);
-		    int nMCParticles = simhit.getMCParticleCount();
-		    for (int iMC=0; iMC<nMCParticles; iMC++) {
-			MCParticle part = simhit.getMCParticle(iMC);
-			Set<CalorimeterHit> hitSet = mapTruthToHitSets.get(part);
-			if (hitSet == null) { hitSet = new HashSet<CalorimeterHit>(); mapTruthToHitSets.put(part,hitSet); }
-			hitSet.add(hit);
+		System.out.println("  Track with p="+trackMomentum+" has "+allTruthHitsInEcal.size()+" ECAL + "+allTruthHitsInHcal.size()+" HCAL hits total. Of these, core has "+countCoreHitsEcal+" ECAL + "+countCoreHitsHcal+" HCAL hits and halo has "+countSharedHitsEcal+" ECAL + "+countSharedHitsHcal+" HCAL (weighted to "+countWeightedSharedHitsEcal+" + "+countWeightedSharedHitsHcal+"). Unmatched shared hits: "+countUnmatchedSharedHitsEcal+" ECAL + "+countUnmatchedSharedHitsHcal+" HCAL.");
+		// MORE DEBUG
+		System.out.println("Core clusters:");
+		for (Cluster clus : subClusters) {
+		    MCParticle domPart = quoteDominantParticle(clus);
+		    System.out.println("   -> "+clus.getCalorimeterHits().size()+" (dominant: "+domPart.getPDGID()+" with p="+domPart.getMomentum().magnitude());
+		}
+		// MORE DEBUG
+		System.out.println("Core contributions:");
+		Map<MCParticle,Set<CalorimeterHit>> mapTruthToHitSets = new HashMap<MCParticle,Set<CalorimeterHit>>();
+		for (Cluster clus : subClusters) {
+		    for (CalorimeterHit hit : clus.getCalorimeterHits()) {
+			SimCalorimeterHit simhit = (SimCalorimeterHit)(hit);
+			int nMCParticles = simhit.getMCParticleCount();
+			for (int iMC=0; iMC<nMCParticles; iMC++) {
+			    MCParticle part = simhit.getMCParticle(iMC);
+			    Set<CalorimeterHit> hitSet = mapTruthToHitSets.get(part);
+			    if (hitSet == null) { hitSet = new HashSet<CalorimeterHit>(); mapTruthToHitSets.put(part,hitSet); }
+			    hitSet.add(hit);
+			}
 		    }
 		}
+		for (MCParticle part : mapTruthToHitSets.keySet()) {
+		    Set<CalorimeterHit> hitSet = mapTruthToHitSets.get(part);
+		    System.out.println("   -> "+part.getPDGID()+" with p="+part.getMomentum().magnitude()+" has "+hitSet.size()+" core hits.");
+		}
 	    }
-	    for (MCParticle part : mapTruthToHitSets.keySet()) {
-		Set<CalorimeterHit> hitSet = mapTruthToHitSets.get(part);
-		System.out.println("   -> "+part.getPDGID()+" with p="+part.getMomentum().magnitude()+" has "+hitSet.size()+" core hits.");
+	    for (Cluster clus : photonClusters) {
+		debugPrint("Photon", clus,tracksSortedByMomentum,newMapTrackToShowerComponents,newMapShowerComponentToTrack,allSharedClusters,newMapTrackToVetoedAdditions);
+		debugPrint(clus, newMapShowerComponentToTrack, photonClusters, mips, clumps,largeClustersWithoutSkeletons);
+	    }
+	    for (Cluster clus : mips) {
+		debugPrint("MIP", clus,tracksSortedByMomentum,newMapTrackToShowerComponents,newMapShowerComponentToTrack,allSharedClusters,newMapTrackToVetoedAdditions);
+		debugPrint(clus, newMapShowerComponentToTrack, photonClusters, mips, clumps,largeClustersWithoutSkeletons);
+	    }
+	    for (Cluster clus : clumps) {
+		debugPrint("Clump", clus,tracksSortedByMomentum,newMapTrackToShowerComponents,newMapShowerComponentToTrack,allSharedClusters,newMapTrackToVetoedAdditions);
+		debugPrint(clus, newMapShowerComponentToTrack, photonClusters, mips, clumps,largeClustersWithoutSkeletons);
+	    }
+	    for (Cluster clus : largeClustersWithoutSkeletons) {
+		debugPrint("LargeClus", clus,tracksSortedByMomentum,newMapTrackToShowerComponents,newMapShowerComponentToTrack,allSharedClusters,newMapTrackToVetoedAdditions);
+		debugPrint(clus, newMapShowerComponentToTrack, photonClusters, mips, clumps,largeClustersWithoutSkeletons);
+	    }
+	    for (Cluster clus : smallClusterSeeds) {
+		debugPrint("SmallSeed", clus,tracksSortedByMomentum,newMapTrackToShowerComponents,newMapShowerComponentToTrack,allSharedClusters,newMapTrackToVetoedAdditions);
+		debugPrint(clus, newMapShowerComponentToTrack, photonClusters, mips, clumps, smallClusterSeeds);
 	    }
-	}
-	for (Cluster clus : photonClusters) {
-	    debugPrint("Photon", clus,tracksSortedByMomentum,newMapTrackToShowerComponents,newMapShowerComponentToTrack,allSharedClusters,newMapTrackToVetoedAdditions);
-	    debugPrint(clus, newMapShowerComponentToTrack, photonClusters, mips, clumps,largeClustersWithoutSkeletons);
-	}
-	for (Cluster clus : mips) {
-	    debugPrint("MIP", clus,tracksSortedByMomentum,newMapTrackToShowerComponents,newMapShowerComponentToTrack,allSharedClusters,newMapTrackToVetoedAdditions);
-	    debugPrint(clus, newMapShowerComponentToTrack, photonClusters, mips, clumps,largeClustersWithoutSkeletons);
-	}
-	for (Cluster clus : clumps) {
-	    debugPrint("Clump", clus,tracksSortedByMomentum,newMapTrackToShowerComponents,newMapShowerComponentToTrack,allSharedClusters,newMapTrackToVetoedAdditions);
-	    debugPrint(clus, newMapShowerComponentToTrack, photonClusters, mips, clumps,largeClustersWithoutSkeletons);
-	}
-	for (Cluster clus : largeClustersWithoutSkeletons) {
-	    debugPrint("LargeClus", clus,tracksSortedByMomentum,newMapTrackToShowerComponents,newMapShowerComponentToTrack,allSharedClusters,newMapTrackToVetoedAdditions);
-	    debugPrint(clus, newMapShowerComponentToTrack, photonClusters, mips, clumps,largeClustersWithoutSkeletons);
-	}
-	for (Cluster clus : smallClusterSeeds) {
-	    debugPrint("SmallSeed", clus,tracksSortedByMomentum,newMapTrackToShowerComponents,newMapShowerComponentToTrack,allSharedClusters,newMapTrackToVetoedAdditions);
-	    debugPrint(clus, newMapShowerComponentToTrack, photonClusters, mips, clumps, smallClusterSeeds);
 	}
     }
 
CVSspam 0.2.8