Skip to content
Snippets Groups Projects

Test MC associations for Sprucing output

Merged Nicole Skidmore requested to merge MC_Sprucing into master
Files
4
###############################################################################
# (c) Copyright 2022 CERN for the benefit of the LHCb Collaboration #
# #
# This software is distributed under the terms of the GNU General Public #
# Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". #
# #
# In applying this licence, CERN does not waive the privileges and immunities #
# granted to it by virtue of its status as an Intergovernmental Organization #
# or submit itself to any jurisdiction. #
###############################################################################
from FunTuple import FunctorCollection
import Functors as F
from FunTuple import FunTuple_Particles as Funtuple
from FunTuple.functorcollections import Kinematics
from DaVinci.truth_matching import ConfiguredMCTruthAndBkgCatAlg
from DaVinci.algorithms import add_filter
from PyConf.application import make_data_with_FetchDataFromFile
#FunTuple: define branches.
fields = {
'B0': "[B0 -> D_s- K+]CC",
'Ds': "[B0 -> ^D_s- K+]CC",
'Kp': "[B0 -> D_s- ^K+]CC"
}
#FunTuple: make functor collection from the imported functor library Kinematics
variables_all = Kinematics()
#FunTuple: associate functor collections to branch name
variables = {
'ALL': variables_all, #adds variables to all branches
}
def main():
B_data = make_data_with_FetchDataFromFile(
"/Event/Spruce/Spruce_Test_line/Particles")
my_filter = add_filter("HDRFilter_B",
"HLT_PASS('Spruce_Test_lineDecision')")
#get configured "MCTruthAndBkgCatAlg" algorithm for HLT2 output
mctruth = ConfiguredMCTruthAndBkgCatAlg(
inputs=B_data, root_in_tes="/Event/Spruce/HLT2")
#Add trueid info to each of the branches
trueid_bkgcat_info = {
"TRUEID":
F.MAP_INPUT(Functor=F.PARTICLE_ID, Relations=mctruth.MCAssocTable),
"TRUEKEY":
F.MAP_INPUT(Functor=F.OBJECT_KEY, Relations=mctruth.MCAssocTable),
"TRUEPT":
F.MAP_INPUT(Functor=F.PT, Relations=mctruth.MCAssocTable),
"TRUEPX":
F.MAP_INPUT(Functor=F.PX, Relations=mctruth.MCAssocTable),
"TRUEPY":
F.MAP_INPUT(Functor=F.PY, Relations=mctruth.MCAssocTable),
"TRUEPZ":
F.MAP_INPUT(Functor=F.PZ, Relations=mctruth.MCAssocTable),
"TRUEENERGY":
F.MAP_INPUT(Functor=F.ENERGY, Relations=mctruth.MCAssocTable),
"TRUEP":
F.MAP_INPUT(Functor=F.P, Relations=mctruth.MCAssocTable),
"TRUEFOURMOMENTUM":
F.MAP_INPUT(Functor=F.FOURMOMENTUM, Relations=mctruth.MCAssocTable),
"BKGCAT":
F.BKGCAT(Relations=mctruth.BkgCatTable)
}
for branch in variables.keys():
variables[branch] += FunctorCollection(trueid_bkgcat_info)
my_tuple = Funtuple(
name="Tuple",
tuple_name="DecayTree",
fields=fields,
variables=variables,
inputs=B_data)
return {"UserAlgs": [my_filter, mctruth, my_tuple]}, []
Loading