Commit in lcsim/src/org/lcsim/recon/util on MAIN
McTruthLinker.java+115-2371.6 -> 1.7
Fixed a bug that leads to a crash a particles have no parents

lcsim/src/org/lcsim/recon/util
McTruthLinker.java 1.6 -> 1.7
diff -u -r1.6 -r1.7
--- McTruthLinker.java	17 Feb 2012 10:31:36 -0000	1.6
+++ McTruthLinker.java	8 Mar 2013 16:10:44 -0000	1.7
@@ -128,109 +128,77 @@
 		// skimmed mc particles
 		if (useSkimmedMcParticles) {
 			try {
-				List<MCParticle> mcParticles = event.get(MCParticle.class,
-						mcParticleCollectionName);
+				List<MCParticle> mcParticles = event.get(MCParticle.class, mcParticleCollectionName);
 				mcParticlesSkimmed = createSkimmedMcParticleList(mcParticles);
-				mcParticleToSkimmed = fillMcParticleToSkimmedMap(mcParticles,
-						mcParticlesSkimmed);
+				mcParticleToSkimmed = fillMcParticleToSkimmedMap(mcParticles, mcParticlesSkimmed);
 				int flags = event.getMetaData(mcParticles).getFlags();
 				flags = LCIOUtil.bitSet(flags, LCIOConstants.BITSubset, true);
-				event.put(mcParticlesSkimmedName, mcParticlesSkimmed,
-						MCParticle.class, flags);
-				print(HLEVEL_NORMAL, "Added skimmed mc particles \""
-						+ mcParticlesSkimmedName + "\" to the event.");
+				event.put(mcParticlesSkimmedName, mcParticlesSkimmed, MCParticle.class, flags);
+				print(HLEVEL_NORMAL, "Added skimmed mc particles \"" + mcParticlesSkimmedName + "\" to the event.");
 			} catch (IllegalArgumentException e) {
-				print(HLEVEL_DEFAULT,
-						"WARNING: no skimmed mc particle collection created.\n"
-								+ "e.getMessage()", true);
+				print(HLEVEL_DEFAULT, "WARNING: no skimmed mc particle collection created.\n" + "e.getMessage()", true);
 			}
 		}
 
 		// track to mc particle relation
