HLT2 selection API

HLT2 selection.

Standard particle makers

Maker functions for Particle definitions common across HLT2.

The Run 2 code makes the sensible choice of creating Particle objects first, and then filtering these with FilterDesktop instances. Because the FunctionalParticleMaker can apply ThOr predicates directly to Track and ProtoParticle objects, we just do the one step.

Implemented filters and builders: - get_{all, long, down, upstream, ttrack}_track_selector : selectors of specific track type containers - standard_protoparticle_filter : basic protoparticle filter - _make_particles : basic particle maker - _make_{ , all, long}_ChargedBasics : basic maker using Proto2ChargedBasic - make_long_cb_{electrons, muons, pions, kaons, protons} : maker of long ChargedBasic particles per type - make_has_rich_long_cb_{pions, kaons} : maker of long ChargedBasic particles per type requiring RICH - make_photons : basic builder for photons - make_long_electrons_{no, with}_brem : basic builders for long electrons with or without brem corrections - make_long_{muons, pions, kaons, protons} : basic builder for long muons, pions, kaons, protons - make_ismuon_long_muon : basic builder for long muons with ISMUON condition - make_{up, down}_{electrons_no_brem, muons, pions, kaons, protons} : basic builders for upstream or downstream electrons (no brem correction), muons, pions, kaons, protons - make_ttrack_{pions, protons} : basic builders for ttrack protons or pions - make_has_rich_{long, down, up}_{pions, kaons, protons} : basic builders for longstream, downstream and upstream pions, kaons, protons - make_has_rich_ttrack_{pions, protons} : basic builders for ttrack pions, protons - make_{resolved, merged}_pi0s : basic builder to make resolved and merged pi0 - filter_leptons_loose : basic filter for preselection of leptons - _make_dielectron_with_brem : - make_detached_{dielectron, mue, mumu} : detached dilepton builded - make_detached_{dielectron, mue}_with_brem : detached dilepton builder with included brem correction - make_dimuon_base : basic maker for dimuon combination - make_mass_constrained_jpsi2mumu : JpsiToMuMu builder using dimuon_base - make_phi2kk : basic builder for PhiToKK - _make_{long, down, up}_for_V0 : basic builder base for V0 combination basic particles - make_{long, down, up}_{pions, kaons, protons}_for_V0 : builders of particles for V0 - _make_V0{LL, DD, LD_UL} : basic builder for V0 particles - make_Ks{LL, DD, LD, UL} : builder of KS for LL, DD, LD, UL combinations - make_Ks{LL, DD}_fromSV : builder for KS originating from SV - make_Lambda{LL, DD} : builder for Lambda0, LL and DD combination - make_LambdaTT : builder for Lambda0, TT combination, using MVA filtered T tracks, uses a single RK extrapolation in first iteration of vertex fit - make_LambdaTT_gated : builder for Lambda0, TT combination, to go after a rare process in the control flow, uses a single RK extrapolation in first iteration of vertex fit - make_KsTT : builder for KS, TT combination, using MVA filtered T tracks, uses a single RK extrapolation in first iteration of vertex fit - make_KsTT_gated : builder for KS, TT combination, to go after a rare process in the control flow, uses a single RK extrapolation in first iteration of vertex fit

TO DO: - port LoKi-based track selectors to a proper ThOr-based track selectors

FunctionalDiElectronMaker(InputParticles, **kwargs)[source]
filter_leptons_loose(particles, lepton, pv_maker=<function make_pvs>, fake=False, pt_min=500.0, p_min=0.0, probnn_e=None, probnn_mu=None, pid_e=-999, pid_mu=None, ismuon=False, minipchi2=-999, trghostprob=None)[source]

Returns loosely preselected leptons

