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
 use_eVeto
str manual_sel_evetowp = "loose":
 saveCombinedSF

Detailed Description

the ConfigBlock for the tau working point efficiency computation

Definition at line 344 of file TauAnalysisConfig.py.

Constructor & Destructor Documentation

◆ __init__()

python.TauAnalysisConfig.TauWorkingPointEfficiencyConfig.__init__ ( self)

Definition at line 347 of file TauAnalysisConfig.py.

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

Member Function Documentation

◆ instanceName()

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

Definition at line 387 of file TauAnalysisConfig.py.

387 def instanceName (self) :
388 """Return the instance name for this block"""
389 if self.postfix is not None:
390 return self.containerName + '_' + self.selectionName + self.postfix
391 else:
392 return self.containerName + '_' + self.selectionName
393

◆ makeAlgs()

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

Definition at line 394 of file TauAnalysisConfig.py.

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

Member Data Documentation

◆ containerName

python.TauAnalysisConfig.TauWorkingPointEfficiencyConfig.containerName

Definition at line 434 of file TauAnalysisConfig.py.

◆ manual_sel_evetowp

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

Definition at line 494 of file TauAnalysisConfig.py.

◆ noEffSF

python.TauAnalysisConfig.TauWorkingPointEfficiencyConfig.noEffSF

Definition at line 414 of file TauAnalysisConfig.py.

◆ saveCombinedSF

python.TauAnalysisConfig.TauWorkingPointEfficiencyConfig.saveCombinedSF

Definition at line 560 of file TauAnalysisConfig.py.

◆ saveDetailedSF

python.TauAnalysisConfig.TauWorkingPointEfficiencyConfig.saveDetailedSF

Definition at line 433 of file TauAnalysisConfig.py.

◆ use_eVeto

python.TauAnalysisConfig.TauWorkingPointEfficiencyConfig.use_eVeto

Definition at line 482 of file TauAnalysisConfig.py.


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