ATLAS Offline Software
Loading...
Searching...
No Matches
TLA2.py
Go to the documentation of this file.
1# Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
2#====================================================================
3# Slimmed DAOD_PHYSLITE.py for Run 3 trigger-object level analyses (TLAs)
4# It contains minimal variables needed for the Run 3 ISR+DiJet TLA searches
5#====================================================================
6
7from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
8from AthenaConfiguration.ComponentFactory import CompFactory
9from AthenaConfiguration.Enums import MetadataCategory
10
11# Skimming config
12def TLA2SkimmingCfg(flags):
13 """Configure the skimming tool"""
14 acc = ComponentAccumulator()
15
16 from DerivationFrameworkTLA.TLATriggerList import SupportPhotonTriggers, PrimaryISRTLATriggers, SupportTLATriggers, FTagPEBTLATriggers
17
18 tlaLiteTriggerList = PrimaryISRTLATriggers + SupportTLATriggers + SupportPhotonTriggers + FTagPEBTLATriggers
19
20
21 if not flags.Input.isMC:
22 TLA2TriggerSkimmingTool = CompFactory.DerivationFramework.TriggerSkimmingTool(
23 name = "TLA2TriggerSkimmingTool1",
24 TriggerListOR = tlaLiteTriggerList
25 )
26 acc.addPublicTool(TLA2TriggerSkimmingTool, primary=True)
27
28 return acc
29
30
31# Main thinning config and common augmentations
32def TLA2KernelCfg(flags, name='TLA2Kernel', **kwargs):
33 """Configure the derivation framework driving algorithm (kernel) for TLA2"""
34 acc = ComponentAccumulator()
35
36 # Skimming
37 skimmingTool = None
38 if not flags.Input.isMC:
39 skimmingTool = acc.getPrimaryAndMerge(TLA2SkimmingCfg(flags))
40
41 # Common augmentations
42 from DerivationFrameworkTLA.TLACommonConfig import TLACommonAugmentationsCfg
43 acc.merge(TLACommonAugmentationsCfg(flags, prefix="TLA2_", TriggerListsHelper = kwargs['TriggerListsHelper']))
44
45 from DerivationFrameworkInDet.InDetToolsConfig import InDetTrackSelectionToolWrapperCfg
46 DFCommonTrackSelection = acc.getPrimaryAndMerge(InDetTrackSelectionToolWrapperCfg(
47 flags,
48 name = "DFCommonTrackSelectionLoose",
49 CutLevel = "Loose",
50 DecorationName = "DFTLA2Loose"))
51
52 acc.addEventAlgo(CompFactory.DerivationFramework.CommonAugmentation("TLA2CommonKernel", AugmentationTools = [DFCommonTrackSelection]))
53
54 # Thinning tools...
55 from DerivationFrameworkInDet.InDetToolsConfig import MuonTrackParticleThinningCfg, EgammaTrackParticleThinningCfg, JetTrackParticleThinningCfg
56
57 # Include inner detector tracks associated with muons
58 TLA2MuonTPThinningTool = acc.getPrimaryAndMerge(MuonTrackParticleThinningCfg(
59 flags,
60 name = "TLA2MuonTPThinningTool",
61 StreamName = kwargs['StreamName'],
62 MuonKey = "Muons",
63 InDetTrackParticlesKey = "InDetTrackParticles"))
64
65 # Include inner detector tracks associated with electonrs
66 TLA2ElectronTPThinningTool = acc.getPrimaryAndMerge(EgammaTrackParticleThinningCfg(
67 flags,
68 name = "TLA2ElectronTPThinningTool",
69 StreamName = kwargs['StreamName'],
70 SGKey = "Electrons",
71 InDetTrackParticlesKey = "InDetTrackParticles"))
72
73 TLA2_thinning_expression = ""
74
75 TLA2Akt4JetTPThinningTool = acc.getPrimaryAndMerge(JetTrackParticleThinningCfg(
76 flags,
77 name = "TLA2Akt4JetTPThinningTool",
78 StreamName = kwargs['StreamName'],
79 JetKey = "AntiKt4EMTopoJets",
80 SelectionString = "AntiKt4EMTopoJets.pt > 18*GeV",
81 TrackSelectionString = TLA2_thinning_expression,
82 InDetTrackParticlesKey = "InDetTrackParticles"))
83
84 TLA2Akt4PFlowJetTPThinningTool = acc.getPrimaryAndMerge(JetTrackParticleThinningCfg(
85 flags,
86 name = "TLA2Akt4PFlowJetTPThinningTool",
87 StreamName = kwargs['StreamName'],
88 JetKey = "AntiKt4EMPFlowJets",
89 SelectionString = "AntiKt4EMPFlowJets.pt > 18*GeV",
90 TrackSelectionString = TLA2_thinning_expression,
91 InDetTrackParticlesKey = "InDetTrackParticles"))
92
93 # Finally the kernel itself
94 thinningTools = [TLA2MuonTPThinningTool,
95 TLA2ElectronTPThinningTool,
96 TLA2Akt4JetTPThinningTool,
97 TLA2Akt4PFlowJetTPThinningTool]
98
99 # create the derivation kernel
100 DerivationKernel = CompFactory.DerivationFramework.DerivationKernel
101 acc.addEventAlgo(DerivationKernel(
102 name,
103 ThinningTools = thinningTools,
104 SkimmingTools = [skimmingTool] if skimmingTool is not None else []
105 ))
106
107
108 return acc
109
110# Main setup of the config & format
111def TLA2Cfg(flags):
112 stream_name = 'StreamDAOD_TLA2'
113 acc = ComponentAccumulator()
114
115 # Get the lists of triggers needed for trigger matching.
116 # This is needed at this scope (for the slimming) and further down in the config chain
117 # for actually configuring the matching, so we create it here and pass it down
118 from DerivationFrameworkPhys.TriggerListsHelper import TriggerListsHelper
119 TLA2TriggerListsHelper = TriggerListsHelper(flags)
120
121
122 # Common augmentations and TLA2 thinning & skimming
123 acc.merge(TLA2KernelCfg(flags, name="TLA2Kernel", StreamName = stream_name, TriggerListsHelper = TLA2TriggerListsHelper))
124
125 # ============================
126 # Define contents of the format
127 # =============================
128 from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
129 from xAODMetaDataCnv.InfileMetaDataConfig import SetupMetaDataForStreamCfg
130 from DerivationFrameworkCore.SlimmingHelper import SlimmingHelper
131
132 TLA2SlimmingHelper = SlimmingHelper("TLA2SlimmingHelper", NamesAndTypes = flags.Input.TypedCollections, flags = flags)
133
134 TLA2SlimmingHelper.SmartCollections = [
135 "EventInfo",
136 "Electrons",
137 "Photons",
138 "PrimaryVertices",
139 "Muons",
140 "AntiKt4EMTopoJets",
141 "AntiKt4EMPFlowJets",
142
143 ]
144
145 # Extra content
146 if flags.Input.isMC:
147 TLA2SlimmingHelper.ExtraVariables += [
148 "AntiKt4EMTopoJets.ConeExclBHadronsFinal.ConeExclCHadronsFinal.GhostBHadronsFinal.GhostCHadronsFinal.GhostBHadronsFinalCount.GhostBHadronsFinalPt.GhostCHadronsFinalCount.GhostCHadronsFinalPt",
149
150 "AntiKt4EMPFlowJets.ConeExclBHadronsFinal.ConeExclCHadronsFinal.GhostBHadronsFinal.GhostCHadronsFinal.GhostBHadronsFinalCount.GhostBHadronsFinalPt.GhostCHadronsFinalCount.GhostCHadronsFinalPt",
151
152 "TruthPrimaryVertices.t.x.y.z",
153
154 "EventInfo.hardScatterVertexLink.timeStampNSOffset",
155 ]
156 else:
157 TLA2SlimmingHelper.ExtraVariables += [
158 "AntiKt4EMPFlowJets.HECQuality.TrackSumMass.PSFrac.TrackSumPt.SumPtChargedPFOPt1000.EMFrac.Width.JetEMScaleMomentum_pt.JetEMScaleMomentum_eta.TracksForBTagging.SumPtTrkPt1000.TrackWidthPt500",
159
160 "EventInfo.hardScatterVertexLink.timeStampNSOffset",
161
162 "PrimaryVertices.neutralWeights.chiSquared.numberDoF.sumPt2.covariance.trackWeights"
163 ]
164
165 TLA2SlimmingHelper.AllVariables = [
166 # store event shape variables to get full objects (also included by jet CP content)
167 "Kt4EMTopoOriginEventShape","Kt4EMPFlowEventShape", # EMTopo and EMPFlow event shapes
168 "Kt4EMPFlowNeutEventShape", # new event shape used for Run 3 offline calibration
169 # store muon segments in case they are needed for offline jet calibrations
170 "MuonSegments",
171 ]
172
173 # add eEM RoIs
174 # based on L1CALOCore.py implementation
175 L1Calo_eEM_postfix = "" # empty unless otherwise set
176 # append to slimming helper dictionaties so that the code knows the container type
177 TLA2SlimmingHelper.AppendToDictionary.update(
178 {"L1_eEMRoI"+L1Calo_eEM_postfix : "xAOD::eFexEMRoIContainer",
179 "L1_eEMRoI"+L1Calo_eEM_postfix+"Aux" : "xAOD::eFexEMRoIAuxContainer"})
180 # add the RoIs to the derivation
181 TLA2SlimmingHelper.AllVariables += ["L1_eEMRoI"+L1Calo_eEM_postfix]
182
183
184 # Truth extra content
185 if flags.Input.isMC:
186 from DerivationFrameworkTLA.TLACommonConfig import addTLATruth3ContentToSlimmerTool
187 addTLATruth3ContentToSlimmerTool(TLA2SlimmingHelper)
188 TLA2SlimmingHelper.AllVariables += [
189 'TruthHFWithDecayParticles',
190 'TruthHFWithDecayVertices',
191 'TruthCharm',
192 'TruthPileupParticles',
193 'InTimeAntiKt4TruthJets',
194 'OutOfTimeAntiKt4TruthJets',
195 ]
196 TLA2SlimmingHelper.ExtraVariables += [
197 "Electrons.TruthLink",
198 "Photons.TruthLink"
199 ]
200 # truth jet collections for calibrations and performance studies
201 # replicates jet collection configuration in JETM1 (with the exception of AntiKt4TruthDressedWZJets which doesn't exist there)
202 TLA2SlimmingHelper.SmartCollections += ["AntiKt4TruthWZJets"]
203 TLA2SlimmingHelper.AllVariables += ["AntiKt4TruthJets", "AntiKt4TruthDressedWZJets"]
204
205 # Trigger content
206 # only save B-jet trigger content and trigger navigation when running on MC
207 TLA2SlimmingHelper.IncludeTriggerNavigation = True
208 TLA2SlimmingHelper.IncludeJetTriggerContent = True
209 TLA2SlimmingHelper.IncludeMuonTriggerContent = False
210 TLA2SlimmingHelper.IncludeTrackingTriggerContent = True
211 TLA2SlimmingHelper.IncludeEGammaTriggerContent = True
212 TLA2SlimmingHelper.IncludeTauTriggerContent = False
213 TLA2SlimmingHelper.IncludeEtMissTriggerContent = False
214 TLA2SlimmingHelper.IncludeBJetTriggerContent = True
215 TLA2SlimmingHelper.IncludeBPhysTriggerContent = False
216 TLA2SlimmingHelper.IncludeMinBiasTriggerContent = False
217 TLA2SlimmingHelper.OverrideJetTriggerContentWithTLAContent = True
218
219 # Trigger matching
220 # Run 2
221 if flags.Trigger.EDMVersion == 2:
222 from DerivationFrameworkPhys.TriggerMatchingCommonConfig import AddRun2TriggerMatchingToSlimmingHelper
223 AddRun2TriggerMatchingToSlimmingHelper(SlimmingHelper = TLA2SlimmingHelper,
224 OutputContainerPrefix = "TrigMatch_",
225 TriggerList = TLA2TriggerListsHelper.Run2TriggerNamesTau)
226 AddRun2TriggerMatchingToSlimmingHelper(SlimmingHelper = TLA2SlimmingHelper,
227 OutputContainerPrefix = "TrigMatch_",
228 TriggerList = TLA2TriggerListsHelper.Run2TriggerNamesNoTau)
229 # Run 3, or Run 2 with navigation conversion
230 if flags.Trigger.EDMVersion == 3 or (flags.Trigger.EDMVersion == 2 and flags.Trigger.doEDMVersionConversion):
231 from TrigNavSlimmingMT.TrigNavSlimmingMTConfig import AddRun3TrigNavSlimmingCollectionsToSlimmingHelper
232 AddRun3TrigNavSlimmingCollectionsToSlimmingHelper(TLA2SlimmingHelper)
233
234 # Output stream
235 TLA2ItemList = TLA2SlimmingHelper.GetItemList()
236 acc.merge(OutputStreamCfg(flags, "DAOD_TLA2", ItemList=TLA2ItemList, AcceptAlgs=["TLA2Kernel"]))
237 acc.merge(SetupMetaDataForStreamCfg(flags, "DAOD_TLA2", AcceptAlgs=["TLA2Kernel"], createMetadata=[MetadataCategory.CutFlowMetaData, MetadataCategory.TruthMetaData]))
238
239 return acc
240
TLA2KernelCfg(flags, name='TLA2Kernel', **kwargs)
Definition TLA2.py:32
TLA2SkimmingCfg(flags)
Definition TLA2.py:12
TLA2Cfg(flags)
Definition TLA2.py:111