Skip to content
Snippets Groups Projects
Commit e6482bab authored by Eduardo Rodrigues's avatar Eduardo Rodrigues Committed by Patrick Koppenburg
Browse files

Fix ConfiguredMCTruthAndBkgCatAlg correctly propagating RootInTES

parent af145852
No related branches found
No related tags found
2 merge requests!1103Draft: Add AnalysisHelpers to DaVinci Stack,!640Fix ConfiguredMCTruthAndBkgCatAlg correctly propagating RootInTES
......@@ -9,48 +9,82 @@
# or submit itself to any jurisdiction. #
###############################################################################
from Gaudi.Configuration import INFO
from PyConf.Algorithms import MCTruthAndBkgCatAlg
from PyConf.Tools import DaVinciSmartAssociator, MCMatchObjP2MCRelator, ParticleDescendants
from PyConf.Tools import BackgroundCategory, BackgroundCategoryViaRelations
from PyConf.Tools import P2MCPFromProtoP
def ConfiguredMCTruthAndBkgCatAlg(
inputs,
relations_locs=["Relations/ChargedPP2MCP", "Relations/NeutralPP2MCP"],
root_in_tes="/Event/HLT2",
redo_neutral_assoc=False,
root_in_tes="/Event/HLT2"):
output_level=INFO):
"""
Function that configures the tools related to the `MCTruthAndBkgCatAlg` algorithm for HLT2 output
(configuration for Sprucing output is the same if the correct "`relations_locs` and `root_in_tes` are set).
Function to help configure the tools instantiated by the `MCTruthAndBkgCatAlg` algorithm.
The tools configured are `DaVinciSmartAssociator`, `MCMatchObjP2MCRelator`,
`BackgroundCategory`, `BackgroundCategoryViaRelations` and `P2MCPFromProtoP`.
The tools configured are DaVinciSmartAssociator, P2MCPFromProtoP, MCMatchObjP2MCRelator, BackgroundCategory.
The output of this algorithm is two relation tables: one for MC association (P->MCP) and one for background category (P->BKGCAT).
The MC association table can be used as input to MAP_INPUT functor and the background category table serves as input for BKGCAT functor.
The configuration for Sprucing output is the same as for HLT2 output
provided the correct `relations_locs` and `root_in_tes` arguments are set.
The output of this algorithm is two relation tables:
one for MC association (P->MCP) and one for background category (P->BKGCAT).
The MC association table can be used as input to the `MAP_INPUT` functor
and the background category table serves as input for `BKGCAT` functor.
Args:
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".
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.
root_in_tes (str, optional): RootInTES location that can be different for sprucing output. Defaults to "/Event/HLT2".
output_level (int, optional): the standard `OutputLevel` from `Gaudi.Configuration`
to set for all instantiated algorithms and tools. Defaults to `output_level=INFO=3`.
Returns:
MCTruthAndBkgCatAlg: configured instance of algorithm MCTruthAndBkgCatAlg.
"""
from PyConf.Algorithms import MCTruthAndBkgCatAlg
from PyConf.Tools import DaVinciSmartAssociator, P2MCPFromProtoP, MCMatchObjP2MCRelator, BackgroundCategory
# Tool used by DaVinciSmartAssociator
p2mctool = P2MCPFromProtoP(
Locations=relations_locs,
RootInTES=root_in_tes,
OutputLevel=output_level)
p2mctool = P2MCPFromProtoP(Locations=relations_locs)
# Tools used by MCTruthAndBkgCatAlg
bkg_cat = BackgroundCategory(
P2MCTool=p2mctool, vetoNeutralRedo=not redo_neutral_assoc)
P2MCTool=p2mctool,
vetoNeutralRedo=not redo_neutral_assoc,
RootInTES=root_in_tes,
OutputLevel=output_level)
bkg_cat_via_rel = BackgroundCategoryViaRelations(
RootInTES=root_in_tes, OutputLevel=output_level)
dv_assc = DaVinciSmartAssociator(
P2MCTool=p2mctool,
RedoNeutral=redo_neutral_assoc,
RootInTES=root_in_tes,
BackgroundCategoryTool=bkg_cat)
mcrel_assc = MCMatchObjP2MCRelator(RelTableLocations=relations_locs)
BackgroundCategoryTool=bkg_cat,
OutputLevel=output_level)
mcrel_assc = MCMatchObjP2MCRelator(
RelTableLocations=relations_locs,
RootInTES=root_in_tes,
OutputLevel=output_level)
part_desc = ParticleDescendants(
RootInTES=root_in_tes, OutputLevel=output_level)
mctruth = MCTruthAndBkgCatAlg(
Input=inputs,
DaVinciSmartAssociator=dv_assc,
MCMatchObjP2MCRelator=mcrel_assc,
BackgroundCategory=bkg_cat)
BackgroundCategory=bkg_cat,
BackgroundCategoryViaRelations=bkg_cat_via_rel,
ParticleDescendants=part_desc,
OutputLevel=output_level)
return mctruth
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment