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 171 of file TauAnalysisConfig.py.

Constructor & Destructor Documentation

◆ __init__()

python.TauAnalysisConfig.TauWorkingPointSelectionConfig.__init__ ( self)

Definition at line 174 of file TauAnalysisConfig.py.

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

Member Function Documentation

◆ instanceName()

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

Definition at line 238 of file TauAnalysisConfig.py.

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

◆ makeAlgs()

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

Definition at line 245 of file TauAnalysisConfig.py.

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

Member Data Documentation

◆ containerName

python.TauAnalysisConfig.TauWorkingPointSelectionConfig.containerName

Definition at line 351 of file TauAnalysisConfig.py.

◆ dropPtCut

python.TauAnalysisConfig.TauWorkingPointSelectionConfig.dropPtCut

Definition at line 264 of file TauAnalysisConfig.py.

◆ selectionName

python.TauAnalysisConfig.TauWorkingPointSelectionConfig.selectionName

Definition at line 351 of file TauAnalysisConfig.py.

◆ use_eVeto

python.TauAnalysisConfig.TauWorkingPointSelectionConfig.use_eVeto

Definition at line 271 of file TauAnalysisConfig.py.

◆ use_muonOLR

python.TauAnalysisConfig.TauWorkingPointSelectionConfig.use_muonOLR

Definition at line 275 of file TauAnalysisConfig.py.

◆ useGNTau

python.TauAnalysisConfig.TauWorkingPointSelectionConfig.useGNTau

Definition at line 261 of file TauAnalysisConfig.py.

◆ useLowPt

python.TauAnalysisConfig.TauWorkingPointSelectionConfig.useLowPt

Definition at line 259 of file TauAnalysisConfig.py.

◆ useSelectionConfigFile

python.TauAnalysisConfig.TauWorkingPointSelectionConfig.useSelectionConfigFile

Definition at line 258 of file TauAnalysisConfig.py.


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