Usage of overlap functors for tracking efficiency determination
This example shows how to use the overlap functors and tuple information to calculate the tag-and-probe tracking efficiency offline
import Functors as F
from FunTuple import FunctorCollection, FunTuple_Particles as Funtuple
from PyConf.reading import (
get_particles,
get_pvs,
)
from DaVinci import Options, make_config
from RecoConf.standard_particles import make_ismuon_long_muon, make_long_pions
jpsi_mup_branches = {
"Jpsi": "J/psi(1S) -> mu+ mu-",
"muprobe": "J/psi(1S) -> ^mu+ mu-",
"mutag": "J/psi(1S) -> mu+ ^mu-",
}
def get_mother_variables():
v2_pvs = get_pvs()
mother_variables = FunctorCollection(
{ # this are standard functors
"ETA": F.ETA,
"ENDVERTEX_CHI2": F.CHI2,
"BPVDIRA": F.BPVDIRA(v2_pvs),
"MINIPCHI2": F.MINIPCHI2(v2_pvs),
"M": F.MASS,
}
)
return mother_variables
def get_daughter_variables():
muons = make_ismuon_long_muon()
pions = make_long_pions()
daughter_variables = FunctorCollection(
{ # non-exhaustive list of variables of the daughter track, and of the track (if matched) to the daughter track
# these are stamdard functors acting on the daughter track
"NDOF": F.VALUE_OR(-1) @ F.NDOF @ F.TRACK,
"NFTHITS": F.VALUE_OR(-1) @ F.NFTHITS @ F.TRACK,
"TRACKPT": F.TRACK_PT,
# these are overlap functors, giving the fraction of overlapping VP hits for the most overlapping track
"VPOVERLAPMUON": F.VPLHCBIDOVERLAP(Particles=muons),
# these are overlap functors, giving the fraction of overlapping VP hits for the most overlapping track, but now with pions
"UTOVERLAPMUON": F.UTLHCBIDOVERLAP(Particles=pions),
# we can also define a minimum overlap criterion
"FTOVERLAPMUON": F.FTLHCBIDOVERLAP(
Particles=muons, FTFrac=0.6, MuonFrac=0.4
),
# or decide to not consider neighbouring muon hits for the overlap
"MUONOVERLAPMUON": F.MUONLHCBIDOVERLAP(
Particles=muons, UseMuonNeighbours=False
),
"MUONOVERLAPWITHNEIGHBOURSMUON": F.MUONLHCBIDOVERLAPWITHNEIGHBOURS(
Particles=muons
),
"PT_OFBESTOVERLAPMUONWITHNEIGHBOURS": F.PT
@ F.BESTLHCBIDOVERLAP(Particles=muons),
"GhostProb_OFBESTOVERLAPMUONWITHNEIGHBOURS": F.GHOSTPROB
@ F.BESTLHCBIDOVERLAP(Particles=muons),
}
)
return daughter_variables
def get_jpsi_tuples(Tuples):
mother_variables = get_mother_variables()
daughter_variables = get_daughter_variables()
jpsi_data = get_particles(
"/Event/Spruce/SpruceTurCalTrackEff_DiMuon_VeloMuon_mup_Tag/Particles"
)
variables_jpsi = {
"Jpsi": mother_variables + FunctorCollection({"NCand": F.SIZE(jpsi_data)}),
"muprobe": daughter_variables,
"mutag": daughter_variables,
}
jpsi_tuple = Funtuple(
name="TrackEffTuple",
tuple_name="DecayTree",
fields=jpsi_mup_branches,
variables=variables_jpsi,
inputs=jpsi_data,
)
Tuples["TrackEffTuple"] = [jpsi_tuple]
def alg_config(options: Options):
Tuples = {}
get_jpsi_tuples(Tuples)
return make_config(options, Tuples)
To run the example:
lbexec DaVinciExamples.tupling.option_davinci_tupling_isoMVA_reltable:alg_config $DAVINCIEXAMPLESROOT/example_data/example_tupling_turcal_rawbanks_2025.yaml
For reference, these are the options of this example