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

str manual_sel_evetowp = "medium":
 noEffSF
 saveDetailedSF
 containerName
 use_eVeto
 saveCombinedSF

Protected Member Functions

 _eVetoEleIDLevel (self)

Detailed Description

the ConfigBlock for the tau working point efficiency computation

Definition at line 355 of file TauAnalysisConfig.py.

Constructor & Destructor Documentation

◆ __init__()

python.TauAnalysisConfig.TauWorkingPointEfficiencyConfig.__init__ ( self)

Definition at line 358 of file TauAnalysisConfig.py.

358 def __init__ (self) :
359 super().__init__()
360 self.setBlockName('TauWorkingPointEfficiency')
361 self.addDependency('TauWorkingPointSelection', required=True)
362 self.addDependency('EventSelection', required=False)
363 self.addDependency('EventSelectionMerger', required=False)
364 self.addOption ('containerName', '', type=str,
365 noneAction='error',
366 info="the name of the input container.",
367 meta={'role':'containerRef'})
368 self.addOption ('selectionName', '', type=str,
369 noneAction='error',
370 info="the name of the tau-jet selection to define (e.g. `tight` or "
371 "`loose`).",
372 meta={'role':'selection'})
373 self.addOption ('postfix', None, type=str,
374 info="a postfix to apply to decorations and algorithm names. "
375 "Typically not needed here as selectionName is used internally.")
376 self.addOption ('quality', None, type=str,
377 info="the ID WP to use. Supported ID WPs: `Tight`, `Medium`, "
378 "`Loose`, `VeryLoose`, `Baseline`, `BaselineForFakes`.",
379 meta={'choices':(['Tight','Medium','Loose','VeryLoose','Baseline','BaselineForFakes'],1)})
380 self.addOption ('use_eVeto', False, type=bool,
381 info="use selection with or without eVeto combined with TauID. "
382 "Recommendations: set it to `True` if electrons mis-reconstructed as tau-jets are a large background for your analysis.")
383 self.addOption ('useGNTau', False, type=bool,
384 info="use GNTau-based ID instead of RNNTau ID. "
385 "Recommendations: experimental feature and might become default soon.",
386 expertMode=True)
387 self.addOption ('manual_sel_rnnwp', None, type=str,
388 info="RNN working point used for tau-jet selection when `useSelectionConfigFile` is set to `False`.")
389 self.addOption ('manual_sel_evetowp', None, type=str,
390 info="eveto working point used for tau-jet selection when `useSelectionConfigFile` is set to `False`.")
391 self.addOption ('noEffSF', False, type=bool,
392 info="disables the calculation of efficiencies and scale factors. "
393 "Experimental! only useful to test a new WP for which scale "
394 "factors are not available.",
395 expertMode=True)
396 self.addOption ('saveDetailedSF', True, type=bool,
397 info="save all the independent detailed object scale factors.")
398 self.addOption ('saveCombinedSF', False, type=bool,
399 info="save the combined object scale factor.")
400

Member Function Documentation

◆ _eVetoEleIDLevel()

python.TauAnalysisConfig.TauWorkingPointEfficiencyConfig._eVetoEleIDLevel ( self)
protected
the EleIDLevel for the eVeto scale factors

Definition at line 408 of file TauAnalysisConfig.py.

408 def _eVetoEleIDLevel (self) :
409 """the EleIDLevel for the eVeto scale factors"""
410 # since all TauSelectionTool config files have loose eRNN, code only this option for now
411 #overwrite decision in case user selects a WP different than "loose" manually
412 if self.manual_sel_evetowp == "medium":
413 return 3
414 return 2
415

◆ instanceName()

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

Definition at line 401 of file TauAnalysisConfig.py.

401 def instanceName (self) :
402 """Return the instance name for this block"""
403 if self.postfix is not None:
404 return self.containerName + '_' + self.selectionName + self.postfix
405 else:
406 return self.containerName + '_' + self.selectionName
407

◆ makeAlgs()

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

Definition at line 416 of file TauAnalysisConfig.py.

416 def makeAlgs (self, config) :
417
418 selectionPostfix = self.selectionName
419 if selectionPostfix != '' and selectionPostfix[0] != '_' :
420 selectionPostfix = '_' + selectionPostfix
421
422 postfix = self.postfix
423 if postfix is None :
424 postfix = self.selectionName
425 if postfix != '' and postfix[0] != '_' :
426 postfix = '_' + postfix
427
428 if self.quality is not None and self.quality not in ['Tight', 'Medium', 'Loose', 'VeryLoose', 'Baseline', 'BaselineForFakes'] :
429 raise ValueError (f"invalid tau quality: \"{self.quality}\", allowed values are Tight, Medium, Loose, "
430 "VeryLoose, Baseline, BaselineForFakes")
431
432 sfList = []
433 # Set up the algorithm calculating the efficiency scale factors for the
434 # taus:
435 if config.dataType() is not DataType.Data and not self.noEffSF:
436 log = logging.getLogger('TauJetSFConfig')
437 # need multiple instances of the TauEfficiencyCorrectionTool
438 # 1) Reco 2) TauID, 3) eVeto for fake tau 4) eVeto for true tau
439 # 3) and 4) are optional if eVeto is used in TauSelectionTool
440
441 # TauEfficiencyCorrectionTool for Reco, this should be always enabled
442 alg = config.createAlgorithm( 'CP::TauEfficiencyCorrectionsAlg',
443 'TauEfficiencyCorrectionsAlgReco' )
444 config.addPrivateTool( 'efficiencyCorrectionsTool',
445 'TauAnalysisTools::TauEfficiencyCorrectionsTool' )
446 alg.efficiencyCorrectionsTool.EfficiencyCorrectionTypes = [0]
447 alg.efficiencyCorrectionsTool.Campaign = _campaign(config)
448 alg.efficiencyCorrectionsTool.useFastSim = config.dataType() is DataType.FastSim
449 alg.scaleFactorDecoration = 'tau_Reco_effSF' + selectionPostfix + '_%SYS%'
450 alg.outOfValidity = 2 #silent
451 alg.outOfValidityDeco = 'bad_Reco_eff' + selectionPostfix
452 alg.taus = config.readName (self.containerName)
453 alg.preselection = config.getPreselection (self.containerName, self.selectionName)
454 if self.saveDetailedSF:
455 config.addOutputVar (self.containerName, alg.scaleFactorDecoration,
456 'Reco_effSF' + postfix)
457 sfList += [alg.scaleFactorDecoration]
458
459
460 campaign = _campaign(config)
461
462 # TauEfficiencyCorrectionTool for Identification, use only in case TauID is requested in TauSelectionTool
463 if self.quality not in ('VeryLoose','Baseline','BaselineForFakes'):
464 alg = config.createAlgorithm( 'CP::TauEfficiencyCorrectionsAlg',
465 'TauEfficiencyCorrectionsAlgID' )
466 config.addPrivateTool( 'efficiencyCorrectionsTool',
467 'TauAnalysisTools::TauEfficiencyCorrectionsTool' )
468 alg.efficiencyCorrectionsTool.EfficiencyCorrectionTypes = [4]
469
470 jetIDLevels = _GNTAU_JETID_LEVELS if self.useGNTau else _RNN_JETID_LEVELS
471 wp = self.quality
472 if not self.useGNTau and self.manual_sel_rnnwp is not None:
473 wp = self.manual_sel_rnnwp.capitalize()
474 if wp not in jetIDLevels:
475 raise ValueError(f'Invalid tauID: "{wp}". Allowed values are Loose, Medium, Tight')
476
477 alg.efficiencyCorrectionsTool.JetIDLevel = jetIDLevels[wp]
478 alg.efficiencyCorrectionsTool.useFastSim = config.dataType() is DataType.FastSim
479 alg.efficiencyCorrectionsTool.Campaign = campaign
480 alg.efficiencyCorrectionsTool.useGNTau = self.useGNTau
481 alg.scaleFactorDecoration = 'tau_ID_effSF' + selectionPostfix + '_%SYS%'
482 alg.outOfValidity = 2 #silent
483 alg.outOfValidityDeco = 'bad_ID_eff' + selectionPostfix
484 alg.taus = config.readName (self.containerName)
485 alg.preselection = config.getPreselection (self.containerName, self.selectionName)
486 if self.saveDetailedSF:
487 config.addOutputVar (self.containerName, alg.scaleFactorDecoration,
488 'ID_effSF' + postfix)
489 sfList += [alg.scaleFactorDecoration]
490
491 # TauEfficiencyCorrectionTool for eVeto both on true tau and fake tau, use only in case eVeto is requested in TauSelectionTool
492 if self.use_eVeto:
493 #use only in case TauID is requested in TauSelectionTool
494 if self.quality not in ('VeryLoose','Baseline','BaselineForFakes'):
495 # correction for fake tau
496 alg = config.createAlgorithm( 'CP::TauEfficiencyCorrectionsAlg',
497 'TauEfficiencyCorrectionsAlgEvetoFakeTau' )
498 config.addPrivateTool( 'efficiencyCorrectionsTool',
499 'TauAnalysisTools::TauEfficiencyCorrectionsTool' )
500 alg.efficiencyCorrectionsTool.EfficiencyCorrectionTypes = [10]
501 alg.efficiencyCorrectionsTool.EleIDLevel = self._eVetoEleIDLevel()
502
503 alg.efficiencyCorrectionsTool.useFastSim = config.dataType() is DataType.FastSim
504 alg.efficiencyCorrectionsTool.Campaign = campaign
505 alg.efficiencyCorrectionsTool.useGNTau = self.useGNTau
506 alg.scaleFactorDecoration = 'tau_EvetoFakeTau_effSF' + selectionPostfix + '_%SYS%'
507
508 # for 2025-prerec, eVeto recommendations are given separately for Loose and Medium RNN
509 jetIDLevels = _GNTAU_JETID_LEVELS if self.useGNTau else _RNN_JETID_LEVELS
510 wp = self.quality
511 if not self.useGNTau and self.manual_sel_rnnwp is not None:
512 wp = self.manual_sel_rnnwp.capitalize()
513 if wp not in jetIDLevels:
514 raise ValueError(f'Invalid tauID: "{wp}". Allowed values are Loose, Medium, Tight')
515 if wp == "Tight":
516 log.warning(
517 "eVeto SFs are not available for Tight WP -> fallback to Medium WP"
518 )
519 wp = "Medium"
520
521 alg.efficiencyCorrectionsTool.JetIDLevel = jetIDLevels[wp]
522 alg.outOfValidity = 2 #silent
523 alg.outOfValidityDeco = 'bad_EvetoFakeTau_eff' + selectionPostfix
524 alg.taus = config.readName (self.containerName)
525 alg.preselection = config.getPreselection (self.containerName, self.selectionName)
526 if self.saveDetailedSF:
527 config.addOutputVar (self.containerName, alg.scaleFactorDecoration,
528 'EvetoFakeTau_effSF' + postfix)
529 sfList += [alg.scaleFactorDecoration]
530
531 # correction for true tau
532 alg = config.createAlgorithm( 'CP::TauEfficiencyCorrectionsAlg',
533 'TauEfficiencyCorrectionsAlgEvetoTrueTau' )
534 config.addPrivateTool( 'efficiencyCorrectionsTool',
535 'TauAnalysisTools::TauEfficiencyCorrectionsTool' )
536 alg.efficiencyCorrectionsTool.EfficiencyCorrectionTypes = [8]
537 alg.efficiencyCorrectionsTool.useFastSim = config.dataType() is DataType.FastSim
538 alg.efficiencyCorrectionsTool.Campaign = _campaign(config)
539 alg.scaleFactorDecoration = 'tau_EvetoTrueTau_effSF' + selectionPostfix + '_%SYS%'
540 alg.efficiencyCorrectionsTool.EleIDLevel = self._eVetoEleIDLevel()
541 alg.outOfValidity = 2 #silent
542 alg.outOfValidityDeco = 'bad_EvetoTrueTau_eff' + selectionPostfix
543 alg.taus = config.readName (self.containerName)
544 alg.preselection = config.getPreselection (self.containerName, self.selectionName)
545 if self.saveDetailedSF:
546 config.addOutputVar (self.containerName, alg.scaleFactorDecoration,
547 'EvetoTrueTau_effSF' + postfix)
548 sfList += [alg.scaleFactorDecoration]
549
550 if self.saveCombinedSF:
551 alg = config.createAlgorithm( 'CP::AsgObjectScaleFactorAlg',
552 'TauCombinedEfficiencyScaleFactorAlg' )
553 alg.particles = config.readName (self.containerName)
554 alg.inScaleFactors = sfList
555 alg.outScaleFactor = 'effSF' + postfix + '_%SYS%'
556 config.addOutputVar (self.containerName, alg.outScaleFactor,
557 'effSF' + postfix)
558
559

Member Data Documentation

◆ containerName

python.TauAnalysisConfig.TauWorkingPointEfficiencyConfig.containerName

Definition at line 455 of file TauAnalysisConfig.py.

◆ manual_sel_evetowp

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

Definition at line 412 of file TauAnalysisConfig.py.

◆ noEffSF

python.TauAnalysisConfig.TauWorkingPointEfficiencyConfig.noEffSF

Definition at line 435 of file TauAnalysisConfig.py.

◆ saveCombinedSF

python.TauAnalysisConfig.TauWorkingPointEfficiencyConfig.saveCombinedSF

Definition at line 550 of file TauAnalysisConfig.py.

◆ saveDetailedSF

python.TauAnalysisConfig.TauWorkingPointEfficiencyConfig.saveDetailedSF

Definition at line 454 of file TauAnalysisConfig.py.

◆ use_eVeto

python.TauAnalysisConfig.TauWorkingPointEfficiencyConfig.use_eVeto

Definition at line 492 of file TauAnalysisConfig.py.


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