Skip to content
Snippets Groups Projects

Update tagging array qmtest including mctruth infos

Merged Davide Fazzini requested to merge dfazzini_update_tagging_test into master
Files
3
@@ -20,53 +20,107 @@ Then the MAP_INPUT_ARRAY functor takes in input this relation map and for each
entry stores the output of an external functor (i.e F.P, F.PT) in a vector.
"""
import Functors as F
from PyConf.Algorithms import ParticleTaggerAlg, ParticleContainerMerger
from FunTuple import FunctorCollection, FunTuple_Particles as Funtuple
from PyConf.reading import get_particles
from PyConf.Algorithms import ParticleTaggerAlg, ParticleContainerMerger
import Functors as F
from FunTuple import FunctorCollection as FC, FunTuple_Particles as Funtuple
from DaVinci import Options, make_config
from DaVinci.algorithms import add_filter
from DaVinci.common_particles import make_long_pions
from DaVinci.truth_matching import configured_MCTruthAndBkgCatAlg
def main(options: Options):
bd2dsk_line = "SpruceB2OC_BdToDsmK_DsmToHHH_FEST_Line"
fields = {
'B0': "[B0 -> D_s- K+]CC",
'Ds': "[B0 -> ^D_s- K+]CC",
'Kp': "[B0 -> D_s- ^K+]CC",
}
bd2dsk_line = "Spruce_Test_line"
bd2dsk_data = get_particles(f"/Event/Spruce/{bd2dsk_line}/Particles")
# define pion container
pions = make_long_pions()
tagging_container = ParticleContainerMerger(
InputContainers=[pions]).OutputContainer
# define ParticleTagger algorithm and create a relation table wrt the decay mother particle, i.e. B0 meson
tagAlg = ParticleTaggerAlg(
Input=bd2dsk_data, TaggingContainer=tagging_container, OutputLevel=3)
tagAlg_rels = tagAlg.OutputRelations
# get configured "MCTruthAndBkgCatAlg" algorithm for HLT2 output
mctruth = configured_MCTruthAndBkgCatAlg(inputs=bd2dsk_data)
mctruth_pions = configured_MCTruthAndBkgCatAlg(inputs=tagging_container)
# helper lambda functions
MCTRUTH = lambda func: F.MAP_INPUT(Functor=func, Relations=mctruth.MCAssocTable)
MCTRUTH_pions = lambda func: F.MAP_INPUT(Functor=func, Relations=mctruth_pions.MCAssocTable)
#make collection of functors
variables_B = FunctorCollection({
variables_B = FC({
'THOR_MASS':
F.MASS,
'PT':
F.PT,
"TRUEID":
F.VALUE_OR(0) @ MCTRUTH(F.PARTICLE_ID),
# Define variables for the tagging particles
"TagTr_P":
F.MAP_INPUT_ARRAY(Functor=F.P, Relations=tagAlg_rels),
# Currently this stores a branch called "indx" which corresponds to nPVs.
# You can give a custom name for this via following
"TagTr_PT[nTags]":
F.MAP_INPUT_ARRAY(Functor=F.PT, Relations=tagAlg_rels),
"TagTr_PHI[nTags]":
F.MAP_INPUT_ARRAY(Functor=F.PHI, Relations=tagAlg_rels),
"TagTr_TRUEID[nTags]":
F.VALUE_OR(0) @ F.MAP_INPUT_ARRAY(
Functor=F.VALUE_OR(0) @ MCTRUTH_pions(F.PARTICLE_ID),
Relations=tagAlg_rels),
"TagTr_TRUEKEY[nTags]":
F.VALUE_OR(-1) @ F.MAP_INPUT_ARRAY(
Functor=F.VALUE_OR(-1) @ MCTRUTH_pions(F.OBJECT_KEY),
Relations=tagAlg_rels),
"TagTr_TRUEP[nTags]":
F.MAP_INPUT_ARRAY(
Functor=F.VALUE_OR(F.NaN) @ MCTRUTH_pions(F.P),
Relations=tagAlg_rels),
"TagTr_TRUEPT[nTags]":
F.MAP_INPUT_ARRAY(
Functor=F.VALUE_OR(F.NaN) @ MCTRUTH_pions(F.PT),
Relations=tagAlg_rels),
"TagTr_TRUEPX[nTags]":
F.MAP_INPUT_ARRAY(
Functor=F.VALUE_OR(F.NaN) @ MCTRUTH_pions(F.PX),
Relations=tagAlg_rels),
"TagTr_TRUEPY[nTags]":
F.MAP_INPUT_ARRAY(
Functor=F.VALUE_OR(F.NaN) @ MCTRUTH_pions(F.PY),
Relations=tagAlg_rels),
"TagTr_TRUEPZ[nTags]":
F.MAP_INPUT_ARRAY(
Functor=F.VALUE_OR(F.NaN) @ MCTRUTH_pions(F.PZ),
Relations=tagAlg_rels),
"TagTr_TRUEENERGY[nTags]":
F.MAP_INPUT_ARRAY(
Functor=F.VALUE_OR(F.NaN) @ MCTRUTH_pions(F.ENERGY),
Relations=tagAlg_rels),
"TagTr_TRUEPHI[nTags]":
F.MAP_INPUT_ARRAY(
Functor=F.VALUE_OR(F.NaN) @ MCTRUTH_pions(F.PHI),
Relations=tagAlg_rels),
})
#make collection of functors for Muplus
variables_all = FunctorCollection({
variables_all = FC({
'THOR_P': F.P,
'THOR_PT': F.PT,
})
fields = {
'B0': "[B0 -> D_s- K+]CC",
'Ds': "[B0 -> ^D_s- K+]CC",
'Kp': "[B0 -> D_s- ^K+]CC",
}
variables = {
'ALL': variables_all, #adds variables to all fields
'B0': variables_B,
@@ -82,5 +136,4 @@ def main(options: Options):
filter_B0DsK = add_filter(options, "HDRFilter_B0DsK",
f"HLT_PASS('{bd2dsk_line}')")
algs = [filter_B0DsK, tuple_B0DsK]
return make_config(options, algs)
return make_config(options, [filter_B0DsK, tuple_B0DsK])
Loading