You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 9 Next »

Package pyana


Module event

This module is a collection of classes and methods to deal with the event data and everything related to it.


Class Event

Construction

Usage: evt = pyana.event.Event(dg)

Creates event object from the corresponding XTC datagram object.

Parameters:

  • dg – datagram object of type _pdsdata.xtc.Dgram

Method seq()

Usage: s = evt.seq()

Returns _pdsdata.xtc.Seq object, equivalent to dg.seq

Method getTime()

Usage: t = evt.getTime()

Returns _pdsdata.xtc.ClockTime object, equivalent to dg.seq.clock()

Method find()

Usage: objects = evt.find(...)

Returns possibly empty list of data objects contained in the event. This method accepts a number of arguments, but all arguments are optional. If no arguments are given then a list of all data objects is returned. If some arguments are given then only those objects that satisfy a particular criteria are returned. The list of possible keyword arguments:

  • typeId – accepts one of the xtc.TypeId.Type.<Xxx>, only return objects which have that TypeId
  • version – accepts number, only return objects whose type version number is equal to number
  • level – accepts one of xtc.Level.<Xxx> values, only returns objects originated at that level
  • detector – accepts one of xtc.DetInfo.Detector.<Xxx> values, only returns objects produced by this detector
  • detId – accepts number, only returns objects produced by this detector ID
  • device – accepts one of xtc.DetInfo.Device.<Xxx> values, only returns objects produced by this device
  • devId – accepts number, only returns objects produced by this device ID
  • addressxtc.DetInfo object or an address string (see User Manual)

The parameters address and any of the detector, detId, device, devId are incompatible, specify only one or another.

Method findFirst()

Usage: object = evt.findFirst(...)

Accepts the same set of arguments as find() methods but instead of list of objects returns fist object found. If no object is satisfying all selection criteria then None is returned.

Method getAcqConfig()

Usage: acqConfig = evt.getAcqConfig(address)

Returns Acqiris configuration data of type acqiris.ConfigV* for specific device. If address given is not very specific then the first matching object is returned.

Parameters:

  • addressxtc.DetInfo object or an address string (see User Manual)

Ordinary configuration objects are contained in a Configure type datagrams only. For client code that means that this method can be used in beginjob() or beginrun() methods only. Note also that configuration objects are stored in the Pyana environment and preferred way to access configuration information is through the environment. This makes this method of little utility to end users.

Method getOpal1kConfig()

Usage: opalConfig = evt.getOpal1kConfig(address)

Returns Opal1k configuration data of type opal1k.ConfigV* for specific device. If address given is not very specific then the first matching object is returned.

Parameters:

  • addressxtc.DetInfo object or an address string (see User Manual)

Same caveats apply as for getAcqConfig() method.

Method getAcqValue()

Usage: acqData = evt.getAcqValue(address, channel, env)

Returns Acqiris data object of type acqiris.DataDescV* for specific device and channel. If address given is not very specific then the first matching object is returned.

Parameters:

  • addressxtc.DetInfo object or an address string (see User Manual)
  • channel – channel number from 0 to max number of channels
  • env – environment object containing Acqiris configuration object

Channel number is an integer number, total number of channels can be extracted from the Acqiris configuration object.

Method getPnCcdValue()

Usage: frame = evt.getPnCcdValue(address, env)

returns pnCCD data object of type pnccd.FrameV* for specific device and channel. If address given is not very specific then the first matching object is returned.

Parameters:

  • addressxtc.DetInfo object or an address string (see User Manual)
  • env – environment object containing pnCCD configuration object

Method getFeeGasDet()

Usage: array = evt.getFeeGasDet()

Returns the list of 4 numbers [f_11_ENRC, f_12_ENRC, f_21_ENRC, f_22_ENRC]

Method getPhaseCavity()

Usage: obj = evt.getPhaseCavity()

Returns data object of type bld.BldDataPhaseCavity.

Method getEBeam()

Usage: obj = evt.getEBeam()

Returns data object of type bld.BldDataEBeam or bld.BldDataEBeamV0 whichever is present in the event.


Class Env

Construction

Usage: env = pyana.event.Env(jobName="pyana", hmgr=None, subproc=False)

Creates environment object.

Parameters:

  • jobName – analysis job name, arbitrary string
  • hmgr – histogram manager object
  • subproc – flag which must be set to true when running in pyana sub-process

Objects of this type are created by pyana itself and end users do not need to create new instances.

Method jobName()

Usage: jobName = env.jobName()

Returns analysis job name string.

Method hmgr()

Usage: hmgr = env.hmgr()

Returns histogram manager object of type pyana.histo.HistoManager*.

Method mkfile()

Usage: file = env.mkfile(filename, mode='w', bufsize=-1)

Opens file for writing output data. This is pyana's alternative for Python open() function which supports multi-processing. If user needs the data in this file to be merged with the files produced by other processes then mkfile() has to be used in place of open().

Parameters:

  • filename – output file name
  • mode – open mode, currently any "w*" modes are supported
  • bufsize – output buffer size, default is to use Python's default

In case of single-process job this method is equivalent to a regular Python open() method. In case of multi-processing when this method is called from a sub-process then the file is created somewhere in a temporary location (with unique name). At the end of the job files from all sub-processes are merged into one file with name filename and the temporary files are deleted.

Method epicsStore()

Usage: store = env.epicsStore()

This is the primary method for user code to access EPICS data. It returns event.EpicsStore object which can be used to retrieve the state of the individual EPICS channels.

