Print

Print


Commit in lcsim/src/org/lcsim/contrib/Cassell/recon/Cheat on MAIN
CheatReconOutputExample.java+106added 1.1
Example of running the cheat reconstruction and writing it to disk

lcsim/src/org/lcsim/contrib/Cassell/recon/Cheat
CheatReconOutputExample.java added at 1.1
diff -N CheatReconOutputExample.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ CheatReconOutputExample.java	8 Nov 2007 23:34:46 -0000	1.1
@@ -0,0 +1,106 @@
+package org.lcsim.contrib.Cassell.recon.Cheat;
+import java.io.File;
+import org.lcsim.event.EventHeader;
+import org.lcsim.event.ReconstructedParticle;
+import org.lcsim.event.MCParticle;
+import org.lcsim.util.Driver;
+import org.lcsim.util.loop.LCIODriver;
+import org.lcsim.contrib.Cassell.recon.Cheat.CheatReconDriver;
+import org.lcsim.contrib.Cassell.recon.Cheat.PPRDriver;
+import hep.physics.vec.Hep3Vector;
+import org.lcsim.util.aida.AIDA;
+import java.util.*;
+
+/**
+ * A example of writing LCIO output.
+ * 
+ * @see org.lcsim.util.loop.LCIODriver
+ * 
+ * @author Tony Johnson
+ * @version $Id: CheatReconOutputExample.java,v 1.1 2007/11/08 23:34:46 cassell Exp $
+ */
+public class CheatReconOutputExample extends Driver
+{
+   private AIDA aida = AIDA.defaultInstance();
+   String CheatReconRname = "ReconPerfectReconParticles";
+   String PPRPflowRname = "PPRReconParticles";
+   String CheatReconFSname = "ReconFSParticles";
+   public CheatReconOutputExample()
+   {
+
+//
+// Do the cheating reconstruction (includes Digisim)
+//
+      CheatReconDriver crd = new CheatReconDriver();
+      crd.setCheatReconstructedParticleOutputName(CheatReconRname);
+      crd.setCheatFSParticleOutputName(CheatReconFSname);
+      add(crd);
+
+
+
+//
+// Make the perfect pattern recognition pflow reconstructed particles from the
+// Cheat Recon particles
+//
+      add(new PPRDriver(CheatReconRname,PPRPflowRname));
+
+//
+// Write the events to disk
+//      
+      File output = new File("E:","CheatReconOutputsid01.slcio");
+      add(new LCIODriver(output));
+
+   }
+    protected void process(EventHeader event)
+    {
+        super.process(event);
+//
+// Get the final state particles
+//
+        List<MCParticle> fs = event.get(MCParticle.class,CheatReconFSname);
+//
+// Get the perfect pattern recognition reconstructed particles
+//
+        List<ReconstructedParticle> ppr = event.get(ReconstructedParticle.class,PPRPflowRname);
+//
+// Plot the energy sum and invariant mass for each event
+//
+        double evtE = 0.;
+        double evtPx = 0.;
+        double evtPy = 0.;
+        double evtPz = 0.;
+        for(MCParticle p:fs)
+        {
+           int pdg = Math.abs(p.getPDGID());
+           if( (pdg == 12)||(pdg == 14)||(pdg == 16) )continue;
+           evtE += p.getEnergy();
+           Hep3Vector P = p.getMomentum();
+           evtPx += P.x();
+           evtPy += P.y();
+           evtPz += P.z();
+        }
+        aida.cloud1D("Event non-neutrino final state energy").fill(evtE);
+        double evtM = Math.sqrt(evtE*evtE - evtPx*evtPx - evtPy*evtPy - evtPz*evtPz);
+        aida.cloud1D("Event non-neutrino final state mass").fill(evtM);
+        evtE = 0.;
+        evtPx = 0.;
+        evtPy = 0.;
+        evtPz = 0.;
+        for(ReconstructedParticle p:ppr)
+        {
+           evtE += p.getEnergy();
+           Hep3Vector P = p.getMomentum();
+           evtPx += P.x();
+           evtPy += P.y();
+           evtPz += P.z();
+        }
+        aida.cloud1D("Event reconstructed energy").fill(evtE);
+        evtM = Math.sqrt(evtE*evtE - evtPx*evtPx - evtPy*evtPy - evtPz*evtPz);
+        aida.cloud1D("Event reconstructed mass").fill(evtM);
+    }
+
+    protected void endOfData()
+    {
+        super.endOfData();
+    }
+}
CVSspam 0.2.8