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 511 of file MuonAnalysisConfig.py.

Constructor & Destructor Documentation

◆ __init__()

python.MuonAnalysisConfig.MuonTriggerAnalysisSFBlock.__init__ ( self)

Definition at line 513 of file MuonAnalysisConfig.py.

513 def __init__ (self) :
514 super (MuonTriggerAnalysisSFBlock, self).__init__ ()
515 self.addDependency('EventSelection', required=False)
516 self.addDependency('EventSelectionMerger', required=False)
517 self.addOption ('triggerChainsPerYear', {}, type=dict,
518 info="a dictionary with key (string) the year and value (list of "
519 "strings) the trigger chains.")
520 self.addOption ('muonID', '', type=str,
521 info="the muon quality WP to use.")
522 self.addOption ('saveSF', True, type=bool,
523 info="whether to decorate the trigger scale factor.")
524 self.addOption ('saveEff', False, type=bool,
525 info="whether to decorate the trigger MC efficiencies.")
526 self.addOption ('saveEffData', False, type=bool,
527 info="whether to decorate the trigger data efficiencies.")
528 self.addOption ('prefixSF', 'trigEffSF', type=str,
529 info="the decoration prefix for trigger scale factors.")
530 self.addOption ('prefixEff', 'trigEff', type=str,
531 info="the decoration prefix for MC trigger efficiencies.")
532 self.addOption ('prefixEffData', 'trigEffData', type=str,
533 info="the decoration prefix for data trigger efficiencies.")
534 self.addOption ('includeAllYearsPerRun', False, type=bool,
535 info="all configured years in the LHC run will "
536 "be included in all jobs.")
537 self.addOption ('removeHLTPrefix', True, type=bool,
538 info="remove the HLT prefix from trigger chain names.")
539 self.addOption ('containerName', '', type=str,
540 info="the input muon container, with a possible selection, in "
541 "the format `container` or `container.selection`.")
542 self.addOption ('customToolSuffix', '', type=str,
543 expertMode=True, info="EXPERIMENTAL: specify custom suffix for the public tool name")
544 self.addOption ('customInputFolder', '', type=str,
545 expertMode=True, info="EXPERIMENTAL: specify custom input folder")
546 self.addOption ('customInputFilePerYear', {}, type=dict,
547 expertMode=True, info="EXPERIMENTAL: specify custom input file per year")
548

Member Function Documentation

◆ instanceName()

python.MuonAnalysisConfig.MuonTriggerAnalysisSFBlock.instanceName ( self)

Definition at line 549 of file MuonAnalysisConfig.py.

549 def instanceName (self) :
550 return self.containerName + '_' + self.muonID
551

◆ makeAlgs()

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

Definition at line 552 of file MuonAnalysisConfig.py.

