ATLAS Offline Software
Loading...
Searching...
No Matches
python.MuonAnalysisConfig.MuonTriggerAnalysisSFBlock Class Reference
Inheritance diagram for python.MuonAnalysisConfig.MuonTriggerAnalysisSFBlock:
Collaboration diagram for python.MuonAnalysisConfig.MuonTriggerAnalysisSFBlock:

Public Member Functions

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

Public Attributes

 includeAllYearsPerRun
 saveSF
 saveEff
 saveEffData
 containerName

Detailed Description

Definition at line 443 of file MuonAnalysisConfig.py.

Constructor & Destructor Documentation

◆ __init__()

python.MuonAnalysisConfig.MuonTriggerAnalysisSFBlock.__init__ ( self)

Definition at line 445 of file MuonAnalysisConfig.py.

445 def __init__ (self) :
446 super (MuonTriggerAnalysisSFBlock, self).__init__ ()
447 self.addDependency('EventSelection', required=False)
448 self.addDependency('EventSelectionMerger', required=False)
449 self.addOption ('triggerChainsPerYear', {}, type=dict,
450 info="a dictionary with key (string) the year and value (list of "
451 "strings) the trigger chains.")
452 self.addOption ('muonID', '', type=str,
453 info="the muon quality WP to use.")
454 self.addOption ('saveSF', True, type=bool,
455 info="whether to decorate the trigger scale factor.")
456 self.addOption ('saveEff', False, type=bool,
457 info="whether to decorate the trigger MC efficiencies.")
458 self.addOption ('saveEffData', False, type=bool,
459 info="whether to decorate the trigger data efficiencies.")
460 self.addOption ('prefixSF', 'trigEffSF', type=str,
461 info="the decoration prefix for trigger scale factors.")
462 self.addOption ('prefixEff', 'trigEff', type=str,
463 info="the decoration prefix for MC trigger efficiencies.")
464 self.addOption ('prefixEffData', 'trigEffData', type=str,
465 info="the decoration prefix for data trigger efficiencies.")
466 self.addOption ('includeAllYearsPerRun', False, type=bool,
467 info="all configured years in the LHC run will "
468 "be included in all jobs.")
469 self.addOption ('removeHLTPrefix', True, type=bool,
470 info="remove the HLT prefix from trigger chain names.")
471 self.addOption ('containerName', '', type=str,
472 info="the input muon container, with a possible selection, in "
473 "the format `container` or `container.selection`.")
474 self.addOption ('customToolSuffix', '', type=str,
475 expertMode=True, info="EXPERIMENTAL: specify custom suffix for the public tool name")
476 self.addOption ('customInputFolder', '', type=str,
477 expertMode=True, info="EXPERIMENTAL: specify custom input folder")
478 self.addOption ('customInputFilePerYear', {}, type=dict,
479 expertMode=True, info="EXPERIMENTAL: specify custom input file per year")
480

Member Function Documentation

◆ instanceName()

python.MuonAnalysisConfig.MuonTriggerAnalysisSFBlock.instanceName ( self)

Definition at line 481 of file MuonAnalysisConfig.py.

481 def instanceName (self) :
482 return self.containerName + '_' + self.muonID
483

◆ makeAlgs()

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

Definition at line 484 of file MuonAnalysisConfig.py.