get_all_track_selector(Code=('::Functors::AcceptAll{}', 'ALL'))[source]
get_down_track_selector(Code=None)[source]
get_long_track_selector(Code=None)[source]
get_ttrack_track_selector(Code=None)[source]
get_upstream_track_selector(Code=None)[source]
make_KsDD(pions_down=None)[source]
make_KsDD_fromSV()[source]
make_KsLD(pions_down=None, pions_long=None)[source]
make_KsLL(pions_long=None)[source]
make_KsLL_fromSV()[source]
make_KsTT()[source]

Takes as input MVA filtered T track protons and pions, to reduce reconstruction time, and combinatorics (to control extrapolation time in the vertex fit). This should be used as standard if the control flow cannot be configured with a clear, infrequent process to control timing. Applies the same selections as for the “gated” combiner, but uses different inputs

make_KsTT_gated()[source]

Make KS0 -> pi pi (TT) candidates with a Runge-Kutta (RK) extrapolation in the first iteration only of vertex fit, linear extrapolation in subsequent iterations. To be used when there is a clear, infrequent signature prior in the control flow. Using the RK extrapolator once improves the vertex bias and mass bias compared to linear extrapolator, but mass resolution is still poor. This improves efficiency in the first half of the magnet wrt purely linear extrapolation.

make_KsUL(pions_long=None, pions_up=None)[source]
make_LambdaDD()[source]
make_LambdaLL()[source]
make_LambdaTT()[source]

Takes as input MVA filtered T track protons and pions, to reduce reconstruction time, and combinatorics (to control extrapolation time in the vertex fit). This should be used as standard if the control flow cannot be configured with a clear, infrequent process to control timing. Applies the same selections as for the “gated” combiner, but uses different inputs

make_LambdaTT_gated()[source]

Make Lambda -> p pi (TT) candidates with a Runge-Kutta (RK) extrapolation in the first iteration only of vertex fit, linear extrapolation in subsequent iterations. To be used when there is a clear, infrequent signature prior in the control flow. Using the RK extrapolator once improves the vertex bias and mass bias compared to linear extrapolator, but mass resolution is still poor. This improves efficiency in the first half of the magnet wrt purely linear extrapolation.

make_detached_dielectron(name='std_make_detached_dielectron_{hash}', pv_maker=<function make_pvs>, opposite_sign=True, dilepton_ID='J/psi(1S)', electron_maker=<function make_long_electrons_no_brem>, pid_e=2, probnn_e=None, pt_e=250.0, minipchi2=9.0, trghostprob=None, adocachi2cut=30, bpvvdchi2=30, vfaspfchi2ndof=10)[source]
make_detached_dielectron_with_brem(electron_maker=<function make_long_electrons_no_brem>, opposite_sign=True, fake_electrons=0, pv_maker=<function make_pvs>, PIDe_min=2.0, probnn_e=None, pt_e=250.0, p_e=0.0, minipchi2=9.0, trghostprob=None, dielectron_ID='J/psi(1S)', pt_diE=0.0, m_diE_min=0.0, m_diE_max=6000.0, adocachi2cut=30, bpvvdchi2=30, vfaspfchi2ndof=10)[source]

Make detached Jpsi -> e+ e- or [Jpsi -> e+ e+ ]cc candidates adding bremsstrahlung correction to the electrons. The selection follows make_detached_dielectron but the dielectron combination is built through _make_dielectron_with_brem, providing an example of the usage of this private method.

make_detached_mue(name='std_make_detached_mue_{hash}', opposite_sign=True, dilepton_ID='J/psi(1S)', fake_electrons=0, fake_muons=0, pv_maker=<function make_pvs>, pid_mu=0.2, probnn_mu=None, pt_mu=0.0, pid_e=2.0, probnn_e=None, pt_e=250.0, minipchi2=9.0, trghostprob=None, adocachi2cut=30, bpvvdchi2=30, vfaspfchi2ndof=10)[source]
make_detached_mue_with_brem(name='std_make_detached_mue_with_brem_{hash}', opposite_sign=True, dilepton_ID='J/psi(1S)', fake_electrons=0, fake_muons=0, pv_maker=<function make_pvs>, min_probnn_mu=None, min_PIDmu=0.0, IsMuon=False, min_pt_mu=0.0, min_PIDe=2, probnn_e=None, min_pt_e=250.0, minipchi2_track=9.0, max_trghostprob=None, max_adocachi2=30, min_bpvvdchi2=30, max_vchi2ndof=10)[source]

