ATLAS Offline Software
TauTruthCommonConfig.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2024 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 
9 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
10 from AthenaConfiguration.ComponentFactory import CompFactory
11 
12 # TODO: should this be in a separate file or ok here?
13 def TauTruthMatchingWrapperCfg(flags, name = "DFCommonTauTruthMatchingWrapper", **kwargs):
14  """Configure the tau truth matching wrapper"""
15  acc = ComponentAccumulator()
16  TauTruthMatchingWrapper = CompFactory.DerivationFramework.TauTruthMatchingWrapper
17  acc.addPublicTool(TauTruthMatchingWrapper(name = name, **kwargs), primary = True)
18  return(acc)
19 
20 # TODO: should this be in a separate file or ok here?
21 def TruthCollectionMakerTauCfg(flags, name, **kwargs):
22  """Configure the tau truth collection maker"""
23  acc = ComponentAccumulator()
24  TruthCollectionMakerTau = CompFactory.DerivationFramework.TruthCollectionMakerTau
25  acc.addPublicTool(TruthCollectionMakerTau(name, **kwargs), primary = True)
26  return(acc)
27 
28 # TODO: should be a common cfg in TauAnalysisTools
29 def TauTruthMatchingToolCfg(flags, name="DFCommonTauTruthMatchingTool", **kwargs):
30  """Configure the tau truth matching tool"""
31  acc = ComponentAccumulator()
32  TauTruthMatchingTool = CompFactory.TauAnalysisTools.TauTruthMatchingTool
33  acc.addPublicTool(TauTruthMatchingTool(name = name, **kwargs), primary = True)
34  return(acc)
35 
36 # TODO: should be a common cfg in TauAnalysisTools
37 def BuildTruthTausCfg(flags, name, **kwargs):
38  """Configure the BuildTruthTaus tool"""
39  acc = ComponentAccumulator()
40  BuildTruthTaus = CompFactory.TauAnalysisTools.BuildTruthTaus
41  acc.addPublicTool(BuildTruthTaus(name = name, **kwargs), primary = True)
42  return(acc)
43 
44 def TauTruthToolsCfg(flags):
45  """Configure tau truth making and matching"""
46 
47  # Ensure that we are running on MC
48  if not flags.Input.isMC:
49  return
50 
51  acc = ComponentAccumulator()
52 
53  DFCommonTauTruthWrapperTools = []
54 
55  # truth tau building
56  acc.merge(BuildTruthTausCfg(flags,
57  name = "DFCommonTauTruthBuilder",
58  WriteInvisibleFourMomentum = True,
59  WriteVisibleNeutralFourMomentum = True ))
60 
61  acc.merge(TruthCollectionMakerTauCfg(flags,
62  name = "DFCommonTauTruthCollectionMaker",
63  BuildTruthTaus = acc.getPublicTool("DFCommonTauTruthBuilder")))
64  DFCommonTauTruthWrapperTools.append(acc.getPublicTool("DFCommonTauTruthCollectionMaker"))
65 
66  # tau truth matching, if reconstructed taus are present in the input
67  # this should be dropped from derivations and deferred to analysis level (the only use case in derivations is PHYSLITE)
68  if "xAOD::TauJetContainer#TauJets" in flags.Input.TypedCollections:
69  DFCommonTauTruthMatchingTool = acc.getPrimaryAndMerge(TauTruthMatchingToolCfg(
70  flags,
71  name = "DFCommonTauTruthMatchingTool",
72  WriteInvisibleFourMomentum = True,
73  WriteVisibleNeutralFourMomentum = True,
74  TruthJetContainerName = "AntiKt4TruthDressedWZJets"))
75  DFCommonTauTruthWrapperTool = acc.getPrimaryAndMerge(TauTruthMatchingWrapperCfg(
76  flags,
77  name = "DFCommonTauTruthMatchingWrapper",
78  TauTruthMatchingTool = DFCommonTauTruthMatchingTool,
79  TauContainerName = "TauJets"))
80  DFCommonTauTruthWrapperTools.append(DFCommonTauTruthWrapperTool)
81 
82  CommonAugmentation = CompFactory.DerivationFramework.CommonAugmentation
83  acc.addEventAlgo(CommonAugmentation( "TauTruthCommonKernel", AugmentationTools = DFCommonTauTruthWrapperTools,
84  ExtraOutputs = {( 'xAOD::TruthParticleContainer' , 'StoreGateSvc+TruthTaus' ),
85  ( 'xAOD::IParticleContainer' , 'StoreGateSvc+TruthTaus' )} ))
86 
87  return acc
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
python.TauTruthCommonConfig.TauTruthMatchingWrapperCfg
def TauTruthMatchingWrapperCfg(flags, name="DFCommonTauTruthMatchingWrapper", **kwargs)
Definition: TauTruthCommonConfig.py:13
python.TauTruthCommonConfig.TruthCollectionMakerTauCfg
def TruthCollectionMakerTauCfg(flags, name, **kwargs)
Definition: TauTruthCommonConfig.py:21
python.TauTruthCommonConfig.TauTruthMatchingToolCfg
def TauTruthMatchingToolCfg(flags, name="DFCommonTauTruthMatchingTool", **kwargs)
Definition: TauTruthCommonConfig.py:29
python.TauTruthCommonConfig.TauTruthToolsCfg
def TauTruthToolsCfg(flags)
Definition: TauTruthCommonConfig.py:44
python.TauTruthCommonConfig.BuildTruthTausCfg
def BuildTruthTausCfg(flags, name, **kwargs)
Definition: TauTruthCommonConfig.py:37