ATLAS Offline Software
Loading...
Searching...
No Matches
TauTruthCommonConfig.py
Go to the documentation of this file.
1# Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
2
3#********************************************************************
4# TauTruthCommonConfig.py
5# Schedules all tools needed for tau truth object selection and writes
6# results into SG. These may then be accessed along the train.
7#********************************************************************
8
9from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
10from AthenaConfiguration.ComponentFactory import CompFactory
11
12
13def DFCommonTauTruthMatchingToolCfg(flags, name = "DFCommonTauTruthMatchingTool", **kwargs):
14 kwargs.setdefault("TruthJetContainerName", "AntiKt4TruthDressedWZJets")
15 from TauAnalysisTools.TauAnalysisToolsConfig import TauTruthMatchingToolCfg
16 return TauTruthMatchingToolCfg(flags, name, **kwargs)
17
18
19def TauTruthMatchingWrapperCfg(flags, cont, **kwargs):
20 """Configure the tau truth matching wrapper"""
21 acc = ComponentAccumulator()
22 name = "DFCommon"+cont+"TruthMatchingWrapper"
23 DFCommonTauTruthMatchingTool = acc.addPublicTool(acc.popToolsAndMerge(
24 DFCommonTauTruthMatchingToolCfg(flags)))
25 kwargs.setdefault("TauTruthMatchingTool", DFCommonTauTruthMatchingTool)
26 kwargs.setdefault("TauContainerName", cont)
27 acc.setPrivateTools(
28 CompFactory.DerivationFramework.TauTruthMatchingWrapper(name = name, **kwargs))
29 return acc
30
31
32def TruthCollectionMakerTauCfg(flags, name= "DFCommonTauTruthCollectionMaker", **kwargs):
33 """Configure the tau truth collection maker"""
34 acc = ComponentAccumulator()
35 from TauAnalysisTools.TauAnalysisToolsConfig import BuildTruthTausCfg
36 kwargs.setdefault("BuildTruthTaus", acc.addPublicTool(acc.popToolsAndMerge(BuildTruthTausCfg(flags,
37 name = "DFCommonTauTruthBuilder",
38 WriteInvisibleFourMomentum = True,
39 WriteVisibleNeutralFourMomentum = True ))))
40 # TruthCollectionMakerTau from DerivationFrameworkMCTruth
41 acc.setPrivateTools(
42 CompFactory.DerivationFramework.TruthCollectionMakerTau(name, **kwargs))
43 return acc
44
45
46def TauTruthToolsCfg(flags):
47 """Configure tau truth making and matching"""
48
49 acc = ComponentAccumulator()
50
51 # Ensure that we are running on MC
52 if not flags.Input.isMC:
53 # FIXME If this happens it indicates an issue with the configuration in the caller, so better to throw an exception?!
54 return acc
55
56 # truth tau building
57 TauTruthAugmentationTools1 = []
58 TauTruthAugmentationTools1.append(
59 acc.addPublicTool(acc.popToolsAndMerge(TruthCollectionMakerTauCfg(flags))))
60 CommonAugmentation = CompFactory.DerivationFramework.CommonAugmentation
61 acc.addEventAlgo(CommonAugmentation("TauTruthCommonKernel1",
62 AugmentationTools = TauTruthAugmentationTools1,
63 ExtraOutputs = {( 'xAOD::TruthParticleContainer' , 'StoreGateSvc+TruthTaus' )} ))
64
65 # tau truth matching, if reconstructed taus are present in the input
66 # this should be dropped from derivations and deferred to analysis level (the only use case in derivations is PHYSLITE)
67 TauTruthAugmentationTools2 = []
68 for cont in ["TauJets","TauJets_EleRM"]:
69 if "xAOD::TauJetContainer#"+cont in flags.Input.TypedCollections:
70 TauTruthAugmentationTools2.append(
71 acc.addPublicTool(acc.popToolsAndMerge(TauTruthMatchingWrapperCfg(flags, cont))))
72
73 acc.addEventAlgo(CommonAugmentation( "TauTruthCommonKernel2",
74 AugmentationTools = TauTruthAugmentationTools2,
75 ExtraInputs = {( 'xAOD::TruthParticleContainer' , 'StoreGateSvc+TruthTaus' )} ))
76
77 return acc
TauTruthMatchingWrapperCfg(flags, cont, **kwargs)
DFCommonTauTruthMatchingToolCfg(flags, name="DFCommonTauTruthMatchingTool", **kwargs)