diff --git a/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_from_collections.py b/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_from_collections.py index 32b6ce43285eac78b7ccdffcb05e431fcb0cbb93..af60c97d4de11ec790e84386d408f39484f25e10 100644 --- a/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_from_collections.py +++ b/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_from_collections.py @@ -23,7 +23,8 @@ from DaVinci.algorithms import get_odin, get_decreports d02kpi_data = force_location("/Event/HLT2/Hlt2CharmD0ToKmPipLine/Particles") #get configured "MCTruthAndBkgCatAlg" algorithm for HLT2 output -mctruth = configured_MCTruthAndBkgCatAlg(inputs=d02kpi_data) +mctruth = configured_MCTruthAndBkgCatAlg( + inputs=d02kpi_data, process=options.process) #get location to odin odin = get_odin(options) diff --git a/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_from_hlt2.py b/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_from_hlt2.py index 54152995a7eca6aca61f9ca7f97799abfbe2fe06..7b2152cbd202d7250d65067442dfe5f66e0f9a5e 100644 --- a/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_from_hlt2.py +++ b/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_from_hlt2.py @@ -74,7 +74,8 @@ def main(): "HLT_PASS('Hlt2CharmD0ToKmPipLineDecision')") #get configured "MCTruthAndBkgCatAlg" algorithm for HLT2 output - mctruth = configured_MCTruthAndBkgCatAlg(inputs=d02kpi_data) + mctruth = configured_MCTruthAndBkgCatAlg( + inputs=d02kpi_data, process=options.process) #Add true ID info to each of the fields (branches) trueid_bkgcat_info = { "TRUEID": diff --git a/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_from_spruce_mc.py b/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_from_spruce_mc.py index 577577d38c93486b191cd238b47dc0180d80980e..a4a51c13fd63614ed30f16509060ec820397dd1d 100644 --- a/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_from_spruce_mc.py +++ b/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_from_spruce_mc.py @@ -40,8 +40,7 @@ def main(): "HLT_PASS('Spruce_Test_lineDecision')") #get configured "MCTruthAndBkgCatAlg" algorithm for HLT2 output - mctruth = configured_MCTruthAndBkgCatAlg( - inputs=B_data, root_in_tes="/Event/Spruce/HLT2") + mctruth = configured_MCTruthAndBkgCatAlg(inputs=B_data) #Add trueid info to each of the branches trueid_bkgcat_info = { "TRUEID": diff --git a/Phys/DaVinci/python/DaVinci/truth_matching.py b/Phys/DaVinci/python/DaVinci/truth_matching.py index 0960056b7ea6faae54dea486102664b1e7c70be3..089ae7e6f449c60b1c5151982f44d1a71e197e8e 100644 --- a/Phys/DaVinci/python/DaVinci/truth_matching.py +++ b/Phys/DaVinci/python/DaVinci/truth_matching.py @@ -20,7 +20,8 @@ from PyConf.Tools import P2MCPFromProtoP def configured_MCTruthAndBkgCatAlg( inputs, relations_locs=["Relations/ChargedPP2MCP", "Relations/NeutralPP2MCP"], - root_in_tes="/Event/HLT2", + process='Spruce', + root_in_tes=None, redo_neutral_assoc=False, output_level=INFO): """ @@ -41,7 +42,9 @@ def configured_MCTruthAndBkgCatAlg( inputs (DataHandle): Output of `Gaudi::Hive::FetchDataFromFile` (the input TES location to the particles). relations_locs (list, optional): TES locations to the pre-existing relations for charged and neutral particles. Defaults to ["Relations/ChargedPP2MCP", "Relations/NeutralPP2MCP"]. - root_in_tes (str, optional): RootInTES location that can be different for Sprucing output. Defaults to "/Event/HLT2". + process (str, optional): Specifies the output being processed i.e. 'Hlt2' or 'Spruce'. Default is 'Spruce'. + root_in_tes (str, optional): RootInTES location that can be different for streamed output. Defaults is None. + If not 'None' then the 'process' argument is completely ignored. redo_neutral_assoc (bool, optional): Whether or not to redo MC association of pure neutral calorimetric basic particle, i.e. gamma and pi0-merged with pi0-resolved treated as composite. Defaults to False. @@ -51,6 +54,17 @@ def configured_MCTruthAndBkgCatAlg( Returns: MCTruthAndBkgCatAlg: configured instance of algorithm MCTruthAndBkgCatAlg. """ + + if not root_in_tes: + if process == 'Spruce': + root_in_tes = '/Event/Spruce/HLT2' + elif process == 'Hlt2': + root_in_tes = '/Event/HLT2' + else: + raise ValueError( + f"The specified 'process' {process} not recognised. Can only be 'Hlt2' or 'Spruce'. Please check!" + ) + # Tool used by DaVinciSmartAssociator p2mctool = P2MCPFromProtoP( Locations=relations_locs,