Writing the Drivers in Jython
The case for Jython
Let's consider the following case: You are an experienced org.lcsim user and have a range of Drivers that perform various tasks for you. You would like a summer student to help you with some coding, but the student has no programming experience whatsoever.
Rather than having to waste two weeks teaching the details of the Java language, you could create an Example in Jython, an object-oriented scripting language that can be learned in a few days.
The Jython wrapper
If you want to use Drivers written in Jython, you will have to use a little wrapper script. That should not be much of a hassle, since your program is likely split up into various Drivers already anyway. (If not, it probably should be). In this case, all you have to do is replace your current Java wrapper with the Jython version.
Please load mainLoop.py into Jas3
Using the Jython wrapper
Please save mainLoop.py, Analysis101.java, Analysis102.py and psiMuMu.slcio to your harddisk. psiMuMu.slcio is a small datasample, Analysis101.java is our analysis module, which is taken straight from the JAS3 examples, Analysis102.py is a slightly modified Jython version of the Java module and mainLoop.py is the wrapper that takes care of loading the analysis module correctly.
After compiling the java file with
javac Analysis101.java
you can start the program with
jython mainLoop.py
which will loop over the data sample and create a file exampleAnalysis.aida
. Please note that this file contains both the output from the Java module and the output from the Jython module.
You can add your own analysis modules by replacing
loop.add(Analysis101()) loop.add(Analysis102())
with your analysis modules
Don't forget to import your Java modules with
import MyJavaAanalysisModule
and your Jython modules with
from MyJythonModuleName import MyJythonClassName