Skip to content

event_management

Classes and function for handling data events.

This module contains classes and functions that manage and count data events processed by OM.

EventCounter

See documentation for the __init__ function.

__init__(*, om_parameters, node_pool_size)

Event count and management.

This class stores all the information needed to count data events processed by OM.

After this class has been initialized, it can be provided with information about OM's processed data events. The class can then be invoked to generate speed reports, and can be queried about whether the number of processed events requires data to be broadcast to external programs.

Parameters:

Name Type Description Default
om_parameters Dict[str, Any]

A set of OM configuration parameters collected together in a parameter group. The parameter group must contain the following entries:

  • speed_report_interval: The number of events that must pass between consecutive speed reports from OM.

  • data_broadcast_interval: The number of events that must pas between consecutive data broadcasts from OM.

  • hit_frame_sending_interval: How often the monitor should send full detector frames to external programs, when events are labelled as hits. If the value of this parameter is None, no hit frames are ever sent. If the value is a number, it is the average number of hit frames that OM skips before the next hit frame is broadcast to external programs. Defaults to None.

  • non_hit_frame_sending_interval: How often the monitor should send full detector frames to external programs, when events are labelled as non-hits. If the value of this parameter is None, no non-hit frames are ever sent. If the value is a number, it is the average number of non-hit frames that OM skips before the next non-hit frame is broadcast to external programs. Defaults to None.

required
node_pool_size int

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

required

add_hit_event()

Adds hit events to the event counter.

This function updates the number of hit events counted by this class.

add_non_hit_event()

Adds non-hit events to the event counter.

This function updates the number of non-hit events counted by this class.

get_start_timestamp()

Gets timestamp of class initialization.

This function returns the time at which the event counter class was initialized. This usually corresponds to the moment when OM started processing events.

Returns:

Type Description
float

The timestamp of for the initialization of the class.

should_broadcast_data()

Whether data should be broadcast to external programs.

This function computes if the number of processed events requires data to be broadcast to external programs.

Returns:

Type Description
bool

Whether data should be broadcast.

should_send_hit_frame()

Whether a hit detector data frame should be broadcast to external programs.

This function computes if the number of processed hit events requires a hit detector data frame to be broadcast to external programs.

Returns:

Type Description
bool

Whether a hit detector frame should be broadcast.

should_send_non_hit_frame()

Whether a non-hit detector data frame should be broadcast to external programs.

This function computes if the number of processed non-hit events requires a non-hit detector data frame to be broadcast to external programs.

Returns:

Type Description
bool

Whether a non-hit detector frame should be broadcast.

get_rank_for_frame_request()

Gets the processing node rank to request a frame from.

This function returns the rank of the processing node from which a hit or non-hit detector data frame should be requested for external broadcast.

This class keeps an internal index of the nodes from which images have been requested in the past, and attempts to spread requests in a round-robin fashion amongst all processing nodes, with the goal of not overloading a single node with requests and of getting a representative sample of the data frames processed by each node.

Returns:

Type Description
int

The rank of the processing node from which a detector data frame should be

int

requested.

get_num_events()

Gets number of processed events.

Returns:

Type Description
int

The number of processed events.

get_num_hits()

Gets number of processed hit events.

Returns:

Type Description
int

The number of processed hit events.

report_speed()

Prints a speed report to the console.

This prints the number of processed events to the console, together with an estimate of the processing speed, based on the number of events recorded by this class.