Print

Print


Commit in lcsim/src/org/lcsim/plugin/web on MAIN
examples/mainLoop.py+28added 1.1
        /Analysis102.py+23added 1.1
examples.html+17-11.2 -> 1.3
+68-1
2 added + 1 modified, total 3 files
Added Jython Examples

lcsim/src/org/lcsim/plugin/web/examples
mainLoop.py added at 1.1
diff -N mainLoop.py
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ mainLoop.py	3 Aug 2005 18:53:04 -0000	1.1
@@ -0,0 +1,28 @@
+#! /usr/bin/env jython
+
+###
+# mainLoop.py
+# Wrapper to enable running outside of JAS3
+# 03-AUG-2005 Jan Strube
+###
+from java.io import File
+from org.lcsim.util.aida import AIDA
+from org.lcsim.util.loop import LCSimLoop
+## importing the Java analysis module
+import Analysis101
+## if Analysis102 cannot be found, please uncomment and modify 
+## the following two lines to tell Jython where to find it
+# import sys
+# sys.path.append('full path to Python module')
+# importing the Analysis102 class in the Jython module Analysis102
+from Analysis102 import Analysis102
+
+loop = LCSimLoop()
+input = File("psiMuMu.slcio")
+loop.setLCIORecordSource(input)
+loop.add(Analysis101())
+loop.add(Analysis102())
+# loop over all events with -1 or over any other positive number
+loop.loop(-1)
+loop.dispose()
+    

lcsim/src/org/lcsim/plugin/web/examples
Analysis102.py added at 1.1
diff -N Analysis102.py
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ Analysis102.py	3 Aug 2005 18:53:04 -0000	1.1
@@ -0,0 +1,23 @@
+from org.lcsim.util.aida import AIDA
+from hep.physics.vec import VecOp
+from org.lcsim.event import MCParticle
+from org.lcsim.util import Driver
+
+class Analysis102(Driver):
+   def __init__(self):
+       self.aida = AIDA.defaultInstance()
+   
+   def process(self, event):
+       # only necessary when adding Drivers to __this__ class.
+       # in this case process() shouldn't do anything else
+       #Driver.invokeChildren(self, event)
+       # Get the list of MCParticles from the event
+       particles = event.get(MCParticle.class, event.MC_PARTICLES)
+       # Histogram the number of particles per event
+       self.aida.cloud1D("nTracks").fill(particles.size())
+       # Loop over the particles
+       for iParticle in range(particles.size()):
+          particle = particles.get(iParticle)
+	  self.aida.cloud1D("mass").fill(particle.getMass())
+          self.aida.cloud1D("pSquared").fill(particle.getMomentum().magnitudeSquared())
+	  

lcsim/src/org/lcsim/plugin/web
examples.html 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- examples.html	16 Mar 2005 02:06:39 -0000	1.2
+++ examples.html	3 Aug 2005 18:53:04 -0000	1.3
@@ -32,4 +32,20 @@
     <td><a href="examples/ClusterFinding.java">ClusterFinding.java</a></td>
     <td>Cluster Finding example</td>
   </tr>
-</table>
\ No newline at end of file
+</table>
+<h2>org.lcsim Jython examples</h2>
+<p>These examples are written in Jython. They have to be executed from within
+mainLoop.py, which is capable of executing Java examples as well. You will have
+to provide data samples by modifying mainLoop.py. For a Tutorial visit
+<a href="http://confluence.slac.stanford.edu/display/ilc/Writing+a+Jython+Driver">
+Writing a Jython Driver</a></p>
+<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" id="AutoNumber2" height="237" width="523">
+  <tr>
+    <td><a href="examples/mainLoop.py">mainLoop.py</a></td>
+    <td>The Main Jython wrapper to load any other example</td>
+  </tr>
+  <tr>
+    <td><a href="examples/Analysis102.py">Analysis102.py</a></td>
+    <td>A modified Jython version of Analysis101.java. Can be run simultaneously with it.</td>
+  </tr>
+</table>
CVSspam 0.2.8