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 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
432 campaign = "mc23" if config.geometry() is LHCPeriod.Run3 else "mc20"
433
434 # TauEfficiencyCorrectionTool for Identification, use only in case TauID is requested in TauSelectionTool
435 if self.quality not in ('VeryLoose','Baseline','BaselineForFakes'):
436 # current recommendations are for RNN ID Run2/Run3 or GNTAU for Run3,
437 if (not self.useGNTau or (self.useGNTau and campaign == "mc23")):
438
439 alg = config.createAlgorithm( 'CP::TauEfficiencyCorrectionsAlg',
440 'TauEfficiencyCorrectionsAlgID' )
441 config.addPrivateTool( 'efficiencyCorrectionsTool',
442 'TauAnalysisTools::TauEfficiencyCorrectionsTool' )
443 alg.efficiencyCorrectionsTool.EfficiencyCorrectionTypes = [4]
444
445 jetIDLevels = (
446 {"Loose": 11, "Medium": 12, "Tight": 13}
447 if self.useGNTau
448 else {"Loose": 7, "Medium": 8, "Tight": 9}
449 )
450 wp = self.quality
451 if not self.useGNTau and self.manual_sel_rnnwp is not None:
452 wp = self.manual_sel_rnnwp.capitalize()
453 if wp not in jetIDLevels:
454 raise ValueError(
455 'Invalid tauID: "'
456 + str(wp)
457 + '". Allowed values are Loose, Medium, Tight'
458 )
459
460 alg.efficiencyCorrectionsTool.JetIDLevel = jetIDLevels[wp]
461 alg.efficiencyCorrectionsTool.useFastSim = config.dataType() is DataType.FastSim
462 alg.efficiencyCorrectionsTool.Campaign = campaign
463 alg.efficiencyCorrectionsTool.useGNTau = self.useGNTau
464 alg.scaleFactorDecoration = 'tau_ID_effSF' + selectionPostfix + '_%SYS%'
465 alg.outOfValidity = 2 #silent
466 alg.outOfValidityDeco = 'bad_ID_eff' + selectionPostfix
467 alg.taus = config.readName (self.containerName)
468 alg.preselection = config.getPreselection (self.containerName, self.selectionName)
469 if self.saveDetailedSF:
470 config.addOutputVar (self.containerName, alg.scaleFactorDecoration,
471 'ID_effSF' + postfix)
472 sfList += [alg.scaleFactorDecoration]
473
474 # TauEfficiencyCorrectionTool for eVeto both on true tau and fake tau, use only in case eVeto is requested in TauSelectionTool
475 if self.use_eVeto:
476 # eVeto correction for fake tau are for RNN ID Run2/Run3, or for GNTau for Run3
477 if (not self.useGNTau or (self.useGNTau and campaign == "mc23")):
478 # correction for fake tau
479 alg = config.createAlgorithm( 'CP::TauEfficiencyCorrectionsAlg',
480 'TauEfficiencyCorrectionsAlgEvetoFakeTau' )
481 config.addPrivateTool( 'efficiencyCorrectionsTool',
482 'TauAnalysisTools::TauEfficiencyCorrectionsTool' )
483 alg.efficiencyCorrectionsTool.EfficiencyCorrectionTypes = [10]
484 # since all TauSelectionTool config files have loose eRNN, code only this option for now
485 alg.efficiencyCorrectionsTool.EleIDLevel = 2
486 #overwrite decision in case user selects a WP manually
487 if self.manual_sel_evetowp == "loose":
488 alg.efficiencyCorrectionsTool.EleIDLevel = 2
489 elif self.manual_sel_evetowp == "medium":
490 alg.efficiencyCorrectionsTool.EleIDLevel = 3
491
492 alg.efficiencyCorrectionsTool.useFastSim = config.dataType() is DataType.FastSim
493 alg.efficiencyCorrectionsTool.Campaign = campaign
494 alg.efficiencyCorrectionsTool.useGNTau = self.useGNTau
495 alg.scaleFactorDecoration = 'tau_EvetoFakeTau_effSF' + selectionPostfix + '_%SYS%'
496
497 # for 2025-prerec, eVeto recommendations are given separately for Loose and Medium RNN
498 jetIDLevels = (
499 {"Loose": 11, "Medium": 12, "Tight": 13}
500 if self.useGNTau
501 else {"Loose": 7, "Medium": 8, "Tight": 9}
502 )
503 wp = self.quality
504 if not self.useGNTau and self.manual_sel_rnnwp is not None:
505 wp = self.manual_sel_rnnwp.capitalize()
506 if wp not in jetIDLevels:
507 raise ValueError(
508 'Invalid tauID: "'
509 + str(wp)
510 + '". Allowed values are Loose, Medium, Tight'
511 )
512 if wp == "Tight":
513 log.warning(
514 "eVeto SFs are not available for Tight WP -> fallback to Medium WP"
515 )
516 wp = "Medium"
517
518 alg.efficiencyCorrectionsTool.JetIDLevel = jetIDLevels[wp]
519 alg.outOfValidity = 2 #silent
520 alg.outOfValidityDeco = 'bad_EvetoFakeTau_eff' + selectionPostfix
521 alg.taus = config.readName (self.containerName)
522 alg.preselection = config.getPreselection (self.containerName, self.selectionName)
523 if self.saveDetailedSF:
524 config.addOutputVar (self.containerName, alg.scaleFactorDecoration,
525 'EvetoFakeTau_effSF' + postfix)
526 sfList += [alg.scaleFactorDecoration]
527
528 # correction for true tau
529 alg = config.createAlgorithm( 'CP::TauEfficiencyCorrectionsAlg',
530 'TauEfficiencyCorrectionsAlgEvetoTrueTau' )
531 config.addPrivateTool( 'efficiencyCorrectionsTool',
532 'TauAnalysisTools::TauEfficiencyCorrectionsTool' )
533 alg.efficiencyCorrectionsTool.EfficiencyCorrectionTypes = [8]
534 alg.efficiencyCorrectionsTool.useFastSim = config.dataType() is DataType.FastSim
535 alg.efficiencyCorrectionsTool.Campaign = "mc23" if config.geometry() is LHCPeriod.Run3 else "mc20"
536 alg.scaleFactorDecoration = 'tau_EvetoTrueTau_effSF' + selectionPostfix + '_%SYS%'
537 # since all TauSelectionTool config files have loose eRNN, code only this option for now
538 alg.efficiencyCorrectionsTool.EleIDLevel = 2
539 #overwrite decision in case user selects a WP manually
540 if self.manual_sel_evetowp == "loose":
541 alg.efficiencyCorrectionsTool.EleIDLevel = 2
542 elif self.manual_sel_evetowp == "medium":
543 alg.efficiencyCorrectionsTool.EleIDLevel = 3
544 alg.outOfValidity = 2 #silent
545 alg.outOfValidityDeco = 'bad_EvetoTrueTau_eff' + selectionPostfix
546 alg.taus = config.readName (self.containerName)
547 alg.preselection = config.getPreselection (self.containerName, self.selectionName)
548 if self.saveDetailedSF:
549 config.addOutputVar (self.containerName, alg.scaleFactorDecoration,
550 'EvetoTrueTau_effSF' + postfix)
551 sfList += [alg.scaleFactorDecoration]
552
553 if self.saveCombinedSF:
554 alg = config.createAlgorithm( 'CP::AsgObjectScaleFactorAlg',
555 'TauCombinedEfficiencyScaleFactorAlg' )
556 alg.particles = config.readName (self.containerName)
557 alg.inScaleFactors = sfList
558 alg.outScaleFactor = 'effSF' + postfix + '_%SYS%'
559 config.addOutputVar (self.containerName, alg.outScaleFactor,
560 'effSF' + postfix)
561
562

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

◆ noEffSF

python.TauAnalysisConfig.TauWorkingPointEfficiencyConfig.noEffSF

Definition at line 407 of file TauAnalysisConfig.py.

◆ saveCombinedSF

python.TauAnalysisConfig.TauWorkingPointEfficiencyConfig.saveCombinedSF

Definition at line 553 of file TauAnalysisConfig.py.

◆ saveDetailedSF

python.TauAnalysisConfig.TauWorkingPointEfficiencyConfig.saveDetailedSF

Definition at line 426 of file TauAnalysisConfig.py.

◆ use_eVeto

python.TauAnalysisConfig.TauWorkingPointEfficiencyConfig.use_eVeto

Definition at line 475 of file TauAnalysisConfig.py.


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