Skip to content

data_event_handlers_psana

Handling of psana-based data events.

This module contains Data Event Handler classes that manipulate events originating from the psana software framework (used at the LCLS facility).

PsanaDataEventHandler

Bases: OmDataEventHandlerProtocol

See documentation of the __init__ function.

__init__(*, source, data_sources, monitor_parameters)

Data Event Handler for psana events.

This class handles data events retrieved from the psana software framework at the LCLS facility.

This class implements the interface described by its base Protocol class. Please see the documentation of that class for additional information about the interface.

  • For this Event Handler, a data event corresponds to the content of an individual psana event.

  • The source string required by this Data Event Handler is a string of the type used by psana to identify specific runs, experiments, or live data streams.

Parameters:

Name Type Description Default
source str

A string describing the data event source.

required
data_sources Dict[str, OmDataSourceProtocol]

A dictionary containing a set of Data Source class instances.

  • Each dictionary key must define the name of a data source.

  • The corresponding dictionary value must store the instance of the Data Source class # noqa: E501 that describes the source.

required
monitor_parameters MonitorParameters

An object storing OM's configuration parameters.

required

initialize_event_handling_on_collecting_node(*, node_rank, node_pool_size)

Initializes psana event handling on the collecting node.

Please see the documentation of the base Protocol class for additional information about this method.

Psana event handling does not need to be initialized on the collecting node, so this function actually does nothing.

Parameters:

Name Type Description Default
node_rank int

The rank, in the OM pool, of the processing node calling the function.

required
node_pool_size int

The total number of nodes in the OM pool, including all the processing nodes and the collecting node.

required

initialize_event_handling_on_processing_node(node_rank, node_pool_size)

Initializes psana event handling on the processing nodes.

Please see the documentation of the base Protocol class for additional information about this method.

Psana event handling does not need to be initialized on the processing nodes, so this function actually does nothing.

Parameters:

Name Type Description Default
node_rank int

The rank, in the OM pool, of the processing node calling the function.

required
node_pool_size int

The total number of nodes in the OM pool, including all the processing nodes and the collecting node.

required

event_generator(*, node_rank, node_pool_size)

Retrieves psana events.

Please see the documentation of the base Protocol class for additional information about this method.

This function retrieves data events on the processing nodes. Each retrieved event corresponds to a single psana event.

When OM retrieves real-time data at the LCLS facility, each processing node receives data from a shared memory server operated by the facility, running on the same machine as the node. The server takes care of distributing the data events. When instead OM uses the psana framework to read offline data, this function tries to distribute the events as evenly as possible across all the processing nodes, with each node ideally processing the same number of events. If the total number of events cannot be split evenly, the last last node processes fewer events than the others.

Parameters:

Name Type Description Default
node_rank int

The OM rank of the current node int the OM node pool. The rank is an integer that unambiguously identifies the node in the pool.

required
node_pool_size int

The total number of nodes in the OM pool, including all the processing nodes and the collecting node.

required

open_event(*, event)

Opens a psana event.

Please see the documentation of the base Protocol class for additional information about this method.

Psana events do not need to be opened, so this function actually does nothing.

Parameters:

Name Type Description Default
event Dict[str, Any]

A dictionary storing the event data.

required

close_event(*, event)

Closes a psana event.

Please see the documentation of the base Protocol class for additional information about this method.

Psana events do not need to be closed, so this function actually does nothing.

Parameters:

Name Type Description Default
event Dict[str, Any]

A dictionary storing the event data.

required

extract_data(*, event)

Extracts data from a psana data event.

Please see the documentation of the base Protocol class for additional information about this method.

Parameters:

Name Type Description Default
event Dict[str, Any]

A dictionary storing the event data.

required

Returns:

Type Description
Dict[str, Any]

A dictionary storing the extracted data.

  • Each dictionary key identifies a Data Source in the event for which data has been retrieved.

  • The corresponding dictionary value stores the data extracted from the Data Source for the event being processed.

Raises:

Type Description
OmDataExtractionError

Raised when data cannot be extracted from the event.

initialize_event_data_retrieval()

Initializes event data retrievals from psana.

This function initializes the retrieval of single standalone data events from psana.

Please see the documentation of the base Protocol class for additional information about this method.

retrieve_event_data(event_id)

Retrieves all data related to the requested event.

Please see the documentation of the base Protocol class for additional information about this method.

This function retrieves all data related to the event specified by the provided identifier. The psana unique event identifier is a string combining psana's timestamp and fiducial information, with the following format: {timestamp: seconds}-{timestamp: nanoseconds}-{fiducials}.

Parameters:

Name Type Description Default
event_id str

A string that uniquely identifies a data event.

required

Returns:

Type Description
Dict[str, Any]

All data related to the requested event.

Raises:

Type Description
OmMissingDataEventError

Raised when an event cannot be retrieved from the data source.