Make detached J/psi(1S) -> mu e candidates with ismuon muons and adding bremsstrahlung correction to the electrons. The opposite_sign flag is a boolean that can be activated.

make_detached_mumu(name='std_make_detached_mumu_{hash}', opposite_sign=True, fake_muons=0, dilepton_ID='J/psi(1S)', pv_maker=<function make_pvs>, pid_mu=2, IsMuon=False, probnn_mu=None, pt_mu=0.0, p_mu=0.0, minipchi2=9.0, trghostprob=None, adocachi2cut=30, bpvvdchi2=30, vfaspfchi2ndof=10)[source]
make_dimuon_base(name='std_DiMuonBaseCombiner_{hash}', maxVCHI2PDOF=25, pt=None, pid_mu=None, probnn_mu=None, adoca_chi2=None)[source]

Basic dimuon without any requirements but common vertex Please DO NOT add pt requirements here: a dedicated (tighter) dimuon filter is implemented in the dimuon module.

make_down_electrons()[source]
make_down_electrons_no_brem()[source]
make_down_kaons()[source]
make_down_kaons_for_V0()[source]
make_down_muons()[source]
make_down_pions()[source]
make_down_pions_for_V0()[source]
make_down_protons()[source]
make_down_protons_for_V0()[source]
make_has_rich_down_kaons()[source]
make_has_rich_down_pions()[source]
make_has_rich_down_protons()[source]
make_has_rich_long_cb_kaons()[source]
make_has_rich_long_cb_pions()[source]
make_has_rich_long_kaons()[source]
make_has_rich_long_pions()[source]
make_has_rich_long_protons()[source]
make_has_rich_ttrack_pions()[source]
make_has_rich_ttrack_protons()[source]
make_has_rich_up_kaons()[source]
make_has_rich_up_pions()[source]
make_has_rich_up_protons()[source]
make_ismuon_long_muon()[source]
make_long_cb_electrons()[source]
make_long_cb_kaons()[source]
make_long_cb_muons()[source]
make_long_cb_pions()[source]
make_long_cb_protons()[source]
make_long_electrons_no_brem()[source]
make_long_electrons_with_brem(bremadder='SelectiveBremAdder')[source]

Make long electrons adding bremsstrahlung correction to the track momentum. No extra cuts are applied.

make_long_kaons()[source]
make_long_muons()[source]
make_long_omegas()[source]
make_long_pions()[source]
make_long_pions_for_V0()[source]
make_long_protons()[source]
make_long_protons_for_V0()[source]
make_long_sigmams()[source]
make_long_sigmaps()[source]
make_long_xis()[source]
make_mass_constrained_jpsi2mumu(name='std_MassConstrJpsi2MuMuMaker_{hash}', jpsi_maker=<FunctionWrapper at 0x7f319e2ae100 for function>, nominal_mass=3096.9, pid_mu=0, probnn_mu=None, pt_mu=500.0, admass=250.0, adoca_chi2=20, vchi2=16)[source]

Make the Jpsi, starting from dimuons

make_merged_pi0s(mass_window=60.0, PtCut=2000.0, make_neutral_protoparticles=<function make_neutral_protoparticles>, pvs=<function make_pvs>, **kwargs)[source]
make_mva_filtered_ttrack_pions_for_V0()[source]
make_mva_filtered_ttrack_protons_for_V0()[source]
make_mva_ttrack_pions()[source]
make_mva_ttrack_protons()[source]
make_phi2kk(pv_maker=<function make_pvs>, am_max=1060.0, asumpt_min=500.0, kaon_p_min=2500.0, kaon_pt_min=250.0, kaon_pidk_min=-5, adoca12_max=0.3, vchi2=25.0, mipchi2_min=None, name='std_make_phi2kk_{hash}')[source]
make_photons(make_neutral_protoparticles=<function make_neutral_protoparticles>, pv_maker=<function make_pvs>, **kwargs)[source]

