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
 useLowPt
 useGNTau
 dropPtCut
 use_eVeto
 use_muonOLR
 containerName
 selectionName

Detailed Description

the ConfigBlock for the tau working point selection

Definition at line 169 of file TauAnalysisConfig.py.

Constructor & Destructor Documentation

◆ __init__()

python.TauAnalysisConfig.TauWorkingPointSelectionConfig.__init__ ( self)

Definition at line 172 of file TauAnalysisConfig.py.

172 def __init__ (self) :
173 super().__init__()
174 self.setBlockName('TauWorkingPointSelection')
175 self.addOption ('containerName', '', type=str,
176 noneAction='error',
177 info="the name of the input container.",
178 meta={'role':'containerRef'})
179 self.addOption ('selectionName', '', type=str,
180 noneAction='error',
181 info="the name of the tau-jet selection to define (e.g. `tight` or "
182 "`loose`).",
183 meta={'role':'selection'})
184 self.addOption ('postfix', None, type=str,
185 info="a postfix to apply to decorations and algorithm names. "
186 "Typically not needed here as selectionName is used internally.")
187 self.addOption ('quality', None, type=str,
188 info="the ID WP to use. Supported ID WPs: `Tight`, `Medium`, "
189 "`Loose`, `VeryLoose`, `Baseline`, `BaselineForFakes`.",
190 meta={'choices':(['Tight','Medium','Loose','VeryLoose','Baseline','BaselineForFakes'],1)})
191 self.addOption ('use_eVeto', False, type=bool,
192 info="use selection with or without eVeto combined with TauID. "
193 "Recommendations: set it to `True` if electrons mis-reconstructed as tau-jets are a large background for your analysis.")
194 self.addOption ('use_muonOLR', False, type=bool,
195 info="use selection with or without muonOLR with TauID. "
196 "Recommendations: set it to `True` if muons mis-reconstructed as tau-jets are a large background for your analysis.")
197 self.addOption ('useGNTau', False, type=bool,
198 info="use GNTau-based ID instead of RNNTau ID. "
199 "Recommendations: experimental feature and might become default soon.",
200 expertMode=True)
201 self.addOption ('dropPtCut', False, type=bool,
202 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. "
203 "Recommendations: experimental feature and not supported for all combinations of ID/eVeto WPs.",
204 expertMode=True)
205 self.addOption ('useLowPt', False, type=bool,
206 info="select taus starting from 15 GeV instead of the default 20 GeV cut "
207 "recommendations: experimental feature and not supported for all combinations of ID/eVeto WPs.",
208 expertMode=True)
209 self.addOption ('useSelectionConfigFile', True, type=bool,
210 info="use pre-defined configuration files for selecting tau-jets. "
211 "Recommendations: set this to `False` only if you want to test/optimise the tau-jet selection for selections not already provided through config files.")
212 self.addOption ('manual_sel_minpt', 20.0, type=float,
213 info=r"minimum $p_\mathrm{T}$ cut (in GeV) used for tau-jet selection when `useSelectionConfigFile` is set to `False`.")
214 self.addOption ('manual_sel_absetaregion', [0, 1.37, 1.52, 2.5], type=list,
215 info=r"$\vert\eta\vert$ regions cut used for tau-jet selection when `useSelectionConfigFile` is set to `False`.")
216 self.addOption ('manual_sel_abscharges', [1,], type=list,
217 info="charge of the tau-jet cut used for tau-jet selection when `useSelectionConfigFile` is set to `False`.")
218 self.addOption ('manual_sel_ntracks', [1,3], type=list,
219 info="number of tau-jet tracks used for tau-jet selection when `useSelectionConfigFile` is set to `False`.")
220 self.addOption ('manual_sel_minrnnscore', -1, type=float,
221 info="minimum RNN score cut used for tau-jet selection when `useSelectionConfigFile` is set to `False`.")
222 self.addOption ('manual_sel_mingntauscore', -1, type=float,
223 info="minimum GNTau score selection when `useSelectionConfigFile` is set to `False`.")
224 self.addOption ('manual_sel_rnnwp', None, type=str,
225 info="RNN working point used for tau-jet selection when `useSelectionConfigFile` is set to `False`.")
226 self.addOption ('manual_sel_gntauwp', None, type=str,
227 info="GNTau working point used for tau-jet selection when `useSelectionConfigFile` is set to `False`.")
228 self.addOption ('manual_sel_evetowp', None, type=str,
229 info="eveto working point used for tau-jet selection when `useSelectionConfigFile` is set to `False`.")
230 self.addOption ('manual_sel_muonolr', False, type=bool,
231 info="use `muonolr` for tau-jet selection when `useSelectionConfigFile` is set to `False`.")
232 self.addOption ('addSelectionToPreselection', True, type=bool,
233 info="whether to retain only tau-jets satisfying the working point "
234 "requirements.")
235

Member Function Documentation

◆ instanceName()

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

Definition at line 236 of file TauAnalysisConfig.py.

236 def instanceName (self) :
237 """Return the instance name for this block"""
238 if self.postfix is not None:
239 return self.containerName + '_' + self.selectionName + self.postfix
240 else:
241 return self.containerName + '_' + self.selectionName
242

◆ makeAlgs()

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

Definition at line 243 of file TauAnalysisConfig.py.

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

Member Data Documentation

◆ containerName

python.TauAnalysisConfig.TauWorkingPointSelectionConfig.containerName

Definition at line 349 of file TauAnalysisConfig.py.

◆ dropPtCut

python.TauAnalysisConfig.TauWorkingPointSelectionConfig.dropPtCut

Definition at line 262 of file TauAnalysisConfig.py.

◆ selectionName

python.TauAnalysisConfig.TauWorkingPointSelectionConfig.selectionName

Definition at line 349 of file TauAnalysisConfig.py.

◆ use_eVeto

python.TauAnalysisConfig.TauWorkingPointSelectionConfig.use_eVeto

Definition at line 269 of file TauAnalysisConfig.py.

◆ use_muonOLR

python.TauAnalysisConfig.TauWorkingPointSelectionConfig.use_muonOLR

Definition at line 273 of file TauAnalysisConfig.py.

◆ useGNTau

python.TauAnalysisConfig.TauWorkingPointSelectionConfig.useGNTau

Definition at line 259 of file TauAnalysisConfig.py.

◆ useLowPt

python.TauAnalysisConfig.TauWorkingPointSelectionConfig.useLowPt

Definition at line 257 of file TauAnalysisConfig.py.

◆ useSelectionConfigFile

python.TauAnalysisConfig.TauWorkingPointSelectionConfig.useSelectionConfigFile

Definition at line 256 of file TauAnalysisConfig.py.


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