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

Public Member Functions

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

Public Attributes

 noEffSF
 saveDetailedSF
 containerName
# current recommendations are for RNN ID, so donCPTauEfficiencyCorrectionsAlgTauEfficiencyCorrectionsAlgIDefficiencyCorrectionsToolTauAnalysisToolsTauEfficiencyCorrectionsTooltau_ID_effSF_%SYS%bad_ID_effID_effSFt use them for GNTau useGNTau
str manual_sel_evetowp = "loose":
str quality = "loose":
 saveCombinedSF

Detailed Description

the ConfigBlock for the tau working point efficiency computation

Definition at line 337 of file TauAnalysisConfig.py.

Constructor & Destructor Documentation

◆ __init__()

python.TauAnalysisConfig.TauWorkingPointEfficiencyConfig.__init__ ( self)

Definition at line 340 of file TauAnalysisConfig.py.

340 def __init__ (self) :
341 super (TauWorkingPointEfficiencyConfig, self).__init__ ()
342 self.setBlockName('TauWorkingPointEfficiency')
343 self.addDependency('TauWorkingPointSelection', required=True)
344 self.addDependency('EventSelection', required=False)
345 self.addDependency('EventSelectionMerger', required=False)
346 self.addOption ('containerName', '', type=str,
347 noneAction='error',
348 info="the name of the input container.")
349 self.addOption ('selectionName', '', type=str,
350 noneAction='error',
351 info="the name of the tau-jet selection to define (e.g. `tight` or "
352 "`loose`).")
353 self.addOption ('postfix', None, type=str,
354 info="a postfix to apply to decorations and algorithm names. "
355 "Typically not needed here as selectionName is used internally.")
356 self.addOption ('quality', None, type=str,
357 info="the ID WP to use. Supported ID WPs: `Tight`, `Medium`, "
358 "`Loose`, `VeryLoose`, `Baseline`, `BaselineForFakes`.")
359 self.addOption ('use_eVeto', False, type=bool,
360 info="use selection with or without eVeto combined with TauID. "
361 "Recommendations: set it to `True` if electrons mis-reconstructed as tau-jets are a large background for your analysis.")
362 self.addOption ('useGNTau', False, type=bool,
363 info="use GNTau-based ID instead of RNNTau ID. "
364 "Recommendations: experimental feature and might become default soon.",
365 expertMode=True)
366 self.addOption ('manual_sel_rnnwp', None, type=str,
367 info="RNN working point used for tau-jet selection when `useSelectionConfigFile` is set to `False`.")
368 self.addOption ('manual_sel_evetowp', None, type=str,
369 info="eveto working point used for tau-jet selection when `useSelectionConfigFile` is set to `False`.")
370 self.addOption ('noEffSF', False, type=bool,
371 info="disables the calculation of efficiencies and scale factors. "
372 "Experimental! only useful to test a new WP for which scale "
373 "factors are not available.",
374 expertMode=True)
375 self.addOption ('saveDetailedSF', True, type=bool,
376 info="save all the independent detailed object scale factors.")
377 self.addOption ('saveCombinedSF', False, type=bool,
378 info="save the combined object scale factor.")
379

Member Function Documentation

◆ instanceName()

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

Definition at line 380 of file TauAnalysisConfig.py.

380 def instanceName (self) :
381 """Return the instance name for this block"""
382 if self.postfix is not None:
383 return self.containerName + '_' + self.selectionName + self.postfix
384 else:
385 return self.containerName + '_' + self.selectionName
386

◆ makeAlgs()

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

Definition at line 387 of file TauAnalysisConfig.py.

