ATLAS Offline Software
Public Member Functions | List of all members
python.MuonAnalysisConfig.MuonTriggerAnalysisSFBlock Class Reference
Inheritance diagram for python.MuonAnalysisConfig.MuonTriggerAnalysisSFBlock:
Collaboration diagram for python.MuonAnalysisConfig.MuonTriggerAnalysisSFBlock:

Public Member Functions

def __init__ (self)
 
def instanceName (self)
 
def makeAlgs (self, config)
 

Detailed Description

Definition at line 384 of file MuonAnalysisConfig.py.

Constructor & Destructor Documentation

◆ __init__()

def python.MuonAnalysisConfig.MuonTriggerAnalysisSFBlock.__init__ (   self)

Definition at line 386 of file MuonAnalysisConfig.py.

386  def __init__ (self) :
387  super (MuonTriggerAnalysisSFBlock, self).__init__ ()
388 
389  self.addOption ('triggerChainsPerYear', {}, type=None,
390  info="a dictionary with key (string) the year and value (list of "
391  "strings) the trigger chains. The default is {} (empty dictionary).")
392  self.addOption ('muonID', '', type=str,
393  info="the muon quality WP (string) to use.")
394  self.addOption ('saveSF', True, type=bool,
395  info="define whether we decorate the trigger scale factor "
396  "The default is True.")
397  self.addOption ('saveEff', False, type=bool,
398  info="define whether we decorate the trigger MC efficiencies "
399  "The default is False.")
400  self.addOption ('saveEffData', False, type=bool,
401  info="define whether we decorate the trigger data efficiencies "
402  "The default is False.")
403  self.addOption ('prefixSF', 'trigEffSF', type=str,
404  info="the decoration prefix for trigger scale factors, "
405  "the default is 'trigEffSF'")
406  self.addOption ('prefixEff', 'trigEff', type=str,
407  info="the decoration prefix for MC trigger efficiencies, "
408  "the default is 'trigEff'")
409  self.addOption ('prefixEffData', 'trigEffData', type=str,
410  info="the decoration prefix for data trigger efficiencies, "
411  "the default is 'trigEffData'")
412  self.addOption ('includeAllYearsPerRun', False, type=bool,
413  info="if True, all configured years in the LHC run will "
414  "be included in all jobs. The default is False.")
415  self.addOption ('removeHLTPrefix', True, type=bool,
416  info="remove the HLT prefix from trigger chain names, "
417  "The default is True.")
418  self.addOption ('containerName', '', type=str,
419  info="the input muon container, with a possible selection, in "
420  "the format container or container.selection.")
421 

Member Function Documentation

◆ instanceName()

def python.MuonAnalysisConfig.MuonTriggerAnalysisSFBlock.instanceName (   self)

Definition at line 422 of file MuonAnalysisConfig.py.

422  def instanceName (self) :
423  return self.containerName + '_' + self.muonID
424 

◆ makeAlgs()

def python.MuonAnalysisConfig.MuonTriggerAnalysisSFBlock.makeAlgs (   self,
  config 
)

Definition at line 425 of file MuonAnalysisConfig.py.

