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

Constructor & Destructor Documentation

◆ __init__()

python.MuonAnalysisConfig.MuonTriggerAnalysisSFBlock.__init__ ( self)

Definition at line 487 of file MuonAnalysisConfig.py.

487 def __init__ (self) :
488 super (MuonTriggerAnalysisSFBlock, self).__init__ ()
489 self.addDependency('EventSelection', required=False)
490 self.addDependency('EventSelectionMerger', required=False)
491 self.addOption ('triggerChainsPerYear', {}, type=dict,
492 info="a dictionary with key (string) the year and value (list of "
493 "strings) the trigger chains.")
494 self.addOption ('muonID', '', type=str,
495 info="the muon quality WP to use.")
496 self.addOption ('saveSF', True, type=bool,
497 info="whether to decorate the trigger scale factor.")
498 self.addOption ('saveEff', False, type=bool,
499 info="whether to decorate the trigger MC efficiencies.")
500 self.addOption ('saveEffData', False, type=bool,
501 info="whether to decorate the trigger data efficiencies.")
502 self.addOption ('prefixSF', 'trigEffSF', type=str,
503 info="the decoration prefix for trigger scale factors.")
504 self.addOption ('prefixEff', 'trigEff', type=str,
505 info="the decoration prefix for MC trigger efficiencies.")
506 self.addOption ('prefixEffData', 'trigEffData', type=str,
507 info="the decoration prefix for data trigger efficiencies.")
508 self.addOption ('includeAllYearsPerRun', False, type=bool,
509 info="all configured years in the LHC run will "
510 "be included in all jobs.")
511 self.addOption ('removeHLTPrefix', True, type=bool,
512 info="remove the HLT prefix from trigger chain names.")
513 self.addOption ('containerName', '', type=str,
514 info="the input muon container, with a possible selection, in "
515 "the format `container` or `container.selection`.")
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 }
551
552 triggerConfigs = {}
553 triggerConfigYears = {}
554 from TriggerAnalysisAlgorithms.TriggerAnalysisConfig import is_year_in_current_period
555 for year in years:
556 if not is_year_in_current_period(config, year):
557 continue
558
559 triggerChains = self.triggerChainsPerYear.get(int(year), self.triggerChainsPerYear.get(str(year), []))
560 for chain in triggerChains:
561 chain = chain.replace(" || ", "_OR_")
562 chain_noHLT = chain.replace("HLT_", "")
563 chain_out = chain_noHLT if self.removeHLTPrefix else chain
564 legs = triggerDict[chain_noHLT]
565 if not legs:
566 if chain_noHLT.startswith('mu') and chain_noHLT[2].isdigit:
567 # Need to support HLT_mu26_ivarmedium_OR_HLT_mu50
568 triggerConfigs[chain_out] = chain
569 if chain_out in triggerConfigYears.keys():
570 triggerConfigYears[chain_out].append(year)
571 else:
572 triggerConfigYears[chain_out] = [year]
573 else:
574 for leg in legs:
575 if leg.startswith('mu') and leg[2].isdigit:
576 # Need to support HLT_mu14_ivarloose
577 leg_out = leg if self.removeHLTPrefix else f"HLT_{leg}"
578 triggerConfigs[leg_out] = f"HLT_{leg}"
579 if leg_out in triggerConfigYears.keys():
580 triggerConfigYears[leg_out].append(year)
581 else:
582 triggerConfigYears[leg_out] = [year]
583
584 if not triggerConfigs:
585 return
586
587 # Make the public tool for this configuration
588 sfTool = config.createPublicTool("CP::MuonTriggerScaleFactors", f"{self.instanceName()}_SFTool{self.customToolSuffix}")
589 # Reproduce config from TrigGlobalEfficiencyAlg
590 sfTool.MuonQuality = self.muonID
591 sfTool.AllowZeroSF = True
592 sfTool.CustomInputFolder = self.customInputFolder
593 sfTool.CustomInputFilePerYear = self.customInputFilePerYear
594 sfTool.Campaign = config.campaign().value
595
596 for trig_short, trig in triggerConfigs.items():
597 alg = config.createAlgorithm('CP::MuonTriggerEfficiencyScaleFactorAlg',
598 'MuonTrigEfficiencyCorrectionsAlg_' + trig_short)
599 alg.efficiencyScaleFactorTool = f"{sfTool.getType()}/{sfTool.getName()}"
600
601 # Avoid warnings for missing triggers
602 if self.includeAllYearsPerRun:
603 alg.minRunNumber = 0
604 alg.maxRunNumber = 999999
605
606 if triggerConfigYears[trig_short][0] != years[0]:
607 alg.minRunNumber = triggerYearStartBoundaries.get(triggerConfigYears[trig_short][0], 999999)
608 if triggerConfigYears[trig_short][-1] != years[-1]:
609 alg.maxRunNumber = triggerYearStartBoundaries.get(triggerConfigYears[trig_short][-1] + 1, 999999)
610 elif config.campaign() is Campaign.MC20a: # to avoid potential corner-cases keep the default config unchanged
611 if triggerConfigYears[trig_short] == [2015]:
612 alg.maxRunNumber = 290000
613 elif triggerConfigYears[trig_short] == [2016]:
614 alg.minRunNumber = 290000
615
616 alg.trigger = trig
617
618 # Some triggers in `250731_SummerUpdate` recommendations are not supported in 2022 period F
619 if config.campaign() is Campaign.MC23a and (trig_short == "HLT_mu8noL1_FSNOSEED" or trig_short == "HLT_mu22_L1MU14FCH"):
620 alg.minRunNumber = 435816 # Start of 2022 period H
621
622 if self.saveSF:
623 alg.scaleFactorDecoration = f"muon_{self.prefixSF}_{trig_short}_%SYS%"
624 if self.saveEff:
625 alg.mcEfficiencyDecoration = f"muon_{self.prefixEff}_{trig_short}_%SYS%"
626 if self.saveEffData:
627 alg.dataEfficiencyDecoration = f"muon_{self.prefixEffData}_{trig_short}_%SYS%"
628 alg.outOfValidity = 2 #silent
629 alg.outOfValidityDeco = f"bad_eff_muontrig_{trig_short}"
630 alg.muons = config.readName (self.containerName)
631 alg.preselection = config.getPreselection (self.containerName, '')
632 if self.saveSF:
633 config.addOutputVar (self.containerName, alg.scaleFactorDecoration, f"{self.prefixSF}_{trig_short}")
634 if self.saveEff:
635 config.addOutputVar (self.containerName, alg.mcEfficiencyDecoration, f"{self.prefixEff}_{trig_short}")
636 if self.saveEffData:
637 config.addOutputVar (self.containerName, alg.dataEfficiencyDecoration, f"{self.prefixEffData}_{trig_short}")
638
639
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 633 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 624 of file MuonAnalysisConfig.py.

◆ saveEffData

python.MuonAnalysisConfig.MuonTriggerAnalysisSFBlock.saveEffData

Definition at line 626 of file MuonAnalysisConfig.py.

◆ saveSF

python.MuonAnalysisConfig.MuonTriggerAnalysisSFBlock.saveSF

Definition at line 622 of file MuonAnalysisConfig.py.


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