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

Constructor & Destructor Documentation

◆ __init__()

python.MuonAnalysisConfig.MuonTriggerAnalysisSFBlock.__init__ ( self)

Definition at line 491 of file MuonAnalysisConfig.py.

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

Member Function Documentation

◆ instanceName()

python.MuonAnalysisConfig.MuonTriggerAnalysisSFBlock.instanceName ( self)

Definition at line 527 of file MuonAnalysisConfig.py.

527 def instanceName (self) :
528 return self.containerName + '_' + self.muonID
529

◆ makeAlgs()

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

Definition at line 530 of file MuonAnalysisConfig.py.

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

◆ includeAllYearsPerRun

python.MuonAnalysisConfig.MuonTriggerAnalysisSFBlock.includeAllYearsPerRun

Definition at line 539 of file MuonAnalysisConfig.py.

◆ saveEff

python.MuonAnalysisConfig.MuonTriggerAnalysisSFBlock.saveEff

Definition at line 628 of file MuonAnalysisConfig.py.

◆ saveEffData

python.MuonAnalysisConfig.MuonTriggerAnalysisSFBlock.saveEffData

Definition at line 630 of file MuonAnalysisConfig.py.

◆ saveSF

python.MuonAnalysisConfig.MuonTriggerAnalysisSFBlock.saveSF

Definition at line 626 of file MuonAnalysisConfig.py.


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