creates photon LHCb::Particles from LHCb::ProtoParticles (PVs are optional)

make_prompt_dielectron_with_brem(electron_maker=<function make_long_electrons_no_brem>, opposite_sign=True, pv_maker=<function make_pvs>, PIDe_min=2.0, probnn_e=None, pt_e=250.0, p_e=0.0, maxipchi2=9.0, trghostprob=0.25, dielectron_ID='J/psi(1S)', pt_diE=0.0, m_diE_min=0.0, m_diE_max=6000.0, adocachi2cut=30, bpvvdchi2=30, vfaspfchi2ndof=10)[source]

Make prompt Jpsi -> e+ e- or [Jpsi -> e+ e+ ]cc candidates adding bremsstrahlung correction to the electrons. The selection follows make_detached_dielectron_with_brem but the dielectron combination is built through _make_dielectron_with_brem, providing an example of the usage of this private method.

make_resolved_pi0s(particles=<FunctionWrapper at 0x7f319e3378e0 for function>, nominal_mass=134.9768, mass_window=30.0, PtCut=0.0, **kwargs)[source]
make_ttrack_pions(make_protoparticles=<FunctionWrapper at 0x7f319e330820 for function>)[source]
make_ttrack_pions_for_V0(make_pions=<FunctionWrapper at 0x7f319e337ac0 for function>, make_pvs=<function make_pvs>, pt_min=75.0, p_min=0.0, minipchi2_min=0.0)[source]
make_ttrack_protons(make_protoparticles=<FunctionWrapper at 0x7f319e330820 for function>)[source]
make_ttrack_protons_for_V0(make_protons=<FunctionWrapper at 0x7f319e337be0 for function>, make_pvs=<function make_pvs>, p_min=20000.0, pt_min=400.0, minip_max=400.0, minipchi2_max=30000.0, minipchi2_min=0.0)[source]
make_up_electrons_no_brem()[source]
make_up_kaons()[source]
make_up_kaons_for_V0()[source]
make_up_muons()[source]
make_up_pions()[source]
make_up_pions_for_V0()[source]
make_up_protons()[source]
make_up_protons_for_V0()[source]
standard_protoparticle_filter(Code=('::Functors::AcceptAll{}', 'ALL'))[source]

Standard primary vertex makers

Module to allow switching between prompt reconstruction and reconstruction from file.

The user can switch between the two options in a top level configuration file by binding the argument from_file of the function reconstruction.

make_pvs()[source]

Return a DataHandle to the container of PVs

Selection algorithms – ThOr

These Python helper functions wrap C++ algorithm configurables that use ThOr functors.

The Converting an HLT2 line to ThOr functors tutorial is a good place to learn more about ThOr functors if you are unfamiliar with them.

Particle filters

Each filter takes a single container of particles as input. They all inherit their functionality from the Pr::Filter C++ algorithm.

ParticleFilter(Input, Cut, **kwargs)[source]

Return the output of a particle filter.

