diff --git a/DaVinciExamples/python/DaVinciExamples/tupling/AllFunctors.py b/DaVinciExamples/python/DaVinciExamples/tupling/AllFunctors.py index 62a94279acdc148cd268368142b4f5ab2063757a..1a60a96d49d0151cf4a53b533cb0fa1ab5165940 100644 --- a/DaVinciExamples/python/DaVinciExamples/tupling/AllFunctors.py +++ b/DaVinciExamples/python/DaVinciExamples/tupling/AllFunctors.py @@ -17,7 +17,7 @@ rst_description: This example shows how to: 1. create a dictionary with functors of interest for various type of particles 2. add a tuple with the selected functors. -rst_running: lbexec DaVinciExamples.tupling.AllFunctors:alg_config $DAVINCIEXAMPLESROOT/example_options/example_tupling_allfunctors.yaml +rst_running: lbexec DaVinciExamples.tupling.AllFunctors:alg_config $DAVINCIEXAMPLESROOT/example_options/example_tupling_allfunctors.yaml rst_yaml: ../DaVinciExamples/example_options/example_tupling_allfunctors.yaml """ __author__ = "P. Koppenburg" @@ -196,6 +196,22 @@ def all_variables(pvs, dtf, mctruth, ptype, candidates=None, ftAlg=None): all_vars.update({'DTF_PT': dtf(F.PT)}) all_vars.update({'DTF_BPVIPCHI2': dtf(F.BPVIPCHI2(pvs))}) + if top: + all_vars.update({'DTF_NITER': dtf.NITER}) + all_vars.update({'DTF_CHI2': dtf.CHI2}) + all_vars.update({'DTF_NDOF': dtf.NDOF}) + all_vars.update({'DTF_CHI2DOF': dtf.CHI2DOF}) + + if comp: + all_vars.update({'DTF_MASS': dtf.MASS}) + all_vars.update({'DTF_MASSERR': dtf.MASSERR}) + all_vars.update({'DTF_P': dtf.P}) + all_vars.update({'DTF_PERR': dtf.PERR}) + all_vars.update({'DTF_TAU': dtf.TAU}) + all_vars.update({'DTF_TAUERR': dtf.TAUERR}) + all_vars.update({'DTF_FD': dtf.FD}) + all_vars.update({'DTF_FDERR': dtf.FDERR}) + all_vars.update({'MASS': F.MASS}) if top: # B all_vars.update({ diff --git a/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_DTF_pvs.py b/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_DTF_pvs.py new file mode 100644 index 0000000000000000000000000000000000000000..af8af99326e6bb28b27e201916a7b7c1cd4af11b --- /dev/null +++ b/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_DTF_pvs.py @@ -0,0 +1,103 @@ +############################################################################### +# (c) Copyright 2022-2023 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. # +############################################################################### +r"""option_davinci_tupling_DTF_pvs.py +Example options to show the usage of the DecayTreeFitter with PV constraints. +rst_title: DecayTreeFitter with PV constraints +rst_description: This example shows how to use DecayTreeFitter with PV constraints. +It runs two different versions of the DecayTreeFitter algorithm: the first version uses the best PV constraint and v1 PV, while the second version considers all possible PV constraints and uses v2 PVs. +rst_running: lbexec DaVinciExamples.tupling.option_davinci_tupling_DTF_pvs:main $DAVINCIEXAMPLESROOT/example_data/test_passthrough_thor_lines.yaml +rst_yaml: ../DaVinciExamples/example_data/test_passthrough_thor_lines.yaml +""" + +from PyConf.reading import get_particles, get_pvs, get_pvs_v1 +from DecayTreeFitter import DecayTreeFitter +from FunTuple import FunTuple_Particles as Funtuple +from FunTuple import functorcollections as FC +from DaVinci.algorithms import create_lines_filter +from DaVinci import Options, make_config + + +def main(options: Options): + + B_Line = "Hlt2BsToJpsiPhi_JPsi2MuMu_PhiToKK_Line" + B_Data = get_particles(f'/Event/HLT2/{B_Line}/Particles') + + my_filter = create_lines_filter( + name="HDRFilter_Bs2JpsiPhi", lines=[B_Line]) + + # DTF works for both v1 and v2 vertices + pvs_v1 = get_pvs_v1() + pvs_v2 = get_pvs() + + fields = { + 'Bs': "[ B_s0 -> (J/psi(1S) -> mu+ mu-) (phi(1020) -> K+ K-) ]CC", + 'Jpsi': "[ B_s0 -> ^(J/psi(1S) -> mu+ mu-) (phi(1020) -> K+ K-) ]CC", + 'Phi': "[ B_s0 -> (J/psi(1S) -> mu+ mu-) ^(phi(1020) -> K+ K-) ]CC", + 'MuP': "[ B_s0 -> (J/psi(1S) -> ^mu+ mu-) (phi(1020) -> K+ K-) ]CC", + 'MuM': "[ B_s0 -> (J/psi(1S) -> mu+ ^mu-) (phi(1020) -> K+ K-) ]CC", + 'KP': "[ B_s0 -> (J/psi(1S) -> mu+ mu-) (phi(1020) -> ^K+ K-) ]CC", + 'KM': "[ B_s0 -> (J/psi(1S) -> mu+ mu-) (phi(1020) -> K+ ^K-) ]CC", + } + + DTF_BestPV = DecayTreeFitter( + name='DTF_BestPV', + input_particles=B_Data, + mass_constraints=['B_s0', 'J/psi(1S)'], + input_pvs=pvs_v1, + fit_all_pvs=False) + + DTF_AllPVs = DecayTreeFitter( + name='DTF_AllPVs', + input_particles=B_Data, + mass_constraints=['B_s0', 'J/psi(1S)'], + input_pvs=pvs_v2, + fit_all_pvs=True) + + variables = { + 'Bs': + FC.DecayTreeFitterResults( + DTF=DTF_BestPV, + prefix='DTF_BestPV', + decay_origin=True, + with_lifetime=True, + with_kinematics=False) + FC.DecayTreeFitterResults( + DTF=DTF_AllPVs, + prefix='DTF_AllPVs', + decay_origin=True, + with_lifetime=True, + with_kinematics=False), + 'ALL': + FC.DecayTreeFitterResults( + DTF=DTF_BestPV, + prefix='DTF_BestPV', + decay_origin=False, + with_lifetime=False, + with_kinematics=True) + FC.DecayTreeFitterResults( + DTF=DTF_AllPVs, + prefix='DTF_AllPVs', + decay_origin=False, + with_lifetime=False, + with_kinematics=True), + } + + #Configure Funtuple algorithm + funtuple = Funtuple( + name="JpsiPhi_Tuple", + tuple_name="DecayTree", + fields=fields, + variables=variables, + inputs=B_Data) + + # Run + algs = { + "JpsiPhi_Tuple": [my_filter, funtuple], + } + return make_config(options, algs) diff --git a/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_DTF_substitutePID.py b/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_DTF_substitutePID.py index daa4d7ace4692c63d591263873c0173be8168489..1ef54b6b7fd5ddea2cc3e1d6860cee73e00f44db 100644 --- a/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_DTF_substitutePID.py +++ b/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_DTF_substitutePID.py @@ -11,14 +11,14 @@ r"""option_davinci_tupling_DTF_substitutePID.py Example options to show the usage of DecayTreeFitter with SubstitutePID. rst_title: DecayTreeFitter with SubstitutePID -rst_description: This example shows how to use DecayTreeFitter with SubstitutePID. +rst_description: This example shows how to use DecayTreeFitter with SubstitutePID. Two tuples are made. One with the signal mode :math:`B^0_s \to J/\psi \phi` and another one with :math:`B^0 \to J/\psi K^*(892)` background obtained by sustituting the id of a :math:`K` with a :math:`\pi`. rst_running: lbexec DaVinciExamples.tupling.option_davinci_tupling_DTF_substitutePID:main $DAVINCIEXAMPLESROOT/example_data/test_passthrough_thor_lines.yaml -rst_yaml: ../DaVinciExamples/example_data/test_passthrough_thor_lines.yaml +rst_yaml: ../DaVinciExamples/example_data/test_passthrough_thor_lines.yaml """ from Gaudi.Configuration import INFO -from PyConf.reading import get_particles, get_pvs_v1 +from PyConf.reading import get_particles, get_pvs import Functors as F from DecayTreeFitter import DecayTreeFitter from FunTuple import FunTuple_Particles as Funtuple @@ -35,18 +35,18 @@ def main(options: Options): my_filter = create_lines_filter( name="HDRFilter_Bs2JpsiPhi", lines=[f"{B_Line}"]) - pvs_v1 = get_pvs_v1() + pvs = get_pvs() DTF_JpsiPhi = DecayTreeFitter( name='DTF_JpsiPhi', input_particles=B_Data, mass_constraints=['B_s0', 'J/psi(1S)'], - input_pvs=pvs_v1, + input_pvs=pvs, output_level=INFO) DTF_JpsiKst = DecayTreeFitter( name='DTF_JpsiKst', input_particles=B_Data, - input_pvs=pvs_v1, + input_pvs=pvs, substitutions=[ 'B_s0{{B0}} -> (J/psi(1S) -> mu+ mu-) (phi(1020){{K*(892)0}} -> K+ K-{{pi-}})', 'B_s~0{{B0}} -> (J/psi(1S) -> mu+ mu-) (phi(1020){{K*(892)~0}} -> K- K+{{pi+}})', 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 b364d20068c7788d04284fb57035a32350830d12..2d206cd95621a1c3a253c7d91023a668e840cb18 100644 --- a/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_from_collections.py +++ b/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_from_collections.py @@ -27,6 +27,7 @@ from FunTuple import FunTuple_Particles as Funtuple, FunTuple_MCParticles as MCF from DaVinci.algorithms import create_lines_filter from DaVinci import Options, make_config from DaVinciMCTools import MCTruthAndBkgCat +from DecayTreeFitter import DecayTreeFitter #define functor collections that need to be excluded. #Delete the collection "HltTisTos" since the @@ -75,6 +76,9 @@ def main(options: Options): # get configured "MCTruthAndBkgCatAlg" algorithm for HLT2 output MCTRUTH = MCTruthAndBkgCat(d02kpi_data, name='MCTruthAndBkgCat_coll') + # define DTF + DTF = DecayTreeFitter(name='DecayTreeFitter', input_particles=d02kpi_data) + # configure "WeightedRelTableAlg" algorithm for HLT2 output iso_rel_table = WeightedRelTableAlg( ReferenceParticles=d02kpi_data, @@ -94,7 +98,12 @@ def main(options: Options): FC.MCPromptDecay(mctruth_alg=MCTRUTH), FC.TrackIsolation(iso_rel_table=iso_rel_table), FC.NeutralCaloInfo(), - FC.ParticleID() + FC.ParticleID(), + FC.DecayTreeFitterResults( + DTF=DTF, + decay_origin=False, + with_lifetime=False, + with_kinematics=True), ] mc_collections = [ 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 37d3707de950b7be8fda4deb12266ac21ea45fd9..8f3155424cda1c9e2bda348623cfa0be6bc71574 100755 --- a/DaVinciExamples/tests/qmtest/tupling.qms/test_davinci_tupling_All.qmt +++ b/DaVinciExamples/tests/qmtest/tupling.qms/test_davinci_tupling_All.qmt @@ -58,6 +58,7 @@ import sys, os, glob from ROOT import TFile B_vars_stored = ['B0_ISBASIC', 'B0_ABS_PX', 'B0_ALLPVX', 'B0_ALLPVY', 'B0_ALLPVZ', 'B0_ALLPV_FD', 'B0_ALLPV_IP', 'B0_ALV', 'B0_BKGCAT', 'B0_BPVCORRM', 'B0_BPVCORRMERR', '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_BPVX', 'B0_BPVY', 'B0_BPVZ', '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_M', 'B0_MASS', 'B0_MASSWITHHYPOTHESES', 'B0_MAXDOCA', 'B0_MAXDOCACHI2', 'B0_MAXPT', 'B0_MC_GD_GD_MOTHER_ID', 'B0_MC_GD_GD_MOTHER_KEY', 'B0_MC_GD_MOTHER_ID', 'B0_MC_GD_MOTHER_KEY', 'B0_MC_ISPROMPT', 'B0_MC_LONGLIVED_ID', 'B0_MC_LONGLIVED_KEY', 'B0_MC_MO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'Kaon_BREMHYPOMATCH', 'Kaon_BREMPIDE', 'Kaon_CHARGE', 'Kaon_CHI2', 'Kaon_CHI2DOF', 'Kaon_CLUSTERMATCH', 'Kaon_DTF_BPVIPCHI2', 'Kaon_DTF_PT', 'Kaon_ECALPIDE', 'Kaon_ECALPIDMU', 'Kaon_ELECTRONENERGY', 'Kaon_ELECTRONID', 'Kaon_ELECTRONMATCH', 'Kaon_ELECTRONSHOWEREOP', 'Kaon_ENERGY', 'Kaon_ETA', 'Kaon_FOURMOMENTUME', 'Kaon_FOURMOMENTUMX', 'Kaon_FOURMOMENTUMY', 'Kaon_FOURMOMENTUMZ', 'Kaon_GHOSTPROB', 'Kaon_HASBREM', 'Kaon_HCALEOP', 'Kaon_HCALPIDE', 'Kaon_HCALPIDMU', 'Kaon_INECAL', 'Kaon_INHCAL', 'Kaon_INMUON', 'Kaon_ISMUON', 'Kaon_IS_ABS_ID_pi', 'Kaon_IS_ID_pi', 'Kaon_PDG_MASS_pi', 'Kaon_SIGNED_DELTA_MASS_pi', 'Kaon_ABS_DELTA_MASS_pi', 'Kaon_IS_NOT_H', 'Kaon_IS_PHOTON', 'Kaon_M', 'Kaon_MASS', 'Kaon_MC_GD_GD_MOTHER_ID', 'Kaon_MC_GD_GD_MOTHER_KEY', 'Kaon_MC_GD_MOTHER_ID', 'Kaon_MC_GD_MOTHER_KEY', 'Kaon_MC_MOTHER_ID', 'Kaon_MC_MOTHER_KEY', 'Kaon_MINIP', 'Kaon_MINIPCHI2', 'Kaon_NDOF', 'Kaon_NFTHITS', 'Kaon_NHITS', 'Kaon_NUTHITS', 'Kaon_NVPHITS', 'Kaon_OBJECT_KEY', '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_QOVERP', 'Kaon_REFERENCEPOINT_X', 'Kaon_REFERENCEPOINT_Y', 'Kaon_REFERENCEPOINT_Z', 'Kaon_SHOWER_SHAPE', 'Kaon_TRACKHASUT', 'Kaon_TRACKHASVELO', 'Kaon_TRACKHISTORY', 'Kaon_TRACKPT', 'Kaon_TRACK_MOM_X', 'Kaon_TRACK_MOM_Y', 'Kaon_TRACK_MOM_Z', 'Kaon_TRACK_POS_CLOSESTTOBEAM_X', 'Kaon_TRACK_POS_CLOSESTTOBEAM_Y', 'Kaon_TRACK_POS_CLOSESTTOBEAM_Z', 'Kaon_TRUEENERGY', 'Kaon_TRUEID', 'Kaon_TRUEP', 'Kaon_TRUEPT', 'Kaon_TRUEPX', 'Kaon_TRUEPY', 'Kaon_TRUEPZ', 'Kaon_TX', 'Kaon_TY', 'ODINTCK', 'PV_SIZE', 'RUNNUMBER', 'SpruceB2OC_BdToDsmK_DsmToHHH_FEST_LineDecision', 'Spruce_TCK', 'nPVs', 'pip_ABS_PX', 'pip_ALLPVX', 'pip_ALLPVY', 'pip_ALLPVZ', 'pip_BPVIP', 'pip_BPVIPCHI2', 'pip_BPVX', 'pip_BPVY', 'pip_BPVZ', 'pip_BREMBENDCORR', 'pip_BREMENERGY', 'pip_BREMHYPODELTAX', 'pip_BREMHYPOENERGY', 'pip_BREMHYPOMATCH', 'pip_BREMPIDE', 'pip_CHARGE', 'pip_CHI2', 'pip_CHI2DOF', 'pip_CLUSTERMATCH', 'pip_DTF_BPVIPCHI2', 'pip_DTF_PT', 'pip_ECALPIDE', 'pip_ECALPIDMU', 'pip_ELECTRONENERGY', 'pip_ELECTRONID', 'pip_ELECTRONMATCH', 'pip_ELECTRONSHOWEREOP', 'pip_ENERGY', 'pip_ETA', 'pip_FOURMOMENTUME', 'pip_FOURMOMENTUMX', 'pip_FOURMOMENTUMY', 'pip_FOURMOMENTUMZ', 'pip_GHOSTPROB', 'pip_HASBREM', 'pip_HCALEOP', 'pip_HCALPIDE', 'pip_HCALPIDMU', 'pip_INECAL', 'pip_INHCAL', 'pip_INMUON', 'pip_ISMUON', 'pip_IS_ABS_ID_pi', 'pip_IS_ID_pi', 'pip_PDG_MASS_pi', 'pip_SIGNED_DELTA_MASS_pi', 'pip_ABS_DELTA_MASS_pi', 'pip_IS_NOT_H', 'pip_IS_PHOTON', 'pip_M', 'pip_MASS', 'pip_MC_GD_GD_MOTHER_ID', 'pip_MC_GD_GD_MOTHER_KEY', 'pip_MC_GD_MOTHER_ID', 'pip_MC_GD_MOTHER_KEY', 'pip_MC_MOTHER_ID', 'pip_MC_MOTHER_KEY', 'pip_MINIP', 'pip_MINIPCHI2', 'pip_NDOF', 'pip_NFTHITS', 'pip_NHITS', 'pip_NUTHITS', 'pip_NVPHITS', 'pip_OBJECT_KEY', '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_QOVERP', 'pip_REFERENCEPOINT_X', 'pip_REFERENCEPOINT_Y', 'pip_REFERENCEPOINT_Z', 'pip_SHOWER_SHAPE', 'pip_TRACKHASUT', 'pip_TRACKHASVELO', 'pip_TRACKHISTORY', 'pip_TRACKPT', 'pip_TRACK_MOM_X', 'pip_TRACK_MOM_Y', 'pip_TRACK_MOM_Z', 'pip_TRACK_POS_CLOSESTTOBEAM_X', 'pip_TRACK_POS_CLOSESTTOBEAM_Y', 'pip_TRACK_POS_CLOSESTTOBEAM_Z', 'pip_TRUEENERGY', 'pip_TRUEID', 'pip_TRUEP', 'pip_TRUEPT', 'pip_TRUEPX', 'pip_TRUEPY', 'pip_TRUEPZ', 'pip_TX', 'pip_TY', 'pip_ISBASIC'] +B_vars_stored += ['Ds_DTF_TAUERR', 'Ds_DTF_MASSERR', 'Ds_DTF_FDERR', 'B0_DTF_MASS', 'B0_DTF_PERR', 'B0_DTF_TAUERR', 'Ds_DTF_PERR', 'Ds_DTF_MASS', 'B0_DTF_TAU', 'B0_DTF_NDOF', 'B0_DTF_MASSERR', 'Ds_DTF_TAU', 'Ds_DTF_FD', 'B0_DTF_CHI2', 'B0_DTF_FD', 'B0_DTF_NITER', 'Ds_DTF_P', 'B0_DTF_FDERR', 'B0_DTF_CHI2DOF', 'B0_DTF_P'] #sort the expected vars B_vars_stored = sorted(B_vars_stored) diff --git a/DaVinciExamples/tests/qmtest/tupling.qms/test_davinci_tupling_All_olddst.qmt b/DaVinciExamples/tests/qmtest/tupling.qms/test_davinci_tupling_All_olddst.qmt index 7f8f6b9a76547248d8e20cd8a4a6b94407fe72a3..ee6b673d2f7c1c44098b9a5d0c00be8c407b3c53 100755 --- a/DaVinciExamples/tests/qmtest/tupling.qms/test_davinci_tupling_All_olddst.qmt +++ b/DaVinciExamples/tests/qmtest/tupling.qms/test_davinci_tupling_All_olddst.qmt @@ -58,6 +58,7 @@ import sys, os, glob from ROOT import TFile B_vars_stored = ['B0_ISBASIC', 'B0_ABS_PX', 'B0_ALLPVX', 'B0_ALLPVY', 'B0_ALLPVZ', 'B0_ALLPV_FD', 'B0_ALLPV_IP', 'B0_ALV', 'B0_BKGCAT', 'B0_BPVCORRM', 'B0_BPVCORRMERR', '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_BPVX', 'B0_BPVY', 'B0_BPVZ', '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_M', 'B0_MASS', 'B0_MASSWITHHYPOTHESES', 'B0_MAXDOCA', 'B0_MAXDOCACHI2', 'B0_MAXPT', 'B0_MC_GD_GD_MOTHER_ID', 'B0_MC_GD_GD_MOTHER_KEY', 'B0_MC_GD_MOTHER_ID', 'B0_MC_GD_MOTHER_KEY', 'B0_MC_ISPROMPT', 'B0_MC_LONGLIVED_ID', 'B0_MC_LONGLIVED_KEY', 'B0_MC_MOTHER_ID', 'B0_MC_MOTHER_KEY', 'B0_MINIP', 'B0_MINIPCHI2', 'B0_MINPT', 'B0_OBJECT_KEY', 'B0_P', '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', 'B0_TRUEENDVERTEX_X', 'B0_TRUEENDVERTEX_Y', 'B0_TRUEENDVERTEX_Z', 'B0_TRUEENERGY', 'B0_TRUEID', 'B0_TRUEORIGINVERTEX_X', 'B0_TRUEORIGINVERTEX_Y', 'B0_TRUEORIGINVERTEX_Z', 'B0_TRUEP', 'B0_TRUEPT', 'B0_TRUEPX', 'B0_TRUEPY', 'B0_TRUEPZ', 'BUNCHCROSSING_ID', 'BUNCHCROSS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ds_REFERENCEPOINT_Y', 'Ds_REFERENCEPOINT_Z', 'Ds_SDOCA', 'Ds_SDOCACHI2', 'Ds_SUBCOMB12_MM', 'Ds_SUMPT', 'Ds_TRUEENDVERTEX_X', 'Ds_TRUEENDVERTEX_Y', 'Ds_TRUEENDVERTEX_Z', 'Ds_TRUEENERGY', 'Ds_TRUEID', 'Ds_TRUEORIGINVERTEX_X', 'Ds_TRUEORIGINVERTEX_Y', 'Ds_TRUEORIGINVERTEX_Z', 'Ds_TRUEP', 'Ds_TRUEPT', 'Ds_TRUEPX', 'Ds_TRUEPY', 'Ds_TRUEPZ', 'EVENTNUMBER', 'EVENTTYPE', 'GPSTIME', 'Kaon_ISBASIC', 'Kaon_ABS_PX', 'Kaon_ALLPVX', 'Kaon_ALLPVY', 'Kaon_ALLPVZ', 'Kaon_BPVIP', 'Kaon_BPVIPCHI2', 'Kaon_BPVX', 'Kaon_BPVY', 'Kaon_BPVZ', 'Kaon_BREMBENDCORR', 'Kaon_BREMENERGY', 'Kaon_BREMHYPODELTAX', 'Kaon_BREMHYPOENERGY', 'Kaon_BREMHYPOMATCH', 'Kaon_BREMPIDE', 'Kaon_CHARGE', 'Kaon_CHI2', 'Kaon_CHI2DOF', 'Kaon_CLUSTERMATCH', 'Kaon_DTF_BPVIPCHI2', 'Kaon_DTF_PT', 'Kaon_ECALPIDE', 'Kaon_ECALPIDMU', 'Kaon_ELECTRONENERGY', 'Kaon_ELECTRONID', 'Kaon_ELECTRONMATCH', 'Kaon_ELECTRONSHOWEREOP', 'Kaon_ENERGY', 'Kaon_ETA', 'Kaon_FOURMOMENTUME', 'Kaon_FOURMOMENTUMX', 'Kaon_FOURMOMENTUMY', 'Kaon_FOURMOMENTUMZ', 'Kaon_GHOSTPROB', 'Kaon_HASBREM', 'Kaon_HCALEOP', 'Kaon_HCALPIDE', 'Kaon_HCALPIDMU', 'Kaon_INECAL', 'Kaon_INHCAL', 'Kaon_INMUON', 'Kaon_ISMUON', 'Kaon_IS_ABS_ID_pi', 'Kaon_IS_ID_pi', 'Kaon_PDG_MASS_pi', 'Kaon_SIGNED_DELTA_MASS_pi', 'Kaon_ABS_DELTA_MASS_pi', 'Kaon_IS_NOT_H', 'Kaon_IS_PHOTON', 'Kaon_M', 'Kaon_MASS', 'Kaon_MC_GD_GD_MOTHER_ID', 'Kaon_MC_GD_GD_MOTHER_KEY', 'Kaon_MC_GD_MOTHER_ID', 'Kaon_MC_GD_MOTHER_KEY', 'Kaon_MC_MOTHER_ID', 'Kaon_MC_MOTHER_KEY', 'Kaon_MINIP', 'Kaon_MINIPCHI2', 'Kaon_NDOF', 'Kaon_NFTHITS', 'Kaon_NHITS', 'Kaon_NUTHITS', 'Kaon_NVPHITS', 'Kaon_OBJECT_KEY', '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_QOVERP', 'Kaon_REFERENCEPOINT_X', 'Kaon_REFERENCEPOINT_Y', 'Kaon_REFERENCEPOINT_Z', 'Kaon_SHOWER_SHAPE', 'Kaon_TRACKHASUT', 'Kaon_TRACKHASVELO', 'Kaon_TRACKHISTORY', 'Kaon_TRACKPT', 'Kaon_TRACK_MOM_X', 'Kaon_TRACK_MOM_Y', 'Kaon_TRACK_MOM_Z', 'Kaon_TRACK_POS_CLOSESTTOBEAM_X', 'Kaon_TRACK_POS_CLOSESTTOBEAM_Y', 'Kaon_TRACK_POS_CLOSESTTOBEAM_Z', 'Kaon_TRUEENERGY', 'Kaon_TRUEID', 'Kaon_TRUEP', 'Kaon_TRUEPT', 'Kaon_TRUEPX', 'Kaon_TRUEPY', 'Kaon_TRUEPZ', 'Kaon_TX', 'Kaon_TY', 'ODINTCK', 'PV_SIZE', 'RUNNUMBER', 'SpruceB2OC_BdToDsmK_DsmToHHH_FEST_LineDecision', 'Spruce_TCK', 'nPVs', 'pip_ABS_PX', 'pip_ALLPVX', 'pip_ALLPVY', 'pip_ALLPVZ', 'pip_BPVIP', 'pip_BPVIPCHI2', 'pip_BPVX', 'pip_BPVY', 'pip_BPVZ', 'pip_BREMBENDCORR', 'pip_BREMENERGY', 'pip_BREMHYPODELTAX', 'pip_BREMHYPOENERGY', 'pip_BREMHYPOMATCH', 'pip_BREMPIDE', 'pip_CHARGE', 'pip_CHI2', 'pip_CHI2DOF', 'pip_CLUSTERMATCH', 'pip_DTF_BPVIPCHI2', 'pip_DTF_PT', 'pip_ECALPIDE', 'pip_ECALPIDMU', 'pip_ELECTRONENERGY', 'pip_ELECTRONID', 'pip_ELECTRONMATCH', 'pip_ELECTRONSHOWEREOP', 'pip_ENERGY', 'pip_ETA', 'pip_FOURMOMENTUME', 'pip_FOURMOMENTUMX', 'pip_FOURMOMENTUMY', 'pip_FOURMOMENTUMZ', 'pip_GHOSTPROB', 'pip_HASBREM', 'pip_HCALEOP', 'pip_HCALPIDE', 'pip_HCALPIDMU', 'pip_INECAL', 'pip_INHCAL', 'pip_INMUON', 'pip_ISMUON', 'pip_IS_ABS_ID_pi', 'pip_IS_ID_pi', 'pip_PDG_MASS_pi', 'pip_SIGNED_DELTA_MASS_pi', 'pip_ABS_DELTA_MASS_pi', 'pip_IS_NOT_H', 'pip_IS_PHOTON', 'pip_M', 'pip_MASS', 'pip_MC_GD_GD_MOTHER_ID', 'pip_MC_GD_GD_MOTHER_KEY', 'pip_MC_GD_MOTHER_ID', 'pip_MC_GD_MOTHER_KEY', 'pip_MC_MOTHER_ID', 'pip_MC_MOTHER_KEY', 'pip_MINIP', 'pip_MINIPCHI2', 'pip_NDOF', 'pip_NFTHITS', 'pip_NHITS', 'pip_NUTHITS', 'pip_NVPHITS', 'pip_OBJECT_KEY', '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_QOVERP', 'pip_REFERENCEPOINT_X', 'pip_REFERENCEPOINT_Y', 'pip_REFERENCEPOINT_Z', 'pip_SHOWER_SHAPE', 'pip_TRACKHASUT', 'pip_TRACKHASVELO', 'pip_TRACKHISTORY', 'pip_TRACKPT', 'pip_TRACK_MOM_X', 'pip_TRACK_MOM_Y', 'pip_TRACK_MOM_Z', 'pip_TRACK_POS_CLOSESTTOBEAM_X', 'pip_TRACK_POS_CLOSESTTOBEAM_Y', 'pip_TRACK_POS_CLOSESTTOBEAM_Z', 'pip_TRUEENERGY', 'pip_TRUEID', 'pip_TRUEP', 'pip_TRUEPT', 'pip_TRUEPX', 'pip_TRUEPY', 'pip_TRUEPZ', 'pip_TX', 'pip_TY', 'pip_ISBASIC'] +B_vars_stored += ['Ds_DTF_TAUERR', 'Ds_DTF_MASSERR', 'Ds_DTF_FDERR', 'B0_DTF_MASS', 'B0_DTF_PERR', 'B0_DTF_TAUERR', 'Ds_DTF_PERR', 'Ds_DTF_MASS', 'B0_DTF_TAU', 'B0_DTF_NDOF', 'B0_DTF_MASSERR', 'Ds_DTF_TAU', 'Ds_DTF_FD', 'B0_DTF_CHI2', 'B0_DTF_FD', 'B0_DTF_NITER', 'Ds_DTF_P', 'B0_DTF_FDERR', 'B0_DTF_CHI2DOF', 'B0_DTF_P'] #sort the expected vars B_vars_stored = sorted(B_vars_stored) diff --git a/DaVinciExamples/tests/qmtest/tupling.qms/test_davinci_tupling_DTF_pvs.qmt b/DaVinciExamples/tests/qmtest/tupling.qms/test_davinci_tupling_DTF_pvs.qmt new file mode 100644 index 0000000000000000000000000000000000000000..377664facfafee4bb21e18beedcb3c10502e0985 --- /dev/null +++ b/DaVinciExamples/tests/qmtest/tupling.qms/test_davinci_tupling_DTF_pvs.qmt @@ -0,0 +1,69 @@ +<?xml version="1.0" ?> +<!-- +############################################################################### +# (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. # +############################################################################### +--> +<!DOCTYPE extension PUBLIC '-//QM/2.3/Extension//EN' 'http://www.codesourcery.com/qm/dtds/2.3/-//qm/2.3/extension//en.dtd'> +<extension class="GaudiTest.GaudiExeTest" kind="test"> + <argument name="program"><text>lbexec</text></argument> + <argument name="args"><set> + <text>DaVinciExamples.tupling.option_davinci_tupling_DTF_pvs:main</text> + </set></argument> + <argument name="options_yaml_fn"><text>$DAVINCIEXAMPLESROOT/example_data/test_passthrough_thor_lines.yaml</text></argument> + <argument name="extra_options_yaml"><text> + print_freq: 100 + histo_file: dtf_pvs_histo.root + ntuple_file: dtf_pvs_tuple.root + evt_max: 100 + </text></argument> + <argument name="validator"><text> +from DaVinciTests.QMTest.DaVinciExclusions import remove_known_warnings +from PyConf.components import findRootObjByDir +countErrorLines({"FATAL": 0, "ERROR": 0}, + stdout=remove_known_warnings(stdout)) +import sys, os +from ROOT import TFile + + +B_vars_stored = ['Bs_DTF_AllPVs_CHI2', 'Bs_DTF_AllPVs_CHI2DOF', 'Bs_DTF_AllPVs_FD', 'Bs_DTF_AllPVs_FDERR', 'Bs_DTF_AllPVs_IDX', 'Bs_DTF_AllPVs_MASS', 'Bs_DTF_AllPVs_MASSERR', 'Bs_DTF_AllPVs_NDOF', 'Bs_DTF_AllPVs_NITER', 'Bs_DTF_AllPVs_P', 'Bs_DTF_AllPVs_PE', 'Bs_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PX', 'KP_DTF_AllPVs_PY', 'KP_DTF_AllPVs_PZ', 'KP_DTF_BestPV_PE', 'KP_DTF_BestPV_PX', 'KP_DTF_BestPV_PY', 'KP_DTF_BestPV_PZ', 'MuM_DTF_AllPVs_IDX', 'MuM_DTF_AllPVs_PE', 'MuM_DTF_AllPVs_PX', 'MuM_DTF_AllPVs_PY', 'MuM_DTF_AllPVs_PZ', 'MuM_DTF_BestPV_PE', 'MuM_DTF_BestPV_PX', 'MuM_DTF_BestPV_PY', 'MuM_DTF_BestPV_PZ', 'MuP_DTF_AllPVs_IDX', 'MuP_DTF_AllPVs_PE', 'MuP_DTF_AllPVs_PX', 'MuP_DTF_AllPVs_PY', 'MuP_DTF_AllPVs_PZ', 'MuP_DTF_BestPV_PE', 'MuP_DTF_BestPV_PX', 'MuP_DTF_BestPV_PY', 'MuP_DTF_BestPV_PZ', 'Phi_DTF_AllPVs_IDX', 'Phi_DTF_AllPVs_PE', 'Phi_DTF_AllPVs_PX', 'Phi_DTF_AllPVs_PY', 'Phi_DTF_AllPVs_PZ', 'Phi_DTF_BestPV_PE', 'Phi_DTF_BestPV_PX', 'Phi_DTF_BestPV_PY', 'Phi_DTF_BestPV_PZ', 'RUNNUMBER'] + +# The hash is got from DaVinci/v63r6 with 5 significant digit +# dd4hep platform desc platform +expected_chi2_hashs = [-6712918245859272476, -5204790546497831928] + +#sort the expected vars +B_vars_stored = sorted(B_vars_stored) + +#open the TFile and TTree +ntuple = 'dtf_pvs_tuple.root' +if not os.path.isfile(ntuple): raise Exception(f"File: {ntuple} does not exist!") +f = TFile.Open(ntuple) +t_B = findRootObjByDir(f, 'JpsiPhi_Tuple', 'DecayTree') + +#sort the stores vars +b_names = sorted([b.GetName() for b in t_B.GetListOfLeaves()]) + +B_excluded_1 = set(B_vars_stored) - set(b_names) +B_excluded_2 = set(b_names) - set(B_vars_stored) +if len(B_excluded_1) != 0: raise Exception('Number of stored variables is less than what is expected. The extra variables expected are: ' , B_excluded_1) +if len(B_excluded_2) != 0: raise Exception('Number of stored variables is greater than what is expected. The extra variables stored are: ', B_excluded_2) + +from DaVinciTests.QMTest.check_helpers import get_hash_from_branch +got_chi2_hash = get_hash_from_branch(ntuple, "JpsiPhi_Tuple/DecayTree", 'Bs_DTF_BestPV_CHI2', significant_digits=5) +if not got_chi2_hash in expected_chi2_hashs: + msg_str = f"Output tuple has unexpected values in JpsiPhi_Tuple/DecayTree/Bs_DTF_BestPV_CHI2, got_hash = {got_chi2_hash}, expected_hashs = {expected_chi2_hashs}" + causes.append(msg_str) + +f.Close() +os.system(f"rm {ntuple}") + + </text></argument> +</extension> diff --git a/DaVinciExamples/tests/qmtest/tupling.qms/test_davinci_tupling_from_collections.qmt b/DaVinciExamples/tests/qmtest/tupling.qms/test_davinci_tupling_from_collections.qmt index 5d2db2a796cccd5b720bbd02553f7ea0fe845f10..8d10da5d742f8c793e4586ae5a4256dff7a0d179 100644 --- a/DaVinciExamples/tests/qmtest/tupling.qms/test_davinci_tupling_from_collections.qmt +++ b/DaVinciExamples/tests/qmtest/tupling.qms/test_davinci_tupling_from_collections.qmt @@ -35,6 +35,7 @@ from ROOT import TFile expected_branches = ['BUNCHCROSSING_ID', 'BUNCHCROSSING_TYPE', 'D0_CaloClusterMass', 'D0_CaloNeutral1To9EnergyRatio', 'D0_CaloNeutral4To9EnergyRatio', 'D0_CaloNeutralEcalEnergy', 'D0_CaloNeutralHcal2EcalEnergyRatio', 'D0_CaloNeutralID', 'D0_CaloNeutralShowerShape', 'D0_CaloNumSaturatedCells', 'D0_CaloTrackMatchChi2', 'D0_ENERGY', 'D0_HEAD_CMULT', 'D0_HEAD_CP', 'D0_HEAD_CPT', 'D0_HEAD_CPX', 'D0_HEAD_CPY', 'D0_HEAD_CPZ', 'D0_HEAD_DETA', 'D0_HEAD_DPHI', 'D0_HEAD_PASY', 'D0_HEAD_PTASY', 'D0_HEAD_PXASY', 'D0_HEAD_PYASY', 'D0_HEAD_PZASY', 'D0_M', 'D0_MC_GD_GD_MOTHER_ID', 'D0_MC_GD_GD_MOTHER_KEY', 'D0_MC_GD_MOTHER_ID', 'D0_MC_GD_MOTHER_KEY', 'D0_MC_ISPROMPT', 'D0_MC_LONGLIVED_ID', 'D0_MC_LONGLIVED_KEY', 'D0_MC_MOTHER_ID', 'D0_MC_MOTHER_KEY', 'D0_P', 'D0_PARTICLE_ID', 'D0_PROBNN_D', 'D0_PROBNN_E', 'D0_PROBNN_GHOST', 'D0_PROBNN_K', 'D0_PROBNN_MU', 'D0_PROBNN_P', 'D0_PROBNN_PI', 'D0_PT', 'D0_PX', 'D0_PY', 'D0_PZ', 'D0_TRUEENDVERTEX_X', 'D0_TRUEENDVERTEX_Y', 'D0_TRUEENDVERTEX_Z', 'D0_TRUEENERGY', 'D0_TRUEID', 'D0_TRUEORIGINVERTEX_X', 'D0_TRUEORIGINVERTEX_Y', 'D0_TRUEORIGINVERTEX_Z', 'D0_TRUEP', 'D0_TRUEPT', 'D0_TRUEPX', 'D0_TRUEPY', 'D0_TRUEPZ', 'EVENTNUMBER', 'GPSTIME', 'Hlt2_TCK', 'Kminus_CaloClusterMass', 'Kminus_CaloNeutral1To9EnergyRatio', 'Kminus_CaloNeutral4To9EnergyRatio', 'Kminus_CaloNeutralEcalEnergy', 'Kminus_CaloNeutralHcal2EcalEnergyRatio', 'Kminus_CaloNeutralID', 'Kminus_CaloNeutralShowerShape', 'Kminus_CaloNumSaturatedCells', 'Kminus_CaloTrackMatchChi2', 'Kminus_ENERGY', 'Kminus_HEAD_CMULT', 'Kminus_HEAD_CP', 'Kminus_HEAD_CPT', 'Kminus_HEAD_CPX', 'Kminus_HEAD_CPY', 'Kminus_HEAD_CPZ', 'Kminus_HEAD_DETA', 'Kminus_HEAD_DPHI', 'Kminus_HEAD_PASY', 'Kminus_HEAD_PTASY', 'Kminus_HEAD_PXASY', 'Kminus_HEAD_PYASY', 'Kminus_HEAD_PZASY', 'Kminus_M', 'Kminus_MC_GD_GD_MOTHER_ID', 'Kminus_MC_GD_GD_MOTHER_KEY', 'Kminus_MC_GD_MOTHER_ID', 'Kminus_MC_GD_MOTHER_KEY', 'Kminus_MC_ISPROMPT', 'Kminus_MC_LONGLIVED_ID', 'Kminus_MC_LONGLIVED_KEY', 'Kminus_MC_MOTHER_ID', 'Kminus_MC_MOTHER_KEY', 'Kminus_P', 'Kminus_PARTICLE_ID', 'Kminus_PROBNN_D', 'Kminus_PROBNN_E', 'Kminus_PROBNN_GHOST', 'Kminus_PROBNN_K', 'Kminus_PROBNN_MU', 'Kminus_PROBNN_P', 'Kminus_PROBNN_PI', 'Kminus_PT', 'Kminus_PX', 'Kminus_PY', 'Kminus_PZ', 'Kminus_TRUEENDVERTEX_X', 'Kminus_TRUEENDVERTEX_Y', 'Kminus_TRUEENDVERTEX_Z', 'Kminus_TRUEENERGY', 'Kminus_TRUEID', 'Kminus_TRUEORIGINVERTEX_X', 'Kminus_TRUEORIGINVERTEX_Y', 'Kminus_TRUEORIGINVERTEX_Z', 'Kminus_TRUEP', 'Kminus_TRUEPT', 'Kminus_TRUEPX', 'Kminus_TRUEPY', 'Kminus_TRUEPZ', 'ODINTCK', 'RUNNUMBER', 'indx', 'piplus_CaloClusterMass', 'piplus_CaloNeutral1To9EnergyRatio', 'piplus_CaloNeutral4To9EnergyRatio', 'piplus_CaloNeutralEcalEnergy', 'piplus_CaloNeutralHcal2EcalEnergyRatio', 'piplus_CaloNeutralID', 'piplus_CaloNeutralShowerShape', 'piplus_CaloNumSaturatedCells', 'piplus_CaloTrackMatchChi2', 'piplus_ENERGY', 'piplus_HEAD_CMULT', 'piplus_HEAD_CP', 'piplus_HEAD_CPT', 'piplus_HEAD_CPX', 'piplus_HEAD_CPY', 'piplus_HEAD_CPZ', 'piplus_HEAD_DETA', 'piplus_HEAD_DPHI', 'piplus_HEAD_PASY', 'piplus_HEAD_PTASY', 'piplus_HEAD_PXASY', 'piplus_HEAD_PYASY', 'piplus_HEAD_PZASY', 'piplus_M', 'piplus_MC_GD_GD_MOTHER_ID', 'piplus_MC_GD_GD_MOTHER_KEY', 'piplus_MC_GD_MOTHER_ID', 'piplus_MC_GD_MOTHER_KEY', 'piplus_MC_ISPROMPT', 'piplus_MC_LONGLIVED_ID', 'piplus_MC_LONGLIVED_KEY', 'piplus_MC_MOTHER_ID', 'piplus_MC_MOTHER_KEY', 'piplus_P', 'piplus_PARTICLE_ID', 'piplus_PROBNN_D', 'piplus_PROBNN_E', 'piplus_PROBNN_GHOST', 'piplus_PROBNN_K', 'piplus_PROBNN_MU', 'piplus_PROBNN_P', 'piplus_PROBNN_PI', 'piplus_PT', 'piplus_PX', 'piplus_PY', 'piplus_PZ', 'piplus_TRUEENDVERTEX_X', 'piplus_TRUEENDVERTEX_Y', 'piplus_TRUEENDVERTEX_Z', 'piplus_TRUEENERGY', 'piplus_TRUEID', 'piplus_TRUEORIGINVERTEX_X', 'piplus_TRUEORIGINVERTEX_Y', 'piplus_TRUEORIGINVERTEX_Z', 'piplus_TRUEP', 'piplus_TRUEPT', 'piplus_TRUEPX', 'piplus_TRUEPY', 'piplus_TRUEPZ', 'Hlt2Charm_D0ToKmPip_LineDecision'] expected_mc_branches = ['BUNCHCROSSING_ID', 'BUNCHCROSSING_TYPE', 'D0_MC_ACCT', 'D0_MC_ACCT1', 'D0_MC_ACCT1S', 'D0_MC_ACCT1X', 'D0_MC_ACCT2', 'D0_MC_ACCT2S', 'D0_MC_ACCT2X', 'D0_MC_ACCT3', 'D0_MC_ACCT3S', 'D0_MC_ACCT3X', 'D0_MC_ACCUT', 'D0_MC_ACCUT1', 'D0_MC_ACCUT2', 'D0_MC_ACCVELO', 'D0_MC_ACCVELO_AND_T', 'D0_MC_GD_GD_MOTHER_ID', 'D0_MC_GD_GD_MOTHER_KEY', 'D0_MC_GD_MOTHER_ID', 'D0_MC_GD_MOTHER_KEY', 'D0_MC_HAST', 'D0_MC_HAST1', 'D0_MC_HAST1S', 'D0_MC_HAST1X', 'D0_MC_HAST2', 'D0_MC_HAST2S', 'D0_MC_HAST2X', 'D0_MC_HAST3', 'D0_MC_HAST3S', 'D0_MC_HAST3X', 'D0_MC_HASUT', 'D0_MC_HASUT1', 'D0_MC_HASUT2', 'D0_MC_HASVELO', 'D0_MC_HASVELO_AND_T', 'D0_MC_ISPROMPT', 'D0_MC_LONGLIVED_ID', 'D0_MC_LONGLIVED_KEY', 'D0_MC_MOTHER_ID', 'D0_MC_MOTHER_KEY', 'D0_MC_RECONSTRUCTIBLE', 'D0_RECONSTRUCTED', 'D0_TRUEENDVERTEX_X', 'D0_TRUEENDVERTEX_Y', 'D0_TRUEENDVERTEX_Z', 'D0_TRUEID', 'D0_TRUEORIGINVERTEX_X', 'D0_TRUEORIGINVERTEX_Y', 'D0_TRUEORIGINVERTEX_Z', 'GPSTIME', 'Kminus_MC_ACCT', 'Kminus_MC_ACCT1', 'Kminus_MC_ACCT1S', 'Kminus_MC_ACCT1X', 'Kminus_MC_ACCT2', 'Kminus_MC_ACCT2S', 'Kminus_MC_ACCT2X', 'Kminus_MC_ACCT3', 'Kminus_MC_ACCT3S', 'Kminus_MC_ACCT3X', 'Kminus_MC_ACCUT', 'Kminus_MC_ACCUT1', 'Kminus_MC_ACCUT2', 'Kminus_MC_ACCVELO', 'Kminus_MC_ACCVELO_AND_T', 'Kminus_MC_GD_GD_MOTHER_ID', 'Kminus_MC_GD_GD_MOTHER_KEY', 'Kminus_MC_GD_MOTHER_ID', 'Kminus_MC_GD_MOTHER_KEY', 'Kminus_MC_HAST', 'Kminus_MC_HAST1', 'Kminus_MC_HAST1S', 'Kminus_MC_HAST1X', 'Kminus_MC_HAST2', 'Kminus_MC_HAST2S', 'Kminus_MC_HAST2X', 'Kminus_MC_HAST3', 'Kminus_MC_HAST3S', 'Kminus_MC_HAST3X', 'Kminus_MC_HASUT', 'Kminus_MC_HASUT1', 'Kminus_MC_HASUT2', 'Kminus_MC_HASVELO', 'Kminus_MC_HASVELO_AND_T', 'Kminus_MC_ISPROMPT', 'Kminus_MC_LONGLIVED_ID', 'Kminus_MC_LONGLIVED_KEY', 'Kminus_MC_MOTHER_ID', 'Kminus_MC_MOTHER_KEY', 'Kminus_MC_RECONSTRUCTIBLE', 'Kminus_RECONSTRUCTED', 'Kminus_TRUEENDVERTEX_X', 'Kminus_TRUEENDVERTEX_Y', 'Kminus_TRUEENDVERTEX_Z', 'Kminus_TRUEID', 'Kminus_TRUEORIGINVERTEX_X', 'Kminus_TRUEORIGINVERTEX_Y', 'Kminus_TRUEORIGINVERTEX_Z', 'MCPVT', 'MCPVX', 'MCPVY', 'MCPVZ', 'MCPV_IDX', 'MCPV_SIZE', 'ODINTCK', 'piplus_MC_ACCT', 'piplus_MC_ACCT1', 'piplus_MC_ACCT1S', 'piplus_MC_ACCT1X', 'piplus_MC_ACCT2', 'piplus_MC_ACCT2S', 'piplus_MC_ACCT2X', 'piplus_MC_ACCT3', 'piplus_MC_ACCT3S', 'piplus_MC_ACCT3X', 'piplus_MC_ACCUT', 'piplus_MC_ACCUT1', 'piplus_MC_ACCUT2', 'piplus_MC_ACCVELO', 'piplus_MC_ACCVELO_AND_T', 'piplus_MC_GD_GD_MOTHER_ID', 'piplus_MC_GD_GD_MOTHER_KEY', 'piplus_MC_GD_MOTHER_ID', 'piplus_MC_GD_MOTHER_KEY', 'piplus_MC_HAST', 'piplus_MC_HAST1', 'piplus_MC_HAST1S', 'piplus_MC_HAST1X', 'piplus_MC_HAST2', 'piplus_MC_HAST2S', 'piplus_MC_HAST2X', 'piplus_MC_HAST3', 'piplus_MC_HAST3S', 'piplus_MC_HAST3X', 'piplus_MC_HASUT', 'piplus_MC_HASUT1', 'piplus_MC_HASUT2', 'piplus_MC_HASVELO', 'piplus_MC_HASVELO_AND_T', 'piplus_MC_ISPROMPT', 'piplus_MC_LONGLIVED_ID', 'piplus_MC_LONGLIVED_KEY', 'piplus_MC_MOTHER_ID', 'piplus_MC_MOTHER_KEY', 'piplus_MC_RECONSTRUCTIBLE', 'piplus_RECONSTRUCTED', 'piplus_TRUEENDVERTEX_X', 'piplus_TRUEENDVERTEX_Y', 'piplus_TRUEENDVERTEX_Z', 'piplus_TRUEID', 'piplus_TRUEORIGINVERTEX_X', 'piplus_TRUEORIGINVERTEX_Y', 'piplus_TRUEORIGINVERTEX_Z'] +expected_branches += ['piplus_DTF_PX', 'piplus_DTF_PY', 'D0_DTF_PY', 'piplus_DTF_PZ', 'Kminus_DTF_PE', 'Kminus_DTF_PY', 'D0_DTF_PX', 'piplus_DTF_PE', 'D0_DTF_PZ', 'D0_DTF_PE', 'Kminus_DTF_PX', 'Kminus_DTF_PZ'] #sort the expected vars expected_branches = sorted(expected_branches) diff --git a/DaVinciTests/python/DaVinciTests/DTF_test.py b/DaVinciTests/python/DaVinciTests/DTF_test.py index 1f7a724b551423a9bcc5e31c582091135d0b1aef..5e8ec7ab6c6fa05b7c486b35e7b6b43ee392dc77 100644 --- a/DaVinciTests/python/DaVinciTests/DTF_test.py +++ b/DaVinciTests/python/DaVinciTests/DTF_test.py @@ -50,8 +50,8 @@ def main(options: Options): #make collection of functors for Jpsi variables_jpsi = FunctorCollection({ 'THOR_MASS': F.MASS, - 'DTF_PT': DTF(Functor=F.PT), - 'DTF_MASS': DTF(Functor=F.MASS), + 'DTF_PT': DTF(F.PT), + 'DTF_MASS': DTF(F.MASS), }) #associate FunctorCollection to field (branch) name diff --git a/DaVinciTests/python/DaVinciTests/QMTest/check_helpers.py b/DaVinciTests/python/DaVinciTests/QMTest/check_helpers.py index be53b9a6f64baf02940286b53555cafc13f3a011..192224c52a6f269da089493cd8bc694081e87584 100644 --- a/DaVinciTests/python/DaVinciTests/QMTest/check_helpers.py +++ b/DaVinciTests/python/DaVinciTests/QMTest/check_helpers.py @@ -12,6 +12,7 @@ from typing import Iterable import pandas as pd from ROOT import RDataFrame +import math def has_nan(filename: str, @@ -24,7 +25,7 @@ def has_nan(filename: str, Ntuple fields (branches) can be explicitly given and/or excluded with the `columns` and `exclude` arguments, respectively, as detailed in the documentation of `RDataFrame.AsNumpy`. - + Args: filename (str): The full path to the ROOT file. ntuple_name (str): The full path to the ntuple, e.g. My/Dir/MyNtuple. @@ -91,3 +92,54 @@ def get_pandas_dataframe(filename: str, ar = rdf.AsNumpy(columns, exclude) return pd.DataFrame(ar) + + +def round_to_significant(num, significant_digits: int = 4): + """ + Round a float to the specified number of significant digits. + + Args: + num (float or int): The float to round. + significant_digits (int): The number of significant digits to round to. Defaults to 4. + + Returns: + The rounded float. + + Examples: + >>> round_to_significant(0.000123456789, 3) + 0.000123 + """ + return round( + num, -int(math.floor(math.log10(abs(num)))) + (significant_digits - 1)) + + +def get_hash_from_branch(filename: str, + ntuple_name: str, + branch_name: str, + significant_digits: int = 4): + """ + Helper function for calculating the hash value of a branch within a TTree in a ROOT file. + + Args: + filename (str): The full path to the ROOT file. + ntuple_name (str): The full path to the ntuple, e.g. My/Dir/MyNtuple. + branch_name (str): The name of the branch to hash. + significant_digits (int, optional): The number of significant digits to round to. Defaults to 4. + + Returns: + The hash value of the rounded branch values. + + Examples: + >>> get_hash_from_branch('myfile.root', 'My/Dir/MyNtuple', 'MyBranch', 3) + 123456789 + """ + # Load the ROOT file and retrieve the branch values as a list + rdf = RDataFrame(ntuple_name, filename) + values = rdf.AsNumpy([branch_name])[branch_name].tolist() + + # Round the branch values to the specified number of significant digits + rounded = tuple( + [round_to_significant(val, significant_digits) for val in values]) + + # Compute and return the hash of the rounded values + return hash(rounded)