diff --git a/DaVinciExamples/python/DaVinciExamples/tupling/example-tupling-AllFunctors.py b/DaVinciExamples/python/DaVinciExamples/tupling/example-tupling-AllFunctors.py index ff97323610c288c6018ff9b73b43ebffcb581237..6ddeb1f110eaf8af09e4e658cbc58a080927086f 100644 --- a/DaVinciExamples/python/DaVinciExamples/tupling/example-tupling-AllFunctors.py +++ b/DaVinciExamples/python/DaVinciExamples/tupling/example-tupling-AllFunctors.py @@ -22,8 +22,10 @@ from FunTuple import FunctorCollection from FunTuple import FunTuple_Particles as Funtuple from PyConf.components import force_location from DaVinci.reco_objects import make_pvs_v2 -from DaVinci.algorithms import add_filter +from DaVinci.algorithms import add_filter, get_decreports, get_odin from DecayTreeFitter import DTFAlg +from DaVinci.truth_matching import configured_MCTruthAndBkgCatAlg +from PyConf.Algorithms import PrintDecayTree from DaVinci import options @@ -35,88 +37,142 @@ bd2dsk_data = force_location(f"/Event/Spruce/{bd2dsk_line}/Particles") _basic = 'basic' _composite = 'composite' +_toplevel = 'toplevel' options.ntuple_file = "DV_example_allFunctors_ntp.root" options.histo_file = "DV_example_allFunctors_his.root" -def all_variables(pvs, DTFR, ptype): +def all_variables(pvs, DTFR, mctruth, ptype): """ function that returns dictonary of functors that work. - functors are listed in order of https://gitlab.cern.ch/lhcb/Rec/-/blob/master/Phys/FunctorCore/python/Functors/__init__.py + functors are listed in order of https://lhcbdoc.web.cern.ch/lhcbdoc/moore/master/selection/thor_functors_reference.html#module-Functors """ if ptype not in [_basic, _composite]: Exception("I want {0} or {1}. Got {2}".format(_basic, _composite, ptype)) all_vars = {} - all_vars['REFERENCEPOINT_X'] = F.REFERENCEPOINT_X - all_vars['REFERENCEPOINT_Y'] = F.REFERENCEPOINT_Y - all_vars['REFERENCEPOINT_Z'] = F.REFERENCEPOINT_Z - all_vars['TX'] = F.TX - all_vars['TY'] = F.TY - # all_vars['COV'] = F.COV # 'Track__Covariance' object has no attribute 'to_json' - all_vars['P'] = F.P - all_vars['PT'] = F.PT - all_vars['PHI'] = F.PHI - all_vars['ETA'] = F.ETA - all_vars['PX'] = F.PX - all_vars['PY'] = F.PY - all_vars['PZ'] = F.PZ - all_vars['ENERGY'] = F.ENERGY - all_vars['FOURMOMENTUM'] = F.FOURMOMENTUM - all_vars['MASS'] = F.MASS + comp = (_composite == ptype or _toplevel == ptype) # is composite + basic = (_basic == ptype) # is not composite + top = (_toplevel == ptype) # the B - if (_basic == ptype): - all_vars['ISMUON'] = F.ISMUON + # ALL : Not useful for tupling + if comp: + all_vars['ALV'] = F.ALV(Child1=1, Child2=2) -# all_vars['NDOF'] = F.NDOF # no member named 'nDoF' in 'LHCb::Particle - all_vars['CHI2DOF'] = F.CHI2DOF - all_vars['CHI2'] = F.CHI2 + all_vars['BKGCAT'] = F.BKGCAT(Relations=mctruth.BkgCatTable) - if (_basic == ptype): - all_vars['GHOSTPROB'] = F.GHOSTPROB - # all_vars['CLOSESTTOBEAM'] = F.CLOSESTTOBEAM # 'Track__ClosestToBeamState' object has no attribute 'to_json' - # all_vars['NHITS'] = F.NHITS # 'no member named 'nHits' in 'LHCb::Particle'' - # all_vars['NVPHITS'] = F.NVPHITS - # all_vars['NUTHITS'] = F.NUTHITS - # all_vars['NFTHITS'] = F.NFTHITS - # all_vars['TRACKHISTORY'] = F.TRACKHISTORY + if comp: # all these require a vertex + all_vars['BPVCORRM'] = F.BPVCORRM(pvs) + all_vars['BPVDIRA'] = F.BPVDIRA(pvs) + all_vars['BPVDLS'] = F.BPVDLS(pvs) + all_vars['BPVETA'] = F.BPVETA(pvs) + all_vars['BPVFD'] = F.BPVFD(pvs) + all_vars['BPVFDCHI2'] = F.BPVFDCHI2(pvs) + all_vars['BPVFDIR'] = F.BPVFDIR(pvs) + all_vars['BPVFDVEC'] = F.BPVFDVEC(pvs) - all_vars['MINIP'] = F.MINIP(pvs) - all_vars['MINIPCHI2'] = F.MINIPCHI2(pvs) + all_vars['BPVIP'] = F.BPVIP(pvs) + all_vars['BPVIPCHI2'] = F.BPVIPCHI2(pvs) - if (_composite == ptype): - all_vars['SUMPT'] = F.SUM(F.PT) - all_vars['MINPT'] = F.MIN(F.PT) - all_vars['MAXPT'] = F.MAX(F.PT) - all_vars['CHILD'] = F.CHILD(1, F.PT) - all_vars['SUBCOMB12_MM'] = F.SUBCOMB(Functor=F.MASS, Indices=(1, 2)) - all_vars['MASSWITHHYPOTHESES'] = F.MASSWITHHYPOTHESES((939., 939.)) - all_vars['END_VX'] = F.END_VX - all_vars['END_VY'] = F.END_VY - all_vars['END_VZ'] = F.END_VZ - all_vars['END_VRHO'] = F.END_VRHO + if comp: # all these require a vertex + all_vars['BPVLTIME'] = F.BPVLTIME(pvs) + all_vars['BPVVDRHO'] = F.BPVVDRHO(pvs) + all_vars['BPVVDX'] = F.BPVVDX(pvs) + all_vars['BPVVDY'] = F.BPVVDY(pvs) + all_vars['BPVVDZ'] = F.BPVVDZ(pvs) + + all_vars['CHARGE'] = F.CHARGE + all_vars['CHI2'] = F.CHI2 + all_vars['CHI2DOF'] = F.CHI2DOF + if top: # apply this only to B + all_vars['CHILD1_PT'] = F.CHILD(1, F.PT) # example of CHILD all_vars['Ds_END_VZ'] = F.CHILD(1, F.END_VZ) all_vars['Delta_END_VZ_DsB0'] = F.CHILD(1, F.END_VZ) - F.END_VZ - # use 'SDOCA' instad of 'DOCA' to avoid accessing the conditions DB for the magnetic field + # if basic: all_vars['CLOSESTTOBEAM'] = F.CLOSESTTOBEAM # 'Track__ClosestToBeamState' object has no attribute 'to_json' + # COMB + # if basic: all_vars['COV'] = F.COV # 'Track__Covariance' object has no attribute 'to_json' + + if comp: all_vars['DOCA'] = F.SDOCA(Child1=1, Child2=2) all_vars['DOCACHI2'] = F.SDOCACHI2(Child1=1, Child2=2) - all_vars['ALV'] = F.ALV(Child1=1, Child2=2) + all_vars['END_VRHO'] = F.END_VRHO + all_vars['END_VX'] = F.END_VX + all_vars['END_VY'] = F.END_VY + all_vars['END_VZ'] = F.END_VZ + + all_vars['ENERGY'] = F.ENERGY + all_vars['ETA'] = F.ETA + # FILTER + all_vars['FOURMOMENTUM'] = F.FOURMOMENTUM + + if basic: + all_vars['GHOSTPROB'] = F.GHOSTPROB + all_vars['ISMUON'] = F.ISMUON + + all_vars['IS_ABS_ID_pi'] = F.IS_ABS_ID('pi+') + all_vars['IS_ID_pi'] = F.IS_ID('pi-') + all_vars['IS_NOT_H'] = F.IS_NOT_H + if basic: + all_vars['IS_PHOTON'] = F.IS_PHOTON + + all_vars['DTF_PT'] = F.MAP_INPUT(Functor=F.PT, Relations=DTFR) + all_vars['DTF_BPVIPCHI2'] = F.MAP_INPUT( + Functor=F.BPVIPCHI2(pvs), Relations=DTFR) + # MAP_INPUT_ARRAY + # MAP_RANGE + + all_vars['MASS'] = F.MASS + if top: # B + all_vars['MASSWITHHYPOTHESES'] = F.MASSWITHHYPOTHESES((939., 939.)) + elif comp: # Ds + all_vars['MASSWITHHYPOTHESES'] = F.MASSWITHHYPOTHESES((493.7, 493.7, + 139.6)) + if comp: + all_vars['MAXPT'] = F.MAX(F.PT) all_vars['MAXDOCA'] = F.MAXSDOCA all_vars['MAXDOCACHI2'] = F.MAXSDOCACHI2 + # the above in cut versions. - all_vars['CHARGE'] = F.CHARGE + all_vars['MC_MOTHER_ID'] = F.MAP_INPUT( + Functor=F.MC_MOTHER(1, F.PARTICLE_ID), Relations=mctruth.MCAssocTable) - if (_basic == ptype): - all_vars['PID_MU'] = F.PID_MU - all_vars['PID_PI'] = F.PID_PI + if comp: all_vars['MINPT'] = F.MIN(F.PT) + all_vars['MINIP'] = F.MINIP(pvs) + all_vars['MINIPCHI2'] = F.MINIPCHI2(pvs) + + # MVA needs a MVA + # all_vars['NDOF'] = F.NDOF + # if basic: + # all_vars['NFTHITS'] = F.NFTHITS + # all_vars['NHITS'] = F.NHITS + # all_vars['NUTHITS'] = F.NUTHITS # crashes + # all_vars['NVPHITS'] = F.NVPHITS + + all_vars['OBJECT_KEY'] = F.OBJECT_KEY + + all_vars['ORIGIN_VX'] = F.MAP_INPUT( + Functor=F.ORIGIN_VX, Relations=mctruth.MCAssocTable) + all_vars['ORIGIN_VY'] = F.MAP_INPUT( + Functor=F.ORIGIN_VY, Relations=mctruth.MCAssocTable) + all_vars['ORIGIN_VZ'] = F.MAP_INPUT( + Functor=F.ORIGIN_VZ, Relations=mctruth.MCAssocTable) + + all_vars['P'] = F.P + all_vars['PARTICLE_ID'] = F.PARTICLE_ID + all_vars['PHI'] = F.PHI + + if basic: + all_vars['PID_E'] = F.PID_E all_vars['PID_K'] = F.PID_K + all_vars['PID_MU'] = F.PID_MU all_vars['PID_P'] = F.PID_P - all_vars['PID_E'] = F.PID_E + all_vars['PID_PI'] = F.PID_PI + # POD all_vars['PROBNN_D'] = F.PROBNN_D all_vars['PROBNN_E'] = F.PROBNN_E all_vars['PROBNN_GHOST'] = F.PROBNN_GHOST @@ -125,34 +181,66 @@ def all_variables(pvs, DTFR, ptype): all_vars['PROBNN_P'] = F.PROBNN_P all_vars['PROBNN_PI'] = F.PROBNN_PI - # all_vars['SIZE'] = F.SIZE(DTFR) # no matching function for call to 'invoke' + all_vars['PT'] = F.PT + all_vars['PX'] = F.PX + all_vars['PY'] = F.PY + all_vars['PZ'] = F.PZ + # if basic: all_vars['QOVERP'] = F.QOVERP - all_vars['BPVIP'] = F.BPVIP(pvs) - all_vars['BPVIPCHI2'] = F.BPVIPCHI2(pvs) - if (_composite == ptype): # all these require a vertex - all_vars['BPVETA'] = F.BPVETA(pvs) - all_vars['BPVCORRM'] = F.BPVCORRM(pvs) - all_vars['BPVDIRA'] = F.BPVDIRA(pvs) - all_vars['BPVFDCHI2'] = F.BPVFDCHI2(pvs) - all_vars['BPVVDZ'] = F.BPVVDZ(pvs) - all_vars['BPVVDRHO'] = F.BPVVDRHO(pvs) - all_vars['BPVLTIME'] = F.BPVLTIME(pvs) - all_vars['BPVDLS'] = F.BPVDLS(pvs) - # all_vars['RUNNUMBER'] = F.RUNNUMBER(ODINLocation) # doesn't work. - # all_vars['EVENTNUMBER'] = F.EVENTNUMBER('/Event/DAQ/RawBanks/ODIN') - # all_vars['EVENTTYPE'] = F.EVENTTYPE('/Event/DAQ/RawBanks/ODIN') - # all_vars['MVA'] = F.MVA # needs an MVA - # all_vars['COMB'] = F.COMB # starts from combination - # all_vars['POD'] = F.POD # starts from combination + all_vars['REFERENCEPOINT_X'] = F.REFERENCEPOINT_X + all_vars['REFERENCEPOINT_Y'] = F.REFERENCEPOINT_Y + all_vars['REFERENCEPOINT_Z'] = F.REFERENCEPOINT_Z - all_vars['DTF_PT'] = F.MAP_INPUT(Functor=F.PT, Relations=DTFR) - all_vars['DTF_BPVIPCHI2'] = F.MAP_INPUT( - Functor=F.BPVIPCHI2(pvs), Relations=DTFR) + if comp: + all_vars['SDOCA'] = F.SDOCA(1, 2) + all_vars['SDOCACHI2'] = F.SDOCACHI2(1, 2) + if basic: + all_vars['SHOWER_SHAPE'] = F.SHOWER_SHAPE + + if comp: + all_vars['SUBCOMB12_MM'] = F.SUBCOMB(Functor=F.MASS, Indices=(1, 2)) + all_vars['SUMPT'] = F.SUM(F.PT) + + if basic: + # all_vars['TRACKHISTORY'] = F.TRACKHISTORY + all_vars['TX'] = F.TX + all_vars['TY'] = F.TY print("For {0} returning variables {1}".format(ptype, all_vars.keys())) return all_vars +def event_variables(PVs, ODIN, decreports): + """ + event variables + """ + evt_vars = {} + if ODIN: + evt_vars['BUNCHCROSSING_ID'] = F.BUNCHCROSSING_ID(ODIN) + evt_vars['BUNCHCROSSING_TYPE'] = F.BUNCHCROSSING_TYPE(ODIN) + if decreports: + evt_vars['DECISIONS'] = F.DECISIONS( + Lines=[bd2dsk_line + "Decision"], DecReports=decreports) + evt_vars['DECREPORTS_FILTER'] = F.DECREPORTS_FILTER( + Lines=[bd2dsk_line + "Decision"], DecReports=decreports) + # DECREPORTS_RE_FILTER + if ODIN: + evt_vars['EVENTNUMBER'] = F.EVENTNUMBER( + ODIN + ) # WARNING FunTupleBase<Gaudi::NamedRange_<std::vector<LHCb::Particle const*,std::allocator<LHCb::Particle const*> >,__gnu_cxx::__normal_iterator<LHCb::Particle const* const*,std::vector<LHCb::Particle const*,std::allocator<LHCb::Particle const*> > > > >:: Tuple 'DecayTree' 'unsigned long' has different sizes on 32/64 bit systems. Casting 'EVENTNUMBER' to 'unsigned long long' + evt_vars['EVENTTYPE'] = F.EVENTTYPE(ODIN) + evt_vars['GPSTIME'] = F.GPSTIME( + ODIN + ) # WARNING FunTupleBase<Gaudi::NamedRange_<std::vector<LHCb::Particle const*,std::allocator<LHCb::Particle const*> >,__gnu_cxx::__normal_iterator<LHCb::Particle const* const*,std::vector<LHCb::Particle const*,std::allocator<LHCb::Particle const*> > > > >:: Tuple 'DecayTree' 'unsigned long' has different sizes on 32/64 bit systems. Casting 'EVENTNUMBER' to 'unsigned long long' + evt_vars['ODINTCK'] = F.ODINTCK(ODIN) + evt_vars['RUNNUMBER'] = F.RUNNUMBER(ODIN) + evt_vars['PV_SIZE'] = F.SIZE( + PVs) # no matching function for call to 'invoke' + if decreports: evt_vars['TCK'] = F.TCK(decreports) + + return evt_vars + + def alg_config(): """ Algorithm configuration function called from the comad line @@ -168,20 +256,45 @@ def alg_config(): DTF = DTFAlg(Input=bd2dsk_data) # DTFParts = DTF.Output # Particles (not needed) DTFRelations = DTF.OutputRelations # Relations - + # + # MC truth + # + mctruth = configured_MCTruthAndBkgCatAlg(inputs=bd2dsk_data) # # Definition of fields (branches) and functors # fields_dsk = { - 'B0': "[B0 -> D_s- K+]CC", - 'Kaon': "[B0 -> D_s- ^K+]CC", + 'B0': "[B0 -> (D_s- -> pi+ pi- pi-) K+]CC", + 'Kaon': "[B0 -> (D_s- -> pi+ pi- pi-) ^K+]CC", + 'Ds': "[B0 -> ^(D_s- -> pi+ pi- pi-) K+]CC", + 'pip': "[B0 -> (D_s- -> ^pi+ pi- pi-) K+]CC", } variables_dsk = { - 'B0': FunctorCollection( - all_variables(v2_pvs, DTFRelations, _composite)), - 'Kaon': FunctorCollection(all_variables(v2_pvs, DTFRelations, _basic)), + 'B0': + FunctorCollection( + all_variables(v2_pvs, DTFRelations, mctruth, _toplevel)), + 'Kaon': + FunctorCollection( + all_variables(v2_pvs, DTFRelations, mctruth, _basic)), + 'Ds': + FunctorCollection( + all_variables(v2_pvs, DTFRelations, mctruth, _composite)), + 'pip': + FunctorCollection( + all_variables(v2_pvs, DTFRelations, mctruth, _basic)), } + # + # event variables + # + odin = None + odin = get_odin(options) # does not work + decreports = None + decreports = get_decreports( + 'Spruce', + options) # name of line incorrect, Gerhard has a fix I need to try + evt_vars = FunctorCollection(event_variables(v2_pvs, odin, decreports)) + # # Sprucing filter # @@ -196,10 +309,13 @@ def alg_config(): tuple_name="DecayTree", fields=fields_dsk, variables=variables_dsk, + event_variables=evt_vars, loki_preamble=[], inputs=bd2dsk_data) # # Algorithms to be run # - return {"UserAlgs": [my_filter, my_tuple]}, [] + return { + "UserAlgs": [PrintDecayTree(Input=bd2dsk_data), my_filter, my_tuple] + }, [] diff --git a/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_from_collections.py b/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_from_collections.py index 32b6ce43285eac78b7ccdffcb05e431fcb0cbb93..af60c97d4de11ec790e84386d408f39484f25e10 100644 --- a/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_from_collections.py +++ b/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_from_collections.py @@ -23,7 +23,8 @@ from DaVinci.algorithms import get_odin, get_decreports d02kpi_data = force_location("/Event/HLT2/Hlt2CharmD0ToKmPipLine/Particles") #get configured "MCTruthAndBkgCatAlg" algorithm for HLT2 output -mctruth = configured_MCTruthAndBkgCatAlg(inputs=d02kpi_data) +mctruth = configured_MCTruthAndBkgCatAlg( + inputs=d02kpi_data, process=options.process) #get location to odin odin = get_odin(options) diff --git a/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_from_hlt2.py b/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_from_hlt2.py index 54152995a7eca6aca61f9ca7f97799abfbe2fe06..7b2152cbd202d7250d65067442dfe5f66e0f9a5e 100644 --- a/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_from_hlt2.py +++ b/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_from_hlt2.py @@ -74,7 +74,8 @@ def main(): "HLT_PASS('Hlt2CharmD0ToKmPipLineDecision')") #get configured "MCTruthAndBkgCatAlg" algorithm for HLT2 output - mctruth = configured_MCTruthAndBkgCatAlg(inputs=d02kpi_data) + mctruth = configured_MCTruthAndBkgCatAlg( + inputs=d02kpi_data, process=options.process) #Add true ID info to each of the fields (branches) trueid_bkgcat_info = { "TRUEID": diff --git a/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_from_spruce_mc.py b/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_from_spruce_mc.py index 577577d38c93486b191cd238b47dc0180d80980e..a4a51c13fd63614ed30f16509060ec820397dd1d 100644 --- a/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_from_spruce_mc.py +++ b/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_from_spruce_mc.py @@ -40,8 +40,7 @@ def main(): "HLT_PASS('Spruce_Test_lineDecision')") #get configured "MCTruthAndBkgCatAlg" algorithm for HLT2 output - mctruth = configured_MCTruthAndBkgCatAlg( - inputs=B_data, root_in_tes="/Event/Spruce/HLT2") + mctruth = configured_MCTruthAndBkgCatAlg(inputs=B_data) #Add trueid info to each of the branches trueid_bkgcat_info = { "TRUEID": diff --git a/DaVinciExamples/tests/qmtest/tupling.qms/test_davinci_tupling_All.qmt b/DaVinciExamples/tests/qmtest/tupling.qms/test_davinci_tupling_All.qmt index 3614189c6fb91c07189b6038a89e5071486468e0..a723ae93223cce3d6cca5872e9c99ddad5be5222 100755 --- a/DaVinciExamples/tests/qmtest/tupling.qms/test_davinci_tupling_All.qmt +++ b/DaVinciExamples/tests/qmtest/tupling.qms/test_davinci_tupling_All.qmt @@ -41,7 +41,7 @@ findReferenceBlock("""B0DsK_Tuple SUCCESS Booked 1 N-Tup import sys, os, glob from ROOT import TFile -B_vars_stored = ['B0_SUBCOMB12_MM', 'B0_ALV', 'B0_BPVCORRM', 'B0_BPVDIRA', 'B0_BPVDLS', 'B0_BPVETA', 'B0_BPVFDCHI2', 'B0_BPVIP', 'B0_BPVIPCHI2', 'B0_BPVLTIME', 'B0_BPVVDRHO', 'B0_BPVVDZ', 'B0_CHARGE', 'B0_CHI2', 'B0_CHI2DOF', 'B0_CHILD', 'B0_DOCA', 'B0_DOCACHI2', 'B0_DTF_BPVIPCHI2', 'B0_DTF_PT', 'B0_Delta_END_VZ_DsB0', 'B0_Ds_END_VZ', 'B0_END_VRHO', 'B0_END_VX', 'B0_END_VY', 'B0_END_VZ', 'B0_ENERGY', 'B0_ETA', 'B0_FOURMOMENTUME', 'B0_FOURMOMENTUMX', 'B0_FOURMOMENTUMY', 'B0_FOURMOMENTUMZ', 'B0_MASS', 'B0_MASSWITHHYPOTHESES', 'B0_MAXDOCA', 'B0_MAXDOCACHI2', 'B0_MAXPT', 'B0_MINIP', 'B0_MINIPCHI2', 'B0_MINPT', 'B0_P', 'B0_PHI', 'B0_PT', 'B0_PX', 'B0_PY', 'B0_PZ', 'B0_REFERENCEPOINT_X', 'B0_REFERENCEPOINT_Y', 'B0_REFERENCEPOINT_Z', 'B0_SUMPT', 'B0_TX', 'B0_TY', 'Kaon_BPVIP', 'Kaon_BPVIPCHI2', 'Kaon_CHARGE', 'Kaon_CHI2', 'Kaon_CHI2DOF', 'Kaon_DTF_BPVIPCHI2', 'Kaon_DTF_PT', 'Kaon_ENERGY', 'Kaon_ETA', 'Kaon_FOURMOMENTUME', 'Kaon_FOURMOMENTUMX', 'Kaon_FOURMOMENTUMY', 'Kaon_FOURMOMENTUMZ', 'Kaon_GHOSTPROB', 'Kaon_ISMUON', 'Kaon_MASS', 'Kaon_MINIP', 'Kaon_MINIPCHI2', 'Kaon_P', 'Kaon_PHI', 'Kaon_PID_E', 'Kaon_PID_K', 'Kaon_PID_MU', 'Kaon_PID_P', 'Kaon_PID_PI', 'Kaon_PROBNN_D', 'Kaon_PROBNN_E', 'Kaon_PROBNN_GHOST', 'Kaon_PROBNN_K', 'Kaon_PROBNN_MU', 'Kaon_PROBNN_P', 'Kaon_PROBNN_PI', 'Kaon_PT', 'Kaon_PX', 'Kaon_PY', 'Kaon_PZ', 'Kaon_REFERENCEPOINT_X', 'Kaon_REFERENCEPOINT_Y', 'Kaon_REFERENCEPOINT_Z', 'Kaon_TX', 'Kaon_TY'] +B_vars_stored = ['B0_ALV', 'B0_BKGCAT', 'B0_BPVCORRM', 'B0_BPVDIRA', 'B0_BPVDLS', 'B0_BPVETA', 'B0_BPVFD', 'B0_BPVFDCHI2', 'B0_BPVFDIRX', 'B0_BPVFDIRY', 'B0_BPVFDIRZ', 'B0_BPVFDVECX', 'B0_BPVFDVECY', 'B0_BPVFDVECZ', 'B0_BPVIP', 'B0_BPVIPCHI2', 'B0_BPVLTIME', 'B0_BPVVDRHO', 'B0_BPVVDX', 'B0_BPVVDY', 'B0_BPVVDZ', 'B0_CHARGE', 'B0_CHI2', 'B0_CHI2DOF', 'B0_CHILD1_PT', 'B0_DOCA', 'B0_DOCACHI2', 'B0_DTF_BPVIPCHI2', 'B0_DTF_PT', 'B0_Delta_END_VZ_DsB0', 'B0_Ds_END_VZ', 'B0_END_VRHO', 'B0_END_VX', 'B0_END_VY', 'B0_END_VZ', 'B0_ENERGY', 'B0_ETA', 'B0_FOURMOMENTUME', 'B0_FOURMOMENTUMX', 'B0_FOURMOMENTUMY', 'B0_FOURMOMENTUMZ', 'B0_IS_ABS_ID_pi', 'B0_IS_ID_pi', 'B0_IS_NOT_H', 'B0_MASS', 'B0_MASSWITHHYPOTHESES', 'B0_MAXDOCA', 'B0_MAXDOCACHI2', 'B0_MAXPT', 'B0_MC_MOTHER_ID', 'B0_MINIP', 'B0_MINIPCHI2', 'B0_MINPT', 'B0_OBJECT_KEY', 'B0_ORIGIN_VX', 'B0_ORIGIN_VY', 'B0_ORIGIN_VZ', 'B0_P', 'B0_PARTICLE_ID', 'B0_PHI', 'B0_PT', 'B0_PX', 'B0_PY', 'B0_PZ', 'B0_REFERENCEPOINT_X', 'B0_REFERENCEPOINT_Y', 'B0_REFERENCEPOINT_Z', 'B0_SDOCA', 'B0_SDOCACHI2', 'B0_SUBCOMB12_MM', 'B0_SUMPT', 'BUNCHCROSSING_ID', 'BUNCHCROSSING_TYPE', 'DECISIONS_SpruceB2OC_BdToDsmK_DsmToHHH_FEST_LineDecision', 'DECREPORTS_FILTER', 'Ds_ALV', 'Ds_BKGCAT', 'Ds_BPVCORRM', 'Ds_BPVDIRA', 'Ds_BPVDLS', 'Ds_BPVETA', 'Ds_BPVFD', 'Ds_BPVFDCHI2', 'Ds_BPVFDIRX', 'Ds_BPVFDIRY', 'Ds_BPVFDIRZ', 'Ds_BPVFDVECX', 'Ds_BPVFDVECY', 'Ds_BPVFDVECZ', 'Ds_BPVIP', 'Ds_BPVIPCHI2', 'Ds_BPVLTIME', 'Ds_BPVVDRHO', 'Ds_BPVVDX', 'Ds_BPVVDY', 'Ds_BPVVDZ', 'Ds_CHARGE', 'Ds_CHI2', 'Ds_CHI2DOF', 'Ds_DOCA', 'Ds_DOCACHI2', 'Ds_DTF_BPVIPCHI2', 'Ds_DTF_PT', 'Ds_END_VRHO', 'Ds_END_VX', 'Ds_END_VY', 'Ds_END_VZ', 'Ds_ENERGY', 'Ds_ETA', 'Ds_FOURMOMENTUME', 'Ds_FOURMOMENTUMX', 'Ds_FOURMOMENTUMY', 'Ds_FOURMOMENTUMZ', 'Ds_IS_ABS_ID_pi', 'Ds_IS_ID_pi', 'Ds_IS_NOT_H', 'Ds_MASS', 'Ds_MASSWITHHYPOTHESES', 'Ds_MAXDOCA', 'Ds_MAXDOCACHI2', 'Ds_MAXPT', 'Ds_MC_MOTHER_ID', 'Ds_MINIP', 'Ds_MINIPCHI2', 'Ds_MINPT', 'Ds_OBJECT_KEY', 'Ds_ORIGIN_VX', 'Ds_ORIGIN_VY', 'Ds_ORIGIN_VZ', 'Ds_P', 'Ds_PARTICLE_ID', 'Ds_PHI', 'Ds_PT', 'Ds_PX', 'Ds_PY', 'Ds_PZ', 'Ds_REFERENCEPOINT_X', 'Ds_REFERENCEPOINT_Y', 'Ds_REFERENCEPOINT_Z', 'Ds_SDOCA', 'Ds_SDOCACHI2', 'Ds_SUBCOMB12_MM', 'Ds_SUMPT', 'EVENTNUMBER', 'EVENTTYPE', 'GPSTIME', 'Kaon_BKGCAT', 'Kaon_BPVIP', 'Kaon_BPVIPCHI2', 'Kaon_CHARGE', 'Kaon_CHI2', 'Kaon_CHI2DOF', 'Kaon_DTF_BPVIPCHI2', 'Kaon_DTF_PT', 'Kaon_ENERGY', 'Kaon_ETA', 'Kaon_FOURMOMENTUME', 'Kaon_FOURMOMENTUMX', 'Kaon_FOURMOMENTUMY', 'Kaon_FOURMOMENTUMZ', 'Kaon_GHOSTPROB', 'Kaon_ISMUON', 'Kaon_IS_ABS_ID_pi', 'Kaon_IS_ID_pi', 'Kaon_IS_NOT_H', 'Kaon_IS_PHOTON', 'Kaon_MASS', 'Kaon_MC_MOTHER_ID', 'Kaon_MINIP', 'Kaon_MINIPCHI2', 'Kaon_OBJECT_KEY', 'Kaon_ORIGIN_VX', 'Kaon_ORIGIN_VY', 'Kaon_ORIGIN_VZ', 'Kaon_P', 'Kaon_PARTICLE_ID', 'Kaon_PHI', 'Kaon_PID_E', 'Kaon_PID_K', 'Kaon_PID_MU', 'Kaon_PID_P', 'Kaon_PID_PI', 'Kaon_PROBNN_D', 'Kaon_PROBNN_E', 'Kaon_PROBNN_GHOST', 'Kaon_PROBNN_K', 'Kaon_PROBNN_MU', 'Kaon_PROBNN_P', 'Kaon_PROBNN_PI', 'Kaon_PT', 'Kaon_PX', 'Kaon_PY', 'Kaon_PZ', 'Kaon_REFERENCEPOINT_X', 'Kaon_REFERENCEPOINT_Y', 'Kaon_REFERENCEPOINT_Z', 'Kaon_SHOWER_SHAPE', 'Kaon_TX', 'Kaon_TY', 'ODINTCK', 'PV_SIZE', 'RUNNUMBER', 'TCK', 'pip_BKGCAT', 'pip_BPVIP', 'pip_BPVIPCHI2', 'pip_CHARGE', 'pip_CHI2', 'pip_CHI2DOF', 'pip_DTF_BPVIPCHI2', 'pip_DTF_PT', 'pip_ENERGY', 'pip_ETA', 'pip_FOURMOMENTUME', 'pip_FOURMOMENTUMX', 'pip_FOURMOMENTUMY', 'pip_FOURMOMENTUMZ', 'pip_GHOSTPROB', 'pip_ISMUON', 'pip_IS_ABS_ID_pi', 'pip_IS_ID_pi', 'pip_IS_NOT_H', 'pip_IS_PHOTON', 'pip_MASS', 'pip_MC_MOTHER_ID', 'pip_MINIP', 'pip_MINIPCHI2', 'pip_OBJECT_KEY', 'pip_ORIGIN_VX', 'pip_ORIGIN_VY', 'pip_ORIGIN_VZ', 'pip_P', 'pip_PARTICLE_ID', 'pip_PHI', 'pip_PID_E', 'pip_PID_K', 'pip_PID_MU', 'pip_PID_P', 'pip_PID_PI', 'pip_PROBNN_D', 'pip_PROBNN_E', 'pip_PROBNN_GHOST', 'pip_PROBNN_K', 'pip_PROBNN_MU', 'pip_PROBNN_P', 'pip_PROBNN_PI', 'pip_PT', 'pip_PX', 'pip_PY', 'pip_PZ', 'pip_REFERENCEPOINT_X', 'pip_REFERENCEPOINT_Y', 'pip_REFERENCEPOINT_Z', 'pip_SHOWER_SHAPE', 'pip_TX', 'pip_TY'] #sort the expected vars B_vars_stored = sorted(B_vars_stored) diff --git a/DaVinciExamples/tests/refs/test_davinci_tupling_from_hlt2.ref b/DaVinciExamples/tests/refs/test_davinci_tupling_from_hlt2.ref index 4b8119520497972631541d2a1e35a0ecac620fa6..560c2be7473e676c96ab5670fd20cce7e1595b74 100644 --- a/DaVinciExamples/tests/refs/test_davinci_tupling_from_hlt2.ref +++ b/DaVinciExamples/tests/refs/test_davinci_tupling_from_hlt2.ref @@ -20,20 +20,10 @@ ApplicationMgr INFO Application Manager Started successf EventPersistencySvc INFO Added successfully Conversion service:RootCnvSvc EventSelector SUCCESS Reading Event record 1. Record number within stream 1: 1 RFileCnv INFO opening Root file "tuple_D0_Kpi_10evts_fromHlt2.root" for writing -Tuple WARNING FunTupleBase<Gaudi::NamedRange_<std::vector<LHCb::Particle const*,std::allocator<LHCb::Particle const*> >,__gnu_cxx::__normal_iterator<LHCb::Particle const* const*,std::vector<LHCb::Particle const*,std::allocator<LHCb::Particle const*> > > > >:: Tuple 'DecayTree' 'unsigned long' has different sizes on 32/64 bit systems. Casting 'EVENTNUMBER' to 'unsigned long long' RCWNTupleCnv INFO Booked TTree with ID: DecayTree "DecayTree" in directory tuple_D0_Kpi_10evts_fromHlt2.root:/Tuple EventSelector SUCCESS Reading Event record 2. Record number within stream 1: 2 -Tuple WARNING FunTupleBase<Gaudi::NamedRange_<std::vector<LHCb::Particle const*,std::allocator<LHCb::Particle const*> >,__gnu_cxx::__normal_iterator<LHCb::Particle const* const*,std::vector<LHCb::Particle const*,std::allocator<LHCb::Particle const*> > > > >:: Tuple 'DecayTree' 'unsigned long' has different sizes on 32/64 bit systems. Casting 'EVENTNUMBER' to 'unsigned long long' -Tuple WARNING FunTupleBase<Gaudi::NamedRange_<std::vector<LHCb::Particle const*,std::allocator<LHCb::Particle const*> >,__gnu_cxx::__normal_iterator<LHCb::Particle const* const*,std::vector<LHCb::Particle const*,std::allocator<LHCb::Particle const*> > > > >:: Tuple 'DecayTree' 'unsigned long' has different sizes on 32/64 bit systems. Casting 'EVENTNUMBER' to 'unsigned long long' EventSelector SUCCESS Reading Event record 3. Record number within stream 1: 3 -Tuple WARNING FunTupleBase<Gaudi::NamedRange_<std::vector<LHCb::Particle const*,std::allocator<LHCb::Particle const*> >,__gnu_cxx::__normal_iterator<LHCb::Particle const* const*,std::vector<LHCb::Particle const*,std::allocator<LHCb::Particle const*> > > > >:: Tuple 'DecayTree' 'unsigned long' has different sizes on 32/64 bit systems. Casting 'EVENTNUMBER' to 'unsigned long long' EventSelector SUCCESS Reading Event record 4. Record number within stream 1: 4 -Tuple WARNING FunTupleBase<Gaudi::NamedRange_<std::vector<LHCb::Particle const*,std::allocator<LHCb::Particle const*> >,__gnu_cxx::__normal_iterator<LHCb::Particle const* const*,std::vector<LHCb::Particle const*,std::allocator<LHCb::Particle const*> > > > >:: Tuple 'DecayTree' 'unsigned long' has different sizes on 32/64 bit systems. Casting 'EVENTNUMBER' to 'unsigned long long' -Tuple WARNING FunTupleBase<Gaudi::NamedRange_<std::vector<LHCb::Particle const*,std::allocator<LHCb::Particle const*> >,__gnu_cxx::__normal_iterator<LHCb::Particle const* const*,std::vector<LHCb::Particle const*,std::allocator<LHCb::Particle const*> > > > >:: Tuple 'DecayTree' 'unsigned long' has different sizes on 32/64 bit systems. Casting 'EVENTNUMBER' to 'unsigned long long' -Tuple WARNING FunTupleBase<Gaudi::NamedRange_<std::vector<LHCb::Particle const*,std::allocator<LHCb::Particle const*> >,__gnu_cxx::__normal_iterator<LHCb::Particle const* const*,std::vector<LHCb::Particle const*,std::allocator<LHCb::Particle const*> > > > >:: Tuple 'DecayTree' 'unsigned long' has different sizes on 32/64 bit systems. Casting 'EVENTNUMBER' to 'unsigned long long' -Tuple WARNING FunTupleBase<Gaudi::NamedRange_<std::vector<LHCb::Particle const*,std::allocator<LHCb::Particle const*> >,__gnu_cxx::__normal_iterator<LHCb::Particle const* const*,std::vector<LHCb::Particle const*,std::allocator<LHCb::Particle const*> > > > >:: Tuple 'DecayTree' 'unsigned long' has different sizes on 32/64 bit systems. Casting 'EVENTNUMBER' to 'unsigned long long' -Tuple WARNING FunTupleBase<Gaudi::NamedRange_<std::vector<LHCb::Particle const*,std::allocator<LHCb::Particle const*> >,__gnu_cxx::__normal_iterator<LHCb::Particle const* const*,std::vector<LHCb::Particle const*,std::allocator<LHCb::Particle const*> > > > >:: Tuple 'DecayTree' 'unsigned long' has different sizes on 32/64 bit systems. Casting 'EVENTNUMBER' to 'unsigned long long' -Tuple WARNING FunTupleBase<Gaudi::NamedRange_<std::vector<LHCb::Particle const*,std::allocator<LHCb::Particle const*> >,__gnu_cxx::__normal_iterator<LHCb::Particle const* const*,std::vector<LHCb::Particle const*,std::allocator<LHCb::Particle const*> > > > >:: The WARNING message is suppressed : 'Tuple 'DecayTree' 'unsigned long' has different sizes on 32/64 bit systems. Casting 'EVENTNUMBER' to 'unsigned long long'' EventSelector SUCCESS Reading Event record 5. Record number within stream 1: 5 ApplicationMgr INFO Application Manager Stopped successfully FSROutputStreamDstWriter INFO Set up File Summary Record @@ -41,7 +31,6 @@ FSROutputStreamDstWriter INFO Events output: 1 Tuple SUCCESS Booked 1 N-Tuples and 0 Event Tag Collections Tuple SUCCESS List of booked N-Tuples in directory "FILE1/Tuple" Tuple SUCCESS ID=DecayTree Title="DecayTree" #items=79 {EVENTNUMBER,Hlt2_TCK,RUNNUMBER,D0_ID,D0_KEY,D0_PT,D0_PX,D0_PY,D0_PZ,D0_ENERGY,D0_} -Tuple SUCCESS #WARNINGS = 12 Message = 'Tuple 'DecayTree' 'unsigned long' has different sizes on 32/64 bit systems. Casting 'EVENTNUMBER' to 'unsigned long long'' LAZY_AND: DaVinci #=5 Sum=5 Eff=|( 100.0000 +- 0.00000 )%| NONLAZY_OR: FileSummaryRecords #=5 Sum=5 Eff=|( 100.0000 +- 0.00000 )%| LAZY_AND: GenFSR #=5 Sum=5 Eff=|( 100.0000 +- 0.00000 )%| diff --git a/Phys/DaVinci/python/DaVinci/algorithms.py b/Phys/DaVinci/python/DaVinci/algorithms.py index ab56ab8392e8e9878b6cb72c2c71c06649326700..c11d6da7e9ebd6435b970858ac9903bc67d17349 100644 --- a/Phys/DaVinci/python/DaVinci/algorithms.py +++ b/Phys/DaVinci/python/DaVinci/algorithms.py @@ -11,13 +11,18 @@ import os, sys, importlib from GaudiKernel.ProcessJobOptions import importOptions -from PyConf.Algorithms import (LoKi__HDRFilter as HDRFilter, LoKi__VoidFilter - as VoidFilter) +from PyConf.Algorithms import ( + FilterDecays, + LoKi__HDRFilter as HDRFilter, + LoKi__VoidFilter as VoidFilter, +) from DaVinci.optionChecker import DVImportError, log_click from DaVinci.configOptions import set_properties -from PyConf.application import ComponentConfig -from PyConf.application import default_raw_event, make_odin -from PyConf.Algorithms import FilterDecays +from PyConf.application import ( + default_raw_event, + ComponentConfig, + make_odin, +) from DaVinci.algorithms_pyconf import make_dvalgorithm from PyConf.components import force_location @@ -401,8 +406,13 @@ def get_odin(dv_options): Returns: odin_loc: Location of the LHCb::ODIN """ + + if dv_options.process == 'Hlt2': + stream = "" + else: + stream = dv_options.stream with default_raw_event.bind(raw_event_format=dv_options.input_raw_format): - odin_loc = make_odin() + odin_loc = make_odin(stream=stream) return odin_loc diff --git a/Phys/DaVinci/python/DaVinci/truth_matching.py b/Phys/DaVinci/python/DaVinci/truth_matching.py index 0960056b7ea6faae54dea486102664b1e7c70be3..089ae7e6f449c60b1c5151982f44d1a71e197e8e 100644 --- a/Phys/DaVinci/python/DaVinci/truth_matching.py +++ b/Phys/DaVinci/python/DaVinci/truth_matching.py @@ -20,7 +20,8 @@ from PyConf.Tools import P2MCPFromProtoP def configured_MCTruthAndBkgCatAlg( inputs, relations_locs=["Relations/ChargedPP2MCP", "Relations/NeutralPP2MCP"], - root_in_tes="/Event/HLT2", + process='Spruce', + root_in_tes=None, redo_neutral_assoc=False, output_level=INFO): """ @@ -41,7 +42,9 @@ def configured_MCTruthAndBkgCatAlg( inputs (DataHandle): Output of `Gaudi::Hive::FetchDataFromFile` (the input TES location to the particles). relations_locs (list, optional): TES locations to the pre-existing relations for charged and neutral particles. Defaults to ["Relations/ChargedPP2MCP", "Relations/NeutralPP2MCP"]. - root_in_tes (str, optional): RootInTES location that can be different for Sprucing output. Defaults to "/Event/HLT2". + process (str, optional): Specifies the output being processed i.e. 'Hlt2' or 'Spruce'. Default is 'Spruce'. + root_in_tes (str, optional): RootInTES location that can be different for streamed output. Defaults is None. + If not 'None' then the 'process' argument is completely ignored. redo_neutral_assoc (bool, optional): Whether or not to redo MC association of pure neutral calorimetric basic particle, i.e. gamma and pi0-merged with pi0-resolved treated as composite. Defaults to False. @@ -51,6 +54,17 @@ def configured_MCTruthAndBkgCatAlg( Returns: MCTruthAndBkgCatAlg: configured instance of algorithm MCTruthAndBkgCatAlg. """ + + if not root_in_tes: + if process == 'Spruce': + root_in_tes = '/Event/Spruce/HLT2' + elif process == 'Hlt2': + root_in_tes = '/Event/HLT2' + else: + raise ValueError( + f"The specified 'process' {process} not recognised. Can only be 'Hlt2' or 'Spruce'. Please check!" + ) + # Tool used by DaVinciSmartAssociator p2mctool = P2MCPFromProtoP( Locations=relations_locs,