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

Constructor & Destructor Documentation

◆ __init__()

python.MuonAnalysisConfig.MuonTriggerAnalysisSFBlock.__init__ ( self)

Definition at line 488 of file MuonAnalysisConfig.py.

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

Member Function Documentation

◆ instanceName()

python.MuonAnalysisConfig.MuonTriggerAnalysisSFBlock.instanceName ( self)

Definition at line 525 of file MuonAnalysisConfig.py.

525 def instanceName (self) :
526 return self.containerName + '_' + self.muonID
527

◆ makeAlgs()

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

Definition at line 528 of file MuonAnalysisConfig.py.

528 def makeAlgs (self, config) :
529
530 if config.dataType() is not DataType.Data:
531
532 # Dictionary from TrigGlobalEfficiencyCorrection/Triggers.cfg
533 # Key is trigger chain (w/o HLT prefix)
534 # Value is empty for single leg trigger or list of legs
535 triggerDict = TriggerDict()
536
537 if self.includeAllYearsPerRun:
538 years = [int(year) for year in self.triggerChainsPerYear.keys()]
539 else:
540 from TriggerAnalysisAlgorithms.TriggerAnalysisSFConfig import (
541 get_input_years)
542 years = get_input_years(config)
543
544 triggerYearStartBoundaries = {
545 2015: 260000,
546 2016: 290000,
547 2017: 324000,
548 2018: 348000,
549 2022: 410000,
550 2023: 450000,
551 2024: 470000,
552 2025: 495000,
553 2026: 516000,
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 config.setExtraInputs ({('xAOD::EventInfo', 'EventInfo.RandomRunNumber')})
604 alg.efficiencyScaleFactorTool = f"{sfTool.getType()}/{sfTool.getName()}"
605
606 # Avoid warnings for missing triggers
607 if self.includeAllYearsPerRun:
608 alg.minRunNumber = 0
609 alg.maxRunNumber = 999999
610
611 if triggerConfigYears[trig_short][0] != years[0]:
612 alg.minRunNumber = triggerYearStartBoundaries.get(triggerConfigYears[trig_short][0], 999999)
613 if triggerConfigYears[trig_short][-1] != years[-1]:
614 alg.maxRunNumber = triggerYearStartBoundaries.get(triggerConfigYears[trig_short][-1] + 1, 999999)
615 elif config.campaign() is Campaign.MC20a: # to avoid potential corner-cases keep the default config unchanged
616 if triggerConfigYears[trig_short] == [2015]:
617 alg.maxRunNumber = 290000
618 elif triggerConfigYears[trig_short] == [2016]:
619 alg.minRunNumber = 290000
620
621 alg.trigger = trig
622
623 # Some triggers in `250731_SummerUpdate` recommendations are not supported in 2022 period F
624 if config.campaign() is Campaign.MC23a and (trig_short == "HLT_mu8noL1_FSNOSEED" or trig_short == "HLT_mu22_L1MU14FCH"):
625 alg.minRunNumber = 435816 # Start of 2022 period H
626
627 if self.saveSF:
628 alg.scaleFactorDecoration = f"muon_{self.prefixSF}_{trig_short}_%SYS%"
629 if self.saveEff:
630 alg.mcEfficiencyDecoration = f"muon_{self.prefixEff}_{trig_short}_%SYS%"
631 if self.saveEffData:
632 alg.dataEfficiencyDecoration = f"muon_{self.prefixEffData}_{trig_short}_%SYS%"
633 alg.outOfValidity = 2 #silent
634 alg.outOfValidityDeco = f"bad_eff_muontrig_{trig_short}"
635 alg.muons = config.readName (self.containerName)
636 alg.preselection = config.getPreselection (self.containerName, '')
637 if self.saveSF:
638 config.addOutputVar (self.containerName, alg.scaleFactorDecoration, f"{self.prefixSF}_{trig_short}", auxType='float')
639 if self.saveEff:
640 config.addOutputVar (self.containerName, alg.mcEfficiencyDecoration, f"{self.prefixEff}_{trig_short}", auxType='float')
641 if self.saveEffData:
642 config.addOutputVar (self.containerName, alg.dataEfficiencyDecoration, f"{self.prefixEffData}_{trig_short}", auxType='float')
643
644
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 638 of file MuonAnalysisConfig.py.

◆ includeAllYearsPerRun

python.MuonAnalysisConfig.MuonTriggerAnalysisSFBlock.includeAllYearsPerRun

Definition at line 537 of file MuonAnalysisConfig.py.

◆ saveEff

python.MuonAnalysisConfig.MuonTriggerAnalysisSFBlock.saveEff

Definition at line 629 of file MuonAnalysisConfig.py.

◆ saveEffData

python.MuonAnalysisConfig.MuonTriggerAnalysisSFBlock.saveEffData

Definition at line 631 of file MuonAnalysisConfig.py.

◆ saveSF

python.MuonAnalysisConfig.MuonTriggerAnalysisSFBlock.saveSF

Definition at line 627 of file MuonAnalysisConfig.py.


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