ATLAS Offline Software
Loading...
Searching...
No Matches
TLA2.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 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 # Jets
46 from DerivationFrameworkJetEtMiss.JetCommonConfig import JetCommonCfg
47 acc.merge(JetCommonCfg(flags))
48
49 from DerivationFrameworkInDet.InDetToolsConfig import InDetTrackSelectionToolWrapperCfg
50 DFCommonTrackSelection = acc.getPrimaryAndMerge(InDetTrackSelectionToolWrapperCfg(
51 flags,
52 name = "DFCommonTrackSelectionLoose",
53 CutLevel = "Loose",
54 DecorationName = "DFTLA2Loose"))
55
56 acc.addEventAlgo(CompFactory.DerivationFramework.CommonAugmentation("TLA2CommonKernel", AugmentationTools = [DFCommonTrackSelection]))
57
58 # Thinning tools...
59 from DerivationFrameworkInDet.InDetToolsConfig import MuonTrackParticleThinningCfg, EgammaTrackParticleThinningCfg, JetTrackParticleThinningCfg
60
61 # Include inner detector tracks associated with muons
62 TLA2MuonTPThinningTool = acc.getPrimaryAndMerge(MuonTrackParticleThinningCfg(
63 flags,
64 name = "TLA2MuonTPThinningTool",
65 StreamName = kwargs['StreamName'],
66 MuonKey = "Muons",
67 InDetTrackParticlesKey = "InDetTrackParticles"))
68
69 # Include inner detector tracks associated with electonrs
70 TLA2ElectronTPThinningTool = acc.getPrimaryAndMerge(EgammaTrackParticleThinningCfg(
71 flags,
72 name = "TLA2ElectronTPThinningTool",
73 StreamName = kwargs['StreamName'],
74 SGKey = "Electrons",
75 InDetTrackParticlesKey = "InDetTrackParticles"))
76
77 TLA2_thinning_expression = "InDetTrackParticles.DFTLA2Loose && ( abs(InDetTrackParticles.d0) < 5.0*mm ) && ( abs(DFCommonInDetTrackZ0AtPV*sin(InDetTrackParticles.theta)) < 5.0*mm )"
78
79 TLA2Akt4JetTPThinningTool = acc.getPrimaryAndMerge(JetTrackParticleThinningCfg(
80 flags,
81 name = "TLA2Akt4JetTPThinningTool",
82 StreamName = kwargs['StreamName'],
83 JetKey = "AntiKt4EMTopoJets",
84 SelectionString = "AntiKt4EMTopoJets.pt > 18*GeV",
85 TrackSelectionString = TLA2_thinning_expression,
86 InDetTrackParticlesKey = "InDetTrackParticles"))
87
88 TLA2Akt4PFlowJetTPThinningTool = acc.getPrimaryAndMerge(JetTrackParticleThinningCfg(
89 flags,
90 name = "TLA2Akt4PFlowJetTPThinningTool",
91 StreamName = kwargs['StreamName'],
92 JetKey = "AntiKt4EMPFlowJets",
93 SelectionString = "AntiKt4EMPFlowJets.pt > 18*GeV",
94 TrackSelectionString = TLA2_thinning_expression,
95 InDetTrackParticlesKey = "InDetTrackParticles"))
96
97 # Finally the kernel itself
98 thinningTools = [TLA2MuonTPThinningTool,
99 TLA2ElectronTPThinningTool,
100 TLA2Akt4JetTPThinningTool,
101 TLA2Akt4PFlowJetTPThinningTool]
102
103 # create the derivation kernel
104 DerivationKernel = CompFactory.DerivationFramework.DerivationKernel
105 acc.addEventAlgo(DerivationKernel(
106 name,
107 ThinningTools = thinningTools,
108 SkimmingTools = [skimmingTool] if skimmingTool is not None else []
109 ))
110
111
112 return acc
113
114# Main setup of the config & format
115def TLA2Cfg(flags):
116 stream_name = 'StreamDAOD_TLA2'
117 acc = ComponentAccumulator()
118
119 # Get the lists of triggers needed for trigger matching.
120 # This is needed at this scope (for the slimming) and further down in the config chain
121 # for actually configuring the matching, so we create it here and pass it down
122 from DerivationFrameworkPhys.TriggerListsHelper import TriggerListsHelper
123 TLA2TriggerListsHelper = TriggerListsHelper(flags)
124
125
126 # Common augmentations and TLA2 thinning & skimming
127 acc.merge(TLA2KernelCfg(flags, name="TLA2Kernel", StreamName = stream_name, TriggerListsHelper = TLA2TriggerListsHelper))
128
129 # ============================
130 # Define contents of the format
131 # =============================
132 from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
133 from xAODMetaDataCnv.InfileMetaDataConfig import SetupMetaDataForStreamCfg
134 from DerivationFrameworkCore.SlimmingHelper import SlimmingHelper
135
136 TLA2SlimmingHelper = SlimmingHelper("TLA2SlimmingHelper", NamesAndTypes = flags.Input.TypedCollections, flags = flags)
137
138 TLA2SlimmingHelper.SmartCollections = [
139 "EventInfo",
140 "Electrons",
141 "Photons",
142 "PrimaryVertices",
143 "Muons",
144 "AntiKt4EMTopoJets",
145 "AntiKt4EMPFlowJets",
146
147 ]
148
149 # Extra content
150 if flags.Input.isMC:
151 TLA2SlimmingHelper.ExtraVariables += [
152 "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",
153
154 "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",
155
156 "TruthPrimaryVertices.t.x.y.z",
157
158 "EventInfo.hardScatterVertexLink.timeStampNSOffset",
159 ]
160 else:
161 TLA2SlimmingHelper.ExtraVariables += [
162 "AntiKt4EMTopoJets.DFCommonJets_QGTagger_NTracks.DFCommonJets_QGTagger_TracksWidth.DFCommonJets_QGTagger_TracksC1",
163
164 "AntiKt4EMPFlowJets.DFCommonJets_QGTagger_NTracks.DFCommonJets_QGTagger_TracksWidth.DFCommonJets_QGTagger_TracksC1.DFCommonJets_QGTagger_truthjet_pt.DFCommonJets_QGTagger_truthjet_eta.DFCommonJets_QGTagger_truthjet_nCharged.HECQuality.TrackSumMass.PSFrac.TrackSumPt.SumPtChargedPFOPt1000.EMFrac.Width.JetEMScaleMomentum_pt.JetEMScaleMomentum_eta.TracksForBTagging.SumPtTrkPt1000.TrackWidthPt500",
165
166 "EventInfo.hardScatterVertexLink.timeStampNSOffset",
167
168 "PrimaryVertices.neutralWeights.chiSquared.numberDoF.sumPt2.covariance.trackWeights"
169 ]
170
171 TLA2SlimmingHelper.AllVariables = [
172 # store event shape variables to get full objects (also included by jet CP content)
173 "Kt4EMTopoOriginEventShape","Kt4EMPFlowEventShape", # EMTopo and EMPFlow event shapes
174 "Kt4EMPFlowPUSBEventShape","Kt4EMPFlowNeutEventShape", # newer event shapes for testing (e.g. if offline jet calibration changes)
175 # store muon segments in case they are needed for offline jet calibrations
176 "MuonSegments",
177 ]
178
179 # add eEM RoIs
180 # based on L1CALOCore.py implementation
181 L1Calo_eEM_postfix = "" # empty unless otherwise set
182 # append to slimming helper dictionaties so that the code knows the container type
183 TLA2SlimmingHelper.AppendToDictionary.update(
184 {"L1_eEMRoI"+L1Calo_eEM_postfix : "xAOD::eFexEMRoIContainer",
185 "L1_eEMRoI"+L1Calo_eEM_postfix+"Aux" : "xAOD::eFexEMRoIAuxContainer"})
186 # add the RoIs to the derivation
187 TLA2SlimmingHelper.AllVariables += ["L1_eEMRoI"+L1Calo_eEM_postfix]
188
189
190 # Truth extra content
191 if flags.Input.isMC:
192 from DerivationFrameworkTLA.TLACommonConfig import addTLATruth3ContentToSlimmerTool
193 addTLATruth3ContentToSlimmerTool(TLA2SlimmingHelper)
194 TLA2SlimmingHelper.AllVariables += [
195 'TruthHFWithDecayParticles',
196 'TruthHFWithDecayVertices',
197 'TruthCharm',
198 'TruthPileupParticles',
199 'InTimeAntiKt4TruthJets',
200 'OutOfTimeAntiKt4TruthJets',
201 ]
202 TLA2SlimmingHelper.ExtraVariables += [
203 "Electrons.TruthLink",
204 "Photons.TruthLink"
205 ]
206 # truth jet collections for calibrations and performance studies
207 # replicates jet collection configuration in JETM1 (with the exception of AntiKt4TruthDressedWZJets which doesn't exist there)
208 TLA2SlimmingHelper.SmartCollections += ["AntiKt4TruthWZJets"]
209 TLA2SlimmingHelper.AllVariables += ["AntiKt4TruthJets", "AntiKt4TruthDressedWZJets"]
210
211 # Trigger content
212 # only save B-jet trigger content and trigger navigation when running on MC
213 TLA2SlimmingHelper.IncludeTriggerNavigation = True
214 TLA2SlimmingHelper.IncludeJetTriggerContent = True
215 TLA2SlimmingHelper.IncludeMuonTriggerContent = False
216 TLA2SlimmingHelper.IncludeTrackingTriggerContent = True
217 TLA2SlimmingHelper.IncludeEGammaTriggerContent = True
218 TLA2SlimmingHelper.IncludeTauTriggerContent = False
219 TLA2SlimmingHelper.IncludeEtMissTriggerContent = False
220 TLA2SlimmingHelper.IncludeBJetTriggerContent = True
221 TLA2SlimmingHelper.IncludeBPhysTriggerContent = False
222 TLA2SlimmingHelper.IncludeMinBiasTriggerContent = False
223 TLA2SlimmingHelper.OverrideJetTriggerContentWithTLAContent = True
224
225 # Trigger matching
226 # Run 2
227 if flags.Trigger.EDMVersion == 2:
228 from DerivationFrameworkPhys.TriggerMatchingCommonConfig import AddRun2TriggerMatchingToSlimmingHelper
229 AddRun2TriggerMatchingToSlimmingHelper(SlimmingHelper = TLA2SlimmingHelper,
230 OutputContainerPrefix = "TrigMatch_",
231 TriggerList = TLA2TriggerListsHelper.Run2TriggerNamesTau)
232 AddRun2TriggerMatchingToSlimmingHelper(SlimmingHelper = TLA2SlimmingHelper,
233 OutputContainerPrefix = "TrigMatch_",
234 TriggerList = TLA2TriggerListsHelper.Run2TriggerNamesNoTau)
235 # Run 3, or Run 2 with navigation conversion
236 if flags.Trigger.EDMVersion == 3 or (flags.Trigger.EDMVersion == 2 and flags.Trigger.doEDMVersionConversion):
237 from TrigNavSlimmingMT.TrigNavSlimmingMTConfig import AddRun3TrigNavSlimmingCollectionsToSlimmingHelper
238 AddRun3TrigNavSlimmingCollectionsToSlimmingHelper(TLA2SlimmingHelper)
239
240 # Output stream
241 TLA2ItemList = TLA2SlimmingHelper.GetItemList()
242 acc.merge(OutputStreamCfg(flags, "DAOD_TLA2", ItemList=TLA2ItemList, AcceptAlgs=["TLA2Kernel"]))
243 acc.merge(SetupMetaDataForStreamCfg(flags, "DAOD_TLA2", AcceptAlgs=["TLA2Kernel"], createMetadata=[MetadataCategory.CutFlowMetaData, MetadataCategory.TruthMetaData]))
244
245 return acc
246
TLA2KernelCfg(flags, name='TLA2Kernel', **kwargs)
Definition TLA2.py:32
TLA2SkimmingCfg(flags)
Definition TLA2.py:12
TLA2Cfg(flags)
Definition TLA2.py:115