Commit 0acb80d1 authored by Patrick Koppenburg's avatar Patrick Koppenburg 🍃
Browse files

all functors

parent 0e2931ce
Pipeline #3288509 failed with stages
in 1 minute and 11 seconds
###############################################################################
# (c) Copyright 2021 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. #
###############################################################################
"""
Example of a DaVinci job filling all available functors. This is obviously a stress test and not realistic.
This example is meant to be run with
$ ./run davinci run-mc --inputfiledb Upgrade_Bd2KstarMuMu_ldst Phys/DaVinci/options/DaVinciDB-Example.yaml --joboptfile DaVinciExamples/python/DaVinciExamples/tupling/example-tupling-DTF-run-mc.yaml --user_algorithms AllFunctors:main --evt_max 100
"""
__author__ = "P. Koppenburg"
__date__ = "2021-11-23"
import Functors as F
from DaVinci.standard_particles import make_detached_mumu
from DaVinci.reco_objects import upfront_reconstruction_from_file as upfront_reconstruction
from DaVinci.reco_objects import reconstruction
from FunTuple import FunctorCollection
from FunTuple import FunTuple_Particles as Funtuple
# Prepare the node with the selection
dimuons = make_detached_mumu()
PVs = reconstruction()["PVs"]
#
# DecayTreeFitter Algorithm
#
from PyConf.Algorithms import DecayTreeFitterAlg
DTF = DecayTreeFitterAlg(
Input=dimuons, MassConstraints=[443], PrintTree=True, OutputLevel=3)
DTFParts = DTF.Output # Particles
DTFRelations = DTF.OutputRelations # Relations
#FunTuple: Jpsi info
branches = {}
branches['Jpsi'] = 'J/psi(1S) -> mu+ mu-'
branches['MuPlus'] = 'J/psi(1S) -> ^mu+ mu-'
#make collection of functors for Jpsi
variables_jpsi = FunctorCollection({
# grep "Functor(" ../Rec/Phys/FunctorCore/python/Functors/__init__.py | awk '{print " \x27THOR_"$1"\x27 : F."$1", "}'
####
# Already tested
####
'THOR_P' : F.P,
'THOR_PT' : F.PT,
'THOR_PHI' : F.PHI,
'THOR_ETA' : F.ETA,
# 'THOR_MINIP' : F.MINIP(PVs),
# 'THOR_MINIPCHI2' : F.MINIPCHI2(PVs),
# 'THOR_MINIPCUT' : F.MINIPCUT(PVs),
# 'THOR_MINIPCHI2CUT' : F.MINIPCHI2CUT(PVs),
'THOR_ALL' : F.ALL,
'THOR_NONE' : F.NONE,
# 'THOR_CHILD' : F.CHILD(1,F.PT), # strangely doesn't work
# 'THOR_SUBCOMB' : F.SUBCOMB,
# 'THOR_MASSWITHHYPOTHESES' : F.MASSWITHHYPOTHESES([939.,939.]), relies on numChildren. Not in LHCb::Particle
'THOR_MASS' : F.MASS,
'THOR_VX' : F.VX,
'THOR_VY' : F.VY,
'THOR_VZ' : F.VZ,
'THOR_VRho' : F.VRho,
# 'THOR_DOCA' : F.DOCA(Child1=1,Child2=2), # no member named 'doca' in 'LHCb::Particle' (?)
# 'THOR_DOCACHI2' : F.DOCACHI2(Child1=1,Child2=2), # same here
# 'THOR_ALV' : F.ALV(Child1=1,Child2=2), # wants cos_angle_prod
# 'THOR_MAXDOCA' : F.MAXDOCA, # does not work
# 'THOR_MAXDOCACHI2' : F.MAXDOCACHI2,
# 'THOR_MAXDOCACUT' : F.MAXDOCACUT(0.1),
# 'THOR_MAXDOCACHI2CUT' : F.MAXDOCACHI2CUT(0.5),
'THOR_CHARGE' : F.CHARGE,
# 'THOR_SIZE' : F.SIZE(DTFParts), # doesn't work
'THOR_BPVETA' : F.BPVETA(PVs),
'THOR_BPVCORRM' : F.BPVCORRM(PVs),
'THOR_BPVDIRA' : F.BPVDIRA(PVs),
'THOR_BPVIPCHI2' : F.BPVIPCHI2(PVs),
'THOR_BPVFDCHI2' : F.BPVFDCHI2(PVs),
'THOR_BPVVDZ' : F.BPVVDZ(PVs),
'THOR_BPVVDRHO' : F.BPVVDRHO(PVs),
'THOR_BPVLTIME' : F.BPVLTIME(PVs),
'THOR_BPVDLS' : F.BPVDLS(PVs),
# 'THOR_RUNNUMBER' : F.RUNNUMBER('/Event/DAQ/RawBanks/ODIN'), # doesn't work. Wrong location?
# 'THOR_EVENTNUMBER' : F.EVENTNUMBER('/Event/DAQ/RawBanks/ODIN'),
# 'THOR_EVENTTYPE' : F.EVENTTYPE('/Event/DAQ/RawBanks/ODIN'),
# 'THOR_MVA' : F.MVA, # needs an MVA
# 'THOR_COMB' : F.COMB, # starts from combination
# 'THOR_POD' : F.POD, # starts from combination
# DecayTreeFitter
'THOR_MAP_INPUT': F.MAP_INPUT(Functor=F.PT, Relations=DTFRelations),
})
#make collection of functors for Muplus. Move Track functors here
variables_muplus = FunctorCollection({ # add tracklike ones
# 'THOR_FILTER' : F.FILTER(F.ISMUON), # no filter in FunTuple
# 'THOR_X' : F.X, # does not apply to Particles. It has also does not have a closes to beam state
# 'THOR_CLOSESTTOBEAM_X' : F.CLOSESTTOBEAM(F.X), # why doesn't it defer to Track?
# 'THOR_Y' : F.Y,
# 'THOR_Z' : F.Z,
# 'THOR_TX' : F.TX, # not for Particle
# 'THOR_TY' : F.TY, # not for Particle
# 'THOR_COV' : F.COV(Row=1,Col=1), # not for Particle
'THOR_PID_MU' : F.PID_MU,
'THOR_PID_PI' : F.PID_PI,
'THOR_PID_K' : F.PID_K,
'THOR_PID_P' : F.PID_P,
'THOR_PID_E' : F.PID_E,
'THOR_PROBNN_D' : F.PROBNN_D,
'THOR_PROBNN_E' : F.PROBNN_E,
'THOR_PROBNN_GHOST' : F.PROBNN_GHOST,
'THOR_PROBNN_K' : F.PROBNN_K,
'THOR_PROBNN_MU' : F.PROBNN_MU,
'THOR_PROBNN_P' : F.PROBNN_P,
'THOR_PROBNN_PI' : F.PROBNN_PI,
'THOR_P' : F.P,
'THOR_PT' : F.PT,
'THOR_PHI' : F.PHI,
'THOR_ETA' : F.ETA,
# 'THOR_NDOF' : F.NDOF, # not for Particle
# 'THOR_QOVERP' : F.QOVERP, # not for Particle
# 'THOR_CHI2DOF' : F.CHI2DOF, # not for Particle
# 'THOR_CHI2' : F.CHI2, # not for Particle
# 'THOR_CLOSESTTOBEAM_Z' : F.CLOSESTTOBEAM(F.Z),
# 'THOR_NHITS' : F.NHITS,
'THOR_MINIP' : F.MINIP(PVs),
'THOR_MINIPCHI2' : F.MINIPCHI2(PVs),
'THOR_MASS' : F.MASS,
'THOR_VRho' : F.VRho,
'THOR_CHARGE' : F.CHARGE,
'THOR_BPVETA' : F.BPVETA(PVs),
'THOR_BPVCORRM' : F.BPVCORRM(PVs),
'THOR_BPVDIRA' : F.BPVDIRA(PVs),
'THOR_BPVIPCHI2' : F.BPVIPCHI2(PVs),
'THOR_BPVFDCHI2' : F.BPVFDCHI2(PVs),
'THOR_BPVVDZ' : F.BPVVDZ(PVs),
'THOR_BPVVDRHO' : F.BPVVDRHO(PVs),
# 'THOR_RUNNUMBER' : F.RUNNUMBER('/Event/DAQ/RawBanks/ODIN'), # doesn't work. Wrong location?
# 'THOR_EVENTNUMBER' : F.EVENTNUMBER('/Event/DAQ/RawBanks/ODIN'),
# 'THOR_EVENTTYPE' : F.EVENTTYPE('/Event/DAQ/RawBanks/ODIN'),
# 'THOR_MVA' : F.MVA, # needs an MVA
# 'THOR_COMB' : F.COMB, # starts from combination
# 'THOR_POD' : F.POD, # starts from combination
# DecayTreeFitter
'THOR_MAP_INPUT': F.MAP_INPUT(Functor=F.PT, Relations=DTFRelations),
})
#associate FunctorCollection to branch name
variables = {}
variables['Jpsi'] = variables_jpsi
variables['MuPlus'] = variables_muplus
#FunTuple: define list of preambles for loki
loki_preamble = ['TRACK_MAX_PT = MAXTREE(ISBASIC & HASTRACK, PT, -1)']
#Configure Funtuple algorithm
tuple_dimuons = Funtuple(
name="DimuonsTuple",
tree_name="DecayTree",
branches=branches,
variables=variables,
loki_preamble=loki_preamble,
inputs=dimuons)
def main():
tools = []
algs = upfront_reconstruction() + [dimuons, DTF, tuple_dimuons]
return algs, tools
......@@ -15,7 +15,8 @@ Example of a typical DaVinci job:
- runs DecayTreeFitterAlg and stores some output
This example is meant to be run with
$ ./run davinci run-mc --inputfiledb Upgrade_Bd2KstarMuMu_ldst Phys/DaVinci/options/DaVinciDB-Example.yaml --joboptfile DaVinciExamples/python/DaVinciExamples/tupling/example-tupling-DTF-run-mc.yaml --user_algorithms AllFunctors:main --evt_max 100
$ ./run davinci run-mc --inputfiledb Upgrade_Bd2KstarMuMu_ldst Phys/DaVinci/options/DaVinciDB-Example.yaml --joboptfile DaVinciExamples/python/DaVinciExamples/tupling/example-tupling-DTF-run-mc.yaml --user_algorithms DaVinciExamples/python/DaVinciExamples/tupling/example-tupling-DTF-run-mc:main --evt_max -1 |& cat | tee log
"""
__author__ = "P. Koppenburg"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment