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

Public Member Functions

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

Public Attributes

str quality = 'Tight' :
 trackSelection
 containerName
 selectionName
 onlyRecoEffSF
 saveDetailedSF
 noEffSF
 saveCombinedSF

Detailed Description

the ConfigBlock for the muon working point

This may at some point be split into multiple blocks (10 Mar 22).

Definition at line 161 of file MuonAnalysisConfig.py.

Constructor & Destructor Documentation

◆ __init__()

python.MuonAnalysisConfig.MuonWorkingPointConfig.__init__ ( self)

Definition at line 166 of file MuonAnalysisConfig.py.

166 def __init__ (self) :
167 super (MuonWorkingPointConfig, self).__init__ ()
168 self.setBlockName('MuonsWorkingPoint')
169 self.addOption ('containerName', '', type=str,
170 noneAction='error',
171 info="the name of the input container.")
172 self.addOption ('selectionName', '', type=str,
173 noneAction='error',
174 info="the name of the muon selection to define (e.g. `tight` or `loose`).")
175 self.addOption ('postfix', None, type=str,
176 info="a postfix to apply to decorations and algorithm names. "
177 "Typically not needed here as selectionName is used internally.")
178 self.addOption ('trackSelection', True, type=bool,
179 info="whether or not to set up an instance of "
180 "`CP::AsgLeptonTrackSelectionAlg`, with the recommended $d_0$ and "
181 r"$z_0\sin\theta$ cuts.")
182 self.addOption ('maxD0Significance', 3, type=float,
183 info="maximum $d_0$ significance used for the track selection.")
184 self.addOption ('maxDeltaZ0SinTheta', 0.5, type=float,
185 info=r"maximum $\Delta z_0\sin\theta$ in mm used for the track selection.")
186 self.addOption ('quality', None, type=str,
187 info="the ID WP to use. Supported ID WPs: `Tight`, `Medium`, "
188 "`Loose`, `LowPt`, `HighPt`.")
189 self.addOption ('isolation', None, type=str,
190 info="the isolation WP to use. Supported isolation WPs: "
191 "`PflowLoose_VarRad`, `PflowTight_VarRad`, `Loose_VarRad`, "
192 "`Tight_VarRad`, `NonIso`.")
193 self.addOption ('addSelectionToPreselection', True, type=bool,
194 info="whether to retain only muons satisfying the working point "
195 "requirements")
196 self.addOption ('isoDecSuffix', '', type=str,
197 info="the `isoDecSuffix` name if using close-by-corrected isolation working points.")
198 self.addOption ('systematicBreakdown', False, type=bool,
199 info="enables the full breakdown of efficiency SF systematics "
200 "(1 NP per uncertainty source, instead of 1 NP in total).")
201 self.addOption ('noEffSF', False, type=bool,
202 info="disables the calculation of efficiencies and scale factors. "
203 "Experimental! Only useful to test a new WP for which scale "
204 "factors are not available.",
205 expertMode=True)
206 self.addOption ('onlyRecoEffSF', False, type=bool,
207 info="same as `noEffSF`, but retains the ID scale factor. "
208 "Experimental! Only useful for CI tests.",
209 expertMode=True)
210 self.addOption ('saveDetailedSF', True, type=bool,
211 info="save all the independent detailed object scale factors.")
212 self.addOption ('saveCombinedSF', False, type=bool,
213 info="save the combined object scale factor.")
214 self.addOption ('excludeNSWFromPrecisionLayers', False, type=bool,
215 info="only for testing purposes, turn on to ignore NSW hits and "
216 "fix a crash with older derivations (p-tag <p5834).")
217

Member Function Documentation

◆ instanceName()

python.MuonAnalysisConfig.MuonWorkingPointConfig.instanceName ( self)

Definition at line 218 of file MuonAnalysisConfig.py.

218 def instanceName (self) :
219 if self.postfix is not None:
220 return self.containerName + '_' + self.postfix
221 else:
222 return self.containerName + '_' + self.selectionName
223

◆ makeAlgs()

python.MuonAnalysisConfig.MuonWorkingPointConfig.makeAlgs ( self,
config )

Definition at line 224 of file MuonAnalysisConfig.py.

224 def makeAlgs (self, config) :
225 log = logging.getLogger('MuonWorkingPointConfig')
226
227 from xAODMuon.xAODMuonEnums import xAODMuonEnums
228 if self.quality == 'Tight' :
229 quality = xAODMuonEnums.Quality.Tight
230 elif self.quality == 'Medium' :
231 quality = xAODMuonEnums.Quality.Medium
232 elif self.quality == 'Loose' :
233 quality = xAODMuonEnums.Quality.Loose
234 elif self.quality == 'VeryLoose' :
235 quality = xAODMuonEnums.Quality.VeryLoose
236 elif self.quality == 'HighPt' :
237 quality = 4
238 elif self.quality == 'LowPt' :
239 quality = 5
240 else :
241 raise ValueError ("invalid muon quality: \"" + self.quality +
242 "\", allowed values are Tight, Medium, Loose, " +
243 "VeryLoose, HighPt, LowPt")
244
245 # The setup below is inappropriate for Run 1
246 if config.geometry() is LHCPeriod.Run1:
247 raise ValueError ("Can't set up the MuonWorkingPointConfig with %s, there must be something wrong!" % config.geometry().value)
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 # Set up the track selection algorithm:
256 if self.trackSelection:
257 alg = config.createAlgorithm( 'CP::AsgLeptonTrackSelectionAlg',
258 'MuonTrackSelectionAlg',
259 reentrant=True )
260 alg.selectionDecoration = 'trackSelection' + postfix + ',as_bits'
261 alg.maxD0Significance = self.maxD0Significance
262 alg.maxDeltaZ0SinTheta = self.maxDeltaZ0SinTheta
263 alg.particles = config.readName (self.containerName)
264 alg.preselection = config.getPreselection (self.containerName, '')
265 config.addSelection (self.containerName, self.selectionName, alg.selectionDecoration, preselection=self.addSelectionToPreselection)
266
267 # Setup the muon quality selection
268 alg = config.createAlgorithm( 'CP::MuonSelectionAlgV2',
269 'MuonSelectionAlg' )
270 config.addPrivateTool( 'selectionTool', 'CP::MuonSelectionTool' )
271 alg.selectionTool.MuQuality = quality
272 alg.selectionTool.IsRun3Geo = config.geometry() >= LHCPeriod.Run3
273 if config.geometry() is LHCPeriod.Run4:
274 log.warning("Disabling NSW hits for Run4 geometry")
275 alg.selectionTool.ExcludeNSWFromPrecisionLayers = True
276 else:
277 alg.selectionTool.ExcludeNSWFromPrecisionLayers = self.excludeNSWFromPrecisionLayers and (config.geometry() >= LHCPeriod.Run3)
278 alg.selectionDecoration = 'good_muon' + postfix + ',as_char'
279 alg.badMuonVetoDecoration = 'is_bad' + postfix + ',as_char'
280 alg.muons = config.readName (self.containerName)
281 alg.preselection = config.getPreselection (self.containerName, self.selectionName)
282 config.addSelection (self.containerName, self.selectionName,
283 alg.selectionDecoration,
284 preselection=self.addSelectionToPreselection)
285 if self.quality == 'HighPt':
286 config.addOutputVar (self.containerName, 'is_bad' + postfix, 'is_bad' + postfix)
287
288 # Set up the isolation calculation algorithm:
289 if self.isolation != 'NonIso' :
290 alg = config.createAlgorithm( 'CP::MuonIsolationAlg',
291 'MuonIsolationAlg' )
292 config.addPrivateTool( 'isolationTool', 'CP::IsolationSelectionTool' )
293 alg.isolationTool.MuonWP = self.isolation
294 alg.isolationTool.IsoDecSuffix = self.isoDecSuffix
295 alg.isolationDecoration = 'isolated_muon' + postfix + ',as_char'
296 alg.muons = config.readName (self.containerName)
297 alg.preselection = config.getPreselection (self.containerName, self.selectionName)
298 config.addSelection (self.containerName, self.selectionName,
299 alg.isolationDecoration,
300 preselection=self.addSelectionToPreselection)
301
302 sfList = []
303 # Set up the reco/ID efficiency scale factor calculation algorithm:
304 if config.dataType() is not DataType.Data and (not self.noEffSF or self.onlyRecoEffSF):
305 alg = config.createAlgorithm( 'CP::MuonEfficiencyScaleFactorAlg',
306 'MuonEfficiencyScaleFactorAlgReco' )
307 config.addPrivateTool( 'efficiencyScaleFactorTool',
308 'CP::MuonEfficiencyScaleFactors' )
309 alg.scaleFactorDecoration = 'muon_reco_effSF' + postfix + "_%SYS%"
310 alg.outOfValidity = 2 #silent
311 alg.outOfValidityDeco = 'muon_reco_bad_eff' + postfix
312 alg.efficiencyScaleFactorTool.WorkingPoint = self.quality
313 if config.geometry() >= LHCPeriod.Run3:
314 alg.efficiencyScaleFactorTool.CalibrationRelease = '251211_Preliminary_r24run3'
315 else:
316 alg.efficiencyScaleFactorTool.CalibrationRelease = '230213_Preliminary_r22run2'
317 alg.efficiencyScaleFactorTool.BreakDownSystematics = self.systematicBreakdown
318 alg.muons = config.readName (self.containerName)
319 alg.preselection = config.getPreselection (self.containerName, self.selectionName)
320 if self.saveDetailedSF:
321 config.addOutputVar (self.containerName, alg.scaleFactorDecoration,
322 'reco_effSF' + postfix)
323 sfList += [alg.scaleFactorDecoration]
324
325 # Set up the HighPt-specific BadMuonVeto efficiency scale factor calculation algorithm:
326 if config.dataType() is not DataType.Data and self.quality == 'HighPt' and not self.onlyRecoEffSF and not self.noEffSF:
327 alg = config.createAlgorithm( 'CP::MuonEfficiencyScaleFactorAlg',
328 'MuonEfficiencyScaleFactorAlgBMVHighPt' )
329 config.addPrivateTool( 'efficiencyScaleFactorTool',
330 'CP::MuonEfficiencyScaleFactors' )
331 alg.scaleFactorDecoration = 'muon_BadMuonVeto_effSF' + postfix + "_%SYS%"
332 alg.outOfValidity = 2 #silent
333 alg.outOfValidityDeco = 'muon_BadMuonVeto_bad_eff' + postfix
334 alg.efficiencyScaleFactorTool.WorkingPoint = 'BadMuonVeto_HighPt'
335 if config.geometry() >= LHCPeriod.Run3:
336 alg.efficiencyScaleFactorTool.CalibrationRelease = '220817_Preliminary_r22run3' # not available as part of '230123_Preliminary_r22run3'!
337 else:
338 alg.efficiencyScaleFactorTool.CalibrationRelease = '230213_Preliminary_r22run2'
339 alg.efficiencyScaleFactorTool.BreakDownSystematics = self.systematicBreakdown
340 alg.muons = config.readName (self.containerName)
341 alg.preselection = config.getPreselection (self.containerName, self.selectionName)
342 if self.saveDetailedSF:
343 config.addOutputVar (self.containerName, alg.scaleFactorDecoration,
344 'BadMuonVeto_effSF' + postfix)
345 sfList += [alg.scaleFactorDecoration]
346
347 # Set up the isolation efficiency scale factor calculation algorithm:
348 if config.dataType() is not DataType.Data and self.isolation != 'NonIso' and not self.onlyRecoEffSF and not self.noEffSF:
349 alg = config.createAlgorithm( 'CP::MuonEfficiencyScaleFactorAlg',
350 'MuonEfficiencyScaleFactorAlgIsol' )
351 config.addPrivateTool( 'efficiencyScaleFactorTool',
352 'CP::MuonEfficiencyScaleFactors' )
353 alg.scaleFactorDecoration = 'muon_isol_effSF' + postfix + "_%SYS%"
354 alg.outOfValidity = 2 #silent
355 alg.outOfValidityDeco = 'muon_isol_bad_eff' + postfix
356 alg.efficiencyScaleFactorTool.WorkingPoint = self.isolation + 'Iso'
357 if config.geometry() >= LHCPeriod.Run3:
358 alg.efficiencyScaleFactorTool.CalibrationRelease = '251211_Preliminary_r24run3'
359 else:
360 alg.efficiencyScaleFactorTool.CalibrationRelease = '230213_Preliminary_r22run2'
361 alg.efficiencyScaleFactorTool.BreakDownSystematics = self.systematicBreakdown
362 alg.muons = config.readName (self.containerName)
363 alg.preselection = config.getPreselection (self.containerName, self.selectionName)
364 if self.saveDetailedSF:
365 config.addOutputVar (self.containerName, alg.scaleFactorDecoration,
366 'isol_effSF' + postfix)
367 sfList += [alg.scaleFactorDecoration]
368
369 # Set up the TTVA scale factor calculation algorithm:
370 if config.dataType() is not DataType.Data and self.trackSelection and not self.onlyRecoEffSF and not self.noEffSF:
371 alg = config.createAlgorithm( 'CP::MuonEfficiencyScaleFactorAlg',
372 'MuonEfficiencyScaleFactorAlgTTVA' )
373 config.addPrivateTool( 'efficiencyScaleFactorTool',
374 'CP::MuonEfficiencyScaleFactors' )
375 alg.scaleFactorDecoration = 'muon_TTVA_effSF' + postfix + "_%SYS%"
376 alg.outOfValidity = 2 #silent
377 alg.outOfValidityDeco = 'muon_TTVA_bad_eff' + postfix
378 alg.efficiencyScaleFactorTool.WorkingPoint = 'TTVA'
379 if config.geometry() >= LHCPeriod.Run3:
380 alg.efficiencyScaleFactorTool.CalibrationRelease = '251211_Preliminary_r24run3'
381 else:
382 alg.efficiencyScaleFactorTool.CalibrationRelease = '230213_Preliminary_r22run2'
383 alg.efficiencyScaleFactorTool.BreakDownSystematics = self.systematicBreakdown
384 alg.muons = config.readName (self.containerName)
385 alg.preselection = config.getPreselection (self.containerName, self.selectionName)
386 if self.saveDetailedSF:
387 config.addOutputVar (self.containerName, alg.scaleFactorDecoration,
388 'TTVA_effSF' + postfix)
389 sfList += [alg.scaleFactorDecoration]
390
391 if config.dataType() is not DataType.Data and not self.noEffSF and self.saveCombinedSF:
392 alg = config.createAlgorithm( 'CP::AsgObjectScaleFactorAlg',
393 'MuonCombinedEfficiencyScaleFactorAlg' )
394 alg.particles = config.readName (self.containerName)
395 alg.inScaleFactors = sfList
396 alg.outScaleFactor = 'effSF' + postfix + '_%SYS%'
397 config.addOutputVar (self.containerName, alg.outScaleFactor, 'effSF' + postfix)
398

Member Data Documentation

◆ containerName

python.MuonAnalysisConfig.MuonWorkingPointConfig.containerName

Definition at line 265 of file MuonAnalysisConfig.py.

◆ noEffSF

python.MuonAnalysisConfig.MuonWorkingPointConfig.noEffSF

Definition at line 370 of file MuonAnalysisConfig.py.

◆ onlyRecoEffSF

python.MuonAnalysisConfig.MuonWorkingPointConfig.onlyRecoEffSF

Definition at line 304 of file MuonAnalysisConfig.py.

◆ quality

str python.MuonAnalysisConfig.MuonWorkingPointConfig.quality = 'Tight' :

Definition at line 228 of file MuonAnalysisConfig.py.

◆ saveCombinedSF

python.MuonAnalysisConfig.MuonWorkingPointConfig.saveCombinedSF

Definition at line 391 of file MuonAnalysisConfig.py.

◆ saveDetailedSF

python.MuonAnalysisConfig.MuonWorkingPointConfig.saveDetailedSF

Definition at line 320 of file MuonAnalysisConfig.py.

◆ selectionName

python.MuonAnalysisConfig.MuonWorkingPointConfig.selectionName

Definition at line 265 of file MuonAnalysisConfig.py.

◆ trackSelection

python.MuonAnalysisConfig.MuonWorkingPointConfig.trackSelection

Definition at line 256 of file MuonAnalysisConfig.py.


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