diff --git a/DaVinciExamples/example_data/Upgrade_Bd2KstarMuMu_ldst.yaml b/DaVinciExamples/example_data/Upgrade_Bd2KstarMuMu_ldst.yaml index a9789cca29b324a7c081ced73d8b840650a7861e..77c207c0e185580a4b70aab543dd5cb2b481786a 100644 --- a/DaVinciExamples/example_data/Upgrade_Bd2KstarMuMu_ldst.yaml +++ b/DaVinciExamples/example_data/Upgrade_Bd2KstarMuMu_ldst.yaml @@ -5,3 +5,4 @@ input_type: ROOT simulation: true conddb_tag: sim-20171127-vc-md100 dddb_tag: dddb-20171126 +process: Turbo \ No newline at end of file diff --git a/DaVinciExamples/example_data/Upgrade_genFSR_ldst.yaml b/DaVinciExamples/example_data/Upgrade_genFSR_ldst.yaml index dfffd6b1941aed89fb7ab8b0dbcfd1c1235e8f0c..ae93c8fce03b584b647641baef726b59f914da64 100644 --- a/DaVinciExamples/example_data/Upgrade_genFSR_ldst.yaml +++ b/DaVinciExamples/example_data/Upgrade_genFSR_ldst.yaml @@ -4,3 +4,4 @@ input_type: ROOT simulation: true conddb_tag: sim-20171127-vc-md100 dddb_tag: dddb-20171126 +process: Turbo diff --git a/DaVinciExamples/example_data/spruce_b2jpsik_opt.yaml b/DaVinciExamples/example_data/spruce_b2jpsik_opt.yaml index 02ea23597dc8d8ab5906bdb46cfb9b03d97b5c08..e509abe2e4c7e577e160cd7556c7305cfa62f0fa 100644 --- a/DaVinciExamples/example_data/spruce_b2jpsik_opt.yaml +++ b/DaVinciExamples/example_data/spruce_b2jpsik_opt.yaml @@ -20,4 +20,5 @@ data_type: Upgrade simulation: true conddb_tag: sim-20201218-vc-md100 dddb_tag: dddb-20201211 +process: Turbo diff --git a/DaVinciExamples/example_data/test_read_xgen.yaml b/DaVinciExamples/example_data/test_read_xgen.yaml index dd931870c90b3eec3508912492c43217322cf62f..e0171c46cc199d7960f33b3505fb6a36fd77277b 100644 --- a/DaVinciExamples/example_data/test_read_xgen.yaml +++ b/DaVinciExamples/example_data/test_read_xgen.yaml @@ -5,3 +5,4 @@ input_type: ROOT simulation: true conddb_tag: sim-20171127-vc-md100 dddb_tag: dddb-20171126 +process: Turbo diff --git a/DaVinciExamples/python/DaVinciExamples/tupling/AllFunctors.py b/DaVinciExamples/python/DaVinciExamples/tupling/AllFunctors.py index 2622bde810a426ca5925073f21b6d05e95262686..52ae9e13f40e676788959e189f93b5be057ad32a 100644 --- a/DaVinciExamples/python/DaVinciExamples/tupling/AllFunctors.py +++ b/DaVinciExamples/python/DaVinciExamples/tupling/AllFunctors.py @@ -18,7 +18,8 @@ import Functors as F from FunTuple import FunctorCollection from FunTuple import FunTuple_Particles as Funtuple from PyConf.reading import get_particles, get_pvs -from DaVinci.algorithms import add_filter, get_decreports, get_odin +from DaVinci.algorithms import add_filter +from PyConf.reading import get_decreports, get_odin from DecayTreeFitter import DTFAlg from DaVinci.truth_matching import configured_MCTruthAndBkgCatAlg from PyConf.Algorithms import PrintDecayTree @@ -26,10 +27,9 @@ from PyConf.Algorithms import PrintDecayTree from DaVinci import Options, make_config # -# Definition of strucing line +# Definition of Sprucing line # bd2dsk_line = "SpruceB2OC_BdToDsmK_DsmToHHH_FEST_Line" -bd2dsk_data = get_particles(f"/Event/Spruce/{bd2dsk_line}/Particles", "Spruce") _basic = 'basic' _composite = 'composite' @@ -255,10 +255,13 @@ def alg_config(options: Options): """ Algorithm configuration function called from the comad line """ + #get the particles from line + bd2dsk_data = get_particles(f"/Event/Spruce/{bd2dsk_line}/Particles") + # # DecayTreeFitter Algorithm # - v2_pvs = get_pvs(options.process) + v2_pvs = get_pvs() # # DecayTreeFitter Algorithm @@ -298,18 +301,15 @@ def alg_config(options: Options): # event variables # odin = None - odin = get_odin(options) # does not work + odin = get_odin() decreports = None - decreports = get_decreports( - 'Spruce', - options) # name of line incorrect, Gerhard has a fix I need to try + decreports = get_decreports('Spruce') evt_vars = FunctorCollection(event_variables(v2_pvs, odin, decreports)) # # Sprucing filter # - my_filter = add_filter(options, "HDRFilter_B0DsK", - f"HLT_PASS('{bd2dsk_line}')") + my_filter = add_filter("HDRFilter_B0DsK", f"HLT_PASS('{bd2dsk_line}')") # # FunTuple diff --git a/DaVinciExamples/python/DaVinciExamples/tupling/DTF_filtered.py b/DaVinciExamples/python/DaVinciExamples/tupling/DTF_filtered.py index 21e992b9d701109f472ce21d7721cf84bf5aa5fd..3ca2d53045295a016eace6d797681ca582015267 100644 --- a/DaVinciExamples/python/DaVinciExamples/tupling/DTF_filtered.py +++ b/DaVinciExamples/python/DaVinciExamples/tupling/DTF_filtered.py @@ -73,8 +73,7 @@ def main(options: Options): #associate FunctorCollection to field (branch) name variables = {'ALL': variables_all, 'Ds': variables_ds} - filter_data = add_filter(options, "SpruceFilter", - f"HLT_PASS('{spruce_line}')") + filter_data = add_filter("SpruceFilter", f"HLT_PASS('{spruce_line}')") #Configure Funtuple algorithm tuple_data = Funtuple( diff --git a/DaVinciExamples/python/DaVinciExamples/tupling/example-tupling-mc-reconstructible-reconstructed.py b/DaVinciExamples/python/DaVinciExamples/tupling/example-tupling-mc-reconstructible-reconstructed.py index 9ad6d380c0960bde930df8ae4f8bb78f2a6cbc60..791d534a152eaa904e63e1d32cc6d0025123bdab 100644 --- a/DaVinciExamples/python/DaVinciExamples/tupling/example-tupling-mc-reconstructible-reconstructed.py +++ b/DaVinciExamples/python/DaVinciExamples/tupling/example-tupling-mc-reconstructible-reconstructed.py @@ -16,9 +16,8 @@ and MCReconstructed. from FunTuple import FunTuple_MCParticles as MCFuntuple from DaVinciMCTools import MCReconstructible, MCReconstructed from DaVinci import Options, make_config -from RecoConf.data_from_file import make_mc_track_info from FunTuple.functorcollections import MCReconstructed_Collection, MCReconstructible_Collection -from PyConf.reading import get_mc_particles, get_pp2mcp_relations, get_charged_protoparticles, get_neutral_protoparticles +from PyConf.reading import get_mc_particles, get_pp2mcp_relations, get_charged_protoparticles, get_neutral_protoparticles, get_mc_track_info def main(options: Options): @@ -28,21 +27,16 @@ def main(options: Options): # PP2MCP relations need MC particles and ProtoParticles # Since MC is already unpacked, only unpack protos and relations extra_inputs = [] - extra_inputs += [get_charged_protoparticles(options.process)] - extra_inputs += [get_neutral_protoparticles(options.process)] + extra_inputs += [get_charged_protoparticles()] + extra_inputs += [get_neutral_protoparticles()] relations_charged = get_pp2mcp_relations( - "/Event/HLT2/Relations/ChargedPP2MCP", - process=options.process, - extra_inputs=extra_inputs) + "/Event/HLT2/Relations/ChargedPP2MCP", extra_inputs=extra_inputs) relations_neutral = get_pp2mcp_relations( - "/Event/HLT2/Relations/NeutralPP2MCP", - process=options.process, - extra_inputs=extra_inputs) + "/Event/HLT2/Relations/NeutralPP2MCP", extra_inputs=extra_inputs) #Get variables related to reconstructible information. - mcrtible = MCReconstructible( - process=options.process, mc_track_info=make_mc_track_info()) + mcrtible = MCReconstructible(mc_track_info=get_mc_track_info()) #The option extra_info is set to False by default and can be set to True to get more information vars_rtible = MCReconstructible_Collection(mcrtible, extra_info=True) print('Reconstructible functors:', vars_rtible.functor_dict.keys()) @@ -62,8 +56,7 @@ def main(options: Options): MC_data, use_best_mcmatch=False, relations_charged=relations_charged, - relations_neutral=relations_neutral, - process=options.process) + relations_neutral=relations_neutral) #The option extra_info below is set to False by default in the functor collection. vars_rted = MCReconstructed_Collection(mcrted_all, extra_info=False) #Note: diff --git a/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_configFuntuple.py b/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_configFuntuple.py index a3352aadc6158d09e10d11ef2d3c83bfe691055e..5b3b5aab16d7939fbb48941829ef035ed122e24a 100644 --- a/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_configFuntuple.py +++ b/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_configFuntuple.py @@ -53,6 +53,6 @@ def main(options: Options): "variables": variables, } - algs = configured_FunTuple(options, {"B0Dspi": config}) + algs = configured_FunTuple({"B0Dspi": config}) return make_config(options, algs) diff --git a/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_array_taggers.py b/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_array_taggers.py index c493dbcfafcd0417a47d15d0b79f6ded2e74f75a..d662baeafd27d707ac71769a01d9bdbd43a14689 100644 --- a/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_array_taggers.py +++ b/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_array_taggers.py @@ -10,11 +10,11 @@ ############################################################################### """ Option file for testing the ParticleTaggerAlg algorithm and the related ThOr -functors MAP_INPUT_ARRAY. +functors MAP_INPUT_ARRAY. The aim of this example, is to retrieve and store in the final ntuple some variables related to the additional tracks generated in the event that are not -included in the decay chain. This kind of task has been developed for flavour +included in the decay chain. This kind of task has been developed for flavour tagging pourposes but can be extended also to other area. In particular, the job runs over a spruced sample and retrieves a @@ -26,7 +26,7 @@ tracks to the B candidate of the events. 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. -In addition, MC truth information for each track in the 'make_long-pions' +In addition, MC truth information for each track in the 'make_long-pions' location is retrieved and stored in the final tuples via the 'configured_MCTruthAndBkgCatAlg' function. N.B. the job runs over a spruced sample, but the same flow can be used also for @@ -189,8 +189,7 @@ def main(options: Options): # Define a filter in order to process only the event with at least on candidates of interest. # This is a very important step aimed to reduce both the computation time required by the job and # to prevent any failure due to empty TES location. - filter_B0DsK = add_filter(options, "HDRFilter_B0DsK", - f"HLT_PASS('{bd2dsk_line}')") + filter_B0DsK = add_filter("HDRFilter_B0DsK", f"HLT_PASS('{bd2dsk_line}')") # Configure DaVinci passing the options and a list of the user-defined algortithms to be run. return make_config(options, [filter_B0DsK, tuple_B0DsK]) diff --git a/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_eventinfo.py b/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_eventinfo.py index ad9787fd35a7a65f02f9b7fba75892da8333abc3..93bcca9b1af2f3b448a93714b1f24efbf80b6ad5 100644 --- a/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_eventinfo.py +++ b/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_eventinfo.py @@ -17,7 +17,6 @@ from FunTuple import FunctorCollection as FC from FunTuple import FunTuple_Particles as Funtuple from DaVinci.algorithms import add_filter from DaVinci import make_config, Options -from DaVinci.algorithms import get_odin from FunTuple.functorcollections import EventInfo from PyConf.reading import get_particles, get_rec_summary @@ -34,21 +33,19 @@ def main(options: Options): #get RecSummary object that holds information about nPVs, nTracks, nFTClusters # Note more information can be added to the RecSummary object # (see MRs: https://gitlab.cern.ch/lhcb/Moore/-/merge_requests/1649) - rec_summary = get_rec_summary(options.process) + rec_summary = get_rec_summary() evt_vars = FC({ 'nTracks': F.VALUE_OR(-1) @ F.NTRACKS(rec_summary), 'nPVs': F.VALUE_OR(-1) @ F.NPVS(rec_summary), 'nFTClusters': F.VALUE_OR(-1) @ F.NFTCLUSTERS(rec_summary) }) #Get RunNUmber and EventNumber - odin = get_odin(options) - evt_vars += EventInfo(odin, extra_info=True) + evt_vars += EventInfo(extra_info=True) #get particles to run over line_name = 'Hlt2SLB_LbToLcMuNu_LcToPKPi_Line' - particles = get_particles( - f"/Event/HLT2/{line_name}/Particles", process=options.process) - my_filter = add_filter(options, "Myfilter", f"HLT_PASS('{line_name}')") + particles = get_particles(f"/Event/HLT2/{line_name}/Particles") + my_filter = add_filter("Myfilter", f"HLT_PASS('{line_name}')") #define tupling algorithm my_tuple = Funtuple( name="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 4f394f08c59164a29ed9246cd30ca584641400fc..eb2d8e72f16af5e913c2af47849b8c4a57b3b074 100644 --- a/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_from_collections.py +++ b/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_from_collections.py @@ -18,32 +18,26 @@ from FunTuple import FunctorCollection, functorcollections from FunTuple import FunTuple_Particles as Funtuple, FunTuple_MCParticles as MCFuntuple from DaVinci.algorithms import add_filter from DaVinci import Options, make_config -from RecoConf.data_from_file import make_mc_track_info from DaVinci.truth_matching import configured_MCTruthAndBkgCatAlg -from DaVinci.algorithms import get_odin, get_decreports from PyConf.Algorithms import WeightedRelTableAlg from Gaudi.Configuration import INFO -from PyConf.reading import get_particles, get_mc_particles +from PyConf.reading import get_particles, get_mc_particles, get_mc_track_info def main(options: Options): line_name = 'Hlt2Charm_D0ToKmPip_Line' - d02kpi_data = get_particles( - f"/Event/HLT2/{line_name}/Particles", process=options.process) + d02kpi_data = get_particles(f"/Event/HLT2/{line_name}/Particles") MC_data = get_mc_particles("/Event/HLT2/MC/Particles") #Get variables related to reconstructible information. - mcrtible = MCReconstructible( - process='Hlt2', mc_track_info=make_mc_track_info()) + mcrtible = MCReconstructible(mc_track_info=get_mc_track_info()) #Get variables related to reconstructed information. - mcrted_all = MCReconstructed( - MC_data, use_best_mcmatch=True, process='Hlt2') + mcrted_all = MCReconstructed(MC_data, use_best_mcmatch=True) #get configured "MCTruthAndBkgCatAlg" algorithm for HLT2 output - mctruth = configured_MCTruthAndBkgCatAlg( - inputs=d02kpi_data, process=options.process) + mctruth = configured_MCTruthAndBkgCatAlg(inputs=d02kpi_data) #configure "WeightedRelTableAlg" algorithm for HLT2 output iso_rel_table = WeightedRelTableAlg( @@ -52,12 +46,6 @@ def main(options: Options): Cut=(F.DR2() < 0.4), OutputLevel=INFO) - #get location to odin - odin = get_odin(options) - - #get location to hlt2 dec report - dec = get_decreports("Hlt2", options) - # use functorcollections to add variables, please expand when there's new collections :) collections = [ functorcollections.Kinematics(), @@ -76,8 +64,8 @@ def main(options: Options): ] evt_collections = [ - functorcollections.EventInfo(odin), - functorcollections.SelectionInfo("Hlt2", dec, [line_name]) + functorcollections.EventInfo(), + functorcollections.SelectionInfo("Hlt2", [line_name]) ] assert len(collections) + len(evt_collections) + len( @@ -127,8 +115,7 @@ def main(options: Options): event_variables=evt_vars, inputs=d02kpi_data) - my_filter = add_filter(options, "HDRFilter_D0Kpi", - f"HLT_PASS('{line_name}')") + my_filter = add_filter("HDRFilter_D0Kpi", f"HLT_PASS('{line_name}')") mc_tuple = MCFuntuple( name="MCTuple", 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 6fb55289d55beea85511f0ddd8f6a5cf984a64f4..e198fcfdfd0d49d11513e2d143e1b8611eb43c38 100644 --- a/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_from_hlt2.py +++ b/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_from_hlt2.py @@ -14,11 +14,10 @@ Read an HLT2 file and create an ntuple with the new DaVinci configuration. import Functors as F from FunTuple import FunctorCollection as FC from FunTuple import FunTuple_Particles as Funtuple -from PyConf.reading import get_particles, get_pvs +from PyConf.reading import get_particles, get_pvs, get_odin from DaVinci.algorithms import add_filter from DaVinci import Options, make_config from DaVinci.truth_matching import configured_MCTruthAndBkgCatAlg -from DaVinci.algorithms import get_odin, get_decreports from FunTuple.functorcollections import SelectionInfo @@ -30,7 +29,7 @@ def main(options: Options): } # Creating v2 reconstructed vertices to be used in the following functor - v2_pvs = get_pvs(process=options.process) + v2_pvs = get_pvs() d0_variables = FC({ "ID": F.PARTICLE_ID, @@ -65,15 +64,12 @@ def main(options: Options): } line_name = 'Hlt2Charm_D0ToKmPip_Line' - d02kpi_data = get_particles( - f"/Event/HLT2/{line_name}/Particles", process=options.process) + d02kpi_data = get_particles(f"/Event/HLT2/{line_name}/Particles") - my_filter = add_filter(options, "HDRFilter_D0Kpi", - f"HLT_PASS('{line_name}')") + my_filter = add_filter("HDRFilter_D0Kpi", f"HLT_PASS('{line_name}')") #get configured "MCTruthAndBkgCatAlg" algorithm for HLT2 output - mctruth = configured_MCTruthAndBkgCatAlg( - inputs=d02kpi_data, process=options.process) + mctruth = configured_MCTruthAndBkgCatAlg(inputs=d02kpi_data) #add helper lambda that configures a functor to get truth information MCTRUTH = lambda func: F.MAP_INPUT(Functor=func, Relations=mctruth.MCAssocTable) trueid_bkgcat_info = { @@ -97,16 +93,15 @@ def main(options: Options): #sort of related issue (https://gitlab.cern.ch/lhcb/Rec/-/issues/356) #variables['D0'] += FC({'TRUEPT_Kaon': MCTRUTH(F.CHILD(1, F.PT))}) - #get ODIN and DecReports location - odin = get_odin(options) - hlt2_dec = get_decreports("Hlt2", options) + #get odin which hold the event information + odin = get_odin() #define event level variables evt_variables = FC({ "RUNNUMBER": F.RUNNUMBER(odin), "EVENTNUMBER": F.EVENTNUMBER(odin) }) - evt_variables += SelectionInfo("Hlt2", hlt2_dec, [line_name]) + evt_variables += SelectionInfo("Hlt2", [line_name]) #For now remove: The 'Hlt2' line decision tuples fine but breaks unit test with an error. (Why?) #see linked issue here: https://gitlab.cern.ch/lhcb/DaVinci/-/merge_requests/654#note_5320732 evt_variables.pop('Hlt2') diff --git a/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_from_passthrough.py b/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_from_passthrough.py index 97c0057cdced66e6215733f228e60f6f3c49db62..3e7973e9772fcdeada7341bcd02ed96d4ee58533 100644 --- a/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_from_passthrough.py +++ b/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_from_passthrough.py @@ -21,8 +21,7 @@ from PyConf.reading import get_particles def main(options: Options): bs2jpsiphi_line = "Hlt2BsToJpsiPhi_JPsi2MuMu_PhiToKK_Line" - bs2jpsiphi_data = get_particles( - f"/Event/HLT2/{bs2jpsiphi_line}/Particles", process=options.process) + bs2jpsiphi_data = get_particles(f"/Event/HLT2/{bs2jpsiphi_line}/Particles") 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", @@ -36,7 +35,7 @@ def main(options: Options): 'ALL': variables_all, #adds variables to all branches } - filter_bs = add_filter(options, "HDRFilter_Bs2JpsiPhi", + filter_bs = add_filter("HDRFilter_Bs2JpsiPhi", f"HLT_PASS('{bs2jpsiphi_line}')") tuple_bs = Funtuple( diff --git a/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_from_spruce.py b/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_from_spruce.py index f50067cf18381f7589490a1609cee52a1a716f6b..53ac2a93530c525c12934252cbfefe50cb70a032 100644 --- a/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_from_spruce.py +++ b/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_from_spruce.py @@ -85,9 +85,8 @@ def main(options: Options): loki_preamble=loki_preamble, inputs=bd2dspi_line) - filter_B0DsK = add_filter(options, "HDRFilter_B0DsK", - f"HLT_PASS('{line_B0DsK}')") - filter_B0Dspi = add_filter(options, "HDRFilter_B0Dspi", + filter_B0DsK = add_filter("HDRFilter_B0DsK", f"HLT_PASS('{line_B0DsK}')") + filter_B0Dspi = add_filter("HDRFilter_B0Dspi", f"HLT_PASS('{line_B0Dspi}')") algs = { 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 bb64a97a28e071de13275aa3a279665730796fa7..a40e4b60858d7ec9d2cb119421ddf8c2699740e3 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 @@ -37,7 +37,7 @@ def main(options: Options): line_name = 'Spruce_Test_line' B_data = get_particles(f"/Event/Spruce/{line_name}/Particles") - my_filter = add_filter(options, "HDRFilter_B", f"HLT_PASS('{line_name}')") + my_filter = add_filter("HDRFilter_B", f"HLT_PASS('{line_name}')") #helper lambda function MCTRUTH = lambda func: F.MAP_INPUT(Functor=func, Relations=mctruth.MCAssocTable) diff --git a/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_weightedrelation_trackvariables.py b/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_weightedrelation_trackvariables.py index 7cea8ff46cfc0f0331a8297e8d435d95943a35c0..e0758705e1b0318a11aa849c46976d08c9af2f20 100644 --- a/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_weightedrelation_trackvariables.py +++ b/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_weightedrelation_trackvariables.py @@ -35,13 +35,11 @@ def main(options: Options): 'Kp': "[B+ -> (J/psi(1S) -> mu+ mu- ) ^K+]CC" } - b2jpsik_data = get_particles( - "/Event/HLT2/Hlt2B2JpsiKLine/Particles", process=options.process) + b2jpsik_data = get_particles("/Event/HLT2/Hlt2B2JpsiKLine/Particles") tagged_data = get_particles( - "/Event/HLT2/Hlt2B2JpsiKLine/LongTaggingParticles/Particles", - process=options.process) + "/Event/HLT2/Hlt2B2JpsiKLine/LongTaggingParticles/Particles") - pvs = get_pvs(process=options.process) + pvs = get_pvs() ftAlg = WeightedRelTableAlg( ReferenceParticles=b2jpsik_data, @@ -87,7 +85,7 @@ def main(options: Options): 'Kp': variables_all + track_iso_variables, } - my_filter = add_filter(options, "HDRFilter_B2JpsiK", + my_filter = add_filter("HDRFilter_B2JpsiK", "HLT_PASS('Hlt2B2JpsiKLineDecision')") my_tuple = Funtuple( name="Tuple", diff --git a/DaVinciExamples/python/DaVinciExamples/tupling/option_trigger_decisions.py b/DaVinciExamples/python/DaVinciExamples/tupling/option_trigger_decisions.py index ccb69d697a37aec9393ae844b7d0a89337fba32d..3cc0558f7b7afe97912e654abae84d4e2b45d371 100644 --- a/DaVinciExamples/python/DaVinciExamples/tupling/option_trigger_decisions.py +++ b/DaVinciExamples/python/DaVinciExamples/tupling/option_trigger_decisions.py @@ -15,7 +15,6 @@ import Functors as F from FunTuple import FunctorCollection from FunTuple import FunTuple_Particles as Funtuple from DaVinci import Options, make_config -from DaVinci.algorithms import get_decreports from PyConf.reading import get_particles from FunTuple.functorcollections import SelectionInfo @@ -28,10 +27,7 @@ def main(options: Options): variables = {"B0": B0_variables} b02dpi_data = get_particles( - "/Event/HLT2/Hlt2B2OC_BdToDmPi_DmToPimPimKp_Line/Particles", - process=options.process) - - hlt1_dec = get_decreports("Hlt1", options) + "/Event/HLT2/Hlt2B2OC_BdToDmPi_DmToPimPimKp_Line/Particles") Hlt1_decisions = [ 'Hlt1TrackMVADecision', 'Hlt1TwoTrackMVADecision', 'Hlt1D2KKDecision', @@ -44,7 +40,7 @@ def main(options: Options): ] #define event level variables - evt_variables = SelectionInfo("Hlt1", hlt1_dec, Hlt1_decisions) + evt_variables = SelectionInfo("Hlt1", Hlt1_decisions) #define FunTuple instance my_tuple = Funtuple( diff --git a/DaVinciExamples/tests/qmtest/debugging.qms/test_example-PrintDecayTree.qmt b/DaVinciExamples/tests/qmtest/debugging.qms/test_example-PrintDecayTree.qmt index 0921bc9642450196433a26bcbefe8a71bcb951b5..b45b6ce587c6be3b1cba7073139698713a785df9 100755 --- a/DaVinciExamples/tests/qmtest/debugging.qms/test_example-PrintDecayTree.qmt +++ b/DaVinciExamples/tests/qmtest/debugging.qms/test_example-PrintDecayTree.qmt @@ -16,6 +16,7 @@ <argument name="extra_options_yaml"><text> evt_max: 100 print_freq: 1 + process: Turbo msg_svc_format: "% F%40W%S%7W%R%T %0W%M" </text></argument> <argument name="timeout"><integer>3600</integer></argument> diff --git a/DaVinciExamples/tests/qmtest/debugging.qms/test_example-PrintHeader.qmt b/DaVinciExamples/tests/qmtest/debugging.qms/test_example-PrintHeader.qmt index c77570ea9bc94ca4ab6cca8db03ca6ce35f21919..b43932d1dff0d7c3cd2f6ff53f8322116726ceac 100755 --- a/DaVinciExamples/tests/qmtest/debugging.qms/test_example-PrintHeader.qmt +++ b/DaVinciExamples/tests/qmtest/debugging.qms/test_example-PrintHeader.qmt @@ -16,6 +16,7 @@ <argument name="extra_options_yaml"><text> evt_max: 7 input_raw_format: 4.3 + process: Turbo </text></argument> <argument name="timeout"><integer>3600</integer></argument> <argument name="args"><set> diff --git a/DaVinciExamples/tests/qmtest/tupling.qms/test_davinci_tupling_weightedrelation_trackvariables.qmt b/DaVinciExamples/tests/qmtest/tupling.qms/test_davinci_tupling_weightedrelation_trackvariables.qmt index dfe02b6eb552706d75a7d3c843c07494faf2efa9..93decda4ace9595f979286ba21c9ed2542c3b1ff 100644 --- a/DaVinciExamples/tests/qmtest/tupling.qms/test_davinci_tupling_weightedrelation_trackvariables.qmt +++ b/DaVinciExamples/tests/qmtest/tupling.qms/test_davinci_tupling_weightedrelation_trackvariables.qmt @@ -25,11 +25,12 @@ print_freq: 1 data_type: Upgrade simulation: true + process: Turbo </text></argument> <argument name="timeout"><integer>3600</integer></argument> <argument name="reference"><text>$DAVINCIEXAMPLESROOT/tests/refs/test_davinci_tupling_weightedrelation_trackvariables.ref</text></argument> <argument name="validator"><text> findReferenceBlock("""Tuple SUCCESS ID=DecayTree Title="DecayTree" #items=32 {B_THOR_P,B_THOR_PT,B_THOR_MASS,B_First_P,B_First_PT,B_Sum_P,B_Sum_PT,B_Max_P,B_Ma}""") -countErrorLines({"FATAL":0, "ERROR":0}) +countErrorLines({"FATAL":0, "ERROR":0}) </text></argument> </extension> diff --git a/DaVinciExamples/tests/qmtest/tupling.qms/test_example-tupling-basic.qmt b/DaVinciExamples/tests/qmtest/tupling.qms/test_example-tupling-basic.qmt index ef5fba35d27a387b38b374ac03ee362a6e4c3820..067d125b43ea5d82bc446912d5f71afd984bda9f 100644 --- a/DaVinciExamples/tests/qmtest/tupling.qms/test_example-tupling-basic.qmt +++ b/DaVinciExamples/tests/qmtest/tupling.qms/test_example-tupling-basic.qmt @@ -21,6 +21,7 @@ histo_file: DV-example-tupling-basic-his.root evt_max: 10 input_raw_format: 4.3 + process: Spruce </text></argument> <argument name="timeout"><integer>3600</integer></argument> <argument name="args"><set> diff --git a/DaVinciExamples/tests/refs/test_davinci_tupling-basic-run-mc.ref b/DaVinciExamples/tests/refs/test_davinci_tupling-basic-run-mc.ref index ceef189ff0cc6c898dc855e2541886d50cc438e0..6241626fce0926a9629197935935a188282c7366 100644 --- a/DaVinciExamples/tests/refs/test_davinci_tupling-basic-run-mc.ref +++ b/DaVinciExamples/tests/refs/test_davinci_tupling-basic-run-mc.ref @@ -2,8 +2,6 @@ ApplicationMgr SUCCESS ==================================================================================================================================== ==================================================================================================================================== ApplicationMgr INFO Application Manager Configured successfully -DetectorPersistencySvc INFO Added successfully Conversion service:XmlCnvSvc -DetectorDataSvc SUCCESS Detector description database: git:/lhcb.xml NTupleSvc INFO Added stream file:DV-example-tupling-basic-ntp-run-mc.root as FILE1 RootHistSvc INFO Writing ROOT histograms to: DV-example-tupling-basic-his-run-mc.root HistogramPersistencySvc INFO Added successfully Conversion service:RootHistSvc diff --git a/DaVinciExamples/tests/refs/test_davinci_tupling_from_passthrough.ref b/DaVinciExamples/tests/refs/test_davinci_tupling_from_passthrough.ref index 3af9249f0ed9114de6e3313935ec8833366e173e..f5ec604539df4681cd763fb6b23ed67d10fb722a 100644 --- a/DaVinciExamples/tests/refs/test_davinci_tupling_from_passthrough.ref +++ b/DaVinciExamples/tests/refs/test_davinci_tupling_from_passthrough.ref @@ -46,7 +46,7 @@ Bs2JpsiPhi_Tuple INFO Number of counters : 7 HDRFilter_Bs2JpsiPhi INFO Number of counters : 1 | Counter | # | sum | mean/eff^* | rms/err^* | min | max | |*"#passed" | 1978 | 298 |( 15.06572 +- 0.8043098)% | -Hlt2 INFO Number of counters : 1 +Hlt2#1 INFO Number of counters : 1 | Counter | # | sum | mean/eff^* | rms/err^* | min | max | | " HltDecReports has a zero TCK, and it is not explicitly specified for decoding -- make sure that this really what you want"| 1978 | HltPackedBufferDecoder INFO Number of counters : 1 diff --git a/DaVinciTests/python/DaVinciTests/filters.py b/DaVinciTests/python/DaVinciTests/filters.py index 1c693c6b0d94517122a9f1f59586867026c5e93c..56ac7fcba3ba8eea58c7f09f67a5fbfb3208f935 100644 --- a/DaVinciTests/python/DaVinciTests/filters.py +++ b/DaVinciTests/python/DaVinciTests/filters.py @@ -17,10 +17,10 @@ from DaVinci import Options, make_config def main(options: Options): filter_B0DsK = add_filter( - options, "HDRFilter_B0DsK", + "HDRFilter_B0DsK", "HLT_PASS('SpruceB2OC_BdToDsmK_DsmToHHH_FEST_LineDecision')") filter_B0Dspi = add_filter( - options, "HDRFilter_B0Dspi", + "HDRFilter_B0Dspi", "HLT_PASS('SpruceB2OC_BdToDsmPi_DsmToHHH_LineDecision')") algs = {"B0DsK": [filter_B0DsK], "B0Dspi": [filter_B0Dspi]} diff --git a/DaVinciTests/python/DaVinciTests/functors.py b/DaVinciTests/python/DaVinciTests/functors.py index b1a53a55984b62b72b7e4f93922df171c0b57e6b..b214b48cb7bfe96b700fbdbcdff29a5ee57fbcac 100644 --- a/DaVinciTests/python/DaVinciTests/functors.py +++ b/DaVinciTests/python/DaVinciTests/functors.py @@ -66,7 +66,6 @@ def main(options: Options): # the "upfront_reconstruction" is what unpacks reconstruction objects, particles and primary vertices # from file and creates protoparticles. - #algs = upfront_reconstruction(process=options.process) + [vd0s, pdt, td0s, pdt2] algs = upfront_reconstruction() + [vd0s, pdt, td0s, pdt2] node = CompositeNode( diff --git a/DaVinciTests/python/DaVinciTests/funtuple_array.py b/DaVinciTests/python/DaVinciTests/funtuple_array.py index e02672bb69a4c92d6ddb77d92b8bf4a98a7f1129..d330dfeb4257a6cd9f758b5dd89f4027e63dd126 100644 --- a/DaVinciTests/python/DaVinciTests/funtuple_array.py +++ b/DaVinciTests/python/DaVinciTests/funtuple_array.py @@ -58,7 +58,7 @@ def main(options: Options): variables=variables, inputs=bd2dsk_data) - filter_B0DsK = add_filter(options, "HDRFilter_B0DsK", + filter_B0DsK = add_filter("HDRFilter_B0DsK", f"HLT_PASS('{bd2dsk_line}Decision')") return make_config(options, [filter_B0DsK, tuple_B0DsK]) diff --git a/DaVinciTests/python/DaVinciTests/option_davinci_for_turbo.py b/DaVinciTests/python/DaVinciTests/option_davinci_for_turbo.py index 623dabd07596e4aeb102168f6258be2b6dc2ff72..0424621b6cbf19b58989d3f6a9e810e7cee8d98f 100644 --- a/DaVinciTests/python/DaVinciTests/option_davinci_for_turbo.py +++ b/DaVinciTests/python/DaVinciTests/option_davinci_for_turbo.py @@ -20,10 +20,8 @@ from DaVinci.algorithms import add_filter def main(options: Options): - bd2dspi_line = "Hlt2B2OC_BdToDsmPi_DsmToKpKmPim" - bd2dspi_data = get_particles( - f"/Event/HLT2/{bd2dspi_line}/Particles", process=options.process) - + bs2jpsiphi_line = "Hlt2Generic_Bs0ToJpsiPhi_JPsiToMupMum_Line" + bs2jpsiphi_data = get_particles(f"/Event/HLT2/{bs2jpsiphi_line}/Particles") fields = { 'B0': "[B0 -> D_s- pi+]CC", 'Ds': "[B0 -> ^D_s- pi+]CC", @@ -37,15 +35,15 @@ def main(options: Options): 'ALL': variables_all, #adds variables to all branches } - filter_bd = add_filter(options, "HDRFilter_B0Dspi", - f"HLT_PASS('{bd2dspi_line}')") + filter_bd = add_filter("HDRFilter_Bs2JpsiPhi", + f"HLT_PASS('{bs2jpsiphi_line}')") tuple_bd = Funtuple( name="B0DsPi_Tuple", tuple_name="DecayTree", fields=fields, variables=variables, - inputs=bd2dspi_data) + inputs=bs2jpsiphi_data) algs = { "B0Dspi": [filter_bd, tuple_bd], diff --git a/DaVinciTests/python/DaVinciTests/recVertices.py b/DaVinciTests/python/DaVinciTests/recVertices.py index fc5034ad998f1bfe4bc11b50076ab058c5ea9b24..0ef48b1bf765ebbadd5a887e5601dc9a73d81fc9 100644 --- a/DaVinciTests/python/DaVinciTests/recVertices.py +++ b/DaVinciTests/python/DaVinciTests/recVertices.py @@ -21,14 +21,13 @@ from DaVinci import Options, make_config def main(options: Options): bd2dsk_line = "SpruceB2OC_BdToDsmK_DsmToHHH_FEST_Line" - bd2dsk_data = get_particles(f"/Event/Spruce/{bd2dsk_line}/Particles", - options.process) + bd2dsk_data = get_particles(f"/Event/Spruce/{bd2dsk_line}/Particles") fields_dsk = { 'B0': "[B0 -> D_s- K+]CC", } - v2_pvs = get_pvs(process=options.process) + v2_pvs = get_pvs() variables_pvs = FunctorCollection({ "BPVDIRA": F.BPVDIRA(v2_pvs), @@ -40,7 +39,7 @@ def main(options: Options): 'B0': variables_pvs, } - my_filter = add_filter(options, "HDRFilter_B0DsK", + my_filter = add_filter("HDRFilter_B0DsK", f"HLT_PASS('{bd2dsk_line}Decision')") my_tuple = Funtuple( name="B0DsK_Tuple", diff --git a/DaVinciTests/tests/options/option_davinci_funtuple_array.py b/DaVinciTests/tests/options/option_davinci_funtuple_array.py index 8a6708bb822bc5c410931a1cd01bfbf35657fd51..f4d0a6d91ca9996986ed4b835b77a289c4d2ea56 100644 --- a/DaVinciTests/tests/options/option_davinci_funtuple_array.py +++ b/DaVinciTests/tests/options/option_davinci_funtuple_array.py @@ -65,7 +65,7 @@ tuple_B0DsK = Funtuple( variables=variables, inputs=bd2dsk_data) -filter_B0DsK = add_filter(options, "HDRFilter_B0DsK", +filter_B0DsK = add_filter("HDRFilter_B0DsK", f"HLT_PASS('{bd2dsk_line}Decision')") diff --git a/DaVinciTests/tests/options/option_davinci_sprucing.py b/DaVinciTests/tests/options/option_davinci_sprucing.py index 24c539117452e97b84f5772520cf53380b3eb4fa..eb9b1a8d76f7e61b62e094ddfe7d6a6d372d0992 100644 --- a/DaVinciTests/tests/options/option_davinci_sprucing.py +++ b/DaVinciTests/tests/options/option_davinci_sprucing.py @@ -63,7 +63,7 @@ def main(options: Options): inputs=bd2dsk_line) filter_B0DsK = add_filter( - options, "HDRFilter_B0DsK", + "HDRFilter_B0DsK", "HLT_PASS('SpruceB2OC_BdToDsmK_DsmToHHH_FEST_LineDecision')") return make_config(options, [filter_B0DsK, tuple_B0DsK]) diff --git a/DaVinciTests/tests/qmtest/functors.qms/test_thor_functors.qmt b/DaVinciTests/tests/qmtest/functors.qms/test_thor_functors.qmt index 9a636b0bd2d88ab6e2c861f48d4f3292c9f81cb9..4d42877a5d770005f23f9c7fa047eba02b62a655 100755 --- a/DaVinciTests/tests/qmtest/functors.qms/test_thor_functors.qmt +++ b/DaVinciTests/tests/qmtest/functors.qms/test_thor_functors.qmt @@ -22,6 +22,7 @@ evt_max: -1 print_freq: 1 msg_svc_format: "% F%60W%S%7W%R%T %0W%M" + process: Turbo </text></argument> <argument name="timeout"><integer>3600</integer></argument> <argument name="args"><set> diff --git a/DaVinciTests/tests/qmtest/io.qms/test_read_mc_digi.qmt b/DaVinciTests/tests/qmtest/io.qms/test_read_mc_digi.qmt index 976ce580121cc2d3860fae0965b51d0619f3aa37..c6c4a1155d3f87a85cf3a1e1e9d823bfa0feef8b 100644 --- a/DaVinciTests/tests/qmtest/io.qms/test_read_mc_digi.qmt +++ b/DaVinciTests/tests/qmtest/io.qms/test_read_mc_digi.qmt @@ -19,6 +19,7 @@ <argument name="test_file_db_options_yaml"><text>upgrade-magdown-sim09c-up02-34112100-digi</text></argument> <argument name="extra_options_yaml"><text> evt_max: 200 + process: Turbo </text></argument> <argument name="reference"><text>../refs/test_davinci_read_mc_digi.ref</text></argument> <argument name="error_reference"><text>../refs/empty.ref</text></argument> diff --git a/DaVinciTests/tests/qmtest/io.qms/test_read_mc_ldst.qmt b/DaVinciTests/tests/qmtest/io.qms/test_read_mc_ldst.qmt index e0f1b1ff2f2074c231ef28ebd8748b234089998c..8eab2bcbb4a2af729c1a047adf85b27f63617548 100644 --- a/DaVinciTests/tests/qmtest/io.qms/test_read_mc_ldst.qmt +++ b/DaVinciTests/tests/qmtest/io.qms/test_read_mc_ldst.qmt @@ -19,6 +19,7 @@ <argument name="test_file_db_options_yaml"><text>upgrade-magdown-sim09c-up02-reco-up01-minbias-ldst</text></argument> <argument name="extra_options_yaml"><text> evt_max: 200 + process: Turbo </text></argument> <argument name="reference"><text>../refs/test_davinci_read_mc_ldst.ref</text></argument> <argument name="error_reference"><text>../refs/empty.ref</text></argument> diff --git a/DaVinciTests/tests/qmtest/io.qms/test_read_mc_mdf.qmt b/DaVinciTests/tests/qmtest/io.qms/test_read_mc_mdf.qmt index b67e99bd9c7df22522afdd433aab148e72dbf4ef..06ef03572e758b739beed53de9b3061483639c5d 100644 --- a/DaVinciTests/tests/qmtest/io.qms/test_read_mc_mdf.qmt +++ b/DaVinciTests/tests/qmtest/io.qms/test_read_mc_mdf.qmt @@ -20,6 +20,7 @@ <argument name="extra_options_yaml"><text> input_type: RAW evt_max: 200 + process: Turbo </text></argument> <argument name="reference"><text>../refs/test_davinci_read_mc_mdf.ref</text></argument> <argument name="error_reference"><text>../refs/empty.ref</text></argument> diff --git a/DaVinciTests/tests/qmtest/io.qms/test_read_mc_xdigi.qmt b/DaVinciTests/tests/qmtest/io.qms/test_read_mc_xdigi.qmt index b5d41cdc0e7cf186f700aadf753c5e2c1e230125..f63eb7e18118081b897ab29ac1763f1d7fca1d53 100644 --- a/DaVinciTests/tests/qmtest/io.qms/test_read_mc_xdigi.qmt +++ b/DaVinciTests/tests/qmtest/io.qms/test_read_mc_xdigi.qmt @@ -19,6 +19,7 @@ <argument name="test_file_db_options_yaml"><text>upgrade_DC19_01_Bs2JPsiPhi_MD</text></argument> <argument name="extra_options_yaml"><text> evt_max: 200 + process: Turbo </text></argument> <argument name="reference"><text>../refs/test_davinci_read_mc_xdigi.ref</text></argument> <argument name="error_reference"><text>../refs/empty.ref</text></argument> diff --git a/DaVinciTests/tests/qmtest/io.qms/test_read_moore_dst.qmt b/DaVinciTests/tests/qmtest/io.qms/test_read_moore_dst.qmt index fe772296a7d5685e73e0f6a978ee3a588a07fc1c..8b0cde2968a627eb0c6a8c3d409d9a6883c857cd 100755 --- a/DaVinciTests/tests/qmtest/io.qms/test_read_moore_dst.qmt +++ b/DaVinciTests/tests/qmtest/io.qms/test_read_moore_dst.qmt @@ -23,6 +23,7 @@ evt_max: -1 print_freq: 1 msg_svc_format: "% F%60W%S%7W%R%T %0W%M" + process: Turbo </text></argument> <argument name="validator"><text> findReferenceBlock("""StdLooseD02KK INFO Number of counters : 6 diff --git a/DaVinciTutorials/python/DaVinciTutorials/tutorial0_basic_DVjob.py b/DaVinciTutorials/python/DaVinciTutorials/tutorial0_basic_DVjob.py index 7af2b2804537a356499210a99bcc6815dbc3719d..2f7792f506380d4efbed56b6a72e61f9b13428e9 100644 --- a/DaVinciTutorials/python/DaVinciTutorials/tutorial0_basic_DVjob.py +++ b/DaVinciTutorials/python/DaVinciTutorials/tutorial0_basic_DVjob.py @@ -21,8 +21,7 @@ def main(options: Options): # (see https://lhcb.github.io/starterkit-lessons/first-analysis-steps/interactive-dst.html) # turbo_line = "Hlt2BsToJpsiPhi_JPsi2MuMu_PhiToKK_Line" - input_data = get_particles( - f"/Event/HLT2/{turbo_line}/Particles", process=options.process) + input_data = get_particles(f"/Event/HLT2/{turbo_line}/Particles") # Add a filter: We are not really filtering over particles, we are getting over a technical hurdle here. # The hurdle being that if the event hasn't fired a HLT2 line then no TES location exists @@ -30,8 +29,7 @@ def main(options: Options): # Side step this issue with a filter, where: # - 1st argument is a user defined name. # - 2nd argument is the line decision (simply append "Decision" to your HLT2 line name (or inspect hlt2_starterkit.tck.json)) - my_filter = add_filter(options, "HDRFilter_SeeNoEvil", - f"HLT_PASS('{turbo_line}')") + my_filter = add_filter("HDRFilter_SeeNoEvil", f"HLT_PASS('{turbo_line}')") # Defining an algorithm. The alorithm here prints the decaytree pdt = PrintDecayTree(name="PrintBsToJpsiPhi", Input=input_data) diff --git a/DaVinciTutorials/python/DaVinciTutorials/tutorial1_functors_specialfield.py b/DaVinciTutorials/python/DaVinciTutorials/tutorial1_functors_specialfield.py index 2be11272711b3c730423fb5ed8da5b4f24ec8902..399e3ab61d33c9e15b02e4333fd5a292097df33c 100644 --- a/DaVinciTutorials/python/DaVinciTutorials/tutorial1_functors_specialfield.py +++ b/DaVinciTutorials/python/DaVinciTutorials/tutorial1_functors_specialfield.py @@ -63,12 +63,10 @@ def main(options: Options): #Define the TES location (see previous example for explanation) turbo_line = "Hlt2BsToJpsiPhi_JPsi2MuMu_PhiToKK_Line" - input_data = get_particles( - f"/Event/HLT2/{turbo_line}/Particles", process=options.process) + input_data = get_particles(f"/Event/HLT2/{turbo_line}/Particles") #Define a filter (see previous example for explaination) - my_filter = add_filter(options, "HDRFilter_SeeNoEvil", - f"HLT_PASS('{turbo_line}')") + my_filter = add_filter("HDRFilter_SeeNoEvil", f"HLT_PASS('{turbo_line}')") #Define instance of FunTuple mytuple = Funtuple( diff --git a/DaVinciTutorials/python/DaVinciTutorials/tutorial2_LoKi.py b/DaVinciTutorials/python/DaVinciTutorials/tutorial2_LoKi.py index ab1668b1d997efa2cfc834085e81b4a3781d88f6..832481630d544ee7603287d3205e66f6caee34e0 100644 --- a/DaVinciTutorials/python/DaVinciTutorials/tutorial2_LoKi.py +++ b/DaVinciTutorials/python/DaVinciTutorials/tutorial2_LoKi.py @@ -64,12 +64,10 @@ def main(options: Options): #Load data from dst onto a TES turbo_line = "Hlt2BsToJpsiPhi_JPsi2MuMu_PhiToKK_Line" - input_data = get_particles( - f"/Event/HLT2/{turbo_line}/Particles", process=options.process) + input_data = get_particles(f"/Event/HLT2/{turbo_line}/Particles") #Add a filter - my_filter = add_filter(options, "HDRFilter_SeeNoEvil", - f"HLT_PASS('{turbo_line}')") + my_filter = add_filter("HDRFilter_SeeNoEvil", f"HLT_PASS('{turbo_line}')") #Define instance of FunTuple mytuple = Funtuple( diff --git a/DaVinciTutorials/python/DaVinciTutorials/tutorial3_ThOrfunctors.py b/DaVinciTutorials/python/DaVinciTutorials/tutorial3_ThOrfunctors.py index 7bdd55146c70bc76e6c00ced0493c9f454142e84..35f4b74c8f5fb22a877b29d1a4a051058d637d64 100644 --- a/DaVinciTutorials/python/DaVinciTutorials/tutorial3_ThOrfunctors.py +++ b/DaVinciTutorials/python/DaVinciTutorials/tutorial3_ThOrfunctors.py @@ -30,7 +30,7 @@ def main(options: Options): # Creating v2 reconstructed vertices to be used in the following functor # For the time being there's a mix of legacy and v2 event classes. That will eventually be cleaned once the # event model is fixed. In the meantime there are helper functions in DaVinci. - pvs = get_pvs(process=options.process) + pvs = get_pvs() #Evaluate the impact parameter all_vars = {} @@ -88,12 +88,10 @@ def main(options: Options): #Load data from dst onto a TES turbo_line = "Hlt2BsToJpsiPhi_JPsi2MuMu_PhiToKK_Line" - input_data = get_particles( - f"/Event/HLT2/{turbo_line}/Particles", process=options.process) + input_data = get_particles(f"/Event/HLT2/{turbo_line}/Particles") #Add a filter - my_filter = add_filter(options, "HDRFilter_SeeNoEvil", - f"HLT_PASS('{turbo_line}')") + my_filter = add_filter("HDRFilter_SeeNoEvil", f"HLT_PASS('{turbo_line}')") #Define instance of FunTuple mytuple = Funtuple( diff --git a/DaVinciTutorials/python/DaVinciTutorials/tutorial4_trigger_eventinfo.py b/DaVinciTutorials/python/DaVinciTutorials/tutorial4_trigger_eventinfo.py index aea11c22d949c658eb685a27a032b90eae061ff0..3551b09ecff0c7c22ef3626f29e2373e5825576b 100644 --- a/DaVinciTutorials/python/DaVinciTutorials/tutorial4_trigger_eventinfo.py +++ b/DaVinciTutorials/python/DaVinciTutorials/tutorial4_trigger_eventinfo.py @@ -62,9 +62,7 @@ def main(options: Options): # These are stored in "LHCb::ODIN" C++ object which the ThOr functors take as input (like PVs in Example7), load it onto TES using "get_odin". # The attribute extra_info is False by default, if set to "True" you get info on # bunchcrossing id, ODIN TCK, GPS Time, etc - from DaVinci.algorithms import get_odin - odin = get_odin(options) - evtinfo = EventInfo(odin, extra_info=False) + evtinfo = EventInfo(extra_info=False) print(evtinfo) #Get selection line decision and HlT2 TCK. @@ -77,25 +75,21 @@ def main(options: Options): # (see example `option_trigger_decisions` in `DaVinciExamples` folder). # For details, can also refer to the [talk](https://indico.cern.ch/event/1164051/#5-accessing-hlt1-decisions-usi) # (The talk mentions that to persist Hlt1 decisions, one needs to add few options to the Moore script). - from DaVinci.algorithms import get_decreports sel_type = "Hlt2" #User defined and will be used as prefix for TBranch in the root file - dec_report = get_decreports(sel_type, options) turbo_line = "Hlt2BsToJpsiPhi_JPsi2MuMu_PhiToKK_Line" turbo_line2 = "Hlt2BsToJpsiPhi_JPsi2ee_PhiToKK_Line" line_names = [f'{turbo_line}Decision', f'{turbo_line2}'] - selinfo = SelectionInfo(sel_type, dec_report, line_names) + selinfo = SelectionInfo(sel_type, line_names) print(selinfo) #Define variables dictionary "field name" -> Collections of functor variables = {"ALL": kin} #Load data from dst onto a TES - input_data = get_particles( - f"/Event/HLT2/{turbo_line}/Particles", process=options.process) + input_data = get_particles(f"/Event/HLT2/{turbo_line}/Particles") #Add a filter - my_filter = add_filter(options, "HDRFilter_SeeNoEvil", - f"HLT_PASS('{turbo_line}')") + my_filter = add_filter("HDRFilter_SeeNoEvil", f"HLT_PASS('{turbo_line}')") #Define instance of FunTuple mytuple = Funtuple( diff --git a/DaVinciTutorials/python/DaVinciTutorials/tutorial5_MCTruth.py b/DaVinciTutorials/python/DaVinciTutorials/tutorial5_MCTruth.py index 8b627c1adca6fcc3802d4f7073343d069ca8e983..59fd5337c2ef5ffc04eb725153aa91d01cd50992 100644 --- a/DaVinciTutorials/python/DaVinciTutorials/tutorial5_MCTruth.py +++ b/DaVinciTutorials/python/DaVinciTutorials/tutorial5_MCTruth.py @@ -43,8 +43,7 @@ def main(options: Options): #Load data from dst onto a TES turbo_line = "Hlt2BsToJpsiPhi_JPsi2MuMu_PhiToKK_Line" - input_data = get_particles( - f"/Event/HLT2/{turbo_line}/Particles", process=options.process) + input_data = get_particles(f"/Event/HLT2/{turbo_line}/Particles") #Define an algorithm that builds a map i.e. one-to-one relation b/w Reco Particle -> Truth MC Particle. mctruth = configured_MCTruthAndBkgCatAlg(inputs=input_data) #print(mctruth.MCAssocTable) @@ -93,8 +92,7 @@ def main(options: Options): variables = {"ALL": kin + mckin + mchierarchy + bkg_cat, "Kp": extra_info} #Add a filter - my_filter = add_filter(options, "HDRFilter_SeeNoEvil", - f"HLT_PASS('{turbo_line}')") + my_filter = add_filter("HDRFilter_SeeNoEvil", f"HLT_PASS('{turbo_line}')") #Define instance of FunTuple mytuple = Funtuple( diff --git a/DaVinciTutorials/python/DaVinciTutorials/tutorial6_DecayTreeFit.py b/DaVinciTutorials/python/DaVinciTutorials/tutorial6_DecayTreeFit.py index 9a31d44399f4238c52d50b165efd2d5c13afe5df..8148896c8dcdf86f35b89eead75df3f3421eae7f 100644 --- a/DaVinciTutorials/python/DaVinciTutorials/tutorial6_DecayTreeFit.py +++ b/DaVinciTutorials/python/DaVinciTutorials/tutorial6_DecayTreeFit.py @@ -36,8 +36,7 @@ def main(options: Options): #Load data from dst onto a TES (See Example7) turbo_line = "Hlt2BsToJpsiPhi_JPsi2MuMu_PhiToKK_Line" - input_data = get_particles( - f"/Event/HLT2/{turbo_line}/Particles", process=options.process) + input_data = get_particles(f"/Event/HLT2/{turbo_line}/Particles") #get kinematic functors kin = Kinematics() @@ -64,8 +63,8 @@ def main(options: Options): # The function "make_pvs()" returns v2 vertices whereas "make_pvs_v1()" returns v1 verticies. # The PV constraint in the Decay tree fitter currently only works with v1 # (see https://gitlab.cern.ch/lhcb/Rec/-/issues/318 and https://gitlab.cern.ch/lhcb/Rec/-/issues/309) - pvs = get_pvs_v1(process=options.process) - pvs_v2 = get_pvs(process=options.process) + pvs = get_pvs_v1() + pvs_v2 = get_pvs() #Add not only mass but also constrain Bs to be coming from primary vertex DTFpv = DTFAlg( @@ -99,8 +98,7 @@ def main(options: Options): variables = {"ALL": kin + dtf_kin, "Bs": pv_coll} #Add a filter (See Example7) - my_filter = add_filter(options, "HDRFilter_SeeNoEvil", - f"HLT_PASS('{turbo_line}')") + my_filter = add_filter("HDRFilter_SeeNoEvil", f"HLT_PASS('{turbo_line}')") #Define instance of FunTuple mytuple = Funtuple( diff --git a/DaVinciTutorials/python/DaVinciTutorials/tutorial7_multiple_sel_lines.py b/DaVinciTutorials/python/DaVinciTutorials/tutorial7_multiple_sel_lines.py index fdd441dc2169cbcdf04bdd0be7f678ccc67cba3c..fca181844e800cc307e234adbe1f99781c509092 100644 --- a/DaVinciTutorials/python/DaVinciTutorials/tutorial7_multiple_sel_lines.py +++ b/DaVinciTutorials/python/DaVinciTutorials/tutorial7_multiple_sel_lines.py @@ -33,9 +33,8 @@ def main(options: Options): #Load data from dst onto a TES turbo_line1 = "Hlt2BsToJpsiPhi_JPsi2MuMu_PhiToKK_Line" - input_data1 = get_particles( - f"/Event/HLT2/{turbo_line1}/Particles", process=options.process) - my_filter1 = add_filter(options, "HDRFilter_SeeNoEvil1", + input_data1 = get_particles(f"/Event/HLT2/{turbo_line1}/Particles") + my_filter1 = add_filter("HDRFilter_SeeNoEvil1", f"HLT_PASS('{turbo_line1}')") mytuple1 = Funtuple( "TDirectoryName1", @@ -46,9 +45,8 @@ def main(options: Options): # If running over several sprucing lines (e.g. for calibration) one can define multiple instances of FunTuple turbo_line2 = "Hlt2BsToJpsiPhi_JPsi2ee_PhiToKK_Line" - input_data2 = get_particles( - f"/Event/HLT2/{turbo_line2}/Particles", process=options.process) - my_filter2 = add_filter(options, "HDRFilter_SeeNoEvil2", + input_data2 = get_particles(f"/Event/HLT2/{turbo_line2}/Particles") + my_filter2 = add_filter("HDRFilter_SeeNoEvil2", f"HLT_PASS('{turbo_line2}')") mytuple2 = Funtuple( "TDirectoryName2", diff --git a/DaVinciTutorials/tests/refs/test_tutorial1_Functors_specialfield.ref b/DaVinciTutorials/tests/refs/test_tutorial1_Functors_specialfield.ref index 5ff4c1426acbe2c333da87834727609e0cd8ef21..1c977c641029bddc712a3b8cb3a7bfc302cbf4e2 100644 --- a/DaVinciTutorials/tests/refs/test_tutorial1_Functors_specialfield.ref +++ b/DaVinciTutorials/tests/refs/test_tutorial1_Functors_specialfield.ref @@ -137,7 +137,7 @@ ApplicationMgr INFO Application Manager Terminated succe HDRFilter_SeeNoEvil INFO Number of counters : 1 | Counter | # | sum | mean/eff^* | rms/err^* | min | max | |*"#passed" | 100 | 12 |( 12.00000 +- 3.249615)% | -Hlt2 INFO Number of counters : 1 +Hlt2#1 INFO Number of counters : 1 | Counter | # | sum | mean/eff^* | rms/err^* | min | max | | " HltDecReports has a zero TCK, and it is not explicitly specified for decoding -- make sure that this really what you want"| 100 | HltPackedBufferDecoder INFO Number of counters : 1 diff --git a/DaVinciTutorials/tests/refs/test_tutorial2_LoKi.ref b/DaVinciTutorials/tests/refs/test_tutorial2_LoKi.ref index 307b129d082bc639f0a4aca89a65846e8e3223f2..002063470f072ad278c5e72208666c0ab2aaa4e4 100644 --- a/DaVinciTutorials/tests/refs/test_tutorial2_LoKi.ref +++ b/DaVinciTutorials/tests/refs/test_tutorial2_LoKi.ref @@ -135,7 +135,7 @@ ApplicationMgr INFO Application Manager Terminated succe HDRFilter_SeeNoEvil INFO Number of counters : 1 | Counter | # | sum | mean/eff^* | rms/err^* | min | max | |*"#passed" | 100 | 12 |( 12.00000 +- 3.249615)% | -Hlt2 INFO Number of counters : 1 +Hlt2#1 INFO Number of counters : 1 | Counter | # | sum | mean/eff^* | rms/err^* | min | max | | " HltDecReports has a zero TCK, and it is not explicitly specified for decoding -- make sure that this really what you want"| 100 | HltPackedBufferDecoder INFO Number of counters : 1 diff --git a/DaVinciTutorials/tests/refs/test_tutorial3_ThOrfunctors.ref b/DaVinciTutorials/tests/refs/test_tutorial3_ThOrfunctors.ref index 11c1b0722450d2be9133c3556b8f3cf3d771e0fe..22886e592b9b64f6d8a1d1f6cffae2d553dda360 100644 --- a/DaVinciTutorials/tests/refs/test_tutorial3_ThOrfunctors.ref +++ b/DaVinciTutorials/tests/refs/test_tutorial3_ThOrfunctors.ref @@ -135,7 +135,7 @@ ApplicationMgr INFO Application Manager Terminated succe HDRFilter_SeeNoEvil INFO Number of counters : 1 | Counter | # | sum | mean/eff^* | rms/err^* | min | max | |*"#passed" | 100 | 12 |( 12.00000 +- 3.249615)% | -Hlt2 INFO Number of counters : 1 +Hlt2#1 INFO Number of counters : 1 | Counter | # | sum | mean/eff^* | rms/err^* | min | max | | " HltDecReports has a zero TCK, and it is not explicitly specified for decoding -- make sure that this really what you want"| 100 | HltPackedBufferDecoder INFO Number of counters : 1 diff --git a/DaVinciTutorials/tests/refs/test_tutorial5_MCTruth.ref b/DaVinciTutorials/tests/refs/test_tutorial5_MCTruth.ref index b31d5f39b5dc47fd05e7201559b2b4cc34e4d78a..3727ae6c98cf88daa9205b302e964257c623cc2a 100644 --- a/DaVinciTutorials/tests/refs/test_tutorial5_MCTruth.ref +++ b/DaVinciTutorials/tests/refs/test_tutorial5_MCTruth.ref @@ -6,9 +6,9 @@ NTupleSvc INFO Added stream file:tutorial5_MCTruth. RootHistSvc INFO Writing ROOT histograms to: tutorial5_MCTruth.root HistogramPersistencySvc INFO Added successfully Conversion service:RootHistSvc FSROutputStreamDstWriter INFO Data source: EventDataSvc output: SVC='Gaudi::RootCnvSvc' -MCTruthAndBkgCatAlg#1.DaVinciSma... INFO Will look into [/Event/Spruce/HLT2/Relations/ChargedPP2MCP, /Event/Spruce/HLT2/Relations/NeutralPP2MCP] -MCTruthAndBkgCatAlg#1.DaVinciSma... INFO Will look into [/Event/Spruce/HLT2/Relations/ChargedPP2MCP, /Event/Spruce/HLT2/Relations/NeutralPP2MCP] -MCTruthAndBkgCatAlg#1.Background... INFO Will look into [/Event/Spruce/HLT2/Relations/ChargedPP2MCP, /Event/Spruce/HLT2/Relations/NeutralPP2MCP] +MCTruthAndBkgCatAlg#1.DaVinciSma... INFO Will look into [/Event/HLT2/Relations/ChargedPP2MCP, /Event/HLT2/Relations/NeutralPP2MCP] +MCTruthAndBkgCatAlg#1.DaVinciSma... INFO Will look into [/Event/HLT2/Relations/ChargedPP2MCP, /Event/HLT2/Relations/NeutralPP2MCP] +MCTruthAndBkgCatAlg#1.Background... INFO Will look into [/Event/HLT2/Relations/ChargedPP2MCP, /Event/HLT2/Relations/NeutralPP2MCP] ApplicationMgr INFO Application Manager Initialized successfully ApplicationMgr INFO Application Manager Started successfully EventPersistencySvc INFO Added successfully Conversion service:RootCnvSvc @@ -138,36 +138,33 @@ ApplicationMgr INFO Application Manager Terminated succe HDRFilter_SeeNoEvil INFO Number of counters : 1 | Counter | # | sum | mean/eff^* | rms/err^* | min | max | |*"#passed" | 100 | 12 |( 12.00000 +- 3.249615)% | -Hlt2 INFO Number of counters : 1 +Hlt2#1 INFO Number of counters : 1 | Counter | # | sum | mean/eff^* | rms/err^* | min | max | | " HltDecReports has a zero TCK, and it is not explicitly specified for decoding -- make sure that this really what you want"| 100 | HltPackedBufferDecoder INFO Number of counters : 1 | Counter | # | sum | mean/eff^* | rms/err^* | min | max | | " DstData raw bank has a zero encoding key, and it is not explicitly specified for decoding -- make sure that this really what you want"| 12 | -HltPackedBufferDecoder#1 INFO Number of counters : 1 - | Counter | # | sum | mean/eff^* | rms/err^* | min | max | - | " DstData raw bank has a zero encoding key, and it is not explicitly specified for decoding -- make sure that this really what you want"| 12 | MCTruthAndBkgCatAlg#1 INFO Number of counters : 3 | Counter | # | sum | mean/eff^* | rms/err^* | min | max | | "Events" | 12 | - | "Ghosts" | 210 | 0 | 0.0000 | 0.0000 | 4.2950e+09 | 0.0000 | + | "Ghosts" | 107 | 0 | 0.0000 | 0.0000 | 4.2950e+09 | 0.0000 | | "Particles" | 210 | 0 | 0.0000 | 0.0000 | 4.2950e+09 | 0.0000 | PP2MCPRelationUnpacker INFO Number of counters : 1 | Counter | # | sum | mean/eff^* | rms/err^* | min | max | - | "# UnknownBuffer" | 12 | 0 | 0.0000 | -PP2MCPRelationUnpacker#1 INFO Number of counters : 1 + | "# PackedData" | 12 | 75 | 6.2500 | +PP2MCPRelationUnpacker#1 INFO Number of counters : 2 | Counter | # | sum | mean/eff^* | rms/err^* | min | max | - | "# UnknownBuffer" | 12 | 0 | 0.0000 | + | "# AbsentBuffer" | 3 | 0 | 0.0000 | + | "# PackedData" | 9 | 1504 | 167.11 | ParticleUnpacker INFO Number of counters : 2 | Counter | # | sum | mean/eff^* | rms/err^* | min | max | | "# Linked BufferData" | 132 | 136208 | 1031.9 | | "# UnpackedData" | 24 | 6282 | 261.75 | -ProtoParticleUnpacker INFO Number of counters : 1 - | Counter | # | sum | mean/eff^* | rms/err^* | min | max | - | "# UnknownBuffer" | 12 | 0 | 0.0000 | -ProtoParticleUnpacker#1 INFO Number of counters : 1 +ProtoParticleUnpacker#1 INFO Number of counters : 3 | Counter | # | sum | mean/eff^* | rms/err^* | min | max | - | "# UnknownBuffer" | 12 | 0 | 0.0000 | + | "# AbsentBuffer" | 3 | 0 | 0.0000 | + | "# Linked BufferData" | 9 | 3882 | 431.33 | + | "# UnpackedData" | 18 | 7578 | 421.00 | TDirectoryName INFO Number of counters : 15 | Counter | # | sum | mean/eff^* | rms/err^* | min | max | | "# events with multiple candidates for field Bs"| 8 | diff --git a/DaVinciTutorials/tests/refs/test_tutorial6_DecayTreeFit.ref b/DaVinciTutorials/tests/refs/test_tutorial6_DecayTreeFit.ref index 8465dceb950b8e9f078bef1ba1428748d2e1340d..354701bb6f3965b946db86e249df5f9ee9733af4 100644 --- a/DaVinciTutorials/tests/refs/test_tutorial6_DecayTreeFit.ref +++ b/DaVinciTutorials/tests/refs/test_tutorial6_DecayTreeFit.ref @@ -147,7 +147,7 @@ DecayTreeFitterAlgWithPV INFO Number of counters : 4 HDRFilter_SeeNoEvil INFO Number of counters : 1 | Counter | # | sum | mean/eff^* | rms/err^* | min | max | |*"#passed" | 100 | 12 |( 12.00000 +- 3.249615)% | -Hlt2 INFO Number of counters : 1 +Hlt2#1 INFO Number of counters : 1 | Counter | # | sum | mean/eff^* | rms/err^* | min | max | | " HltDecReports has a zero TCK, and it is not explicitly specified for decoding -- make sure that this really what you want"| 100 | HltPackedBufferDecoder INFO Number of counters : 1 diff --git a/DaVinciTutorials/tests/refs/test_tutorial7_multiple_sel_lines.ref b/DaVinciTutorials/tests/refs/test_tutorial7_multiple_sel_lines.ref index 5bb238dfd7beedcd39ca708a8d725a5085d54e18..72a1dc1669edf569c0e777004a1fbe9a01de0d4d 100644 --- a/DaVinciTutorials/tests/refs/test_tutorial7_multiple_sel_lines.ref +++ b/DaVinciTutorials/tests/refs/test_tutorial7_multiple_sel_lines.ref @@ -145,7 +145,7 @@ HDRFilter_SeeNoEvil1 INFO Number of counters : 1 HDRFilter_SeeNoEvil2 INFO Number of counters : 1 | Counter | # | sum | mean/eff^* | rms/err^* | min | max | |*"#passed" | 100 | 7 |( 7.000000 +- 2.551470)% | -Hlt2 INFO Number of counters : 1 +Hlt2#1 INFO Number of counters : 1 | Counter | # | sum | mean/eff^* | rms/err^* | min | max | | " HltDecReports has a zero TCK, and it is not explicitly specified for decoding -- make sure that this really what you want"| 100 | HltPackedBufferDecoder INFO Number of counters : 1 diff --git a/Phys/DaVinci/python/DaVinci/LbExec.py b/Phys/DaVinci/python/DaVinci/LbExec.py index ed5b3b3a4ee832840e6efffee77c56623fe53c04..16e7abbae7154a54e1c5cae10ce47660d191789e 100644 --- a/Phys/DaVinci/python/DaVinci/LbExec.py +++ b/Phys/DaVinci/python/DaVinci/LbExec.py @@ -8,25 +8,91 @@ # granted to it by virtue of its status as an Intergovernmental Organization # # or submit itself to any jurisdiction. # ############################################################################### -from enum import Enum +from contextlib import contextmanager from typing import Optional +from GaudiConf.LbExec import Options as DefaultOptions, ProcessTypes +from pydantic import root_validator +from PyConf.reading import (upfront_decoder, reconstruction, get_tes_root, + get_odin, get_hlt_reports, get_mc_track_info) -from GaudiConf.LbExec import Options as DefaultOptions +class Options(DefaultOptions): + """ + A class that holds the user-specified DaVinci options. + This class inherits from the default "GaudiConf.LbExec.Options". -class ProcessTypes(str, Enum): - Turbo = "Turbo" - Hlt2 = "Hlt2" - Spruce = "Spruce" + This class also configures the following PyConf functions, where their keyword + arguments are globally bound to the user-specified values. + This way users do not have to manually configure these functions themselves. + - upfont_decoder + - reconstruction + - get_tes_root + - get_odin + - get_hlt_reports + - get_mc_track_info + Four user-required parameters need to be set in this class: + - process (str): Process type, either 'Spruce' or 'Turbo' or 'Hlt2' + - input_manifest (str): Path to the input manifest file + - annsvc_config (str): Path to the configuration file from sprucing or Hlt2 + - metainfo_additional_tags (str): List of additional tags to be added to the metainfo -class Options(DefaultOptions): + The optional parameters that need to be set are : + - stream (str): Stream name. Default is "default" (Note for "process=Hlt2" the stream must be strictly empty the default value is overwritten in this case). + - lumi (bool): Flag to store luminosity information. Default is False. + - evt_pre_filter (dict[str,str]): Event pre-filter code. Default is None. + - enable_unpack (bool): Flag to enable the unpacking of the input data. Default is True. + - write_fsr (bool): Flag to write full stream record. Default is True. + - merge_genfsr (bool): Flag to merge the full stream record. Default is False. + """ input_manifest_file: Optional[str] metainfo_additional_tags: Optional[list] annsvc_config: Optional[str] - process: ProcessTypes = ProcessTypes.Turbo - stream: str = "default" + process: ProcessTypes + stream: Optional[str] = 'default' lumi: bool = False evt_pre_filters: Optional[dict[str, str]] = None write_fsr: bool = True merge_genfsr: bool = False + + @root_validator(pre=False) + def _stream_default(cls, values): + """ + This is a validator that sets the default "stream" value based on "process" + + Args: + values (dict): User-specified attributes of the Options object. + + Returns: + dict: Modified attributes of the Options object + """ + process = values.get("process") + if process == ProcessTypes.Hlt2: + values['stream'] = '' + + return values + + @contextmanager + def apply_binds(self): + """ + This function configures the following PyConf functions, where their keyword + arguments are globally bound to the user-specified values. + This way users do not have to manually configure these functions themselves. + - upfont_decoder + - reconstruction + - get_tes_root + - get_odin + - get_hlt_reports + - get_mc_track_info + """ + upfront_decoder.global_bind(process=self.process) + reconstruction.global_bind(process=self.process) + get_mc_track_info.global_bind(process=self.process) + get_tes_root.global_bind(process=self.process) + get_odin.global_bind( + process=self.process, + stream=self.stream, + input_raw_format=self.input_raw_format) + get_hlt_reports.global_bind(process=self.process, stream=self.stream) + with super().apply_binds(): + yield diff --git a/Phys/DaVinci/python/DaVinci/algorithms.py b/Phys/DaVinci/python/DaVinci/algorithms.py index 60bd84ed400b837edeaf15ccf2b264adef78ca72..63d453cc7943bfce09c59273af887022d8303dc8 100644 --- a/Phys/DaVinci/python/DaVinci/algorithms.py +++ b/Phys/DaVinci/python/DaVinci/algorithms.py @@ -16,12 +16,8 @@ from PyConf.Algorithms import ( LoKi__HDRFilter as HDRFilter, LoKi__VoidFilter as VoidFilter, ) -from PyConf.application import ( - default_raw_event, - make_odin, -) from Hlt2Conf.algorithms import make_dvalgorithm -from PyConf.reading import get_particles +from PyConf.reading import get_particles, get_hlt_reports log = logging.getLogger(__name__) @@ -49,12 +45,11 @@ def set_filter(name, code, dec_reports): return algFilter -def add_filter(options, name, code): +def add_filter(name, code): """ Adding an event pre-filter using a code defined by the user. Args: - options (class Options): lbexec provided options object name (str): filter's name. code (str): filter's code. @@ -86,7 +81,7 @@ def add_filter(options, name, code): dec_reports = None for source in ["Hlt2", "Spruce"]: if re.search("^HLT_PASS.*" + source, code): - dec_reports = get_hlt_reports(options, source) + dec_reports = get_hlt_reports(source) break algFilter = set_filter(name, code, dec_reports) @@ -113,7 +108,7 @@ def apply_filters_and_unpacking(options, algs_dict): if options.evt_pre_filters: evt_pre_filters = [] for title, code in options.evt_pre_filters.items(): - evt_filter = add_filter(options, title, code) + evt_filter = add_filter(title, code) evt_pre_filters.append(evt_filter) algs_list += evt_pre_filters @@ -151,40 +146,7 @@ def define_fsr_writer(options): return algs -def get_hlt_reports(options, source=''): - """ - Set the Hlt service and algorithms. - - Args: - options (DaVinci.Options): lbexec provided options object - source (str): source ID required by the user. - - Returns: - - HltDecReportsDecoder containing the configuration for hlt1 lines. - - HltDecReportsDecoder containing the configuration for hlt2 lines. - - HltDecReportsDecoder containing the configuration for spruced lines. - """ - from GaudiConf.reading import hlt_decisions - - process = options.process - stream = options.stream - - if source == 'Hlt1' or source == 'Hlt2': - dec_reports = hlt_decisions( - process=process, - stream=stream, - output_loc="/Event/%s/DecReports" % source, - configurables=False, - source=source) - - elif source == 'Spruce': - dec_reports = hlt_decisions( - process=process, stream=stream, configurables=False, source=source) - - return dec_reports - - -def configured_FunTuple(options, config): +def configured_FunTuple(config): """ Function for the FunTuple configuration and instantiation of the related HDR filter. @@ -205,8 +167,7 @@ def configured_FunTuple(options, config): dictAlgs = {} for key in config.keys(): - inputs = get_particles( - config[key]["location"], process=options.process) + inputs = get_particles(config[key]["location"]) dictAlgs[key] = [] i = 0 @@ -216,7 +177,7 @@ def configured_FunTuple(options, config): filter_name += "_%d" % i i = i + 1 - tupleFilter = add_filter(options, filter_name, line) + tupleFilter = add_filter(filter_name, line) dictAlgs[key].append(tupleFilter) funTuple = Funtuple( @@ -232,40 +193,6 @@ def configured_FunTuple(options, config): return dictAlgs -def get_odin(options): - """ - Function to get the LHCb::ODIN location - - Args: - options (DaVinci.Options): lbexec provided options object - Returns: - odin_loc: Location of the LHCb::ODIN - """ - if options.process == 'Hlt2': - stream = "" - else: - stream = options.stream - with default_raw_event.bind(raw_event_format=options.input_raw_format): - odin_loc = make_odin(stream=stream) - - return odin_loc - - -def get_decreports(sel_stage, options): - """ - Function to get the LHCb::DecReports for HLT1, HLT2 or Sprucing. - - Args: - sel_state (str): Selection stage can be "Hlt1" or "Hlt2" or "Spruce" - options (DaVinci.Options): lbexec provided options object - Returns: - dec_loc: Location of the LHCb::DecReports for HLT1 or Hlt2 or Spruce - """ - dec_loc = get_hlt_reports( - options, source=sel_stage).OutputHltDecReportsLocation - return dec_loc - - def apply_algorithm(list_particles, algorithm, **kwargs): """ Function that applies an algorithm, accepting a Particle::Range as input (e.g FilterDecays), @@ -283,10 +210,7 @@ def apply_algorithm(list_particles, algorithm, **kwargs): return dv_algorithm(ParticlesA=list_particles, **kwargs).Particles -def filter_on(location, - process="Spruce", - decay_descriptor=None, - bank_type=None): +def filter_on(location, decay_descriptor=None): """ Function to get particles from Hlt2 or Spruce sample. A FilterDecays is applied before returning the requested particles if a decay descriptor @@ -295,11 +219,10 @@ def filter_on(location, Args: location (str): Transient event store (TES) location of Particles in Hlt2 or Spruce sample decay_descriptor (str, optional): Decay descriptor that will be used to select decays in the event - bank_type (str, optional): Raw bank type Returns: data: TES location of the particles that are loaded from the input samples """ - data = get_particles(location, process=process) + data = get_particles(location) if decay_descriptor: data = apply_algorithm([data], FilterDecays, Code=decay_descriptor) return data diff --git a/Phys/DaVinci/python/DaVinci/truth_matching.py b/Phys/DaVinci/python/DaVinci/truth_matching.py index 7a72d95c51e5534b9f8d2665a09a3aefd73991a4..05218e86cdbd383c94c2eef476376fcc90d7a929 100644 --- a/Phys/DaVinci/python/DaVinci/truth_matching.py +++ b/Phys/DaVinci/python/DaVinci/truth_matching.py @@ -15,14 +15,13 @@ from PyConf.Algorithms import MCTruthAndBkgCatAlg from PyConf.Tools import DaVinciSmartAssociator, MCMatchObjP2MCRelator, ParticleDescendants from PyConf.Tools import BackgroundCategory, BackgroundCategoryViaRelations from PyConf.Tools import P2MCPFromProtoP -from PyConf.reading import get_pp2mcp_relations, get_mc_particles, get_charged_protoparticles, get_neutral_protoparticles +from PyConf.reading import get_pp2mcp_relations, get_mc_particles, get_charged_protoparticles, get_neutral_protoparticles, get_tes_root from PyConf.location_prefix import prefix def configured_MCTruthAndBkgCatAlg( inputs, relations_locs=["Relations/ChargedPP2MCP", "Relations/NeutralPP2MCP"], - process='Spruce', root_in_tes=None, redo_neutral_assoc=False, filter_MCP=True, @@ -45,9 +44,8 @@ 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"]. - 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. + If not 'None' then it is inferred from the 'process' option in yaml file. 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. @@ -59,26 +57,19 @@ def configured_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!" - ) + root_in_tes = get_tes_root() # No algorithm is asking for mc particles and proto particles explicitely # But pp2mcp relation unpacker needs them, so give them as extra_inputs extra_inputs = [] - extra_inputs += [get_charged_protoparticles(process)] - extra_inputs += [get_neutral_protoparticles(process)] + extra_inputs += [get_charged_protoparticles()] + extra_inputs += [get_neutral_protoparticles()] mc_loc = root_in_tes + "/MC/Particles" extra_inputs += [get_mc_particles(mc_loc)] relations = [ - get_pp2mcp_relations(prefix(rel, root_in_tes), process, extra_inputs) + get_pp2mcp_relations(prefix(rel, root_in_tes), extra_inputs) for rel in relations_locs ] diff --git a/Phys/DaVinci/tests/config/test_algorithms.py b/Phys/DaVinci/tests/config/test_algorithms.py index aaf07b967dea951e3a839c27031dc2123eaa75a3..e058addfb6b1aaec5eef880027c2545f8b6a580d 100644 --- a/Phys/DaVinci/tests/config/test_algorithms.py +++ b/Phys/DaVinci/tests/config/test_algorithms.py @@ -15,9 +15,8 @@ from DaVinci.algorithms import ( define_fsr_writer, add_filter, #filter_on apply_filters_and_unpacking, - configured_FunTuple, - get_odin, - get_decreports) + configured_FunTuple) +from PyConf.reading import get_odin, get_decreports, get_hlt_reports, upfront_decoder def test_define_write_fsr(): @@ -26,6 +25,7 @@ def test_define_write_fsr(): """ options = Options( data_type="Upgrade", + process="Turbo", evt_max=1, output_level=3, merge_genfsr=True, @@ -46,8 +46,13 @@ def test_add_hlt2_filter(): process="Hlt2", stream="default", ) - test_filter = add_filter(options, "test_filter", - "HLT_PASS('Hlt2TESTLineDecision')") + #Note here that we need to manually apply a bind to the PyConf functions + # as they are not automatically configured in the pytests. + # When running DV, the PyConf functions are globally configured and one must avoid + # "binding" as much as possible. + with get_hlt_reports.bind(process=options.process, stream=options.stream): + test_filter = add_filter("test_filter", + "HLT_PASS('Hlt2TESTLineDecision')") assert "HDRFilter" in test_filter.fullname @@ -62,8 +67,9 @@ def test_add_spruce_filter(): process="Spruce", stream="default", ) - test_filter = add_filter(options, "test_filter", - "HLT_PASS('SpruceTESTLineDecision')") + with get_hlt_reports.bind(process=options.process, stream=options.stream): + test_filter = add_filter("test_filter", + "HLT_PASS('SpruceTESTLineDecision')") assert "HDRFilter" in test_filter.fullname @@ -74,10 +80,12 @@ def test_add_void_filter(): """ options = Options( data_type="Upgrade", + process="Turbo", evt_max=1, simulation=True, ) - test_filter = add_filter(options, "test_filter", "VOIDTEST_Filter") + with get_hlt_reports.bind(process=options.process, stream=options.stream): + test_filter = add_filter("test_filter", "VOIDTEST_Filter") assert "VoidFilter" in test_filter.fullname @@ -87,6 +95,7 @@ def test_apply_filters_and_unpack(): """ options = Options( data_type="Upgrade", + process="Turbo", evt_max=1, evt_pre_filters={"test_filter": "EVT_PREFILTER"}, simulation=True, @@ -120,11 +129,14 @@ def test_configured_funtuple(): } options = Options( data_type="Upgrade", + process="Turbo", evt_max=1, input_raw_format=0.5, simulation=True, ) - test_dict = configured_FunTuple(options, config) + with upfront_decoder.bind(process=options.process), get_hlt_reports.bind( + process=options.process, stream=options.stream): + test_dict = configured_FunTuple(config) assert any("FunTupleBase_Particles/Tuple_TestTuple" in alg.fullname for alg in test_dict["TestTuple"]) @@ -135,12 +147,16 @@ def test_get_odin(): """ options = Options( data_type="Upgrade", + process="Turbo", evt_max=1, input_raw_format=0.5, simulation=True, ) - odin = get_odin(options) - assert odin.location == "/Event/createODIN/ODIN" + odin = get_odin( + process=options.process, + stream=options.stream, + input_raw_format=options.input_raw_format) + assert odin.location == "/Event/createODIN#1/ODIN" def test_get_decreports(): @@ -154,7 +170,8 @@ def test_get_decreports(): process="Turbo", stream="TurboSP", ) - decreports = get_decreports("Hlt2", options) + with get_hlt_reports.bind(process=options.process, stream=options.stream): + decreports = get_decreports("Hlt2") assert decreports.location == "/Event/Hlt2/DecReports" diff --git a/doc/configuration/davinci_configuration.rst b/doc/configuration/davinci_configuration.rst index 36920726c6a23e066d10b31b52da8acceb4b800d..8a2d7b3e83fb143e8356bda717f451396869da34 100644 --- a/doc/configuration/davinci_configuration.rst +++ b/doc/configuration/davinci_configuration.rst @@ -48,7 +48,7 @@ A filter can also be instantiated using the ``add_filter`` function: .. code-block:: python from DaVinci.algorithms import add_filter - filter = add_filter(options, "Hlt2TopoLineFilter", "HLT_PASS('Hlt2Topo2BodyLineDecision')"). + filter = add_filter("Hlt2TopoLineFilter", "HLT_PASS('Hlt2Topo2BodyLineDecision')"). Additional examples can be found `here <https://gitlab.cern.ch/lhcb/DaVinci/-/blob/master/DaVinciTests/tests/options/option_davinci_filters.py>`_ and `here <https://gitlab.cern.ch/lhcb/DaVinci/-/blob/master/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_from_spruce.py>`__. Additional information on how to implement a filter code can be found `here <https://twiki.cern.ch/twiki/bin/view/LHCb/FAQ/DaVinciFAQ#How_to_process_the_stripped_DSTs>`__ and `here <https://gitlab.cern.ch/lhcb/Phys/blob/master/Phys/PhysConf/python/PhysConf/Filters.py>`__. diff --git a/doc/tutorials/running.rst b/doc/tutorials/running.rst index 0596f34c451eca79406a99d85a6075f6b76ad22a..31b4b0b768fb323463350c5506145ce5ee802dd1 100644 --- a/doc/tutorials/running.rst +++ b/doc/tutorials/running.rst @@ -40,7 +40,7 @@ Make a file named ``my_module.py`` that contains a function that takes an ``opti input_data = get_particles(f"/Event/HLT2/{turbo_line}/Particles") user_algorithms = [ - add_filter(options, "HDRFilter_SeeNoEvil", f"HLT_PASS('{turbo_line}')"), + add_filter("HDRFilter_SeeNoEvil", f"HLT_PASS('{turbo_line}')"), PrintDecayTree(name="PrintBsToJpsiPhi", Input=input_data) ] @@ -50,7 +50,7 @@ Also make a file named ``options.yaml`` containing: .. code-block:: yaml - + input_files: - root://eoslhcb.cern.ch//eos/lhcb/wg/dpa/wp3/tests/hlt2_passthrough_thor_lines.dst annsvc_config: root://eoslhcb.cern.ch//eos/lhcb/wg/dpa/wp3/tests/hlt2_passthrough_thor_lines.tck.json