ATLAS Offline Software
Loading...
Searching...
No Matches
TLA1.py
Go to the documentation of this file.
1# Copyright (C) 2002-2024 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 TLA1SkimmingCfg(flags):
13 """Configure the skimming tool"""
14 acc = ComponentAccumulator()
15
16 from DerivationFrameworkTLA.TLATriggerList import SupportPhotonTriggers, PrimaryISRTLATriggers, SupportTLATriggers
17
18 tlaLiteTriggerList = PrimaryISRTLATriggers + SupportTLATriggers + SupportPhotonTriggers
19
20
21 if not flags.Input.isMC:
22 TLA1TriggerSkimmingTool = CompFactory.DerivationFramework.TriggerSkimmingTool(
23 name = "TLA1TriggerSkimmingTool1",
24 TriggerListOR = tlaLiteTriggerList
25 )
26 acc.addPublicTool(TLA1TriggerSkimmingTool, primary=True)
27
28 return acc
29
30
31# Main thinning config and common augmentations
32def TLA1KernelCfg(flags, name='TLA1Kernel', **kwargs):
33 """Configure the derivation framework driving algorithm (kernel) for TLA1"""
34 acc = ComponentAccumulator()
35
36 # Skimming
37 skimmingTool = None
38 if not flags.Input.isMC:
39 skimmingTool = acc.getPrimaryAndMerge(TLA1SkimmingCfg(flags))
40
41 # Common augmentations
42 from DerivationFrameworkTLA.TLACommonConfig import TLACommonAugmentationsCfg
43 acc.merge(TLACommonAugmentationsCfg(flags, prefix="TLA1_", 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 = "DFTLA1Loose"))
51
52 acc.addEventAlgo(CompFactory.DerivationFramework.CommonAugmentation("TLA1CommonKernel", AugmentationTools = [DFCommonTrackSelection]))
53
54 # Thinning tools...
55 from DerivationFrameworkInDet.InDetToolsConfig import MuonTrackParticleThinningCfg, EgammaTrackParticleThinningCfg, JetTrackParticleThinningCfg
56
57 # Include inner detector tracks associated with muons
58 TLA1MuonTPThinningTool = acc.getPrimaryAndMerge(MuonTrackParticleThinningCfg(
59 flags,
60 name = "TLA1MuonTPThinningTool",
61 StreamName = kwargs['StreamName'],
62 MuonKey = "Muons",
63 InDetTrackParticlesKey = "InDetTrackParticles"))
64
65 # Include inner detector tracks associated with electonrs
66 TLA1ElectronTPThinningTool = acc.getPrimaryAndMerge(EgammaTrackParticleThinningCfg(
67 flags,
68 name = "TLA1ElectronTPThinningTool",
69 StreamName = kwargs['StreamName'],
70 SGKey = "Electrons",
71 InDetTrackParticlesKey = "InDetTrackParticles"))
72
73 TLA1_thinning_expression = "InDetTrackParticles.DFTLA1Loose && ( abs(InDetTrackParticles.d0) < 5.0*mm ) && ( abs(DFCommonInDetTrackZ0AtPV*sin(InDetTrackParticles.theta)) < 5.0*mm )"
74
75 TLA1Akt4JetTPThinningTool = acc.getPrimaryAndMerge(JetTrackParticleThinningCfg(
76 flags,
77 name = "TLA1Akt4JetTPThinningTool",
78 StreamName = kwargs['StreamName'],
79 JetKey = "AntiKt4EMTopoJets",
80 SelectionString = "AntiKt4EMTopoJets.pt > 18*GeV",
81 TrackSelectionString = TLA1_thinning_expression,
82 InDetTrackParticlesKey = "InDetTrackParticles"))
83
84 TLA1Akt4PFlowJetTPThinningTool = acc.getPrimaryAndMerge(JetTrackParticleThinningCfg(
85 flags,
86 name = "TLA1Akt4PFlowJetTPThinningTool",
87 StreamName = kwargs['StreamName'],
88 JetKey = "AntiKt4EMPFlowJets",
89 SelectionString = "AntiKt4EMPFlowJets.pt > 18*GeV",
90 TrackSelectionString = TLA1_thinning_expression,
91 InDetTrackParticlesKey = "InDetTrackParticles"))
92
93 # Finally the kernel itself
94 thinningTools = [TLA1MuonTPThinningTool,
95 TLA1ElectronTPThinningTool,
96 TLA1Akt4JetTPThinningTool,
97 TLA1Akt4PFlowJetTPThinningTool]
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 TLA1Cfg(flags):
112 stream_name = 'StreamDAOD_TLA1'
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 TLA1TriggerListsHelper = TriggerListsHelper(flags)
120
121
122 # Common augmentations and TLA1 thinning & skimming
123 acc.merge(TLA1KernelCfg(flags, name="TLA1Kernel", StreamName = stream_name, TriggerListsHelper = TLA1TriggerListsHelper))
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 TLA1SlimmingHelper = SlimmingHelper("TLA1SlimmingHelper", NamesAndTypes = flags.Input.TypedCollections, flags = flags)
133
134 TLA1SlimmingHelper.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 TLA1SlimmingHelper.ExtraVariables += [
148 "AntiKt4EMTopoJets.DFCommonJets_QGTagger_truthjet_nCharged.DFCommonJets_QGTagger_truthjet_pt.DFCommonJets_QGTagger_truthjet_eta.DFCommonJets_QGTagger_NTracks.DFCommonJets_QGTagger_TracksWidth.DFCommonJets_QGTagger_TracksC1.ConeExclBHadronsFinal.ConeExclCHadronsFinal.GhostBHadronsFinal.GhostCHadronsFinal.GhostBHadronsFinalCount.GhostBHadronsFinalPt.GhostCHadronsFinalCount.GhostCHadronsFinalPt",
149
150 "AntiKt4EMPFlowJets.DFCommonJets_QGTagger_truthjet_nCharged.DFCommonJets_QGTagger_truthjet_pt.DFCommonJets_QGTagger_truthjet_eta.DFCommonJets_QGTagger_NTracks.DFCommonJets_QGTagger_TracksWidth.DFCommonJets_QGTagger_TracksC1.ConeExclBHadronsFinal.ConeExclCHadronsFinal.GhostBHadronsFinal.GhostCHadronsFinal.GhostBHadronsFinalCount.GhostBHadronsFinalPt.GhostCHadronsFinalCount.GhostCHadronsFinalPt",
151
152 "TruthPrimaryVertices.t.x.y.z",
153
154 "EventInfo.hardScatterVertexLink.timeStampNSOffset",
155 ]
156 else:
157 TLA1SlimmingHelper.ExtraVariables += [
158 "AntiKt4EMTopoJets.DFCommonJets_QGTagger_NTracks.DFCommonJets_QGTagger_TracksWidth.DFCommonJets_QGTagger_TracksC1",
159
160 "AntiKt4EMPFlowJets.DFCommonJets_QGTagger_NTracks.DFCommonJets_QGTagger_TracksWidth.DFCommonJets_QGTagger_TracksC1",
161
162 "EventInfo.hardScatterVertexLink.timeStampNSOffset",
163 ]
164
165 TLA1SlimmingHelper.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 "Kt4EMPFlowPUSBEventShape","Kt4EMPFlowNeutEventShape", # newer event shapes for testing (e.g. if offline jet calibration changes)
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 TLA1SlimmingHelper.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 TLA1SlimmingHelper.AllVariables += ["L1_eEMRoI"+L1Calo_eEM_postfix]
182
183
184 # Truth extra content
185 if flags.Input.isMC:
186 # from DerivationFrameworkMCTruth.MCTruthCommonConfig import addTruth3ContentToSlimmerTool
187 from DerivationFrameworkTLA.TLACommonConfig import addTLATruth3ContentToSlimmerTool
188 addTLATruth3ContentToSlimmerTool(TLA1SlimmingHelper)
189 TLA1SlimmingHelper.AllVariables += [
190 'TruthHFWithDecayParticles',
191 'TruthHFWithDecayVertices',
192 'TruthCharm',
193 'TruthPileupParticles',
194 'InTimeAntiKt4TruthJets',
195 'OutOfTimeAntiKt4TruthJets',
196 ]
197 TLA1SlimmingHelper.ExtraVariables += [
198 "Electrons.TruthLink",
199 "Photons.TruthLink"
200 ]
201 # truth jet collections for calibrations and performance studies
202 # replicates jet collection configuration in JETM1 (with the exception of AntiKt4TruthDressedWZJets which doesn't exist there)
203 TLA1SlimmingHelper.SmartCollections += ["AntiKt4TruthWZJets"]
204 TLA1SlimmingHelper.AllVariables += ["AntiKt4TruthJets", "AntiKt4TruthDressedWZJets"]
205
206 # Trigger content
207 # only save B-jet trigger content and trigger navigation when running on MC
208 TLA1SlimmingHelper.IncludeTriggerNavigation = True
209 TLA1SlimmingHelper.IncludeJetTriggerContent = True
210 TLA1SlimmingHelper.IncludeMuonTriggerContent = False
211 TLA1SlimmingHelper.IncludeTrackingTriggerContent = True
212 TLA1SlimmingHelper.IncludeEGammaTriggerContent = True
213 TLA1SlimmingHelper.IncludeTauTriggerContent = False
214 TLA1SlimmingHelper.IncludeEtMissTriggerContent = False
215 TLA1SlimmingHelper.IncludeBJetTriggerContent = True
216 TLA1SlimmingHelper.IncludeBPhysTriggerContent = False
217 TLA1SlimmingHelper.IncludeMinBiasTriggerContent = False
218 TLA1SlimmingHelper.OverrideJetTriggerContentWithTLAContent = True
219
220 # Trigger matching
221 # Run 2
222 if flags.Trigger.EDMVersion == 2:
223 from DerivationFrameworkPhys.TriggerMatchingCommonConfig import AddRun2TriggerMatchingToSlimmingHelper
224 AddRun2TriggerMatchingToSlimmingHelper(SlimmingHelper = TLA1SlimmingHelper,
225 OutputContainerPrefix = "TrigMatch_",
226 TriggerList = TLA1TriggerListsHelper.Run2TriggerNamesTau)
227 AddRun2TriggerMatchingToSlimmingHelper(SlimmingHelper = TLA1SlimmingHelper,
228 OutputContainerPrefix = "TrigMatch_",
229 TriggerList = TLA1TriggerListsHelper.Run2TriggerNamesNoTau)
230 # Run 3, or Run 2 with navigation conversion
231 if flags.Trigger.EDMVersion == 3 or (flags.Trigger.EDMVersion == 2 and flags.Trigger.doEDMVersionConversion):
232 from TrigNavSlimmingMT.TrigNavSlimmingMTConfig import AddRun3TrigNavSlimmingCollectionsToSlimmingHelper
233 AddRun3TrigNavSlimmingCollectionsToSlimmingHelper(TLA1SlimmingHelper)
234
235 # Output stream
236 TLA1ItemList = TLA1SlimmingHelper.GetItemList()
237 acc.merge(OutputStreamCfg(flags, "DAOD_TLA1", ItemList=TLA1ItemList, AcceptAlgs=["TLA1Kernel"]))
238 acc.merge(SetupMetaDataForStreamCfg(flags, "DAOD_TLA1", AcceptAlgs=["TLA1Kernel"], createMetadata=[MetadataCategory.CutFlowMetaData, MetadataCategory.TruthMetaData]))
239
240 return acc
241
TLA1SkimmingCfg(flags)
Definition TLA1.py:12
TLA1KernelCfg(flags, name='TLA1Kernel', **kwargs)
Definition TLA1.py:32
TLA1Cfg(flags)
Definition TLA1.py:111