387 def makeAlgs (self, config) :
388
389 selectionPostfix = self.selectionName
390 if selectionPostfix != '' and selectionPostfix[0] != '_' :
391 selectionPostfix = '_' + selectionPostfix
392
393 postfix = self.postfix
394 if postfix is None :
395 postfix = self.selectionName
396 if postfix != '' and postfix[0] != '_' :
397 postfix = '_' + postfix
398
399 if self.quality is not None and self.quality not in ['Tight', 'Medium', 'Loose', 'VeryLoose', 'Baseline', 'BaselineForFakes'] :
400 raise ValueError ("invalid tau quality: \"" + self.quality +
401 "\", allowed values are Tight, Medium, Loose, " +
402 "VeryLoose, Baseline, BaselineForFakes")
403
404 sfList = []
405 # Set up the algorithm calculating the efficiency scale factors for the
406 # taus:
407 if config.dataType() is not DataType.Data and not self.noEffSF:
408 log = logging.getLogger('TauJetSFConfig')
409 # need multiple instances of the TauEfficiencyCorrectionTool
410 # 1) Reco 2) TauID, 3) eVeto for fake tau 4) eVeto for true tau
411 # 3) and 4) are optional if eVeto is used in TauSelectionTool
412
413 # TauEfficiencyCorrectionTool for Reco, this should be always enabled
414 alg = config.createAlgorithm( 'CP::TauEfficiencyCorrectionsAlg',
415 'TauEfficiencyCorrectionsAlgReco' )
416 config.addPrivateTool( 'efficiencyCorrectionsTool',
417 'TauAnalysisTools::TauEfficiencyCorrectionsTool' )
418 alg.efficiencyCorrectionsTool.EfficiencyCorrectionTypes = [0]
419 alg.efficiencyCorrectionsTool.Campaign = "mc23" if config.geometry() is LHCPeriod.Run3 else "mc20"
420 alg.efficiencyCorrectionsTool.useFastSim = config.dataType() is DataType.FastSim
421 alg.scaleFactorDecoration = 'tau_Reco_effSF' + selectionPostfix + '_%SYS%'
422 alg.outOfValidity = 2 #silent
423 alg.outOfValidityDeco = 'bad_Reco_eff' + selectionPostfix
424 alg.taus = config.readName (self.containerName)
425 alg.preselection = config.getPreselection (self.containerName, self.selectionName)
426 if self.saveDetailedSF:
427 config.addOutputVar (self.containerName, alg.scaleFactorDecoration,
428 'Reco_effSF' + postfix)
429 sfList += [alg.scaleFactorDecoration]
430
431 # TauEfficiencyCorrectionTool for Identification, use only in case TauID is requested in TauSelectionTool
432 if self.quality not in ('VeryLoose','Baseline','BaselineForFakes'):
433 if not self.useGNTau: # current recommendations are for RNN ID, so don't use in case of GNTau
434
435 alg = config.createAlgorithm( 'CP::TauEfficiencyCorrectionsAlg',
436 'TauEfficiencyCorrectionsAlgID' )
437 config.addPrivateTool( 'efficiencyCorrectionsTool',
438 'TauAnalysisTools::TauEfficiencyCorrectionsTool' )
439 alg.efficiencyCorrectionsTool.EfficiencyCorrectionTypes = [4]
440 if self.quality=="Loose" or self.manual_sel_rnnwp == "loose":
441 JetIDLevel = 7
442 elif self.quality=="Medium" or self.manual_sel_rnnwp == "medium":
443 JetIDLevel = 8
444 elif self.quality=="Tight" or self.manual_sel_rnnwp == "tight":
445 JetIDLevel = 9
446 else:
447 raise ValueError ("invalid tauID: \"" + self.quality + "\". Allowed values are loose, medium, tight")
448
449 alg.efficiencyCorrectionsTool.JetIDLevel = JetIDLevel
450 alg.efficiencyCorrectionsTool.useFastSim = config.dataType() is DataType.FastSim
451 alg.efficiencyCorrectionsTool.Campaign = "mc23" if config.geometry() is LHCPeriod.Run3 else "mc20"
452 alg.scaleFactorDecoration = 'tau_ID_effSF' + selectionPostfix + '_%SYS%'
453 alg.outOfValidity = 2 #silent
454 alg.outOfValidityDeco = 'bad_ID_eff' + selectionPostfix
455 alg.taus = config.readName (self.containerName)
456 alg.preselection = config.getPreselection (self.containerName, self.selectionName)
457 if self.saveDetailedSF:
458 config.addOutputVar (self.containerName, alg.scaleFactorDecoration,
459 'ID_effSF' + postfix)
460 sfList += [alg.scaleFactorDecoration]
461
462 # TauEfficiencyCorrectionTool for eVeto both on true tau and fake tau, use only in case eVeto is requested in TauSelectionTool
463 if self.use_eVeto:
464 if not self.useGNTau: # eVeto correction for fake tau are for RNN ID, so don't use them for GNTau
465 # correction for fake tau
466 alg = config.createAlgorithm( 'CP::TauEfficiencyCorrectionsAlg',
467 'TauEfficiencyCorrectionsAlgEvetoFakeTau' )
468 config.addPrivateTool( 'efficiencyCorrectionsTool',
469 'TauAnalysisTools::TauEfficiencyCorrectionsTool' )
470 alg.efficiencyCorrectionsTool.EfficiencyCorrectionTypes = [10]
471 # since all TauSelectionTool config files have loose eRNN, code only this option for now
472 alg.efficiencyCorrectionsTool.EleIDLevel = 2
473 #overwrite decision in case user selects a WP manually
474 if self.manual_sel_evetowp == "loose":
475 alg.efficiencyCorrectionsTool.EleIDLevel = 2
476 elif self.manual_sel_evetowp == "medium":
477 alg.efficiencyCorrectionsTool.EleIDLevel = 3
478
479 alg.efficiencyCorrectionsTool.useFastSim = config.dataType() is DataType.FastSim
480 alg.efficiencyCorrectionsTool.Campaign = "mc23" if config.geometry() is LHCPeriod.Run3 else "mc20"
481 alg.scaleFactorDecoration = 'tau_EvetoFakeTau_effSF' + selectionPostfix + '_%SYS%'
482 # for 2025-prerec, eVeto recommendations are given separately for Loose and Medium RNN
483 if self.quality=="Loose" or self.manual_sel_rnnwp == "loose":
484 JetIDLevel = 7
485 elif self.quality=="Medium" or self.manual_sel_rnnwp == "medium":
486 JetIDLevel = 8
487 elif self.quality=="Tight" or self.manual_sel_rnnwp == "tight":
488 log.warning("eVeto SFs are not available for Tight WP -> fallback to Medium WP")
489 JetIDLevel = 8
490 alg.efficiencyCorrectionsTool.JetIDLevel = JetIDLevel
491 alg.outOfValidity = 2 #silent
492 alg.outOfValidityDeco = 'bad_EvetoFakeTau_eff' + selectionPostfix
493 alg.taus = config.readName (self.containerName)
494 alg.preselection = config.getPreselection (self.containerName, self.selectionName)
495 if self.saveDetailedSF:
496 config.addOutputVar (self.containerName, alg.scaleFactorDecoration,
497 'EvetoFakeTau_effSF' + postfix)
498 sfList += [alg.scaleFactorDecoration]
499
500 # correction for true tau
501 alg = config.createAlgorithm( 'CP::TauEfficiencyCorrectionsAlg',
502 'TauEfficiencyCorrectionsAlgEvetoTrueTau' )
503 config.addPrivateTool( 'efficiencyCorrectionsTool',
504 'TauAnalysisTools::TauEfficiencyCorrectionsTool' )
505 alg.efficiencyCorrectionsTool.EfficiencyCorrectionTypes = [8]
506 alg.efficiencyCorrectionsTool.useFastSim = config.dataType() is DataType.FastSim
507 alg.efficiencyCorrectionsTool.Campaign = "mc23" if config.geometry() is LHCPeriod.Run3 else "mc20"
508 alg.scaleFactorDecoration = 'tau_EvetoTrueTau_effSF' + selectionPostfix + '_%SYS%'
509 # since all TauSelectionTool config files have loose eRNN, code only this option for now
510 alg.efficiencyCorrectionsTool.EleIDLevel = 2
511 #overwrite decision in case user selects a WP manually
512 if self.manual_sel_evetowp == "loose":
513 alg.efficiencyCorrectionsTool.EleIDLevel = 2
514 elif self.manual_sel_evetowp == "medium":
515 alg.efficiencyCorrectionsTool.EleIDLevel = 3
516 alg.outOfValidity = 2 #silent
517 alg.outOfValidityDeco = 'bad_EvetoTrueTau_eff' + selectionPostfix
518 alg.taus = config.readName (self.containerName)
519 alg.preselection = config.getPreselection (self.containerName, self.selectionName)
520 if self.saveDetailedSF:
521 config.addOutputVar (self.containerName, alg.scaleFactorDecoration,
522 'EvetoTrueTau_effSF' + postfix)
523 sfList += [alg.scaleFactorDecoration]
524
525 if self.saveCombinedSF:
526 alg = config.createAlgorithm( 'CP::AsgObjectScaleFactorAlg',
527 'TauCombinedEfficiencyScaleFactorAlg' )
528 alg.particles = config.readName (self.containerName)
529 alg.inScaleFactors = sfList
530 alg.outScaleFactor = 'effSF' + postfix + '_%SYS%'
531 config.addOutputVar (self.containerName, alg.outScaleFactor,
532 'effSF' + postfix)
533
534

