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

Constructor & Destructor Documentation

◆ __init__()

python.MuonAnalysisConfig.MuonTriggerAnalysisSFBlock.__init__ ( self)

Definition at line 505 of file MuonAnalysisConfig.py.

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

Member Function Documentation

◆ instanceName()

python.MuonAnalysisConfig.MuonTriggerAnalysisSFBlock.instanceName ( self)

Definition at line 541 of file MuonAnalysisConfig.py.

541 def instanceName (self) :
542 return self.containerName + '_' + self.muonID
543

◆ makeAlgs()

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

Definition at line 544 of file MuonAnalysisConfig.py.

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

◆ includeAllYearsPerRun

python.MuonAnalysisConfig.MuonTriggerAnalysisSFBlock.includeAllYearsPerRun

Definition at line 553 of file MuonAnalysisConfig.py.

◆ saveEff

python.MuonAnalysisConfig.MuonTriggerAnalysisSFBlock.saveEff

Definition at line 642 of file MuonAnalysisConfig.py.

◆ saveEffData

python.MuonAnalysisConfig.MuonTriggerAnalysisSFBlock.saveEffData

Definition at line 644 of file MuonAnalysisConfig.py.

◆ saveSF

python.MuonAnalysisConfig.MuonTriggerAnalysisSFBlock.saveSF

Definition at line 640 of file MuonAnalysisConfig.py.


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