lcsim/src/org/lcsim/recon/pfa/cheat
diff -u -r1.5 -r1.6
--- PerfectIdentifier.java 11 Feb 2007 17:12:12 -0000 1.5
+++ PerfectIdentifier.java 16 May 2007 17:30:21 -0000 1.6
@@ -14,7 +14,7 @@
/**
*
- * @version $Id: PerfectIdentifier.java,v 1.5 2007/02/11 17:12:12 cassell Exp $
+ * @version $Id: PerfectIdentifier.java,v 1.6 2007/05/16 17:30:21 mcharles Exp $
*/
public class PerfectIdentifier extends Driver
@@ -35,6 +35,38 @@
for (Cluster clus : inputClusterList) {
// Identify
MCParticle truthID = findTruthID(clus, mcList);
+ if (truthID == null) {
+ // This is going to cause a null pointer exception shortly
+ // (as soon as we try to compute the truth particle's
+ // energy, momentum, etc). So pre-emptively throw a diagnostic
+ // exception.
+ String printme = new String();
+ printme += ("Warning: truthID==null for cluster with "+clus.getCalorimeterHits().size()+" hits and MC list of "+mcList.size()+" particles named '"+m_mcName+"'.\n");
+ printme += "Probably the MC list is not complete or is not self-consistent.\n";
+ printme += "Here are the contributing particles:\n";
+ Set<MCParticle> contributingParticles = new HashSet<MCParticle>();
+ for (CalorimeterHit hit : clus.getCalorimeterHits()) {
+ SimCalorimeterHit simHit = (SimCalorimeterHit) (hit);
+ int nContributingParticles = simHit.getMCParticleCount();
+ for (int i=0; i<nContributingParticles; i++) {
+ MCParticle part = simHit.getMCParticle(i);
+ contributingParticles.add(part);
+ }
+ }
+ for (MCParticle part : contributingParticles) {
+ List<MCParticle> parentsInList = findParentsInList(part, mcList);
+ printme += " ";
+ printme += part.getType().getName();
+ printme += " with energy "+part.getEnergy();
+ printme += " with parents in list: { ";
+ for (MCParticle parent : parentsInList) {
+ printme += parent.getType().getName();
+ printme += "(E="+parent.getEnergy()+") ";
+ }
+ printme += " } \n";
+ }
+ throw new NullPointerException(printme);
+ }
// Add to output list
LocalReconstructedParticle part = new LocalReconstructedParticle();
part.addCluster(clus);