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

Constructor & Destructor Documentation

◆ __init__()

python.MuonAnalysisConfig.MuonTriggerAnalysisSFBlock.__init__ ( self)

Definition at line 482 of file MuonAnalysisConfig.py.

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

Member Function Documentation

◆ instanceName()

python.MuonAnalysisConfig.MuonTriggerAnalysisSFBlock.instanceName ( self)

Definition at line 518 of file MuonAnalysisConfig.py.

518 def instanceName (self) :
519 return self.containerName + '_' + self.muonID
520

◆ makeAlgs()

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

Definition at line 521 of file MuonAnalysisConfig.py.

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

Member Data Documentation

◆ containerName

python.MuonAnalysisConfig.MuonTriggerAnalysisSFBlock.containerName

Definition at line 628 of file MuonAnalysisConfig.py.

◆ includeAllYearsPerRun

python.MuonAnalysisConfig.MuonTriggerAnalysisSFBlock.includeAllYearsPerRun

Definition at line 530 of file MuonAnalysisConfig.py.

◆ saveEff

python.MuonAnalysisConfig.MuonTriggerAnalysisSFBlock.saveEff

Definition at line 619 of file MuonAnalysisConfig.py.

◆ saveEffData

python.MuonAnalysisConfig.MuonTriggerAnalysisSFBlock.saveEffData

Definition at line 621 of file MuonAnalysisConfig.py.

◆ saveSF

python.MuonAnalysisConfig.MuonTriggerAnalysisSFBlock.saveSF

Definition at line 617 of file MuonAnalysisConfig.py.


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