Method update()

Usage: env.update(evt)

This method updates environment contents with selected data from event object. This is equivalent to calling env.updateEpics() and env.updateConfig().

Parameters:

  • evt – event object of type event.Event

This method is not supposed to be called from user code, pyana takes care of all updates itself.

Method updateEpics()

Usage: env.updateEpics(evt)

This method updates environment EPICS data from event object.

Parameters:

  • evt – event object of type event.Event

This method is not supposed to be called from user code, pyana takes care of all updates itself.

Method updateConfig()

Usage: env.updateConfig(evt)

This method copies configuration objects from event object into environment.

Parameters:

  • evt – event object of type event.Event

This method is not supposed to be called from user code, pyana takes care of all updates itself.

Method getAcqConfig()

Usage: acqConfig = env.getAcqConfig(...)

Returns Acqiris configuration object for a given device address. If more than one object is matched by the parameters then first arbitrary object is returned.

Keyword arguments:

  • detector – accepts one of xtc.DetInfo.Detector.<Xxx> values, only returns objects produced by this detector
  • detId – accepts number, only returns objects produced by this detector ID
  • device – accepts one of xtc.DetInfo.Device.<Xxx> values, only returns objects produced by this device
  • devId – accepts number, only returns objects produced by this device ID
  • addressxtc.DetInfo object or an address string (see User Manual)

Method getPnCCDConfig()

Usage: pnccdConfig = env.getPnCCDConfig(...)

Returns pnCCD configuration object for a given device address. If more than one object is matched by the parameters then first arbitrary object is returned.

Accepts the same keyword arguments as the getAcqConfig() method.

Method getOpal1kConfig()

Usage: opalConfig = env.getOpal1kConfig(...)

Returns Opal1k configuration object for a given device address. If more than one object is matched by the parameters then first arbitrary object is returned.

Accepts the same keyword arguments as the getAcqConfig() method.

Method result()

Usage: data = env.result()

Method used by pyana to extract the data produced by a single sub-process in multi-processing setup. Not to be used by end users.


Class EpicsStore

Construction

Usage: store = pyana.event.EpicsStore()

Creates EPICS store object.

Objects of this type are created by pyana itself and end users do not need to create new instances.

Method update()

Usage: store.update(evt)

This method updates environment EPICS data from event object.

Parameters:

  • evt – event object of type event.Event

This method is not supposed to be called from user code, pyana takes care of all updates itself.

Method value()

Usage epics = store.value(name)

Returns current value of the EPICS channel with the given name. The type of returned data is either pypdsdata.epics.EpicsPvCtrl or pypdsdata.epics.EpicsPvTime.

Parameters:

  • name – name of the EPICS channel

This is the primary method to access EPICS information in pyana jobs.


Module histo

This module is a collection classes and methods to create and manage histograms from user analysis modules.


Class HistoMgrRoot

This class represents histogram manager implementation based on ROOT library. Histograms that are created by this manager reside either in memory or in a ROOT file.

Construction

Usage: hmgr = pyana.histo.HistoMgrRoot(...)

Creates new histogram manager object. Users should not instantiate new objects, instead the environment method hmgr() should be used to obtain existing manager object.

Keyword arguments:

  • file – name of the ROOT file to store histograms, if missing then histograms will be memory-resident

Method h1d

Usage: hist = hmgr.h1d(...)

Creates 1-dimensional histogram with bin contents stored as double precision numbers.

Method accepts the same arguments as the constructors of the corresponding C++ ROOT class TH1D. The returned object also inherits most of the methods of the C++ class.

Method h1f

Usage: hist = hmgr.h1f(...)

Creates 1-dimensional histogram with bin contents stored as single precision numbers.

Method accepts the same arguments as the constructors of the corresponding C++ ROOT class TH1F. The returned object also inherits most of the methods of the C++ class.

Method h1i

Usage: hist = hmgr.h1i(...)

Creates 1-dimensional histogram with bin contents stored as integer numbers.

Method accepts the same arguments as the constructors of the corresponding C++ ROOT class TH1I. The returned object also inherits most of the methods of the C++ class.

Method h2d

Usage: hist = hmgr.h2d(...)

Creates 2-dimensional histogram with bin contents stored as double precision numbers.

Method accepts the same arguments as the constructors of the corresponding C++ ROOT class TH2D. The returned object also inherits most of the methods of the C++ class.

Method h2f

Usage: hist = hmgr.h2f(...)

Creates 2-dimensional histogram with bin contents stored as single precision numbers.

Method accepts the same arguments as the constructors of the corresponding C++ ROOT class TH2F. The returned object also inherits most of the methods of the C++ class.

Method h2i

Usage: hist = hmgr.h2i(...)

Creates 2-dimensional histogram with bin contents stored as integer numbers.

Method accepts the same arguments as the constructors of the corresponding C++ ROOT class TH2F. The returned object also inherits most of the methods of the C++ class.

Method prof

Usage: hist = hmgr.prof(...)

Creates 1-dimensional profile histogram with bin contents stored as double precision numbers.

Method accepts the same arguments as the constructors of the corresponding C++ ROOT class TProfile. The returned object also inherits most of the methods of the C++ class.

Method prof2d

Usage: hist = hmgr.prof2d(...)

Creates 2-dimensional profile histogram with bin contents stored as double precision numbers.

Method accepts the same arguments as the constructors of the corresponding C++ ROOT class TProfile2D. The returned object also inherits most of the methods of the C++ class.

  • No labels