Parameters
  • Input (DataHandle) – Particle container to filter.

  • Cut – ThOr functor expression.

  • **kwargs – Passed to the algorithm instantiation. It can be used to set a name to the algorithm during development, but not in production code (see Moore#378 and Moore#380)

An example configuration:

from GaudiKernel.SystemOfUnits import MeV
import Functors as F
from Hlt2Conf.standard_particles import (
    make_long_pions,
    make_pvs,
)


pions = make_long_pions()
pvs = make_pvs()
filtered = ParticleFilter(
    Input=pions,
    Cut=F.FILTER(F.require_all(
        F.PT > 500 * MeV,
        F.MINIPCHI2(pvs) > 4,
    )),
)

Particle combiners

The N-body combiner takes a list of \(N\) particle containers as input along with a decay descriptor specifying the single-level decay hypothesis to reconstruct. They all inherit most of their functionality from the NBodyParticleCombiner C++ algorithm.

ParticleCombiner(Inputs, **kwargs)[source]

Return the output of an N-body particle combiner.

Parameters
  • Inputs (list of DataHandle) – The length N of this list is used to instantiate the appropriate NBodyParticleCombiner.

  • **kwargs – Passed to the algorithm instantiation.

Depending on \(N\), different cut parameters are made available which permit selections on intermediate pre-fit combinations of size \(N - 1\), \(N - 2\), and so on.

An example two-body configuration:

from GaudiKernel.SystemOfUnits import GeV, MeV
import Functors as F
from Hlt2Conf.standard_particles import (
    make_long_pions,
    make_pvs,
)


pions = make_long_pions()
pvs = make_pvs()
kshorts = ParticleCombiner(
    Inputs=[pions, pions],
    DecayDescriptor="KS0 -> pi+ pi-",
    CombinationCut=F.require_all(
        F.SUM(F.PT) > 2 * GeV,
        in_range(450 * MeV, F.MASS, 550 * MeV),
    ),
    CompositeCut=F.BPVFDCHI2(pvs) > 2,
)

A two-body decay has no intermediate combinations (only ‘combinations’ where \(N = 1\), selections on which can use a ParticleFilter) and so only selections on the two-body pre-fit combination are configurable: CombinationCut.

An example three-body configuration, using the previous two-body combination as input:

dzero = ParticleCombiner(
    Inputs=[kshorts, pions, pions],
    DecayDescriptor="D0 -> KS0 pi+ pi-",
    Combination12Cut=F.MAXDOCACHI2CUT(10.),
    CombinationCut=F.require_all(
        in_range(1500 * MeV, F.MASS, 2500 * MeV),
        F.MAXDOCACHI2CUT(16.),
    ),
    CompositeCut=F.CHI2DOF < 12,
)

Now the Combination12Cut defines a selection on the intermediate KS0 pi+ combination. The CombinationCut property defines a selection for the full KS0 pi+ pi- combination.

Helpers

require_all(*cuts)[source]

Return a functor expression requiring all arguments.

Example

>>> import Functors as F
>>> functor = F.require_all(F.PT > 1, F.PID_K < 0)
>>> functor.code_repr()
'( ( ( RHO_COORDINATE @ THREEMOMENTUM ) > 1 ) & ( ( VALUE_OR(Value=nan) @ _PID_K ) < 0 ) )'
require_any(*cuts)[source]

Return a functor expression requiring at least one of arguments.

Example

>>> import Functors as F
>>> functor = F.require_any(F.PT > 1, F.PID_K < 0)
>>> functor.code_repr()
'( ( ( RHO_COORDINATE @ THREEMOMENTUM ) > 1 ) | ( ( VALUE_OR(Value=nan) @ _PID_K ) < 0 ) )'

Selection algorithms – LoKi

These Python helper functions wrap C++ algorithm configurables that use LoKi functors.

Note

If at all possible you should use ThOr-based algorithms described in Selection algorithms – ThOr rather than LoKi-based variants.

If you already have LoKi-based HLT2 lines you can follow the Converting an HLT2 line to ThOr functors tutorial to learn how to migrate.

Particle filters

Each filter takes a single container of particles as input. They all inherit their functionality from the FilterDesktop C++ algorithm.

Particle combiners

Each combiner takes a list of particle containers as input along with a decay descriptor specifying the single-level decay hypothesis to reconstruct. They all inherit most of their functionality from the CombineParticles C++ algorithm.