Skip to content

Simplify the monitoring and enable the creation of multidimensional histograms

Miguel Ramos Pernas requested to merge mramospe-monitoring into 2024-patches

Modify the main monitoring class to allow for making multiple histograms using a single algorithm. This massively simplifies the monitoring in HLT2, where there is currently one algorithm being created per histogram made. The new monitoring object allows to create both 1D and 2D histograms using the same instance, and its configuration can be easily defined from python using three helper classes histogram_axis, histogram_1d and histogram_2d. These classes are defined in a dedicated python module, incorporated to SelAlgorithms. The monitoring class can also handle cases where the functors act on global information of the event, integrating the algorithm that was previously defined in VoidMonitor.cpp, which has been removed. The monitoring can now be defined on a very pythonic way, like

import Functors
from GaudiKernel.SystemOfUnits import GeV
from SelAlgorithms import monitoring

particles = ... # data handle referring to the particles

# a 1D histogram of the mass
histogram_configuration_mass = monitoring.histogram_1d('monitor_mass', 'monitor mass', Functors.MASS, bins=100, range=(2 * GeV, 4 * GeV), label='MASS')

# a 2D histogram of the transverse momentum versus the pseudorapidity
axis_pt = monitoring.histogram_axis(Functors.PT, bins=100, range=(0., 10. * GeV), label='PT')
axis_eta = monitoring.histogram_axis(Functors.ETA, bins=100, range=(1.5, 5.5), label='ETA')
histogram_configuration_pt_over_eta = monitoring.histogram_2d('monitor_pt_over_eta', 'pt over eta', xaxis=axis_eta, yaxis=axis_pt)

# a 1D histogram of the number of candidates
histogram_configuration_n_candidates = monitoring.histogram_1d('monitor_n_candidates', 'number of candidates', Functors.SIZE(particles), bins=100, range=(0, 100), 'CANDIDATES')

# make the monitor that works taking input particles as an input
particle_monitor = monitoring.monitor(histograms=[histogram_configuration_mass, histogram_configuration_mass], data=particles)

# make a monitor that works on global information
global_monitor = monitoring.monitor(histograms=[histogram_configuration_n_candidates])

In this code snippet, the instances in particle_monitor and global_monitor will refer to the Gaudi algorithms that will take care of producing the monitoring histograms.

Goes with Moore!3119 (merged).

Edited by Miguel Ramos Pernas

Merge request reports