ATLAS Offline Software
MuonsExtraTriggerConfig.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2 
3 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
4 
5 from TriggerMenuMT.TriggerAPI.TriggerAPI import TriggerAPI
6 from TriggerMenuMT.TriggerAPI.TriggerEnums import TriggerPeriod, TriggerType
7 from AthenaConfiguration.AutoConfigFlags import GetFileMD
8 from DerivationFrameworkPhys.TriggerListsHelper import read_trig_list_file
9 from DerivationFrameworkPhys.TriggerMatchingCommonConfig import AddRun2TriggerMatchingToSlimmingHelper
10 from DerivationFrameworkPhys.TriggerMatchingCommonConfig import TriggerMatchingCommonRun2Cfg
11 
12 
13 # Helper class to add extra trigger content to the Muon derivations.
15  def __init__(self, flags, existingTriggerHelper):
16  self.flags = flags
17  TriggerAPI.setConfigFlags(flags)
18  self.extraChainList = []
19  self.existingTriggerHelper = existingTriggerHelper
20  self.FindExtraChainsRun2()
21 
22  # Find the chains missing in the existing trigger helper
24 
25  md = GetFileMD(self.flags.Input.Files)
26  hlt_menu = md.get('TriggerMenu', {}).get('HLTChains', None)
27 
28  if self.flags.Trigger.EDMVersion <= 2:
29 
30  # Trigger API for Runs 1, 2
31  allperiods = TriggerPeriod.y2015 | TriggerPeriod.y2016 | TriggerPeriod.y2017 | TriggerPeriod.y2018 | TriggerPeriod.future2e34
32  trig_bmu = TriggerAPI.getLowestUnprescaledAnyPeriod(allperiods, triggerType=TriggerType.mu_bphys, livefraction=0.8)
33 
34 
35  extra_file = read_trig_list_file("DerivationFrameworkMuons/run2ExtraMatchingTriggers.txt")
36 
37 
38  trigger_names_full = list(set(trig_bmu+extra_file))
39 
40  if hlt_menu:
41  for chain_name in hlt_menu:
42  if chain_name in trigger_names_full:
43  self.extraChainList.append(chain_name)
44  else: # No means to filter based on in-file metadata
45  self.extraChainList = trigger_names_full
46 
47  # remove overlap with the existing chains
48  self.extraChainList = [c for c in self.extraChainList if c not in self.existingTriggerHelper.Run2TriggerNamesNoTau and c not in self.existingTriggerHelper.Run2TriggerNamesTau ]
49 
50  # schedule the trigger matching tool for our new chains
51  def Run2MatchAugmentationCfg(self, flags, name="PhysCommonTrigMatchExtraMuons"):
52  acc = ComponentAccumulator()
54  flags,
55  name = name,
56  OutputContainerPrefix = "TrigMatch_",
57  ChainNames = self.extraChainList))
58  return acc
59 
60  # add our new match branches to the slimming helper
61  def AddRun2MatchingToSlimmingHelper(self,SlimmingHelper,
62  OutputContainerPrefix = "TrigMatch_"):
63  AddRun2TriggerMatchingToSlimmingHelper(SlimmingHelper = SlimmingHelper,
64  OutputContainerPrefix = OutputContainerPrefix,
65  TriggerList = self.extraChainList)
66 
python.TriggerMatchingCommonConfig.TriggerMatchingCommonRun2Cfg
def TriggerMatchingCommonRun2Cfg(flags, name, **kwargs)
Definition: TriggerMatchingCommonConfig.py:91
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
python.MuonsExtraTriggerConfig.MuonExtraTriggerHelper.Run2MatchAugmentationCfg
def Run2MatchAugmentationCfg(self, flags, name="PhysCommonTrigMatchExtraMuons")
Definition: MuonsExtraTriggerConfig.py:51
python.AutoConfigFlags.GetFileMD
def GetFileMD(filenames, allowEmpty=True)
Definition: AutoConfigFlags.py:51
dumpHVPathFromNtuple.append
bool append
Definition: dumpHVPathFromNtuple.py:91
python.TriggerMatchingCommonConfig.AddRun2TriggerMatchingToSlimmingHelper
def AddRun2TriggerMatchingToSlimmingHelper(**kwargs)
Definition: TriggerMatchingCommonConfig.py:49
python.MuonsExtraTriggerConfig.MuonExtraTriggerHelper.flags
flags
Definition: MuonsExtraTriggerConfig.py:16
histSizes.list
def list(name, path='/')
Definition: histSizes.py:38
python.MuonsExtraTriggerConfig.MuonExtraTriggerHelper
Definition: MuonsExtraTriggerConfig.py:14
CxxUtils::set
constexpr std::enable_if_t< is_bitmask_v< E >, E & > set(E &lhs, E rhs)
Convenience function to set bits in a class enum bitmask.
Definition: bitmask.h:232
python.TriggerListsHelper.read_trig_list_file
def read_trig_list_file(fname)
Definition: TriggerListsHelper.py:9
python.MuonsExtraTriggerConfig.MuonExtraTriggerHelper.AddRun2MatchingToSlimmingHelper
def AddRun2MatchingToSlimmingHelper(self, SlimmingHelper, OutputContainerPrefix="TrigMatch_")
Definition: MuonsExtraTriggerConfig.py:61
python.MuonsExtraTriggerConfig.MuonExtraTriggerHelper.extraChainList
extraChainList
Allow for an additional include-list without polluting PHYS.
Definition: MuonsExtraTriggerConfig.py:18
python.MuonsExtraTriggerConfig.MuonExtraTriggerHelper.existingTriggerHelper
existingTriggerHelper
Definition: MuonsExtraTriggerConfig.py:19
python.MuonsExtraTriggerConfig.MuonExtraTriggerHelper.__init__
def __init__(self, flags, existingTriggerHelper)
Definition: MuonsExtraTriggerConfig.py:15
get
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition: hcg.cxx:127
python.MuonsExtraTriggerConfig.MuonExtraTriggerHelper.FindExtraChainsRun2
def FindExtraChainsRun2(self)
Definition: MuonsExtraTriggerConfig.py:23