ATLAS Offline Software
Loading...
Searching...
No Matches
DiTauAnalysisConfig.py
Go to the documentation of this file.
1# Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
2
3# AnaAlgorithm import(s):
4from AnalysisAlgorithmsConfig.ConfigBlock import ConfigBlock
5from AnalysisAlgorithmsConfig.ConfigSequence import groupBlocks
6from AnalysisAlgorithmsConfig.ConfigAccumulator import DataType
7
8
9class DiTauCalibrationConfig (ConfigBlock):
10 """the ConfigBlock for the tau four-momentum correction"""
11
12 def __init__ (self) :
13 super (DiTauCalibrationConfig, self).__init__ ()
14 self.setBlockName('DiTaus')
15 self.addOption ('inputContainer', '', type=str,
16 info="the name of the input ditau-jet container.")
17 self.addOption ('containerName', '', type=str,
18 noneAction='error',
19 info="the name of the output container after calibration.")
20 self.addOption ('postfix', '', type=str,
21 info="a postfix to apply to decorations and algorithm names. "
22 "Typically not needed here since the calibration is common to "
23 "all ditau-jets.")
24 self.addOption ('rerunTruthMatching', True, type=bool,
25 info="whether to rerun truth matching (sets up an instance of "
26 "`CP::DiTauTruthMatchingAlg`).")
27 self.addOption ('decorateTruth', False, type=bool,
28 info="decorate the truth particle information on the reconstructed one.")
29 self.addOption ('decorateExtraVariables', True, type=bool,
30 info="decorate extra variables for the reconstructed ditau-jet.")
31
32 def instanceName (self) :
33 """Return the instance name for this block"""
34 return self.containerName + self.postfix
35
36 def makeAlgs (self, config) :
37
38 postfix = self.postfix
39 if postfix != '' and postfix[0] != '_' :
40 postfix = '_' + postfix
41
42 inputContainer = "DiTauJets"
44 inputContainer = self.inputContainer
45 config.setSourceName (self.containerName, inputContainer)
46
47 # Set up the tau truth matching algorithm:
48 if self.rerunTruthMatching and config.dataType() is not DataType.Data:
49 alg = config.createAlgorithm( 'CP::DiTauTruthMatchingAlg',
50 'DiTauTruthMatchingAlg' )
51 config.addPrivateTool( 'matchingTool',
52 'TauAnalysisTools::DiTauTruthMatchingTool' )
53 alg.taus = config.readName (self.containerName)
54 alg.preselection = config.getPreselection (self.containerName, '')
55
56
57 # decorate truth tau information on the reconstructed object:
58 if self.decorateTruth and self.rerunTruthMatching and config.dataType() is not DataType.Data:
59 # in the case of the ditau, the DiTauTruthMatchingTool decorates directly the reco ditau with truth information.
60 # So information can be written directly out without any additional algorithm
61 config.addOutputVar (self.containerName, 'TruthVisLeadPt', 'TruthVisLeadPt', noSys=True)
62 config.addOutputVar (self.containerName, 'TruthVisLeadEta', 'TruthVisLeadEta', noSys=True)
63 config.addOutputVar (self.containerName, 'TruthVisLeadPhi', 'TruthVisLeadPhi', noSys=True)
64 config.addOutputVar (self.containerName, 'TruthVisLeadM', 'TruthVisLeadM', noSys=True)
65 config.addOutputVar (self.containerName, 'TruthLeadPdgID', 'TruthLeadPdgID', noSys=True)
66 config.addOutputVar (self.containerName, 'TruthVisSubleadPt', 'TruthVisSubleadPt', noSys=True)
67 config.addOutputVar (self.containerName, 'TruthVisSubleadEta', 'TruthVisSubleadEta', noSys=True)
68 config.addOutputVar (self.containerName, 'TruthVisSubleadPhi', 'TruthVisSubleadPhi', noSys=True)
69 config.addOutputVar (self.containerName, 'TruthVisSubleadM', 'TruthVisSubleadM', noSys=True)
70 config.addOutputVar (self.containerName, 'TruthSubleadPdgID', 'TruthSubleadPdgID', noSys=True)
71 config.addOutputVar (self.containerName, 'TruthVisDeltaR', 'TruthVisDeltaR', noSys=True)
72 config.addOutputVar (self.containerName, 'TruthVisMass', 'TruthVisMass', noSys=True)
73 config.addOutputVar (self.containerName, 'IsTruthMatched', 'IsTruthMatched', noSys=True)
74 config.addOutputVar (self.containerName, 'IsTruthHadronic', 'IsTruthHadronic', noSys=True)
75
76 # Decorate extra variables
78 alg = config.createAlgorithm( 'CP::DiTauExtraVariablesAlg',
79 'DiTauExtraVariablesAlg',
80 reentrant=True )
81 alg.ditaus = config.readName (self.containerName)
82 config.addOutputVar (self.containerName, 'omniScore', 'omniScore', noSys=True)
83 config.addOutputVar (self.containerName, 'nSubjets', 'nSubjets', noSys=True)
84 config.addOutputVar (self.containerName, 'leadSubjetPt', 'leadSubjetPt', noSys=True)
85 config.addOutputVar (self.containerName, 'leadSubjetEta', 'leadSubjetEta', noSys=True)
86 config.addOutputVar (self.containerName, 'leadSubjetPhi', 'leadSubjetPhi', noSys=True)
87 config.addOutputVar (self.containerName, 'leadSubjetE', 'leadSubjetE', noSys=True)
88 config.addOutputVar (self.containerName, 'leadSubjetNTracks', 'leadSubjetNTracks', noSys=True)
89 config.addOutputVar (self.containerName, 'leadSubjetCharge', 'leadSubjetCharge', noSys=True)
90 config.addOutputVar (self.containerName, 'subleadSubjetPt', 'subleadSubjetPt', noSys=True)
91 config.addOutputVar (self.containerName, 'subleadSubjetEta', 'subleadSubjetEta', noSys=True)
92 config.addOutputVar (self.containerName, 'subleadSubjetPhi', 'subleadSubjetPhi', noSys=True)
93 config.addOutputVar (self.containerName, 'subleadSubjetE', 'subleadSubjetE', noSys=True)
94 config.addOutputVar (self.containerName, 'subleadSubjetNTracks', 'subleadSubjetNTracks', noSys=True)
95 config.addOutputVar (self.containerName, 'subleadSubjetCharge', 'subleadSubjetCharge', noSys=True)
96
97 # Set up the tau 4-momentum smearing algorithm:
98 alg = config.createAlgorithm( 'CP::DiTauSmearingAlg', 'DiTauSmearingAlg' )
99 config.addPrivateTool( 'smearingTool', 'TauAnalysisTools::DiTauSmearingTool' )
100 alg.taus = config.readName (self.containerName)
101 alg.tausOut = config.copyName (self.containerName)
102 alg.preselection = config.getPreselection (self.containerName, '')
103
104 # Save base kinematic ditau variables in output
105 config.addOutputVar (self.containerName, 'pt', 'pt')
106 config.addOutputVar (self.containerName, 'eta', 'eta', noSys=True)
107 config.addOutputVar (self.containerName, 'phi', 'phi', noSys=True)
108 config.addOutputVar (self.containerName, 'm', 'm', noSys=True)
109
110
111
113 """the ConfigBlock for the tau working point selection"""
114
115 def __init__ (self) :
116 super (DiTauWorkingPointSelectionConfig, self).__init__ ()
117 self.setBlockName('DiTauWorkingPointSelection')
118 self.addOption ('containerName', '', type=str,
119 noneAction='error',
120 info="the name of the input container.")
121 self.addOption ('selectionName', '', type=str,
122 noneAction='error',
123 info="the name of the ditau-jet selection to define (e.g. `tight` or "
124 "`loose`).")
125 self.addOption ('postfix', None, type=str,
126 info="a postfix to apply to decorations and algorithm names. "
127 "Typically not needed here as `selectionName` is used internally.")
128 self.addOption ('addSelectionToPreselection', True, type=bool,
129 info="whether to retain only ditau-jets satisfying the working point "
130 "requirements.")
131
132 def instanceName (self) :
133 """Return the instance name for this block"""
134 if self.postfix is not None:
135 return self.containerName + '_' + self.selectionName + self.postfix
136 else:
137 return self.containerName + '_' + self.selectionName
138
139 def makeAlgs (self, config) :
140
141 selectionPostfix = self.selectionName
142 if selectionPostfix != '' and selectionPostfix[0] != '_' :
143 selectionPostfix = '_' + selectionPostfix
144
145 postfix = self.postfix
146 if postfix is None :
147 postfix = self.selectionName
148 if postfix != '' and postfix[0] != '_' :
149 postfix = '_' + postfix
150
151 inputfile = 'TauAnalysisAlgorithms/ditau_selection_highpt.conf'
152 if "DiTauJetsLowPt" in self.containerName:
153 inputfile = 'TauAnalysisAlgorithms/ditau_selection_lowpt.conf'
154
155 # Set up the algorithm selecting taus:
156 alg = config.createAlgorithm( 'CP::AsgSelectionAlg', 'DiTauSelectionAlg' )
157 config.addPrivateTool( 'selectionTool', 'TauAnalysisTools::DiTauSelectionTool' )
158 alg.selectionTool.ConfigPath = inputfile
159 alg.selectionDecoration = 'selected_ditau' + selectionPostfix + ',as_char'
160 alg.particles = config.readName (self.containerName)
161 alg.preselection = config.getPreselection (self.containerName, self.selectionName)
162 config.addSelection (self.containerName, self.selectionName, alg.selectionDecoration,
163 preselection=self.addSelectionToPreselection)
164
165
167 """the ConfigBlock for the tau working point efficiency computation"""
168
169 def __init__ (self) :
170 super (DiTauWorkingPointEfficiencyConfig, self).__init__ ()
171 self.setBlockName('DiTauWorkingPointEfficiency')
172 self.addDependency('DiTauWorkingPointSelection', required=True)
173 self.addDependency('EventSelection', required=False)
174 self.addDependency('EventSelectionMerger', required=False)
175 self.addOption ('containerName', '', type=str,
176 noneAction='error',
177 info="the name of the input container.")
178 self.addOption ('selectionName', '', type=str,
179 noneAction='error',
180 info="the name of the ditau-jet selection to define (e.g. `tight` or "
181 "`loose`).")
182 self.addOption ('postfix', None, type=str,
183 info="a postfix to apply to decorations and algorithm names. "
184 "Typically not needed here as `selectionName` is used internally.")
185
186 def instanceName (self) :
187 """Return the instance name for this block"""
188 if self.postfix is not None:
189 return self.containerName + '_' + self.selectionName + self.postfix
190 else:
191 return self.containerName + '_' + self.selectionName
192
193 def makeAlgs (self, config) :
194
195 selectionPostfix = self.selectionName
196 if selectionPostfix != '' and selectionPostfix[0] != '_' :
197 selectionPostfix = '_' + selectionPostfix
198
199 postfix = self.postfix
200 if postfix is None :
201 postfix = self.selectionName
202 if postfix != '' and postfix[0] != '_' :
203 postfix = '_' + postfix
204
205
206 # keep this commented out until TauCP won't provide official recommendations
207 # Set up the algorithm calculating the efficiency scale factors for the
208 # taus:
209 #if config.dataType() is not DataType.Data:
210 # alg = config.createAlgorithm( 'CP::DiTauEfficiencyCorrectionsAlg',
211 # 'DiTauEfficiencyCorrectionsAlg' )
212 # config.addPrivateTool( 'efficiencyCorrectionsTool',
213 # 'TauAnalysisTools::DiTauEfficiencyCorrectionsTool' )
214 # alg.efficiencyCorrectionsTool.JetIDLevel = IDLevel
215 # alg.scaleFactorDecoration = 'tau_effSF' + postfix + '_%SYS%'
216 # # alg.outOfValidity = 2 #silent
217 # # alg.outOfValidityDeco = "bad_eff"
218 # alg.taus = config.readName (self.containerName)
219 # alg.preselection = config.getPreselection (self.containerName, self.selectionName)
220 # config.addOutputVar (self.containerName, alg.scaleFactorDecoration,
221 # 'effSF' + postfix)
222
223
224@groupBlocks