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

◆ saveEffData

python.MuonAnalysisConfig.MuonTriggerAnalysisSFBlock.saveEffData

Definition at line 646 of file MuonAnalysisConfig.py.

◆ saveSF

python.MuonAnalysisConfig.MuonTriggerAnalysisSFBlock.saveSF

Definition at line 642 of file MuonAnalysisConfig.py.


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