Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Added Event Loop Control section

...

Methods beginrun(), endrun(), begincalibcycle(), and endcalibcycle() are optional, analysis module does not have to define them and they are called only if defined.

Anchor
EventLoopControl
EventLoopControl

Event Loop Control

Code in user modules can control framework event loop by returning a value from event() method which is different from None (if there is no return statement in the method it is equivalent to returning None). Following values are recognized by framework:

  • pyana.Skip
    This will skip event() all downstream modules
  • pyana.Stop
    This will stop event loop, all end*() methods are called as usual
  • pyana.Terminate
    This will cause immediate job termination, end*() methods are not called

Here is simplified example of this feature use:

Code Block

# import is necessary to use return codes
import pyana

class ExampleModule(object):
  
    def event(self, evt, env):

        ...

        if pixelsAboveThreshold < 1000:
            # This event is not worth looking at, skip it
            return pyana.Skip

        if self.nGoodEvents > 1000:
           // we collected enough data, can stop now and go to endjob()
           return pyana.Stop

        if temperatureKelvin < 0:
            # data is junk, stop right here and don't call endJob()
            return pyana.Terminate

Anchor
Configuration
Configuration

...

Short

Long

Config File

Option type

Default

Description

-v

--verbose

verbose

integer

0

Command line options do not need any values but can be repeated multiple times, configuration file option accepts single integer number.

-c file

--config=file

 

path

pyana.cfg

Name of the configuration file.

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="d75d47b3e3fec1a9-5c80a84d-428e461a-a6e28ae0-5fd6aae14a31c77eaa9ad821"><ac:plain-text-body><![CDATA[

-C name

--config-name=name

 

string

 

If non-empty string is given then configuration will be read from section [pyana.name] in addition to [pyana].

]]></ac:plain-text-body></ac:structured-macro>

-l file

--file-list=file

file-list

path

 

The list of input data files will be read form a given file which must contain one file name per line.

-n number

--num-events=number

num-events

integer

0

Maximum number of events to process, this counter will include damaged events too.

-s number

--skip-events=number

skip-events

integer

0

number of events to skip

-j name

--job-name=name

job-name

string

 

Sets job name which is accessible to user code via environment method. Default name is based on the input file names.

-m name

--module=name

modules

string

 

User analysis module(s). Command line options can be repeated several times, configuration file option accepts space-separated list of names.

-p number

--num-cpu=number

num-cpu

integer

1

Number of processes to run, if greater than 1 then multi-processing mode will be used.

...