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 = "medium":
 saveCombinedSF

Detailed Description

the ConfigBlock for the tau working point efficiency computation

Definition at line 348 of file TauAnalysisConfig.py.

Constructor & Destructor Documentation

◆ __init__()

python.TauAnalysisConfig.TauWorkingPointEfficiencyConfig.__init__ ( self)

Definition at line 351 of file TauAnalysisConfig.py.

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

Member Function Documentation

◆ instanceName()

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

Definition at line 394 of file TauAnalysisConfig.py.

394 def instanceName (self) :
395 """Return the instance name for this block"""
396 if self.postfix is not None:
397 return self.containerName + '_' + self.selectionName + self.postfix
398 else:
399 return self.containerName + '_' + self.selectionName
400

◆ makeAlgs()

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

Definition at line 401 of file TauAnalysisConfig.py.

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

◆ manual_sel_evetowp

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

Definition at line 498 of file TauAnalysisConfig.py.

◆ noEffSF

python.TauAnalysisConfig.TauWorkingPointEfficiencyConfig.noEffSF

Definition at line 421 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 440 of file TauAnalysisConfig.py.

◆ use_eVeto

python.TauAnalysisConfig.TauWorkingPointEfficiencyConfig.use_eVeto

Definition at line 486 of file TauAnalysisConfig.py.


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