lcsim/test/org/lcsim
diff -u -r1.1 -r1.2
--- NonTrivialPFASingleEventTest.java 4 Sep 2007 22:51:30 -0000 1.1
+++ NonTrivialPFASingleEventTest.java 6 Sep 2007 18:13:49 -0000 1.2
@@ -11,6 +11,9 @@
import org.lcsim.contrib.uiowa.NonTrivialPFA;
import org.lcsim.event.EventHeader;
import org.lcsim.event.MCParticle;
+import org.lcsim.event.ParticleID;
+import org.lcsim.event.ReconstructedParticle;
+import org.lcsim.event.Track;
import org.lcsim.util.Driver;
import org.lcsim.util.cache.FileCache;
import org.lcsim.util.loop.LCIODriver;
@@ -25,18 +28,102 @@
*/
public class NonTrivialPFASingleEventTest extends TestCase
{
+ void setupUp()
+ {
+ Runtime.getRuntime().gc();
+ }
+
public void testSingleEvent() throws IOException, LoopException
{
FileCache cache = new FileCache();
File file = cache.getCachedFile(new URL("http://www.lcsim.org/test/lcio/panpyZZnunubaruds-0-1000_SLIC_v2r1p5_acme0605.slcio"));
+ // Write out output of NonTrivialPFA.
+ System.out.println("Running NonTrivialPFA ...");
LCSimLoop loop = new LCSimLoop();
loop.setLCIORecordSource(file);
loop.add(new NonTrivialPFA());
loop.add(new RemoveMCPColls());
- loop.add(new LCIODriver(new TestOutputFile("NonTrivialPFA.slcio")));
+ File outputfile = new TestOutputFile("NonTrivialPFA.slcio");
+ loop.add(new LCIODriver(outputfile));
+ loop.loop(1);
+ loop.dispose();
+ System.out.println("Done running PFA.");
+
+ System.out.println("Reading back " + outputfile.getAbsolutePath() + " ...");
+ // Read back and perform some checks on ReconstructedParticles.
+ loop = new LCSimLoop();
+ loop.setLCIORecordSource(outputfile);
+ loop.add(new CheckParticleDriver());
loop.loop(1);
- loop.dispose();
+ loop.dispose();
+ System.out.println("Done reading back " + outputfile.getAbsolutePath() + ".");
+ }
+
+ class CheckParticleDriver extends Driver
+ {
+ public void process(EventHeader event)
+ {
+ List<ReconstructedParticle> c = event.get(ReconstructedParticle.class, "PFAReconstructedParticles");
+ int cntr = 0;
+ for (ReconstructedParticle p : c)
+ {
+ System.out.println("Particle " + cntr);
+ int ntracks = p.getTracks().size();
+ if (ntracks > 0)
+ {
+ for (int i=0; i<ntracks; i++)
+ {
+ Track t = p.getTracks().get(i);
+ if (t == null)
+ {
+ System.out.println("WARNING: Track " + i + " is null!");
+ }
+ else
+ {
+ System.out.println(" Track: " + t.hashCode());
+ }
+ }
+ }
+
+ List<ParticleID> ids = p.getParticleIDs();
+ for (int i=0; i<ids.size(); i++)
+ {
+ ParticleID id = ids.get(i);
+ if (id == null)
+ {
+ System.out.println("WARNING: PID " + i + " is null!");
+ }
+ else
+ {
+ System.out.println(" PID: " + id.getPDG());
+ }
+ }
+
+
+ ParticleID idused = p.getParticleIDUsed();
+ if (idused == null)
+ {
+ System.out.println("PIDUsed is null!");
+ }
+ else {
+ System.out.println("PIDUsed: " + idused.getPDG());
+ }
+
+
+ List<ReconstructedParticle> reconp = p.getParticles();
+ for (int i=0; i<reconp.size(); i++)
+ {
+ ReconstructedParticle subp = reconp.get(i);
+ if (subp == null)
+ System.out.println("Sub-Particle " + i + " is null!");
+ else
+ System.out.println("Sub-Particle: " + subp.hashCode());
+ }
+
+ ++cntr;
+ }
+ }
}
class RemoveMCPColls extends Driver
@@ -55,4 +142,4 @@
}
}
}
-}
\ No newline at end of file
+}