ATLAS Offline Software
TauCommonConfig.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2 
3 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
4 from AthenaConfiguration.ComponentFactory import CompFactory
5 
6 def AddTauAugmentationCfg(flags, **kwargs):
7 
8  prefix = kwargs["prefix"]
9  kwargs.setdefault("doVeryLoose", False)
10  kwargs.setdefault("doLoose", False)
11  kwargs.setdefault("doMedium", False)
12  kwargs.setdefault("doTight", False)
13 
14  acc = ComponentAccumulator()
15 
16  # tau selection relies on RNN electron veto, we must decorate the fixed eveto WPs before applying tau selection
17  acc.merge(AddTauIDDecorationCfg(flags, TauContainerName="TauJets"))
18 
19  from DerivationFrameworkTools.DerivationFrameworkToolsConfig import AsgSelectionToolWrapperCfg
20  from TauAnalysisTools.TauAnalysisToolsConfig import TauSelectionToolCfg
21 
22  TauAugmentationTools = []
23 
24  if kwargs["doVeryLoose"]:
25  TauSelectorVeryLoose = acc.popToolsAndMerge(TauSelectionToolCfg(flags,
26  name = 'TauSelectorVeryLoose',
27  ConfigPath = 'TauAnalysisAlgorithms/tau_selection_veryloose_noeleid.conf'))
28  acc.addPublicTool(TauSelectorVeryLoose)
29 
30  TauVeryLooseWrapper = acc.getPrimaryAndMerge(AsgSelectionToolWrapperCfg(flags,
31  name = "TauVeryLooseWrapper",
32  AsgSelectionTool = TauSelectorVeryLoose,
33  StoreGateEntryName = "DFTauVeryLoose",
34  ContainerName = "TauJets"))
35  TauAugmentationTools.append(TauVeryLooseWrapper)
36 
37  if kwargs["doLoose"]:
38  TauSelectorLoose = acc.popToolsAndMerge(TauSelectionToolCfg(flags,
39  name = 'TauSelectorLoose',
40  ConfigPath = 'TauAnalysisAlgorithms/tau_selection_loose_noeleid.conf'))
41  acc.addPublicTool(TauSelectorLoose)
42 
43  TauLooseWrapper = acc.getPrimaryAndMerge(AsgSelectionToolWrapperCfg(flags,
44  name = "TauLooseWrapper",
45  AsgSelectionTool = TauSelectorLoose,
46  StoreGateEntryName = "DFTauLoose",
47  ContainerName = "TauJets"))
48  TauAugmentationTools.append(TauLooseWrapper)
49 
50  if kwargs["doMedium"]:
51  TauSelectorMedium = acc.popToolsAndMerge(TauSelectionToolCfg(flags,
52  name = 'TauSelectorMedium',
53  ConfigPath = 'TauAnalysisAlgorithms/tau_selection_medium_noeleid.conf'))
54  acc.addPublicTool(TauSelectorMedium)
55 
56  TauMediumWrapper = acc.getPrimaryAndMerge(AsgSelectionToolWrapperCfg(flags,
57  name = "TauMediumWrapper",
58  AsgSelectionTool = TauSelectorMedium,
59  StoreGateEntryName = "DFTauMedium",
60  ContainerName = "TauJets"))
61  TauAugmentationTools.append(TauMediumWrapper)
62 
63  if kwargs["doTight"]:
64  TauSelectorTight = acc.popToolsAndMerge(TauSelectionToolCfg(flags,
65  name = 'TauSelectorTight',
66  ConfigPath = 'TauAnalysisAlgorithms/tau_selection_tight_noeleid.conf'))
67  acc.addPublicTool(TauSelectorTight)
68 
69  TauTightWrapper = acc.getPrimaryAndMerge(AsgSelectionToolWrapperCfg(flags,
70  name = "TauTightWrapper",
71  AsgSelectionTool = TauSelectorTight,
72  StoreGateEntryName = "DFTauTight",
73  ContainerName = "TauJets"))
74  TauAugmentationTools.append(TauTightWrapper)
75 
76  if TauAugmentationTools:
77  CommonAugmentation = CompFactory.DerivationFramework.CommonAugmentation
78  acc.addEventAlgo(CommonAugmentation(f"{prefix}_TauAugmentationKernel", AugmentationTools = TauAugmentationTools))
79 
80  return acc
81 
82 
83 # Low pT di-taus
84 def AddDiTauLowPtCfg(flags, **kwargs):
85  """Configure the low-pt di-tau building"""
86 
87  acc = ComponentAccumulator()
88 
89  from JetRecConfig.JetRecConfig import JetRecCfg
90  from JetRecConfig.StandardLargeRJets import AntiKt10LCTopo
91  acc.merge(JetRecCfg(flags,AntiKt10LCTopo))
92 
93  from DiTauRec.DiTauBuilderConfig import DiTauBuilderLowPtCfg
94  acc.merge(DiTauBuilderLowPtCfg(flags, name="DiTauLowPtBuilder"))
95 
96  return acc
97 
98 
99 def AddTauIDDecorationCfg(flags, **kwargs):
100  """Decorate tau ID scores and working points"""
101 
102  kwargs.setdefault("evetoFix", True)
103  kwargs.setdefault("GNNTauID", True)
104  kwargs.setdefault("TauContainerName", "TauJets")
105  kwargs.setdefault("prefix", kwargs['TauContainerName'])
106 
107  acc = ComponentAccumulator()
108 
109  import tauRec.TauToolHolder as tauTools
110  tools = []
111 
112  if kwargs['evetoFix']:
113  tools.append( acc.popToolsAndMerge(tauTools.TauWPDecoratorEleRNNFixCfg(flags)) )
114 
115  if kwargs['GNNTauID']:
116  # vertex-corrected clusters must be rebuilt for tau ID
117  tools.append( acc.popToolsAndMerge(tauTools.TauVertexedClusterDecoratorCfg(flags)) )
118  # Add in GNTau!
119  tools.append( acc.popToolsAndMerge(tauTools.TauGNNEvaluatorCfg(flags,0)) )
120  tools.append( acc.popToolsAndMerge(tauTools.TauGNNEvaluatorCfg(flags,1)) )
121  tools.append( acc.popToolsAndMerge(tauTools.TauWPDecoratorGNNCfg(flags,0)) )
122  tools.append( acc.popToolsAndMerge(tauTools.TauWPDecoratorGNNCfg(flags,1)) )
123 
124  if tools:
125  for tool in tools:
126  acc.addPublicTool(tool)
127 
128  TauIDDecoratorWrapper = CompFactory.DerivationFramework.TauIDDecoratorWrapper
129  TauIDDecoratorKernel = CompFactory.DerivationFramework.CommonAugmentation
130 
131  prefix = kwargs['prefix']
132  tauIDDecoratorWrapper = TauIDDecoratorWrapper(name = f"{prefix}_TauIDDecoratorWrapper",
133  TauContainerName = kwargs['TauContainerName'],
134  TauIDTools = tools)
135 
136  acc.addPublicTool(tauIDDecoratorWrapper)
137  acc.addEventAlgo(TauIDDecoratorKernel(name = f"{prefix}_TauIDDecorKernel",
138  AugmentationTools = [tauIDDecoratorWrapper]))
139 
140  return acc
141 
142 
143 # TauJets_MuonRM steering
144 def AddMuonRemovalTauAODReRecoAlgCfg(flags, **kwargs):
145  """Configure the MuonRM AOD tau building"""
146 
147  acc = ComponentAccumulator()
148 
149  # get tools from holder
150  import tauRec.TauToolHolder as tauTools
151  tools_mod = []
152  tools_mod.append( acc.popToolsAndMerge(tauTools.TauAODMuonRemovalCfg(flags)) )
153  tools_after = []
154  tools_after.append( acc.popToolsAndMerge(tauTools.TauVertexedClusterDecoratorCfg(flags)) )
155  tools_after.append( acc.popToolsAndMerge(tauTools.TauTrackRNNClassifierCfg(flags)) )
156  tools_after.append( acc.popToolsAndMerge(tauTools.EnergyCalibrationLCCfg(flags)) )
157  tools_after.append( acc.popToolsAndMerge(tauTools.TauCommonCalcVarsCfg(flags)) )
158  tools_after.append( acc.popToolsAndMerge(tauTools.TauSubstructureCfg(flags)) )
159  tools_after.append( acc.popToolsAndMerge(tauTools.Pi0ClusterCreatorCfg(flags)) )
160  tools_after.append( acc.popToolsAndMerge(tauTools.Pi0ClusterScalerCfg(flags)) )
161  tools_after.append( acc.popToolsAndMerge(tauTools.Pi0ScoreCalculatorCfg(flags)) )
162  tools_after.append( acc.popToolsAndMerge(tauTools.Pi0SelectorCfg(flags)) )
163  tools_after.append( acc.popToolsAndMerge(tauTools.TauVertexVariablesCfg(flags)) )
164  import PanTauAlgs.JobOptions_Main_PanTau_New as pantau
165  tools_after.append( acc.popToolsAndMerge(pantau.PanTauCfg(flags)) )
166  tools_after.append( acc.popToolsAndMerge(tauTools.TauCombinedTESCfg(flags)) )
167  tools_after.append( acc.popToolsAndMerge(tauTools.MvaTESVariableDecoratorCfg(flags)) )
168  tools_after[-1].EventShapeKey = ''
169  tools_after.append( acc.popToolsAndMerge(tauTools.MvaTESEvaluatorCfg(flags)) )
170  tools_after.append( acc.popToolsAndMerge(tauTools.TauIDVarCalculatorCfg(flags)) )
171  tools_after.append( acc.popToolsAndMerge(tauTools.TauJetRNNEvaluatorCfg(flags)) )
172  tools_after.append( acc.popToolsAndMerge(tauTools.TauWPDecoratorJetRNNCfg(flags)) )
173  tools_after.append( acc.popToolsAndMerge(tauTools.TauEleRNNEvaluatorCfg(flags)) )
174  tools_after.append( acc.popToolsAndMerge(tauTools.TauWPDecoratorEleRNNCfg(flags)) )
175  tools_after.append( acc.popToolsAndMerge(tauTools.TauDecayModeNNClassifierCfg(flags)) )
176  TauAODRunnerAlg=CompFactory.getComp("TauAODRunnerAlg")
177  for tool in tools_mod:
178  tool.inAOD = True
179  for tool in tools_after:
180  tool.inAOD = True
181  myTauAODRunnerAlg = TauAODRunnerAlg(
182  name = "MuonRemovalTauAODReRecoAlg",
183  Key_tauOutputContainer = "TauJets_MuonRM",
184  Key_pi0OutputContainer = "TauFinalPi0s_MuonRM",
185  Key_neutralPFOOutputContainer = "TauNeutralParticleFlowObjects_MuonRM",
186  Key_chargedPFOOutputContainer = "TauChargedParticleFlowObjects_MuonRM",
187  Key_hadronicPFOOutputContainer = "TauHadronicParticleFlowObjects_MuonRM",
188  Key_tauTrackOutputContainer = "TauTracks_MuonRM",
189  Key_vertexOutputContainer = "TauSecondaryVertices_MuonRM",
190  modificationTools = tools_mod,
191  officialTools = tools_after
192  )
193  acc.addEventAlgo(myTauAODRunnerAlg)
194  return acc
195 
196 
197 def TauThinningCfg(flags, name, **kwargs):
198  """configure tau thinning"""
199 
200  acc = ComponentAccumulator()
201  TauThinningTool = CompFactory.DerivationFramework.TauThinningTool
202  acc.addPublicTool(TauThinningTool(name, **kwargs), primary=True)
203  return acc
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
TauAnalysisToolsConfig.TauSelectionToolCfg
def TauSelectionToolCfg(ConfigFlags, name, **kwargs)
Definition: TauAnalysisToolsConfig.py:6
python.TauCommonConfig.AddMuonRemovalTauAODReRecoAlgCfg
def AddMuonRemovalTauAODReRecoAlgCfg(flags, **kwargs)
Definition: TauCommonConfig.py:144
DiTauBuilderConfig.DiTauBuilderLowPtCfg
def DiTauBuilderLowPtCfg(flags, name="DiTauLowPtBuilder", **kwargs)
Definition: DiTauBuilderConfig.py:35
python.TauCommonConfig.AddTauAugmentationCfg
def AddTauAugmentationCfg(flags, **kwargs)
Definition: TauCommonConfig.py:6
python.JetRecConfig.JetRecCfg
def JetRecCfg(flags, jetdef, returnConfiguredDef=False)
Top level functions returning ComponentAccumulator out of JetDefinition.
Definition: JetRecConfig.py:36
python.DerivationFrameworkToolsConfig.AsgSelectionToolWrapperCfg
def AsgSelectionToolWrapperCfg(ConfigFlags, name, **kwargs)
Definition: DerivationFrameworkToolsConfig.py:11
python.TauCommonConfig.AddTauIDDecorationCfg
def AddTauIDDecorationCfg(flags, **kwargs)
Definition: TauCommonConfig.py:99
TauAODRunnerAlg
The implementation of the TauAODRunnerAlg, which is meant to run at AOD level.
Definition: TauAODRunnerAlg.h:40
python.TauCommonConfig.TauThinningCfg
def TauThinningCfg(flags, name, **kwargs)
Definition: TauCommonConfig.py:197
python.TauCommonConfig.AddDiTauLowPtCfg
def AddDiTauLowPtCfg(flags, **kwargs)
Definition: TauCommonConfig.py:84