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

Constructor & Destructor Documentation

◆ __init__()

python.TauAnalysisConfig.TauWorkingPointSelectionConfig.__init__ ( self)

Definition at line 152 of file TauAnalysisConfig.py.

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

Member Function Documentation

◆ instanceName()

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

Definition at line 213 of file TauAnalysisConfig.py.

213 def instanceName (self) :
214 """Return the instance name for this block"""
215 if self.postfix is not None:
216 return self.containerName + '_' + self.selectionName + self.postfix
217 else:
218 return self.containerName + '_' + self.selectionName
219

◆ makeAlgs()

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

Definition at line 220 of file TauAnalysisConfig.py.

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

Member Data Documentation

◆ containerName

python.TauAnalysisConfig.TauWorkingPointSelectionConfig.containerName

Definition at line 340 of file TauAnalysisConfig.py.

◆ dropPtCut

python.TauAnalysisConfig.TauWorkingPointSelectionConfig.dropPtCut

Definition at line 235 of file TauAnalysisConfig.py.

◆ manual_sel_evetowp

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

Definition at line 325 of file TauAnalysisConfig.py.

◆ manual_sel_gntauwp

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

Definition at line 307 of file TauAnalysisConfig.py.

◆ manual_sel_rnnwp

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

Definition at line 289 of file TauAnalysisConfig.py.

◆ selectionName

python.TauAnalysisConfig.TauWorkingPointSelectionConfig.selectionName

Definition at line 340 of file TauAnalysisConfig.py.

◆ use_eVeto

python.TauAnalysisConfig.TauWorkingPointSelectionConfig.use_eVeto

Definition at line 242 of file TauAnalysisConfig.py.

◆ use_muonOLR

python.TauAnalysisConfig.TauWorkingPointSelectionConfig.use_muonOLR

Definition at line 246 of file TauAnalysisConfig.py.

◆ useGNTau

python.TauAnalysisConfig.TauWorkingPointSelectionConfig.useGNTau

Definition at line 239 of file TauAnalysisConfig.py.

◆ useLowPt

python.TauAnalysisConfig.TauWorkingPointSelectionConfig.useLowPt

Definition at line 237 of file TauAnalysisConfig.py.

◆ useSelectionConfigFile

python.TauAnalysisConfig.TauWorkingPointSelectionConfig.useSelectionConfigFile

Definition at line 233 of file TauAnalysisConfig.py.


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