ATLAS Offline Software
Loading...
Searching...
No Matches
python.TauAnalysisConfig.TauWorkingPointSelectionConfig Class Reference
Inheritance diagram for python.TauAnalysisConfig.TauWorkingPointSelectionConfig:
Collaboration diagram for python.TauAnalysisConfig.TauWorkingPointSelectionConfig:

Public Member Functions

 __init__ (self)
 instanceName (self)
 makeAlgs (self, config)

Public Attributes

 useSelectionConfigFile
 dropPtCut
 useLowPt
 useGNTau
 use_eVeto
 use_muonOLR
str manual_sel_rnnwp = "veryloose":
str manual_sel_gntauwp = "veryloose":
str manual_sel_evetowp = "loose":
 containerName
 selectionName

Detailed Description

the ConfigBlock for the tau working point selection

Definition at line 142 of file TauAnalysisConfig.py.

Constructor & Destructor Documentation

◆ __init__()

python.TauAnalysisConfig.TauWorkingPointSelectionConfig.__init__ ( self)

Definition at line 145 of file TauAnalysisConfig.py.

145 def __init__ (self) :
146 super (TauWorkingPointSelectionConfig, self).__init__ ()
147 self.setBlockName('TauWorkingPointSelection')
148 self.addOption ('containerName', '', type=str,
149 noneAction='error',
150 info="the name of the input container.")
151 self.addOption ('selectionName', '', type=str,
152 noneAction='error',
153 info="the name of the tau-jet selection to define (e.g. `tight` or "
154 "`loose`).")
155 self.addOption ('postfix', None, type=str,
156 info="a postfix to apply to decorations and algorithm names. "
157 "Typically not needed here as selectionName is used internally.")
158 self.addOption ('quality', None, type=str,
159 info="the ID WP to use. Supported ID WPs: `Tight`, `Medium`, "
160 "`Loose`, `VeryLoose`, `Baseline`, `BaselineForFakes`.")
161 self.addOption ('use_eVeto', False, type=bool,
162 info="use selection with or without eVeto combined with TauID. "
163 "Recommendations: set it to `True` if electrons mis-reconstructed as tau-jets are a large background for your analysis.")
164 self.addOption ('use_muonOLR', False, type=bool,
165 info="use selection with or without muonOLR with TauID. "
166 "Recommendations: set it to `True` if muons mis-reconstructed as tau-jets are a large background for your analysis.")
167 self.addOption ('useGNTau', False, type=bool,
168 info="use GNTau-based ID instead of RNNTau ID. "
169 "Recommendations: experimental feature and might become default soon.",
170 expertMode=True)
171 self.addOption ('dropPtCut', False, type=bool,
172 info=r"select tau-jets without an explicit minimum $p_\mathrm{T}$ cut. For PHYS/PHYSLITE, this would mean selecting tau-jets starting from 13 GeV. "
173 "Recommendations: experimental feature and not supported for all combinations of ID/eVeto WPs.",
174 expertMode=True)
175 self.addOption ('useLowPt', False, type=bool,
176 info="select taus starting from 15 GeV instead of the default 20 GeV cut "
177 "recommendations: experimental feature and not supported for all combinations of ID/eVeto WPs.",
178 expertMode=True)
179 self.addOption ('useSelectionConfigFile', True, type=bool,
180 info="use pre-defined configuration files for selecting tau-jets. "
181 "Recommendations: set this to `False` only if you want to test/optimise the tau-jet selection for selections not already provided through config files.")
182 self.addOption ('manual_sel_minpt', 20.0, type=float,
183 info=r"minimum $p_\mathrm{T}$ cut (in GeV) used for tau-jet selection when `useSelectionConfigFile` is set to `False`.")
184 self.addOption ('manual_sel_absetaregion', [0, 1.37, 1.52, 2.5], type=list,
185 info=r"$\vert\eta\vert$ regions cut used for tau-jet selection when `useSelectionConfigFile` is set to `False`.")
186 self.addOption ('manual_sel_abscharges', [1,], type=list,
187 info="charge of the tau-jet cut used for tau-jet selection when `useSelectionConfigFile` is set to `False`.")
188 self.addOption ('manual_sel_ntracks', [1,3], type=list,
189 info="number of tau-jet tracks used for tau-jet selection when `useSelectionConfigFile` is set to `False`.")
190 self.addOption ('manual_sel_minrnnscore', -1, type=float,
191 info="minimum RNN score cut used for tau-jet selection when `useSelectionConfigFile` is set to `False`.")
192 self.addOption ('manual_sel_mingntauscore', -1, type=float,
193 info="minimum GNTau score selection when `useSelectionConfigFile` is set to `False`.")
194 self.addOption ('manual_sel_rnnwp', None, type=str,
195 info="RNN working point used for tau-jet selection when `useSelectionConfigFile` is set to `False`.")
196 self.addOption ('manual_sel_gntauwp', None, type=str,
197 info="GNTau working point used for tau-jet selection when `useSelectionConfigFile` is set to `False`.")
198 self.addOption ('manual_sel_evetowp', None, type=str,
199 info="eveto working point used for tau-jet selection when `useSelectionConfigFile` is set to `False`.")
200 self.addOption ('manual_sel_muonolr', False, type=bool,
201 info="use `muonolr` for tau-jet selection when `useSelectionConfigFile` is set to `False`.")
202 self.addOption ('addSelectionToPreselection', True, type=bool,
203 info="whether to retain only tau-jets satisfying the working point "
204 "requirements.")
205