-		if (!trackHitMcRelationName.equals("")
-				&& !trackCollectionName.equals("")) {
+		if (!trackHitMcRelationName.equals("") && !trackCollectionName.equals("")) {
 			try {
-				List<Track> tracks = event
-						.get(Track.class, trackCollectionName);
-				List<LCRelation> trackHitMcRelation = event.get(
-						LCRelation.class, trackHitMcRelationName);
-				trackMcRelation = createTrackMcRelation(tracks,
-						trackHitMcRelation);
+				List<Track> tracks = event.get(Track.class, trackCollectionName);
+				List<LCRelation> trackHitMcRelation = event.get(LCRelation.class, trackHitMcRelationName);
+				trackMcRelation = createTrackMcRelation(tracks, trackHitMcRelation);
 				if (!trackMcRelationName.equals("")) {
 					int flags = 0;
-					flags = LCIOUtil.bitSet(flags,
-							LCIOConstants.LCREL_WEIGHTED, true);
-					event.put(trackMcRelationName, trackMcRelation,
-							LCRelation.class, flags);
-					print(HLEVEL_NORMAL,
-							"Added track to mc particle relations \""
-									+ trackMcRelationName + "\" to the event.");
+					flags = LCIOUtil.bitSet(flags, LCIOConstants.LCREL_WEIGHTED, true);
+					event.put(trackMcRelationName, trackMcRelation, LCRelation.class, flags);
+					print(HLEVEL_NORMAL, "Added track to mc particle relations \"" + trackMcRelationName
+							+ "\" to the event.");
 				}
 			} catch (IllegalArgumentException e) {
-				print(HLEVEL_DEFAULT,
-						"WARNING: no track to mc particle relation created.\n"
-								+ "e.getMessage()", true);
+				print(HLEVEL_DEFAULT, "WARNING: no track to mc particle relation created.\n" + "e.getMessage()", true);
 			}
 		}
 
 		// calorimeter hit to mc particle relation
 		if (!caloHitSimHitRelationName.equals("")) {
 			try {
-				caloHitMcRelation = createCaloHitMcRelation(event.get(
-						LCRelation.class, caloHitSimHitRelationName));
+				caloHitMcRelation = createCaloHitMcRelation(event.get(LCRelation.class, caloHitSimHitRelationName));
 			} catch (IllegalArgumentException e) {
-				print(HLEVEL_DEFAULT,
-						"WARNING: no calorimeter hit to mc particle relation created.\n"
-								+ "e.getMessage()", true);
+				print(HLEVEL_DEFAULT, "WARNING: no calorimeter hit to mc particle relation created.\n"
+						+ "e.getMessage()", true);
 			}
 		}
 
 		// cluster to mc particle relation
 		if (!clusterCollectionName.equals("")) {
 			try {
-				List<Cluster> clusters = event.get(Cluster.class,
-						clusterCollectionName);
-				clusterMcRelation = createClusterMcRelation(clusters,
-						caloHitMcRelation);
+				List<Cluster> clusters = event.get(Cluster.class, clusterCollectionName);
+				clusterMcRelation = createClusterMcRelation(clusters, caloHitMcRelation);
 				if (!clusterMcRelationName.equals("")) {
 					int flags = 0;
-					flags = LCIOUtil.bitSet(flags,
-							LCIOConstants.LCREL_WEIGHTED, true);
-					event.put(clusterMcRelationName, clusterMcRelation,
-							LCRelation.class, flags);
-					print(HLEVEL_NORMAL,
-							"Added cluster to mc particle relations \""
-									+ clusterMcRelationName
-									+ "\" to the event.");
+					flags = LCIOUtil.bitSet(flags, LCIOConstants.LCREL_WEIGHTED, true);
+					event.put(clusterMcRelationName, clusterMcRelation, LCRelation.class, flags);
+					print(HLEVEL_NORMAL, "Added cluster to mc particle relations \"" + clusterMcRelationName
+							+ "\" to the event.");
 				}
 			} catch (IllegalArgumentException e) {
-				print(HLEVEL_DEFAULT,
-						"WARNING: no cluster to mc particle relation created.\n"
-								+ "e.getMessage()", true);
+				print(HLEVEL_DEFAULT, "WARNING: no cluster to mc particle relation created.\n" + "e.getMessage()", true);
 			}
 		}
 
 		// PFO to mc particle relation
 		if (!pfoCollectionName.equals("")) {
 			try {
-				List<ReconstructedParticle> PFOs = event.get(
-						ReconstructedParticle.class, pfoCollectionName);
-				pfoMcRelation = createPfoMcRelation(PFOs, trackMcRelation,
-						clusterMcRelation);
+				List<ReconstructedParticle> PFOs = event.get(ReconstructedParticle.class, pfoCollectionName);
+				pfoMcRelation = createPfoMcRelation(PFOs, trackMcRelation, clusterMcRelation);
 				if (!pfoMcRelationName.equals("")) {
 					int flags = 0;
-					flags = LCIOUtil.bitSet(flags,
-							LCIOConstants.LCREL_WEIGHTED, true);
-					event.put(pfoMcRelationName, pfoMcRelation,
-							LCRelation.class, flags);
-					print(HLEVEL_NORMAL,
-							"Added PFO to mc particle relations \""
-									+ pfoMcRelationName + "\" to the event.");
+					flags = LCIOUtil.bitSet(flags, LCIOConstants.LCREL_WEIGHTED, true);
+					event.put(pfoMcRelationName, pfoMcRelation, LCRelation.class, flags);
+					print(HLEVEL_NORMAL, "Added PFO to mc particle relations \"" + pfoMcRelationName
+							+ "\" to the event.");
 				}
 			} catch (IllegalArgumentException e) {
-				print(HLEVEL_DEFAULT,
-						"WARNING: no PFO to mc particle relation created.\n"
-								+ "e.getMessage()", true);
+				print(HLEVEL_DEFAULT, "WARNING: no PFO to mc particle relation created.\n" + "e.getMessage()", true);
 			}
 		}
 	}
@@ -245,19 +213,15 @@
 		this.useTanimotoDistance = useTanimotoDistance;
 	}
 
