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

Constructor & Destructor Documentation

◆ __init__()

python.TauAnalysisConfig.TauWorkingPointEfficiencyConfig.__init__ ( self)

Definition at line 356 of file TauAnalysisConfig.py.

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

Member Function Documentation

◆ _eVetoEleIDLevel()

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

Definition at line 406 of file TauAnalysisConfig.py.

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

◆ instanceName()

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

Definition at line 399 of file TauAnalysisConfig.py.

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

◆ makeAlgs()

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

Definition at line 414 of file TauAnalysisConfig.py.

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

Member Data Documentation

◆ containerName

python.TauAnalysisConfig.TauWorkingPointEfficiencyConfig.containerName

Definition at line 453 of file TauAnalysisConfig.py.

◆ manual_sel_evetowp

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

Definition at line 410 of file TauAnalysisConfig.py.

◆ noEffSF

python.TauAnalysisConfig.TauWorkingPointEfficiencyConfig.noEffSF

Definition at line 433 of file TauAnalysisConfig.py.

◆ saveCombinedSF

python.TauAnalysisConfig.TauWorkingPointEfficiencyConfig.saveCombinedSF

Definition at line 548 of file TauAnalysisConfig.py.

◆ saveDetailedSF

python.TauAnalysisConfig.TauWorkingPointEfficiencyConfig.saveDetailedSF

Definition at line 452 of file TauAnalysisConfig.py.

◆ use_eVeto

python.TauAnalysisConfig.TauWorkingPointEfficiencyConfig.use_eVeto

Definition at line 490 of file TauAnalysisConfig.py.


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