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

Constructor & Destructor Documentation

◆ __init__()

python.MuonAnalysisConfig.MuonTriggerAnalysisSFBlock.__init__ ( self)

Definition at line 486 of file MuonAnalysisConfig.py.

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

Member Function Documentation

◆ instanceName()

python.MuonAnalysisConfig.MuonTriggerAnalysisSFBlock.instanceName ( self)

Definition at line 523 of file MuonAnalysisConfig.py.

523 def instanceName (self) :
524 return self.containerName + '_' + self.muonID
525

◆ makeAlgs()

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

Definition at line 526 of file MuonAnalysisConfig.py.

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

◆ includeAllYearsPerRun

python.MuonAnalysisConfig.MuonTriggerAnalysisSFBlock.includeAllYearsPerRun

Definition at line 535 of file MuonAnalysisConfig.py.

◆ saveEff

python.MuonAnalysisConfig.MuonTriggerAnalysisSFBlock.saveEff

Definition at line 627 of file MuonAnalysisConfig.py.

◆ saveEffData

python.MuonAnalysisConfig.MuonTriggerAnalysisSFBlock.saveEffData

Definition at line 629 of file MuonAnalysisConfig.py.

◆ saveSF

python.MuonAnalysisConfig.MuonTriggerAnalysisSFBlock.saveSF

Definition at line 625 of file MuonAnalysisConfig.py.


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