event_management#

Classes and function for handling data events.

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

class EventCounter(*, speed_report_interval=None, data_broadcast_interval=None, hit_frame_sending_interval=None, non_hit_frame_sending_interval=None, 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:
  • om_parameters

    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 pass 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.

  • node_pool_size (int) – The total number of nodes in the OM pool, including all the processing nodes and the collecting node.

  • speed_report_interval (int | None)

  • data_broadcast_interval (int | None)

  • hit_frame_sending_interval (int | None)

  • non_hit_frame_sending_interval (int | None)

add_hit_event()#

Adds a hit event to the event counter.

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

Return type:

None

add_non_hit_event()#

Adds a non-hit event to the event counter.

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

Return type:

None

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:

The timestamp of for the initialization of the class.

Return type:

float

should_broadcast_data()#

Whether data should be broadcast to external programs.

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

Returns:

Whether data should be broadcast.

Return type:

bool

should_send_hit_frame()#

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

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

Returns:

Whether a hit detector frame should be broadcast.

Return type:

bool

should_send_non_hit_frame()#

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

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

Returns:

Whether a non-hit detector frame should be broadcast.

Return type:

bool

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.

Om should invoke this function to determine which node should provide a data frame to send to external programs. This event counter class keeps an internal index of the nodes from which frames 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:

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

Return type:

int

get_num_events()#

Gets number of processed events.

Returns:

The number of processed events.

Return type:

int

get_num_hits()#

Gets number of processed hit events.

Returns:

The number of processed hit events.

Return type:

int

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.

Return type:

None