Implement a ThOr functor-based monitoring
Implements an algorithm that creates 1D histograms of any functor applied on track-like or composite objects. Small fix to the mass functor, so it works correctly with LHCb v1 particles.
A possible implementation of the monitoring (in the core of a line builder in lhcb/Moore>) is:
from PyConf.Algorithms import Monitor__ParticleRange
def monitor(name, particles, functor, *, histogram_name, range, bins=100):
assert (len(range) == 2)
config = dict(
name=name,
Input=particles,
Variable=functor,
HistogramName=histogram_name,
Bins=bins,
Range=range)
bk = thor_backend()
if bk == PARTICLE_V1:
return Monitor__ParticleRange(**config)
else:
raise NotImplementedError(
f'Monitoring not implemented for ThOr backend "{bk}"')
@register_line_builder(all_lines)
@configurable
def ks02pipi_line(name="Hlt2KS02pipiLine", prescale=1):
pvs = make_pvs()
pions = filter_decay_products(make_long_pions(), pvs)
kaons = make_kaons('KS0 -> pi+ pi-', [pions, pions], pvs)
mass_min, mass_max = 400. * MeV, 600. * MeV
mass_monitor = monitor(
f'{name}MassMonitor',
kaons,
F.MASS,
histogram_name='mass',
range=(mass_min, mass_max))
return Hlt2Line(
name=name,
algs=upfront_reconstruction() + [kaons, mass_monitor],
prescale=prescale,
)
Related to LHCb!3278 (merged), Phys!997 (merged), Moore!1046 (merged)
Edited by Miguel Ramos Pernas