425  def makeAlgs (self, config) :
426 
427  if config.dataType() is not DataType.Data:
428 
429  # Dictionary from TrigGlobalEfficiencyCorrection/Triggers.cfg
430  # Key is trigger chain (w/o HLT prefix)
431  # Value is empty for single leg trigger or list of legs
432  triggerDict = TriggerDict()
433 
434  if self.includeAllYearsPerRun:
435  years = [int(year) for year in self.triggerChainsPerYear.keys()]
436  else:
437  from TriggerAnalysisAlgorithms.TriggerAnalysisSFConfig import (
438  get_input_years)
439  years = get_input_years(config)
440 
441  triggerYearStartBoundaries = {
442  2015: 260000,
443  2016: 290000,
444  2017: 324000,
445  2018: 348000,
446  2022: 410000,
447  2023: 450000,
448  2024: 470000,
449  }
450 
451  triggerConfigs = {}
452  triggerConfigYears = {}
453  from TriggerAnalysisAlgorithms.TriggerAnalysisConfig import is_year_in_current_period
454  for year in years:
455  if not is_year_in_current_period(config, year):
456  continue
457 
458  triggerChains = self.triggerChainsPerYear.get(int(year), self.triggerChainsPerYear.get(str(year), []))
459  for chain in triggerChains:
460  chain = chain.replace(" || ", "_OR_")
461  chain_noHLT = chain.replace("HLT_", "")
462  chain_out = chain_noHLT if self.removeHLTPrefix else chain
463  legs = triggerDict[chain_noHLT]
464  if not legs:
465  if chain_noHLT.startswith('mu') and chain_noHLT[2].isdigit:
466  # Need to support HLT_mu26_ivarmedium_OR_HLT_mu50
467  triggerConfigs[chain_out] = chain
468  if chain_out in triggerConfigYears.keys():
469  triggerConfigYears[chain_out].append(year)
470  else:
471  triggerConfigYears[chain_out] = [year]
472  else:
473  for leg in legs:
474  if leg.startswith('mu') and leg[2].isdigit:
475  # Need to support HLT_mu14_ivarloose
476  leg_out = leg if self.removeHLTPrefix else f"HLT_{leg}"
477  triggerConfigs[leg_out] = f"HLT_{leg}"
478  if leg_out in triggerConfigYears.keys():
479  triggerConfigYears[leg_out].append(year)
480  else:
481  triggerConfigYears[leg_out] = [year]
482 
483  for trig_short, trig in triggerConfigs.items():
484  alg = config.createAlgorithm('CP::MuonTriggerEfficiencyScaleFactorAlg',
485  'MuonTrigEfficiencyCorrectionsAlg_' + trig_short)
486  config.addPrivateTool( 'efficiencyScaleFactorTool',
487  'CP::MuonTriggerScaleFactors' )
488 
489  # Reproduce config from TrigGlobalEfficiencyAlg
490  alg.efficiencyScaleFactorTool.MuonQuality = self.muonID
491  alg.efficiencyScaleFactorTool.AllowZeroSF = True
492 
493  # Avoid warnings for missing triggers
494  if self.includeAllYearsPerRun:
495  alg.minRunNumber = 0
496  alg.maxRunNumber = 999999
497 
498  if triggerConfigYears[trig_short][0] != years[0]:
499  alg.minRunNumber = triggerYearStartBoundaries.get(triggerConfigYears[trig_short][0], 999999)
500  if triggerConfigYears[trig_short][-1] != years[-1]:
501  alg.maxRunNumber = triggerYearStartBoundaries.get(triggerConfigYears[trig_short][-1] + 1, 999999)
502  elif config.campaign() is Campaign.MC20a: # to avoid potential corner-cases keep the default config unchanged
503  if triggerConfigYears[trig_short] == [2015]:
504  alg.maxRunNumber = 290000
505  elif triggerConfigYears[trig_short] == [2016]:
506  alg.minRunNumber = 290000
507 
508  alg.trigger = trig
509  if self.saveSF:
510  alg.scaleFactorDecoration = f"muon_{self.prefixSF}_{trig_short}_%SYS%"
511  if self.saveEff:
512  alg.mcEfficiencyDecoration = f"muon_{self.prefixEff}_{trig_short}_%SYS%"
513  if self.saveEffData:
514  alg.dataEfficiencyDecoration = f"muon_{self.prefixEffData}_{trig_short}_%SYS%"
515  alg.outOfValidity = 2 #silent
516  alg.outOfValidityDeco = f"bad_eff_muontrig_{trig_short}"
517  alg.muons = config.readName (self.containerName)
518  alg.preselection = config.getPreselection (self.containerName, '')
519  if self.saveSF:
520  config.addOutputVar (self.containerName, alg.scaleFactorDecoration, f"{self.prefixSF}_{trig_short}")
521  if self.saveEff:
522  config.addOutputVar (self.containerName, alg.mcEfficiencyDecoration, f"{self.prefixEff}_{trig_short}")
523  if self.saveEffData:
524  config.addOutputVar (self.containerName, alg.dataEfficiencyDecoration, f"{self.prefixEffData}_{trig_short}")
525 
526 

The documentation for this class was generated from the following file:
dumpHVPathFromNtuple.append
bool append
Definition: dumpHVPathFromNtuple.py:91
python.TriggerAnalysisConfig.is_year_in_current_period
bool is_year_in_current_period(ConfigAccumulator config, int|str year)
Definition: TriggerAnalysisConfig.py:9
python.TriggerAnalysisSFConfig.get_input_years
list[int] get_input_years(ConfigAccumulator config)
Definition: TriggerAnalysisSFConfig.py:35
TriggerLeg_DictHelpers.TriggerDict
def TriggerDict()
Definition: TriggerLeg_DictHelpers.py:8
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18
python.CaloAddPedShiftConfig.int
int
Definition: CaloAddPedShiftConfig.py:45
get
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition: hcg.cxx:127
str
Definition: BTagTrackIpAccessor.cxx:11
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:801