484 def makeAlgs (self, config) :
485
486 if config.dataType() is not DataType.Data:
487
488 # Dictionary from TrigGlobalEfficiencyCorrection/Triggers.cfg
489 # Key is trigger chain (w/o HLT prefix)
490 # Value is empty for single leg trigger or list of legs
491 triggerDict = TriggerDict()
492
493 if self.includeAllYearsPerRun:
494 years = [int(year) for year in self.triggerChainsPerYear.keys()]
495 else:
496 from TriggerAnalysisAlgorithms.TriggerAnalysisSFConfig import (
497 get_input_years)
498 years = get_input_years(config)
499
500 triggerYearStartBoundaries = {
501 2015: 260000,
502 2016: 290000,
503 2017: 324000,
504 2018: 348000,
505 2022: 410000,
506 2023: 450000,
507 2024: 470000,
508 }
509
510 triggerConfigs = {}
511 triggerConfigYears = {}
512 from TriggerAnalysisAlgorithms.TriggerAnalysisConfig import is_year_in_current_period
513 for year in years:
514 if not is_year_in_current_period(config, year):
515 continue
516
517 triggerChains = self.triggerChainsPerYear.get(int(year), self.triggerChainsPerYear.get(str(year), []))
518 for chain in triggerChains:
519 chain = chain.replace(" || ", "_OR_")
520 chain_noHLT = chain.replace("HLT_", "")
521 chain_out = chain_noHLT if self.removeHLTPrefix else chain
522 legs = triggerDict[chain_noHLT]
523 if not legs:
524 if chain_noHLT.startswith('mu') and chain_noHLT[2].isdigit:
525 # Need to support HLT_mu26_ivarmedium_OR_HLT_mu50
526 triggerConfigs[chain_out] = chain
527 if chain_out in triggerConfigYears.keys():
528 triggerConfigYears[chain_out].append(year)
529 else:
530 triggerConfigYears[chain_out] = [year]
531 else:
532 for leg in legs:
533 if leg.startswith('mu') and leg[2].isdigit:
534 # Need to support HLT_mu14_ivarloose
535 leg_out = leg if self.removeHLTPrefix else f"HLT_{leg}"
536 triggerConfigs[leg_out] = f"HLT_{leg}"
537 if leg_out in triggerConfigYears.keys():
538 triggerConfigYears[leg_out].append(year)
539 else:
540 triggerConfigYears[leg_out] = [year]
541
542 if not triggerConfigs:
543 return
544
545 # Make the public tool for this configuration
546 sfTool = config.createPublicTool("CP::MuonTriggerScaleFactors", f"{self.instanceName()}_SFTool{self.customToolSuffix}")
547 # Reproduce config from TrigGlobalEfficiencyAlg
548 sfTool.MuonQuality = self.muonID
549 sfTool.AllowZeroSF = True
550 sfTool.CustomInputFolder = self.customInputFolder
551 sfTool.CustomInputFilePerYear = self.customInputFilePerYear
552 sfTool.Campaign = config.campaign().value
553
554 for trig_short, trig in triggerConfigs.items():
555 alg = config.createAlgorithm('CP::MuonTriggerEfficiencyScaleFactorAlg',
556 'MuonTrigEfficiencyCorrectionsAlg_' + trig_short)
557 alg.efficiencyScaleFactorTool = f"{sfTool.getType()}/{sfTool.getName()}"
558
559 # Avoid warnings for missing triggers
560 if self.includeAllYearsPerRun:
561 alg.minRunNumber = 0
562 alg.maxRunNumber = 999999
563
564 if triggerConfigYears[trig_short][0] != years[0]:
565 alg.minRunNumber = triggerYearStartBoundaries.get(triggerConfigYears[trig_short][0], 999999)
566 if triggerConfigYears[trig_short][-1] != years[-1]:
567 alg.maxRunNumber = triggerYearStartBoundaries.get(triggerConfigYears[trig_short][-1] + 1, 999999)
568 elif config.campaign() is Campaign.MC20a: # to avoid potential corner-cases keep the default config unchanged
569 if triggerConfigYears[trig_short] == [2015]:
570 alg.maxRunNumber = 290000
571 elif triggerConfigYears[trig_short] == [2016]:
572 alg.minRunNumber = 290000
573
574 alg.trigger = trig
575
576 # Some triggers in `250731_SummerUpdate` recommendations are not supported in 2022 period F
577 if config.campaign() is Campaign.MC23a and (trig_short == "HLT_mu8noL1_FSNOSEED" or trig_short == "HLT_mu22_L1MU14FCH"):
578 alg.minRunNumber = 435816 # Start of 2022 period H
579
580 if self.saveSF:
581 alg.scaleFactorDecoration = f"muon_{self.prefixSF}_{trig_short}_%SYS%"
582 if self.saveEff:
583 alg.mcEfficiencyDecoration = f"muon_{self.prefixEff}_{trig_short}_%SYS%"
584 if self.saveEffData:
585 alg.dataEfficiencyDecoration = f"muon_{self.prefixEffData}_{trig_short}_%SYS%"
586 alg.outOfValidity = 2 #silent
587 alg.outOfValidityDeco = f"bad_eff_muontrig_{trig_short}"
588 alg.muons = config.readName (self.containerName)
589 alg.preselection = config.getPreselection (self.containerName, '')
590 if self.saveSF:
591 config.addOutputVar (self.containerName, alg.scaleFactorDecoration, f"{self.prefixSF}_{trig_short}")
592 if self.saveEff:
593 config.addOutputVar (self.containerName, alg.mcEfficiencyDecoration, f"{self.prefixEff}_{trig_short}")
594 if self.saveEffData:
595 config.addOutputVar (self.containerName, alg.dataEfficiencyDecoration, f"{self.prefixEffData}_{trig_short}")
596
597
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition hcg.cxx:130

Member Data Documentation

◆ containerName

python.MuonAnalysisConfig.MuonTriggerAnalysisSFBlock.containerName

Definition at line 591 of file MuonAnalysisConfig.py.

◆ includeAllYearsPerRun

python.MuonAnalysisConfig.MuonTriggerAnalysisSFBlock.includeAllYearsPerRun

Definition at line 493 of file MuonAnalysisConfig.py.

◆ saveEff

python.MuonAnalysisConfig.MuonTriggerAnalysisSFBlock.saveEff

Definition at line 582 of file MuonAnalysisConfig.py.

◆ saveEffData

python.MuonAnalysisConfig.MuonTriggerAnalysisSFBlock.saveEffData

Definition at line 584 of file MuonAnalysisConfig.py.

◆ saveSF

python.MuonAnalysisConfig.MuonTriggerAnalysisSFBlock.saveSF

Definition at line 580 of file MuonAnalysisConfig.py.


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