lcsim/test/org/lcsim
diff -N Sidloi3SimplePfaTest.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ Sidloi3SimplePfaTest.java 17 Nov 2010 00:14:31 -0000 1.1
@@ -0,0 +1,49 @@
+package org.lcsim;
+
+import java.io.File;
+import java.net.URL;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.lcsim.event.EventHeader;
+import org.lcsim.event.ReconstructedParticle;
+import org.lcsim.util.Driver;
+import org.lcsim.util.cache.FileCache;
+import org.lcsim.util.loop.LCSimLoop;
+
+public class Sidloi3SimplePfaTest extends TestCase
+{
+ public void testSingleEvent() throws Exception
+ {
+ URL url = new URL( "http://www.lcsim.org/test/lcio/pythia_uds_nobeam_nobrem-00-500_SLIC-v2r8p3_geant4-v9r3p1_QGSP_BERT_sidloi3.slcio" );
+ FileCache cache = new FileCache();
+ File file = cache.getCachedFile( url );
+
+ LCSimLoop loop = new LCSimLoop();
+ loop.setLCIORecordSource( file );
+ loop.add( new org.lcsim.recon.ui.ReconDriverLoi() );
+ loop.add( new PfaCheckDriver() );
+ loop.loop( 2, null );
+ loop.dispose();
+ }
+
+ static class PfaCheckDriver extends Driver
+ {
+ public void process( EventHeader event )
+ {
+ List<ReconstructedParticle> particles = event.get( ReconstructedParticle.class, EventHeader.RECONSTRUCTEDPARTICLES );
+ if (particles.size() == 0)
+ throw new RuntimeException( "No ReconstructedParticles were created by the PFA." );
+ double esum = 0;
+ for (ReconstructedParticle particle : particles)
+ {
+ esum += particle.getEnergy();
+ }
+ System.out.println( "event <" + event.getEventNumber() + "> esum = " + esum );
+ // Check that energy sum is within 20 GeV of expected total.
+ if (esum < 180. || esum > 220.)
+ throw new RuntimeException("Esum is more than 20 GeV off from 200 GeV event energy.");
+ }
+ }
+}
\ No newline at end of file