Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
class my_ana_mod (object) :

    def __init__ ( self ) :
        pass

    def beginjob( self, evt, env ) :
        pass

    def event( self, evt, env ) :

        time = evt.getTime()   # get event time object
        ebeam = evt.getEBeam() # get EBeam object

        # dump objects        
        print "time: %s, charge: %g, energy=%g" % \
                (time, ebeam.fEbeamCharge, ebeam.fEbeamL3Energy)

    def endjob( self, evt) :
        pass

After you finished editing your module build everything in the release:

Code Block

scons

To run this analysis start pyana giving it module name and input files:

...

And run the job, module name is specified in config file so it is not needed on the command line:

Code Block
% scons
% pyana /reg/d/psdm/AMO/amo14110/xtc/e43-r0100-s0*
Fraction of events with energy>4400 is 16.1945%

More interesting example is to run two instances of the same module in a job with different set of parameters. For this just replace the content of pyana.cfg with this:

Code Block

[pyana]
modules = my_ana_pkg.my_ana_mod:thresh4390 my_ana_pkg.my_ana_mod:thresh4400

[my_ana_pkg.my_ana_mod:thresh4390]
threshold = 4390

[my_ana_pkg.my_ana_mod:thresh4400]
threshold = 4400

and run again:

Code Block

% pyana /reg/d/psdm/AMO/amo14110/xtc/e43-r0100-s0*
Fraction of events with energy>4390 is 56.5572%
Fraction of events with energy>4400 is 16.1945%