Member Data Documentation

◆ containerName

python.TauAnalysisConfig.TauWorkingPointEfficiencyConfig.containerName

Definition at line 427 of file TauAnalysisConfig.py.

◆ manual_sel_evetowp

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

Definition at line 474 of file TauAnalysisConfig.py.

◆ noEffSF

python.TauAnalysisConfig.TauWorkingPointEfficiencyConfig.noEffSF

Definition at line 407 of file TauAnalysisConfig.py.

◆ quality

str python.TauAnalysisConfig.TauWorkingPointEfficiencyConfig.quality = "loose":

Definition at line 483 of file TauAnalysisConfig.py.

◆ saveCombinedSF

python.TauAnalysisConfig.TauWorkingPointEfficiencyConfig.saveCombinedSF

Definition at line 525 of file TauAnalysisConfig.py.

◆ saveDetailedSF

python.TauAnalysisConfig.TauWorkingPointEfficiencyConfig.saveDetailedSF

Definition at line 426 of file TauAnalysisConfig.py.

◆ useGNTau

# current recommendations are for RNN ID, so donCPTauEfficiencyCorrectionsAlgTauEfficiencyCorrectionsAlgIDefficiencyCorrectionsToolTauAnalysisToolsTauEfficiencyCorrectionsTooltau_ID_effSF_%SYS%bad_ID_effID_effSFt use them for GNTau python.TauAnalysisConfig.TauWorkingPointEfficiencyConfig.useGNTau

Definition at line 433 of file TauAnalysisConfig.py.


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