Member Function Documentation

◆ instanceName()

python.TauAnalysisConfig.TauWorkingPointSelectionConfig.instanceName ( self)
Return the instance name for this block

Definition at line 206 of file TauAnalysisConfig.py.

206 def instanceName (self) :
207 """Return the instance name for this block"""
208 if self.postfix is not None:
209 return self.containerName + '_' + self.selectionName + self.postfix
210 else:
211 return self.containerName + '_' + self.selectionName
212

◆ makeAlgs()

python.TauAnalysisConfig.TauWorkingPointSelectionConfig.makeAlgs ( self,
config )

Definition at line 213 of file TauAnalysisConfig.py.

213 def makeAlgs (self, config) :
214
215 selectionPostfix = self.selectionName
216 if selectionPostfix != '' and selectionPostfix[0] != '_' :
217 selectionPostfix = '_' + selectionPostfix
218
219 postfix = self.postfix
220 if postfix is None :
221 postfix = self.selectionName
222 if postfix != '' and postfix[0] != '_' :
223 postfix = '_' + postfix
224
225 # do tau seletion through external txt config file
226 if self.useSelectionConfigFile:
227 nameFormat = 'TauAnalysisAlgorithms/tau_selection_'
228 if self.dropPtCut:
229 nameFormat = nameFormat + 'nopt_'
230 if self.useLowPt:
231 nameFormat = nameFormat + 'lowpt_'
232 if self.useGNTau:
233 nameFormat = nameFormat + 'gntau_'
234 nameFormat = nameFormat + '{}_'
235 if self.use_eVeto:
236 nameFormat = nameFormat + 'eleid'
237 else:
238 nameFormat = nameFormat + 'noeleid'
239 if self.use_muonOLR:
240 nameFormat = nameFormat + '_muonolr'
241 nameFormat = nameFormat + '.conf'
242
243 if self.quality not in ['Tight', 'Medium', 'Loose', 'VeryLoose', 'Baseline', 'BaselineForFakes'] :
244 raise ValueError ("invalid tau quality: \"" + self.quality +
245 "\", allowed values are Tight, Medium, Loose, " +
246 "VeryLoose, Baseline, BaselineForFakes")
247
248 # Set up the algorithm selecting taus:
249 alg = config.createAlgorithm( 'CP::AsgSelectionAlg', 'TauSelectionAlg' )
250 config.addPrivateTool( 'selectionTool', 'TauAnalysisTools::TauSelectionTool' )
251 alg.selectionTool.TauContainerName = config.readName (self.containerName, nominal=True)
252 if self.useSelectionConfigFile:
253 inputfile = nameFormat.format(self.quality.lower())
254 alg.selectionTool.ConfigPath = inputfile
255 else:
256 #build selection from user handmade selection
257 from ROOT import TauAnalysisTools
258 selectioncuts = TauAnalysisTools.SelectionCuts
259 alg.selectionTool.ConfigPath = ""
260 alg.selectionTool.SelectionCuts = int(selectioncuts.CutPt |
261 selectioncuts.CutAbsEta |
262 selectioncuts.CutAbsCharge |
263 selectioncuts.CutNTrack |
264 selectioncuts.CutJetRNNScoreSigTrans |
265 selectioncuts.CutGNTauScoreSigTrans |
266 selectioncuts.CutJetIDWP |
267 selectioncuts.CutEleIDWP |
268 selectioncuts.CutMuonOLR)
269
270 alg.selectionTool.PtMin = self.manual_sel_minpt
271 alg.selectionTool.AbsEtaRegion = self.manual_sel_absetaregion
272 alg.selectionTool.AbsCharges = self.manual_sel_abscharges
273 alg.selectionTool.NTracks = self.manual_sel_ntracks
274 alg.selectionTool.JetRNNSigTransMin = self.manual_sel_minrnnscore
275 alg.selectionTool.GNTauSigTransMin = self.manual_sel_mingntauscore
276 #cross-check that min rnn score and min gntau score are not both set at the same time
277 if self.manual_sel_minrnnscore != -1 and self.manual_sel_mingntauscore != -1:
278 raise RuntimeError("manual_sel_minrnnscore and manual_sel_mingntauscore have been both set; please choose only one type of ID: RNN or GNTau, not both")
279 # working point following the Enums from https://gitlab.cern.ch/atlas/athena/-/blob/main/PhysicsAnalysis/TauID/TauAnalysisTools/TauAnalysisTools/Enums.h
280 if self.manual_sel_rnnwp is None:
281 alg.selectionTool.JetIDWP = 1
282 elif self.manual_sel_rnnwp == "veryloose":
283 alg.selectionTool.JetIDWP = 6
284 elif self.manual_sel_rnnwp == "loose":
285 alg.selectionTool.JetIDWP = 7
286 elif self.manual_sel_rnnwp == "medium":
287 alg.selectionTool.JetIDWP = 8
288 elif self.manual_sel_rnnwp == "tight":
289 alg.selectionTool.JetIDWP = 9
290 else:
291 raise ValueError ("invalid RNN TauID WP: \"" + self.manual_sel_rnnwp + "\". Allowed values are None, veryloose, loose, medium, tight")
292
293 # cross-check that min rnn score and RNN WPs are not set at the same time
294 if self.manual_sel_minrnnscore != -1 and self.manual_sel_rnnwp is not None:
295 raise RuntimeError("manual_sel_minrnnscore and manual_sel_rnnwp have been both set; please set only one of them")
296
297 # working point following the Enums from https://gitlab.cern.ch/atlas/athena/-/blob/main/PhysicsAnalysis/TauID/TauAnalysisTools/TauAnalysisTools/Enums.h
298 if self.manual_sel_gntauwp is None:
299 alg.selectionTool.JetIDWP = 1
300 elif self.manual_sel_gntauwp == "veryloose":
301 alg.selectionTool.JetIDWP = 10
302 elif self.manual_sel_gntauwp == "loose":
303 alg.selectionTool.JetIDWP = 11
304 elif self.manual_sel_gntauwp == "medium":
305 alg.selectionTool.JetIDWP = 12
306 elif self.manual_sel_gntauwp == "tight":
307 alg.selectionTool.JetIDWP = 13
308 else:
309 raise ValueError ("invalid GNN Tau ID WP: \"" + self.manual_sel_gntauwp + "\". Allowed values are None, veryloose, loose, medium, tight")
310
311 # cross-check that min gntau score and GNTau WPs are not set at the same time
312 if self.manual_sel_mingntauscore != -1 and self.manual_sel_gntauwp is not None:
313 raise RuntimeError("manual_sel_mingntauscore and manual_sel_gntauwp have been both set; please set only one of them")
314
315 # working point following the Enums from https://gitlab.cern.ch/atlas/athena/-/blob/main/PhysicsAnalysis/TauID/TauAnalysisTools/TauAnalysisTools/Enums.h
316 if self.manual_sel_evetowp is None:
317 alg.selectionTool.EleIDWP = 1
318 elif self.manual_sel_evetowp == "loose":
319 alg.selectionTool.EleIDWP = 2
320 elif self.manual_sel_evetowp == "medium":
321 alg.selectionTool.EleIDWP = 3
322 elif self.manual_sel_evetowp == "tight":
323 alg.selectionTool.EleIDWP = 4
324 else:
325 raise ValueError ("invalid eVeto WP: \"" + self.manual_sel_evetowp + "\". Allowed values are None, loose, medium, tight")
326
327 # set MuonOLR option:
328 alg.selectionTool.MuonOLR = self.manual_sel_muonolr
329
330 alg.selectionDecoration = 'selected_tau' + selectionPostfix + ',as_char'
331 alg.particles = config.readName (self.containerName)
332 alg.preselection = config.getPreselection (self.containerName, self.selectionName)
333 config.addSelection (self.containerName, self.selectionName, alg.selectionDecoration,
334 preselection=self.addSelectionToPreselection)
335
336

