Page History
...
Code Block |
---|
time: <T:1280631930.026688363>, charge: 0.251309, energy=4386.32 time: <T:1280631930.043360843>, charge: 0.233403, energy=4393.24 time: <T:1280631930.060033392>, charge: 0.246535, energy=4400.88 time: <T:1280631930.076703847>, charge: 0.247861, energy=4396.93 time: <T:1280631930.093381914>, charge: 0.248759, energy=4380.69 time: <T:1280631930.110053067>, charge: 0.240726, energy=4401.18 time: <T:1280631930.126720938>, charge: 0.239678, energy=4387.77 time: <T:1280631930.143398446>, charge: 0.243547, energy=4384.99 ... |
This is probably the simplest module that you can create and it does not use any interesting features such as parameters. Here is an example of slightly more advanced module, it's job is to count fraction of events with beam energy above certain threshold. Replace code in my_ana_pkg/src/my_ana_mod.py
with this:
Code Block |
---|
class my_ana_mod (object) :
def __init__ ( self, threshold ) :
# parameters
self.threshold = float(threshold)
# statistics
self.count = 0
self.total = 0
def beginjob( self, evt, env ) :
pass
def event( self, evt, env ) :
ebeam = evt.getEBeam()
if ebeam:
energy = ebeam.fEbeamL3Energy
if energy > self.threshold: self.count += 1
self.total += 1
def endjob( self, evt) :
print "Fraction of events with energy>%g is %g%%" % \
(self.threshold, self.count*100.0/self.total)
|
That module requires input parameter (threshold) from configuration file. Create file pyana.cfg
in current directory with this contents:
Code Block |
---|
[pyana]
modules = my_ana_pkg.my_ana_mod
[my_ana_pkg.my_ana_mod]
threshold = 4400
|
And run the job, module name is specified in config file so it is not needed on the command line:
Code Block |
---|
% pyana /reg/d/psdm/AMO/amo14110/xtc/e43-r0100-s0*
Fraction of events with energy>4400 is 16.1945%
|
Overview
Content Tools