552 def makeAlgs (self, config) :
553
554 if config.dataType() is not DataType.Data:
555
556 # Dictionary from TrigGlobalEfficiencyCorrection/Triggers.cfg
557 # Key is trigger chain (w/o HLT prefix)
558 # Value is empty for single leg trigger or list of legs
559 triggerDict = TriggerDict()
560
561 if self.includeAllYearsPerRun:
562 years = [int(year) for year in self.triggerChainsPerYear.keys()]
563 else:
564 from TriggerAnalysisAlgorithms.TriggerAnalysisSFConfig import (
565 get_input_years)
566 years = get_input_years(config)
567
568 triggerYearStartBoundaries = {
569 2015: 260000,
570 2016: 290000,
571 2017: 324000,
572 2018: 348000,
573 2022: 410000,
574 2023: 450000,
575 2024: 470000,
576 2025: 495000,
577 2026: 516000,
578 }
579
580 triggerConfigs = {}
581 triggerConfigYears = {}
582 from TriggerAnalysisAlgorithms.TriggerAnalysisConfig import is_year_in_current_period
583 for year in years:
584 if not is_year_in_current_period(config, year):
585 continue
586
587 triggerChains = self.triggerChainsPerYear.get(int(year), self.triggerChainsPerYear.get(str(year), []))
588 for chain in triggerChains:
589 chain = chain.replace(" || ", "_OR_")
590 chain_noHLT = chain.replace("HLT_", "")
591 chain_out = chain_noHLT if self.removeHLTPrefix else chain
592 legs = triggerDict[chain_noHLT]
593 if not legs:
594 if chain_noHLT.startswith('mu') and chain_noHLT[2].isdigit:
595 # Need to support HLT_mu26_ivarmedium_OR_HLT_mu50
596 triggerConfigs[chain_out] = chain
597 if chain_out in triggerConfigYears.keys():
598 triggerConfigYears[chain_out].append(year)
599 else:
600 triggerConfigYears[chain_out] = [year]
601 else:
602 for leg in legs:
603 if leg.startswith('mu') and leg[2].isdigit:
604 # Need to support HLT_mu14_ivarloose
605 leg_out = leg if self.removeHLTPrefix else f"HLT_{leg}"
606 triggerConfigs[leg_out] = f"HLT_{leg}"
607 if leg_out in triggerConfigYears.keys():
608 triggerConfigYears[leg_out].append(year)
609 else:
610 triggerConfigYears[leg_out] = [year]
611
612 if not triggerConfigs:
613 return
614
615 # Make the public tool for this configuration
616 sfTool = config.createPublicTool("CP::MuonTriggerScaleFactors", f"{self.instanceName()}_SFTool{self.customToolSuffix}")
617 # Reproduce config from TrigGlobalEfficiencyAlg
618 sfTool.MuonQuality = self.muonID
619 sfTool.AllowZeroSF = True
620 sfTool.CustomInputFolder = self.customInputFolder
621 sfTool.CustomInputFilePerYear = self.customInputFilePerYear
622 sfTool.Campaign = config.campaign().value
623
624 for trig_short, trig in triggerConfigs.items():
625 alg = config.createAlgorithm('CP::MuonTriggerEfficiencyScaleFactorAlg',
626 'MuonTrigEfficiencyCorrectionsAlg_' + trig_short)
627 alg.efficiencyScaleFactorTool = f"{sfTool.getType()}/{sfTool.getName()}"
628
629 # Avoid warnings for missing triggers
630 if self.includeAllYearsPerRun:
631 alg.minRunNumber = 0
632 alg.maxRunNumber = 999999
633
634 if triggerConfigYears[trig_short][0] != years[0]:
635 alg.minRunNumber = triggerYearStartBoundaries.get(triggerConfigYears[trig_short][0], 999999)
636 if triggerConfigYears[trig_short][-1] != years[-1]:
637 alg.maxRunNumber = triggerYearStartBoundaries.get(triggerConfigYears[trig_short][-1] + 1, 999999)
638 elif config.campaign() is Campaign.MC20a: # to avoid potential corner-cases keep the default config unchanged
639 if triggerConfigYears[trig_short] == [2015]:
640 alg.maxRunNumber = 290000
641 elif triggerConfigYears[trig_short] == [2016]:
642 alg.minRunNumber = 290000
643
644 alg.trigger = trig
645
646 # Some triggers in `250731_SummerUpdate` recommendations are not supported in 2022 period F
647 if config.campaign() is Campaign.MC23a and (trig_short == "HLT_mu8noL1_FSNOSEED" or trig_short == "HLT_mu22_L1MU14FCH"):
648 alg.minRunNumber = 435816 # Start of 2022 period H
649
650 if self.saveSF:
651 alg.scaleFactorDecoration = f"muon_{self.prefixSF}_{trig_short}_%SYS%"
652 if self.saveEff:
653 alg.mcEfficiencyDecoration = f"muon_{self.prefixEff}_{trig_short}_%SYS%"
654 if self.saveEffData:
655 alg.dataEfficiencyDecoration = f"muon_{self.prefixEffData}_{trig_short}_%SYS%"
656 alg.outOfValidity = 2 #silent
657 alg.outOfValidityDeco = f"bad_eff_muontrig_{trig_short}"
658 alg.muons = config.readName (self.containerName)
659 alg.preselection = config.getPreselection (self.containerName, '')
660 if self.saveSF:
661 config.addOutputVar (self.containerName, alg.scaleFactorDecoration, f"{self.prefixSF}_{trig_short}")
662 if self.saveEff:
663 config.addOutputVar (self.containerName, alg.mcEfficiencyDecoration, f"{self.prefixEff}_{trig_short}")
664 if self.saveEffData:
665 config.addOutputVar (self.containerName, alg.dataEfficiencyDecoration, f"{self.prefixEffData}_{trig_short}")
666
667
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition hcg.cxx:132

Member Data Documentation

◆ containerName

python.MuonAnalysisConfig.MuonTriggerAnalysisSFBlock.containerName

Definition at line 661 of file MuonAnalysisConfig.py.

◆ includeAllYearsPerRun

python.MuonAnalysisConfig.MuonTriggerAnalysisSFBlock.includeAllYearsPerRun

Definition at line 561 of file MuonAnalysisConfig.py.

◆ saveEff

python.MuonAnalysisConfig.MuonTriggerAnalysisSFBlock.saveEff

Definition at line 652 of file MuonAnalysisConfig.py.

◆ saveEffData

python.MuonAnalysisConfig.MuonTriggerAnalysisSFBlock.saveEffData

Definition at line 654 of file MuonAnalysisConfig.py.

◆ saveSF

python.MuonAnalysisConfig.MuonTriggerAnalysisSFBlock.saveSF

Definition at line 650 of file MuonAnalysisConfig.py.


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