ATLAS Offline Software
TriggerMatchingCommonConfig.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2 
3 #====================================================================
4 # TriggerMatchingCommonConfig.py
5 # This defines the common trigger matching shared by PHYS and PHYSLITE
6 # Using it avoids name clashes when running in trains
7 # In principle it can also be used by other formats who want to take
8 # advantage of PHYS/PHYSLITE containers
9 # Component accumulator version
10 #====================================================================
11 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
12 from AthenaConfiguration.ComponentFactory import CompFactory
13 from Campaigns.Utils import getMCCampaign, Campaign
14 from PathResolver import PathResolver
15 
17  """Read a text file containing a list of triggers
18 
19  Returns the list of triggers held in the file
20  """
21  triggers = []
22  with open(PathResolver.FindCalibFile(fname)) as fp:
23  for line in fp:
24  line = line.strip()
25  if line == "" or line.startswith("#"):
26  continue
27  triggers.append(line)
28  return triggers
29 
30 def getDataYear(flags):
31  dataYear = 0
32  if flags.Input.isMC:
33  campaign = getMCCampaign(flags.Input.Files)
34  dataYear = {
35  Campaign.MC20a: 2016, # prefer over 2015
36  Campaign.MC20d: 2017,
37  Campaign.MC20e: 2018,
38  Campaign.MC21a: 2022,
39  Campaign.MC23a: 2022,
40  Campaign.MC23c: 2023,
41  Campaign.MC23d: 2023,
42  Campaign.MC23e: 2024,
43  Campaign.PhaseII: 2030,
44  }[campaign]
45  else:
46  dataYear = flags.Input.DataYear
47  return dataYear
48 
50  """Adds the trigger matching info to the slimming helper"""
51 
52  slimmingHelper = kwargs['SlimmingHelper']
53  triggerList = kwargs['TriggerList']
54  containerPrefix = kwargs['OutputContainerPrefix']
55 
56  outputContainers = [
57  "{0}{1}".format(containerPrefix, chain).replace(".", "_")
58  for chain in triggerList
59  ]
60 
61  slimmingHelper.AllVariables += outputContainers
62  for cont in outputContainers:
63  slimmingHelper.AppendToDictionary.update(
64  {
65  cont: "xAOD::TrigCompositeContainer",
66  cont + "Aux": "AOD::AuxContainerBase!",
67  }
68  )
69 
71  slimmingHelper = kwargs['SlimmingHelper']
72  slimmingHelper.AppendToDictionary.update(
73  {
74  "LVL1JetRoIs":"xAOD::JetRoIContainer",
75  "LVL1JetRoIsAux":"xAOD::JetRoIAuxContainer"
76  }
77  )
78  slimmingHelper.AllVariables += ["LVL1JetRoIs"]
79 
81  slimmingHelper = kwargs['SlimmingHelper']
82  slimmingHelper.AppendToDictionary.update(
83  {
84  "L1_jFexSRJetRoI":"xAOD::jFexSRJetRoIContainer",
85  "L1_jFexSRJetRoIAux":"xAOD::jFexSRJetRoIAuxContainer"
86  }
87  )
88  slimmingHelper.AllVariables += ["L1_jFexSRJetRoI"]
89 
90 
91 def TriggerMatchingCommonRun2Cfg(flags, name, **kwargs):
92  """Configure the common trigger matching for run 2 DAODs using the run 2 analysis formalism (matching happens during derivation)"""
93 
94  acc = ComponentAccumulator()
95 
96  # Create trigger matching decorations
97  from DerivationFrameworkTrigger.TriggerMatchingToolConfig import TriggerMatchingToolCfg
98  PhysCommonTriggerMatchingTool = acc.getPrimaryAndMerge(TriggerMatchingToolCfg(flags, name=name, **kwargs))
99  CommonAugmentation = CompFactory.DerivationFramework.CommonAugmentation
100  outputContainerPrefix = kwargs['OutputContainerPrefix']
101  acc.addEventAlgo(CommonAugmentation(f"{outputContainerPrefix}TriggerMatchingKernel",
102  AugmentationTools=[PhysCommonTriggerMatchingTool]))
103 
104  return(acc)
105 
107  """Covert run 2 trigger navigation data these data into the run 3 formalism (matching happens from DAOD)"""
108 
109  acc = ComponentAccumulator()
110 
111  if not flags.Trigger.doEDMVersionConversion:
112  return(acc)
113 
114  from AthenaCommon.Logging import logging
115  msg = logging.getLogger('TriggerMatchingCommonRun2ToRun3Cfg')
116  msg.info('doEDMVersionConversion is True, now scheduling conversion of Run 2 trigger navigation to Run 3')
117 
118  from TrigNavTools.NavConverterConfig import NavConverterCfg
119 
120  # And then run the run 3 slimming on the output of NavConverter
121  triggerList = kwargs['TriggerList']
122  acc.merge(NavConverterCfg(flags, chainsList = triggerList))
123  from TrigNavSlimmingMT.TrigNavSlimmingMTConfig import TrigNavSlimmingMTDerivationCfg
124  acc.merge(TrigNavSlimmingMTDerivationCfg(flags,chainsFilter=triggerList))
125 
126  return(acc)
127 
128 
129 def TriggerMatchingCommonRun3Cfg(flags, **kwargs):
130  """Configure the common trigger matching for run 3 DAODs using the run 3 formalism (matching happens from DAOD)"""
131 
132  if flags.Trigger.EDMVersion != 3:
133  raise ValueError('This configuration can only be used for Run 3 trigger navigation')
134 
135  triggerList = kwargs['TriggerList']
136 
137  acc = ComponentAccumulator()
138 
139  # Run 3 trigger navigation slimming proposal for in-DAOD trigger matching.
140  from TrigNavSlimmingMT.TrigNavSlimmingMTConfig import TrigNavSlimmingMTDerivationCfg
141  acc.merge(TrigNavSlimmingMTDerivationCfg(flags,chainsFilter=triggerList))
142 
143  return(acc)
replace
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition: hcg.cxx:307
python.TriggerMatchingCommonConfig.TriggerMatchingCommonRun2Cfg
def TriggerMatchingCommonRun2Cfg(flags, name, **kwargs)
Definition: TriggerMatchingCommonConfig.py:91
PathResolver::FindCalibFile
static std::string FindCalibFile(const std::string &logical_file_name)
Definition: PathResolver.h:108
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
vtune_athena.format
format
Definition: vtune_athena.py:14
TrigNavSlimmingMTConfig.TrigNavSlimmingMTDerivationCfg
def TrigNavSlimmingMTDerivationCfg(flags, chainsFilter=[])
Definition: TrigNavSlimmingMTConfig.py:54
python.TriggerMatchingCommonConfig.AddjFexRoIsToSlimmingHelper
def AddjFexRoIsToSlimmingHelper(**kwargs)
Definition: TriggerMatchingCommonConfig.py:80
python.TriggerMatchingCommonConfig.getDataYear
def getDataYear(flags)
Definition: TriggerMatchingCommonConfig.py:30
python.TriggerMatchingCommonConfig.AddRun2TriggerMatchingToSlimmingHelper
def AddRun2TriggerMatchingToSlimmingHelper(**kwargs)
Definition: TriggerMatchingCommonConfig.py:49
python.TriggerMatchingCommonConfig.TriggerMatchingCommonRun2ToRun3Cfg
def TriggerMatchingCommonRun2ToRun3Cfg(flags, **kwargs)
Definition: TriggerMatchingCommonConfig.py:106
TriggerMatchingToolConfig.TriggerMatchingToolCfg
def TriggerMatchingToolCfg(ConfigFlags, name, UseTypedScoringTool=False, **kwargs)
Definition: PhysicsAnalysis/DerivationFramework/DerivationFrameworkTrigger/python/TriggerMatchingToolConfig.py:19
python.TriggerMatchingCommonConfig.read_trig_list_file
def read_trig_list_file(fname)
Definition: TriggerMatchingCommonConfig.py:16
Trk::open
@ open
Definition: BinningType.h:40
python.TriggerMatchingCommonConfig.AddLegacyL1JetRoIsToSlimmingHelper
def AddLegacyL1JetRoIsToSlimmingHelper(**kwargs)
Definition: TriggerMatchingCommonConfig.py:70
python.TriggerMatchingCommonConfig.TriggerMatchingCommonRun3Cfg
def TriggerMatchingCommonRun3Cfg(flags, **kwargs)
Definition: TriggerMatchingCommonConfig.py:129
python.Utils.getMCCampaign
def getMCCampaign(files)
Definition: Tools/Campaigns/python/Utils.py:27
python.NavConverterConfig.NavConverterCfg
def NavConverterCfg(flags, chainsList=[], runTheChecker=False)
Definition: NavConverterConfig.py:12