-	public void setPfoTrackWeight(double pfoTrackWeight)
-			throws IllegalArgumentException {
+	public void setPfoTrackWeight(double pfoTrackWeight) throws IllegalArgumentException {
 		if (pfoTrackWeight < 0)
-			throw new IllegalArgumentException(
-					"PFO track weight can not be negative.");
+			throw new IllegalArgumentException("PFO track weight can not be negative.");
 		this.pfoTrackWeight = pfoTrackWeight;
 	}
 
-	public void setPfoClusterWeight(double pfoClusterWeight)
-			throws IllegalArgumentException {
+	public void setPfoClusterWeight(double pfoClusterWeight) throws IllegalArgumentException {
 		if (pfoTrackWeight < 0)
-			throw new IllegalArgumentException(
-					"PFO cluster weight can not be negative.");
+			throw new IllegalArgumentException("PFO cluster weight can not be negative.");
 		this.pfoClusterWeight = pfoClusterWeight;
 	}
 
@@ -322,8 +286,7 @@
 	 * Finally all the particles from a given list (default: gamma, pi0, K0s)
 	 * are kept together with their direct daughters.
 	 */
-	protected List<MCParticle> createSkimmedMcParticleList(
-			List<MCParticle> mcParticles) {
+	protected List<MCParticle> createSkimmedMcParticleList(List<MCParticle> mcParticles) {
 
 		List<MCParticle> skimmedMcParticles = new ArrayList<MCParticle>();
 
@@ -350,12 +313,9 @@
 				if (simStatus.isDecayedInCalorimeter()) {
 					// keep bremsstrahlung
 					for (MCParticle daughter : mcParticle.getDaughters()) {
-						if (daughter.getPDGID() == 22
-								&& daughter.getEnergy() > daughterEnergyCut
-								&& !daughter.getSimulatorStatus()
-										.isBackscatter()) {
-							addMcParticleWithParents(daughter,
-									skimmedMcParticles);
+						if (daughter.getPDGID() == 22 && daughter.getEnergy() > daughterEnergyCut
+								&& !daughter.getSimulatorStatus().isBackscatter()) {
+							addMcParticleWithParents(daughter, skimmedMcParticles);
 						}
 					}
 				}
@@ -365,11 +325,8 @@
 				// and should be kept
 				if (keepDaughtersPDGID.contains(mcParticle.getPDGID())) {
 					for (MCParticle daughter : mcParticle.getDaughters()) {
-						if (daughter.getEnergy() > daughterEnergyCut
-								&& !daughter.getSimulatorStatus()
-										.isBackscatter()) {
-							addMcParticleWithParents(daughter,
-									skimmedMcParticles);
+						if (daughter.getEnergy() > daughterEnergyCut && !daughter.getSimulatorStatus().isBackscatter()) {
+							addMcParticleWithParents(daughter, skimmedMcParticles);
 						}
 					}
 				}
@@ -377,8 +334,8 @@
 			}
 		}
 
-		print(HLEVEL_NORMAL, "Keeping " + skimmedMcParticles.size() + " of "
-				+ mcParticles.size() + " mc particles in skimmed list.");
+		print(HLEVEL_NORMAL, "Keeping " + skimmedMcParticles.size() + " of " + mcParticles.size()
+				+ " mc particles in skimmed list.");
 
 		return skimmedMcParticles;
 	}
@@ -395,48 +352,27 @@
 	 * @return A mapping between all mc particles and their closest ancestor
 	 *         present in the skimmed mc particles
 	 */
-	protected Map<MCParticle, MCParticle> fillMcParticleToSkimmedMap(
-			List<MCParticle> mcParticles, List<MCParticle> skimmedMcParticles) {
+	protected Map<MCParticle, MCParticle> fillMcParticleToSkimmedMap(List<MCParticle> mcParticles,
+			List<MCParticle> skimmedMcParticles) {
 
 		Map<MCParticle, MCParticle> mcParticleToSkimmedMap = new HashMap<MCParticle, MCParticle>();
 
 		for (MCParticle mcParticle : mcParticles) {
-			MCParticle ancestor = findMcParticleAncestor(mcParticle,
-					skimmedMcParticles);
+			MCParticle ancestor = findMcParticleAncestor(mcParticle, skimmedMcParticles);
 			mcParticleToSkimmedMap.put(mcParticle, ancestor);
+			String motherPDGID = "none";
+			if (mcParticle.getParents().size() > 0) {
+				motherPDGID = Integer.toString(mcParticle.getParents().get(0).getPDGID());
+			}
 			if (mcParticle != ancestor) {
-				print(HLEVEL_FULL, "Warning: Rejecting mc particle."
-						+ "\tEnergy: "
-						+ mcParticle.getEnergy()
-						+ "\n"
-						+ "\tCharge: "
-						+ mcParticle.getCharge()
-						+ "\n"
-						+ "\tPDGID: "
-						+ mcParticle.getPDGID()
-						+ "\n"
-						+ "\tGenStatus: "
-						+ mcParticle.getGeneratorStatus()
-						+ "\n"
-						+ "\tCreated in simulation: "
-						+ mcParticle.getSimulatorStatus()
-								.isCreatedInSimulation()
-						+ "\n"
-						+ "\tBackscatter: "
-						+ mcParticle.getSimulatorStatus().isBackscatter()
-						+ "\n"
-						+ "\tDecay in calorimeter: "
-						+ mcParticle.getSimulatorStatus()
-								.isDecayedInCalorimeter()
-						+ "\n"
-						+ "\tDecay in tracker: "
-						+ mcParticle.getSimulatorStatus().isDecayedInTracker()
-						+ "\n"
-						+ "\tStopped: "
-						+ mcParticle.getSimulatorStatus().isStopped()
-						+ "\n"
-						+ "\tMother: "
-						+ mcParticle.getParents().get(0).getPDGID(), true);
+				print(HLEVEL_FULL, "Warning: Rejecting mc particle." + "\tEnergy: " + mcParticle.getEnergy() + "\n"
+						+ "\tCharge: " + mcParticle.getCharge() + "\n" + "\tPDGID: " + mcParticle.getPDGID() + "\n"
+						+ "\tGenStatus: " + mcParticle.getGeneratorStatus() + "\n" + "\tCreated in simulation: "
+						+ mcParticle.getSimulatorStatus().isCreatedInSimulation() + "\n" + "\tBackscatter: "
+						+ mcParticle.getSimulatorStatus().isBackscatter() + "\n" + "\tDecay in calorimeter: "
+						+ mcParticle.getSimulatorStatus().isDecayedInCalorimeter() + "\n" + "\tDecay in tracker: "
+						+ mcParticle.getSimulatorStatus().isDecayedInTracker() + "\n" + "\tStopped: "
+						+ mcParticle.getSimulatorStatus().isStopped() + "\n" + "\tMother: " + motherPDGID, true);
 			}
 		}
 		return mcParticleToSkimmedMap;
@@ -462,12 +398,10 @@
 	 *            The LCRelations between track hits and mc particles
 	 * @return The weighted LCRelations between tracks and mc particles
 	 */
-	protected List<LCRelation> createTrackMcRelation(List<Track> tracks,
-			List<LCRelation> trackHitMcRelation) {
+	protected List<LCRelation> createTrackMcRelation(List<Track> tracks, List<LCRelation> trackHitMcRelation) {
 
 		if (trackHitMcRelation == null) {
-			throw new IllegalArgumentException(
-					"No tracker hit to mc relations given.");
+			throw new IllegalArgumentException("No tracker hit to mc relations given.");
 		}
 
 		RelationalTable<TrackerHit, MCParticle> trackHitMcRelationTable = createRelationalTable(trackHitMcRelation);
@@ -480,13 +414,11 @@
 			double trackHits = trackHitsList.size();
 			double sumOfWeights = 0;
 			for (TrackerHit trackHit : trackHitsList) {
-				for (MCParticle mcParticle : trackHitMcRelationTable
-						.allFrom(trackHit)) {
+				for (MCParticle mcParticle : trackHitMcRelationTable.allFrom(trackHit)) {
 					if (useSkimmedMcParticles)
 						mcParticle = mcParticleToSkimmed.get(mcParticle);
 					if (mcParticleContribution.containsKey(mcParticle)) {
-						mcParticleContribution.put(mcParticle,
-								mcParticleContribution.get(mcParticle) + 1);
+						mcParticleContribution.put(mcParticle, mcParticleContribution.get(mcParticle) + 1);
 					} else {
 						mcParticleContribution.put(mcParticle, 1);
 					}
@@ -497,28 +429,21 @@
 				double weight = 0.0;
 				double recoHits = mcParticleContribution.get(mcParticle);
 				if (useTanimotoDistance) {
-					double trueHits = trackHitMcRelationTable.allTo(mcParticle)
-							.size();
-					weight = 1 - (trackHits + trueHits - 2 * recoHits)
-							/ (trackHits + trueHits - recoHits);
+					double trueHits = trackHitMcRelationTable.allTo(mcParticle).size();
+					weight = 1 - (trackHits + trueHits - 2 * recoHits) / (trackHits + trueHits - recoHits);
 				} else {
 					weight = recoHits / trackHits;
 				}
 				sumOfWeights += weight;
-				trackMcRelation.add(new BaseLCRelation(track, mcParticle,
-						weight));
-				print(HLEVEL_FULL,
-						"Added a track to mc particle relation with weight "
-								+ weight + ".");
+				trackMcRelation.add(new BaseLCRelation(track, mcParticle, weight));
+				print(HLEVEL_FULL, "Added a track to mc particle relation with weight " + weight + ".");
 				if (!fullRecoRelation)
 					break;
 			}
-			print(HLEVEL_HIGH, "Total weight of track contributions is "
-					+ sumOfWeights + ".");
+			print(HLEVEL_HIGH, "Total weight of track contributions is " + sumOfWeights + ".");
 		}
 
-		print(HLEVEL_NORMAL, "Created " + trackMcRelation.size()
-				+ " track to mc particle relations.");
+		print(HLEVEL_NORMAL, "Created " + trackMcRelation.size() + " track to mc particle relations.");
 
 		return trackMcRelation;
 	}
@@ -535,8 +460,7 @@
 	 *            The relations between CalorimeterHits and SimCalorimeterHits
 	 * @return The weighted LCRelations between CalorimeterHits and MCParticles
 	 */
-	protected List<LCRelation> createCaloHitMcRelation(
-			List<LCRelation> caloHitSimHitRelation) {
+	protected List<LCRelation> createCaloHitMcRelation(List<LCRelation> caloHitSimHitRelation) {
 
 		List<LCRelation> caloHitMcRelation = new ArrayList<LCRelation>();
 
@@ -548,19 +472,13 @@
 			for (int i = 0; i < simHit.getMCParticleCount(); i++) {
 				double weight = simHit.getContributedEnergy(i) / hitEnergy;
 				sumOfWeights += weight;
-				caloHitMcRelation.add(new BaseLCRelation(digiHit, simHit
-						.getMCParticle(i), weight));
-				print(HLEVEL_FULL,
-						"Added a calorimeter hit to mc particle relation with weight "
-								+ weight + ".");
-			}
-			print(HLEVEL_FULL,
-					"Total weight of calorimeter hit contributions is "
-							+ sumOfWeights + ".");
+				caloHitMcRelation.add(new BaseLCRelation(digiHit, simHit.getMCParticle(i), weight));
+				print(HLEVEL_FULL, "Added a calorimeter hit to mc particle relation with weight " + weight + ".");
+			}
+			print(HLEVEL_FULL, "Total weight of calorimeter hit contributions is " + sumOfWeights + ".");
 		}
 
-		print(HLEVEL_NORMAL, "Created " + caloHitMcRelation.size()
-				+ " calorimeter hit to mc particle relations.");
+		print(HLEVEL_NORMAL, "Created " + caloHitMcRelation.size() + " calorimeter hit to mc particle relations.");
 
 		return caloHitMcRelation;
 	}
@@ -579,12 +497,11 @@
 	 * @return The weighted LCRelations between Clusters and MCParticles
 	 * @throws IllegalArgumentException
 	 */
-	protected List<LCRelation> createClusterMcRelation(List<Cluster> clusters,
-			List<LCRelation> caloHitMcRelation) throws IllegalArgumentException {
+	protected List<LCRelation> createClusterMcRelation(List<Cluster> clusters, List<LCRelation> caloHitMcRelation)
+			throws IllegalArgumentException {
 
 		if (caloHitMcRelation == null) {
-			throw new IllegalArgumentException(
-					"No calorimeter hit to mc relations given.");
+			throw new IllegalArgumentException("No calorimeter hit to mc relations given.");
 		}
 
 		RelationalTable<CalorimeterHit, MCParticle> caloHitMcRelationTable = createRelationalTable(caloHitMcRelation);
@@ -597,17 +514,14 @@
 			for (CalorimeterHit hit : cluster.getCalorimeterHits()) {
 				double hitEnergy = hit.getCorrectedEnergy();
 				double hitWeight = hitEnergy / clusterEnergy;
-				Map<MCParticle, Double> hitMcParticlesWeight = caloHitMcRelationTable
-						.allFromWithWeights(hit);
+				Map<MCParticle, Double> hitMcParticlesWeight = caloHitMcRelationTable.allFromWithWeights(hit);
 				for (MCParticle mcParticle : hitMcParticlesWeight.keySet()) {
 					// TODO implement optional use of Tanimoto distance
-					double weight = hitWeight
-							* hitMcParticlesWeight.get(mcParticle);
+					double weight = hitWeight * hitMcParticlesWeight.get(mcParticle);
 					if (useSkimmedMcParticles)
 						mcParticle = mcParticleToSkimmed.get(mcParticle);
 					if (mcParticlesWeight.containsKey(mcParticle)) {
-						mcParticlesWeight.put(mcParticle,
-								mcParticlesWeight.get(mcParticle) + weight);
+						mcParticlesWeight.put(mcParticle, mcParticlesWeight.get(mcParticle) + weight);
 					} else {
 						mcParticlesWeight.put(mcParticle, weight);
 					}
@@ -617,20 +531,15 @@
 			for (MCParticle mcParticle : mcParticlesWeight.keySet()) {
 				double weight = mcParticlesWeight.get(mcParticle);
 				sumOfWeights += weight;
-				clusterMcRelation.add(new BaseLCRelation(cluster, mcParticle,
-						weight));
-				print(HLEVEL_FULL,
-						"Added a cluster to mc particle relation with weight "
-								+ weight + ".");
+				clusterMcRelation.add(new BaseLCRelation(cluster, mcParticle, weight));
+				print(HLEVEL_FULL, "Added a cluster to mc particle relation with weight " + weight + ".");
 				if (!fullRecoRelation)
 					break;
 			}
-			print(HLEVEL_HIGH, "Total weight of cluster contributions is "
-					+ sumOfWeights + ".");
+			print(HLEVEL_HIGH, "Total weight of cluster contributions is " + sumOfWeights + ".");
 		}
 
-		print(HLEVEL_NORMAL, "Created " + clusterMcRelation.size()
-				+ " cluster to mc particle relations.");
+		print(HLEVEL_NORMAL, "Created " + clusterMcRelation.size() + " cluster to mc particle relations.");
 
 		return clusterMcRelation;
 	}
@@ -657,18 +566,14 @@
 	 * @return The weighted LCRelations between PFOs and MCParticles
 	 * @throws IllegalArgumentException
 	 */
-	protected List<LCRelation> createPfoMcRelation(
-			List<ReconstructedParticle> recoParticles,
-			List<LCRelation> trackMcRelation, List<LCRelation> clusterMcRelation)
-			throws IllegalArgumentException {
+	protected List<LCRelation> createPfoMcRelation(List<ReconstructedParticle> recoParticles,
+			List<LCRelation> trackMcRelation, List<LCRelation> clusterMcRelation) throws IllegalArgumentException {
 
 		if (trackMcRelation == null) {
-			throw new IllegalArgumentException(
-					"No track to mc relations given.");
+			throw new IllegalArgumentException("No track to mc relations given.");
 		}
 		if (clusterMcRelation == null) {
-			throw new IllegalArgumentException(
-					"No cluster to mc relations given.");
+			throw new IllegalArgumentException("No cluster to mc relations given.");
 		}
 
 		RelationalTable<Track, MCParticle> trackMcRelationTable = createRelationalTable(trackMcRelation);
@@ -680,8 +585,7 @@
 			int pfoTrackHits = 0;
 			double pfoEnergy = recoParticle.getEnergy();
 			double thisPfoClusterWeight = pfoClusterWeight;
-			double trackClusterNormalization = pfoTrackWeight
-					+ pfoClusterWeight;
+			double trackClusterNormalization = pfoTrackWeight + pfoClusterWeight;
 			Map<MCParticle, Double> mcParticlesWeight = new HashMap<MCParticle, Double>();
 			// if PFO has tracks use them for truth link and ignore cluster
 			if (pfoTrackWeight != 0) {
@@ -689,21 +593,16 @@
 					pfoTrackHits += track.getTrackerHits().size();
 				}
 				for (Track track : recoParticle.getTracks()) {
-					Map<MCParticle, Double> trackMcParticlesWeight = trackMcRelationTable
-							.allFromWithWeights(track);
-					double trackWeight = track.getTrackerHits().size()
-							/ (double) pfoTrackHits;
+					Map<MCParticle, Double> trackMcParticlesWeight = trackMcRelationTable.allFromWithWeights(track);
+					double trackWeight = track.getTrackerHits().size() / (double) pfoTrackHits;
 					// weigh the contribution by track to cluster weight
 					trackWeight *= pfoTrackWeight / trackClusterNormalization;
-					for (MCParticle mcParticle : trackMcParticlesWeight
-							.keySet()) {
-						double weight = trackWeight
-								* trackMcParticlesWeight.get(mcParticle);
+					for (MCParticle mcParticle : trackMcParticlesWeight.keySet()) {
+						double weight = trackWeight * trackMcParticlesWeight.get(mcParticle);
 						if (useSkimmedMcParticles)
 							mcParticle = mcParticleToSkimmed.get(mcParticle);
 						if (mcParticlesWeight.containsKey(mcParticle)) {
-							mcParticlesWeight.put(mcParticle,
-									mcParticlesWeight.get(mcParticle) + weight);
+							mcParticlesWeight.put(mcParticle, mcParticlesWeight.get(mcParticle) + weight);
 						} else {
 							mcParticlesWeight.put(mcParticle, weight);
 						}
@@ -722,17 +621,13 @@
 							.allFromWithWeights(cluster);
 					double clusterWeight = cluster.getEnergy() / pfoEnergy;
 					// weigh the contribution by cluster to cluster weight
-					clusterWeight *= thisPfoClusterWeight
-							/ trackClusterNormalization;
-					for (MCParticle mcParticle : clusterMcParticlesWeight
-							.keySet()) {
-						double weight = clusterWeight
-								* clusterMcParticlesWeight.get(mcParticle);
+					clusterWeight *= thisPfoClusterWeight / trackClusterNormalization;
+					for (MCParticle mcParticle : clusterMcParticlesWeight.keySet()) {
+						double weight = clusterWeight * clusterMcParticlesWeight.get(mcParticle);
 						if (useSkimmedMcParticles)
 							mcParticle = mcParticleToSkimmed.get(mcParticle);
 						if (mcParticlesWeight.containsKey(mcParticle)) {
-							mcParticlesWeight.put(mcParticle,
-									mcParticlesWeight.get(mcParticle) + weight);
+							mcParticlesWeight.put(mcParticle, mcParticlesWeight.get(mcParticle) + weight);
 						} else {
 							mcParticlesWeight.put(mcParticle, weight);
 						}
@@ -744,23 +639,17 @@
 				double weight = mcParticlesWeight.get(mcParticle);
 				// need to normalize to total number of track hits
 				sumOfWeights += weight;
-				pfoMcRelation.add(new BaseLCRelation(recoParticle, mcParticle,
-						weight));
-				print(HLEVEL_FULL,
-						"Added a PFO to mc particle relation with weight "
-								+ weight + ".\n" + "\tEnergy: "
-								+ mcParticle.getEnergy() + "\n" + "\tCharge: "
-								+ mcParticle.getCharge() + "\n" + "\tPDGID: "
-								+ mcParticle.getPDGID());
+				pfoMcRelation.add(new BaseLCRelation(recoParticle, mcParticle, weight));
+				print(HLEVEL_FULL, "Added a PFO to mc particle relation with weight " + weight + ".\n" + "\tEnergy: "
+						+ mcParticle.getEnergy() + "\n" + "\tCharge: " + mcParticle.getCharge() + "\n" + "\tPDGID: "
+						+ mcParticle.getPDGID());
 				if (!fullRecoRelation)
 					break;
 			}
-			print(HLEVEL_HIGH, "Total weight of PFO contributions is "
-					+ sumOfWeights + ".");
+			print(HLEVEL_HIGH, "Total weight of PFO contributions is " + sumOfWeights + ".");
 		}
 
-		print(HLEVEL_NORMAL, "Created " + pfoMcRelation.size()
-				+ " PFO to mc particle relations.");
+		print(HLEVEL_NORMAL, "Created " + pfoMcRelation.size() + " PFO to mc particle relations.");
 
 		return pfoMcRelation;
 	}
@@ -811,16 +700,12 @@
 	 * @param mcParticles
 	 *            The list to add the mc particle to
 	 */
-	protected void addMcParticleWithParents(MCParticle mcParticle,
-			List<MCParticle> mcParticles) {
+	protected void addMcParticleWithParents(MCParticle mcParticle, List<MCParticle> mcParticles) {
 		if (!mcParticles.contains(mcParticle)) {
 			mcParticles.add(mcParticle);
-			print(HLEVEL_FULL, "Adding mc particle to skimmed list.\n"
-					+ "\tEnergy: " + mcParticle.getEnergy() + "\n"
-					+ "\tCharge: " + mcParticle.getCharge() + "\n"
-					+ "\tPDGID: " + mcParticle.getPDGID() + "\n"
-					+ "\tGenStatus: " + mcParticle.getGeneratorStatus() + "\n"
-					+ "\tSimStatus: "
+			print(HLEVEL_FULL, "Adding mc particle to skimmed list.\n" + "\tEnergy: " + mcParticle.getEnergy() + "\n"
+					+ "\tCharge: " + mcParticle.getCharge() + "\n" + "\tPDGID: " + mcParticle.getPDGID() + "\n"
+					+ "\tGenStatus: " + mcParticle.getGeneratorStatus() + "\n" + "\tSimStatus: "
 					+ mcParticle.getSimulatorStatus().getValue());
 			for (MCParticle parent : mcParticle.getParents()) {
 				addMcParticleWithParents(parent, mcParticles);
@@ -839,8 +724,7 @@
 	 *            The list of mc particles containing possible ancestors
 	 * @return The mc particle ancestor. Null if none is found.
 	 */
-	protected MCParticle findMcParticleAncestor(MCParticle mcParticle,
-			List<MCParticle> mcParticles) {
+	protected MCParticle findMcParticleAncestor(MCParticle mcParticle, List<MCParticle> mcParticles) {
 		MCParticle ancestor = null;
 
 		if (mcParticles.contains(mcParticle)) {
@@ -854,12 +738,9 @@
 		}
 		if (ancestor == null) {
 			print(HLEVEL_DEFAULT,
-					"Warning: no ancestor found in mc particle list."
-							+ "\tEnergy: " + mcParticle.getEnergy() + "\n"
-							+ "\tCharge: " + mcParticle.getCharge() + "\n"
-							+ "\tPDGID: " + mcParticle.getPDGID() + "\n"
-							+ "\tGenStatus: " + mcParticle.getGeneratorStatus()
-							+ "\n" + "\tSimStatus: "
+					"Warning: no ancestor found in mc particle list." + "\tEnergy: " + mcParticle.getEnergy() + "\n"
+							+ "\tCharge: " + mcParticle.getCharge() + "\n" + "\tPDGID: " + mcParticle.getPDGID() + "\n"
+							+ "\tGenStatus: " + mcParticle.getGeneratorStatus() + "\n" + "\tSimStatus: "
 							+ mcParticle.getSimulatorStatus().getValue(), true);
 		}
 		return ancestor;
@@ -875,12 +756,10 @@
 	 *            A list of LCRelations
 	 * @return A RelationalTable with the same content as the given list
 	 */
-	public static <F, T> RelationalTable<F, T> createRelationalTable(
-			List<LCRelation> relations) {
+	public static <F, T> RelationalTable<F, T> createRelationalTable(List<LCRelation> relations) {
 		RelationalTable<F, T> relationalTable = new BaseRelationalTable<F, T>();
 		for (LCRelation relation : relations) {
-			relationalTable.add((F) relation.getFrom(), (T) relation.getTo(),
-					relation.getWeight());
+			relationalTable.add((F) relation.getFrom(), (T) relation.getTo(), relation.getWeight());
 		}
 		return relationalTable;
 	}
@@ -897,8 +776,7 @@
 		List list = new LinkedList(map.entrySet());
 		Collections.sort(list, new Comparator() {
 			public int compare(Object o1, Object o2) {
-				return -((Comparable) ((Map.Entry) (o1)).getValue())
-						.compareTo(((Map.Entry) (o2)).getValue());
+				return -((Comparable) ((Map.Entry) (o1)).getValue()).compareTo(((Map.Entry) (o2)).getValue());
 			}
 		});
 
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