Member Data Documentation

◆ containerName

python.TauAnalysisConfig.TauWorkingPointSelectionConfig.containerName

Definition at line 333 of file TauAnalysisConfig.py.

◆ dropPtCut

python.TauAnalysisConfig.TauWorkingPointSelectionConfig.dropPtCut

Definition at line 228 of file TauAnalysisConfig.py.

◆ manual_sel_evetowp

str python.TauAnalysisConfig.TauWorkingPointSelectionConfig.manual_sel_evetowp = "loose":

Definition at line 318 of file TauAnalysisConfig.py.

◆ manual_sel_gntauwp

str python.TauAnalysisConfig.TauWorkingPointSelectionConfig.manual_sel_gntauwp = "veryloose":

Definition at line 300 of file TauAnalysisConfig.py.

◆ manual_sel_rnnwp

str python.TauAnalysisConfig.TauWorkingPointSelectionConfig.manual_sel_rnnwp = "veryloose":

Definition at line 282 of file TauAnalysisConfig.py.

◆ selectionName

python.TauAnalysisConfig.TauWorkingPointSelectionConfig.selectionName

Definition at line 333 of file TauAnalysisConfig.py.

◆ use_eVeto

python.TauAnalysisConfig.TauWorkingPointSelectionConfig.use_eVeto

Definition at line 235 of file TauAnalysisConfig.py.

◆ use_muonOLR

python.TauAnalysisConfig.TauWorkingPointSelectionConfig.use_muonOLR

Definition at line 239 of file TauAnalysisConfig.py.

◆ useGNTau

python.TauAnalysisConfig.TauWorkingPointSelectionConfig.useGNTau

Definition at line 232 of file TauAnalysisConfig.py.

◆ useLowPt

python.TauAnalysisConfig.TauWorkingPointSelectionConfig.useLowPt

Definition at line 230 of file TauAnalysisConfig.py.

◆ useSelectionConfigFile

python.TauAnalysisConfig.TauWorkingPointSelectionConfig.useSelectionConfigFile

Definition at line 226 of file TauAnalysisConfig.py.


The documentation for this class was generated from the following file: