Commit in lcsim/src/org/lcsim/contrib/uiowa/util on MAIN
EnergyAssociator.java+27-31.1 -> 1.2
Add protection against non-existent event variables

lcsim/src/org/lcsim/contrib/uiowa/util
EnergyAssociator.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- EnergyAssociator.java	29 Sep 2005 21:05:36 -0000	1.1
+++ EnergyAssociator.java	14 Oct 2005 17:38:19 -0000	1.2
@@ -24,7 +24,7 @@
  * by the sampling fraction) is the best.
  */
 
-class EnergyAssociator implements Associator
+public class EnergyAssociator implements Associator
 {
     protected List<SimCalorimeterHit> m_hits;
     protected List<MCParticle>         m_mcParticles;
@@ -33,6 +33,8 @@
     protected List<ReconstructedParticle> m_reconParticles;
     protected EventHeader                 m_event;
 
+    static private boolean m_printedWarning = false;
+
     public EnergyAssociator(EventHeader event)
     {
 	// Initially, use defaults that people will expect:
@@ -46,9 +48,27 @@
 	// MC Particles
 	setMCParticles(event.getMCParticles());
 	// Tracks
-	setTracks(event.getTracks());
+	try {
+	    setTracks(event.getTracks());
+	} catch (java.lang.IllegalArgumentException x) {
+	    // "Unknown event component Tracks"... le sigh.
+	    if (!m_printedWarning) {
+		System.out.println(this.getClass().getName()+"WARNING: Caught assertion: "+x);
+		System.out.println(this.getClass().getName()+"WARNING: Ignoring and continuing...");
+		m_printedWarning = true;
+	    }
+	}
 	// Reconstructed particles
-	setReconstructedParticles(event.get(ReconstructedParticle.class, event.MCFASTRECONSTRUCTEDPARTICLES));
+	try {
+	    setReconstructedParticles(event.get(ReconstructedParticle.class, event.MCFASTRECONSTRUCTEDPARTICLES));
+	} catch (java.lang.IllegalArgumentException x) {
+	    // "Unknown event component MCFastReconstructedParticles"... le sigh again.
+	    if (!m_printedWarning) {
+	    System.out.println(this.getClass().getName()+"WARNING: Caught assertion: "+x);
+	    System.out.println(this.getClass().getName()+"WARNING: Ignoring and continuing...");	    
+		m_printedWarning = true;
+	    }
+	}
 
 	m_event = event;
     }
@@ -225,6 +245,10 @@
 		throw new AssertionError("Particles "+o1+","+o2+": an energy is undefined. Energies: "+energy1+","+energy2);
 	    }
 	}
+
+	protected double contributedEnergy(MCParticle part) {
+	    return (m_mapParticleToEnergy.get(part)).doubleValue();
+	}
     }
 
     protected Map<MCParticle, ArrayList<SimCalorimeterHit> > m_mapMCParticlesToHits;
CVSspam 0.2.8