ATLAS Offline Software
Loading...
Searching...
No Matches
python.EGAM9 Namespace Reference

Functions

 EGAM9SkimmingToolCfg (flags)
 EGAM9KernelCfg (flags, name="EGAM9Kernel", **kwargs)
 EGAM9Cfg (flags)

Variables

bool thinCells = False
bool keepCells = False
bool saveJets = False

Function Documentation

◆ EGAM9Cfg()

EGAM9Cfg ( flags)

Definition at line 255 of file EGAM9.py.

255def EGAM9Cfg(flags):
256 acc = ComponentAccumulator()
257
258 # Get the lists of triggers needed for trigger matching.
259 # This is needed at this scope (for the slimming) and further down
260 # in the config chain for actually configuring the matching, so we create
261 # it here and pass it down
262 # TODO: this should ideally be called higher up to avoid it being run
263 # multiple times in a train.
264 # TODO: restrict it to relevant triggers
265 from DerivationFrameworkPhys.TriggerListsHelper import TriggerListsHelper
266
267 EGAM9TriggerListsHelper = TriggerListsHelper(flags)
268
269 # configure skimming/thinning/augmentation tools
270 acc.merge(
271 EGAM9KernelCfg(
272 flags,
273 name="EGAM9Kernel",
274 StreamName="StreamDAOD_EGAM9",
275 TriggerListsHelper=EGAM9TriggerListsHelper,
276 )
277 )
278
279 # configure slimming
280 from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
281 from xAODMetaDataCnv.InfileMetaDataConfig import SetupMetaDataForStreamCfg
282 from DerivationFrameworkCore.SlimmingHelper import SlimmingHelper
283
284 EGAM9SlimmingHelper = SlimmingHelper(
285 "EGAM9SlimmingHelper",
286 NamesAndTypes=flags.Input.TypedCollections,
287 flags=flags,
288 )
289
290 # ------------------------------------------
291 # containers for which we save all variables
292 # -------------------------------------------
293
294 # baseline
295 EGAM9SlimmingHelper.AllVariables = [
296 "Electrons",
297 "Photons",
298 "GSFTrackParticles",
299 "egammaClusters",
300 ]
301
302 # for trigger studies we also add:
303 MenuType = ""
304 if flags.Trigger.EDMVersion == 2:
305 MenuType = "Run2"
306 elif flags.Trigger.EDMVersion == 3:
307 MenuType = "Run3"
308
309 if MenuType:
310 EGAM9SlimmingHelper.AllVariables += ExtraContainersTrigger[MenuType]
311 EGAM9SlimmingHelper.AllVariables += ExtraContainersPhotonTrigger[MenuType]
312 if not flags.Input.isMC:
313 EGAM9SlimmingHelper.AllVariables += ExtraContainersTriggerDataOnly[MenuType]
314
315 # and on MC we also add:
316 if flags.Input.isMC:
317 EGAM9SlimmingHelper.AllVariables += [
318 "TruthEvents",
319 "TruthParticles",
320 "TruthVertices",
321 "egammaTruthParticles",
322 ]
323
324 # -------------------------------------------
325 # containers that we slim
326 # -------------------------------------------
327
328 # first add variables from smart-slimming
329 # adding only also those for which we add all variables since
330 # the XXXCPContent.py files also bring in some extra variables
331 # for other collections
332 EGAM9SlimmingHelper.SmartCollections = [
333 "Electrons",
334 "Photons",
335 "InDetTrackParticles",
336 "PrimaryVertices",
337 ]
338 if saveJets:
339 EGAM9SlimmingHelper.SmartCollections += ["AntiKt4EMPFlowJets"]
340 if flags.Input.isMC:
341 EGAM9SlimmingHelper.SmartCollections += [
342 "AntiKt4TruthJets",
343 "AntiKt4TruthDressedWZJets",
344 ]
345
346 # then add extra variables:
347
348 # photons
349 EGAM9SlimmingHelper.ExtraVariables += ["Photons.DFCommonLoosePrime5"]
350
351 # conversion vertices
352 EGAM9SlimmingHelper.ExtraVariables += [
353 "GSFConversionVertices.x.y.z.px.py.pz.pt1.pt2.etaAtCalo.phiAtCalo",
354 "GSFConversionVertices.trackParticleLinks",
355 ]
356
357 # primary vertices
358 EGAM9SlimmingHelper.ExtraVariables += ["PrimaryVertices.x.y.sumPt2"]
359
360 # track jets
361 if saveJets:
362 EGAM9SlimmingHelper.ExtraVariables += [
363 "AntiKt4PV0TrackJets.pt.eta.phi.e.m.btaggingLink.constituentLinks"
364 ]
365
366 # photons and electrons: detailed shower shape variables and track variables
367 EGAM9SlimmingHelper.ExtraVariables += PhotonsCPDetailedContent
368 EGAM9SlimmingHelper.ExtraVariables += ElectronsCPDetailedContent
369 EGAM9SlimmingHelper.ExtraVariables += GSFTracksCPDetailedContent
370
371 # photons: gain and cluster energy per layer
372 from DerivationFrameworkCalo.DerivationFrameworkCaloConfig import (
373 getGainDecorations,
374 getClusterEnergyPerLayerDecorations,
375 )
376
377 gainDecorations = getGainDecorations(acc, flags, "EGAM9Kernel")
378 print("EGAM9 gain decorations: ", gainDecorations)
379 EGAM9SlimmingHelper.ExtraVariables.extend(gainDecorations)
380 clusterEnergyDecorations = getClusterEnergyPerLayerDecorations(acc, "EGAM9Kernel")
381 print("EGAM9 cluster energy decorations: ", clusterEnergyDecorations)
382 EGAM9SlimmingHelper.ExtraVariables.extend(clusterEnergyDecorations)
383
384 # energy density
385 EGAM9SlimmingHelper.ExtraVariables += [
386 "TopoClusterIsoCentralEventShape.Density",
387 "TopoClusterIsoForwardEventShape.Density",
388 "NeutralParticleFlowIsoCentralEventShape.Density",
389 "NeutralParticleFlowIsoForwardEventShape.Density",
390 ]
391
392 # truth
393 if flags.Input.isMC:
394 EGAM9SlimmingHelper.ExtraVariables += [
395 "Photons.truthClassification.truthOrigin.truthType.truthParticleLink"
396 ]
397
398 # Add event info
399 if flags.Derivation.Egamma.doEventInfoSlimming:
400 EGAM9SlimmingHelper.SmartCollections.append("EventInfo")
401 else:
402 EGAM9SlimmingHelper.AllVariables += ["EventInfo"]
403
404 # Add egamma trigger objects
405 EGAM9SlimmingHelper.IncludeEGammaTriggerContent = True
406
407 # Trigger matching
408 # Run 2
409 if flags.Trigger.EDMVersion == 2:
410 from DerivationFrameworkPhys.TriggerMatchingCommonConfig import AddRun2TriggerMatchingToSlimmingHelper
411 AddRun2TriggerMatchingToSlimmingHelper(SlimmingHelper = EGAM9SlimmingHelper,
412 OutputContainerPrefix = "TrigMatch_",
413 TriggerList = EGAM9TriggerListsHelper.Run2TriggerNamesNoTau)
414 # Run 3, or Run 2 with navigation conversion
415 if flags.Trigger.EDMVersion == 3 or (flags.Trigger.EDMVersion == 2 and flags.Trigger.doEDMVersionConversion):
416 from TrigNavSlimmingMT.TrigNavSlimmingMTConfig import AddRun3TrigNavSlimmingCollectionsToSlimmingHelper
417 AddRun3TrigNavSlimmingCollectionsToSlimmingHelper(EGAM9SlimmingHelper)
418
419 # Add CellContainer and cluster->cell links
420 if keepCells:
421 if thinCells:
422 EGAM9SlimmingHelper.StaticContent = [
423 "CaloCellContainer#DFEGAMCellContainer",
424 "CaloClusterCellLinkContainer#egammaClusters_links",
425 ]
426 else:
427 EGAM9SlimmingHelper.StaticContent = [
428 "CaloCellContainer#AllCalo",
429 "CaloClusterCellLinkContainer#egammaClusters_links",
430 ]
431
432 EGAM9ItemList = EGAM9SlimmingHelper.GetItemList()
433 acc.merge(
434 OutputStreamCfg(
435 flags,
436 "DAOD_EGAM9",
437 ItemList=EGAM9ItemList,
438 AcceptAlgs=["EGAM9Kernel"],
439 )
440 )
441 acc.merge(
442 SetupMetaDataForStreamCfg(
443 flags,
444 "DAOD_EGAM9",
445 AcceptAlgs=["EGAM9Kernel"],
446 createMetadata=[
447 MetadataCategory.CutFlowMetaData,
448 MetadataCategory.TruthMetaData,
449 ],
450 )
451 )
452
453 return acc
void print(char *figname, TCanvas *c1)

◆ EGAM9KernelCfg()

EGAM9KernelCfg ( flags,
name = "EGAM9Kernel",
** kwargs )
Configure the derivation framework driving algorithm (kernel)
for EGAM9

Definition at line 88 of file EGAM9.py.

88def EGAM9KernelCfg(flags, name="EGAM9Kernel", **kwargs):
89 """Configure the derivation framework driving algorithm (kernel)
90 for EGAM9"""
91 acc = ComponentAccumulator()
92
93 # Common augmentations
94 from DerivationFrameworkPhys.PhysCommonConfig import PhysCommonAugmentationsCfg
95
96 acc.merge(
97 PhysCommonAugmentationsCfg(
98 flags, TriggerListsHelper=kwargs["TriggerListsHelper"]
99 )
100 )
101
102 # EGAM9 augmentations
103 augmentationTools = []
104
105 # ====================================================================
106 # Common calo decoration tools
107 # ====================================================================
108 from DerivationFrameworkCalo.DerivationFrameworkCaloConfig import (
109 CaloDecoratorKernelCfg)
110 acc.merge(CaloDecoratorKernelCfg(flags))
111
112 # thinning tools
113 thinningTools = []
114 streamName = kwargs["StreamName"]
115
116 # Track thinning
117 if flags.Derivation.Egamma.doTrackThinning:
118 TrackThinningKeepElectronTracks = False
119 TrackThinningKeepPhotonTracks = True
120 TrackThinningKeepPVTracks = False
121
122 # Tracks associated with Electrons
123 if TrackThinningKeepElectronTracks:
124 EGAM9ElectronTPThinningTool = (
125 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
126 name="EGAM9ElectronTPThinningTool",
127 StreamName=streamName,
128 SGKey="Electrons",
129 GSFTrackParticlesKey="GSFTrackParticles",
130 InDetTrackParticlesKey="InDetTrackParticles",
131 SelectionString="Electrons.pt > 0*GeV",
132 BestMatchOnly=True,
133 ConeSize=0.3,
134 )
135 )
136 acc.addPublicTool(EGAM9ElectronTPThinningTool)
137 thinningTools.append(EGAM9ElectronTPThinningTool)
138
139 # Tracks associated with Photons
140 if TrackThinningKeepPhotonTracks:
141 EGAM9PhotonTPThinningTool = (
142 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
143 name="EGAM9PhotonTPThinningTool",
144 StreamName=streamName,
145 SGKey="Photons",
146 GSFTrackParticlesKey="GSFTrackParticles",
147 InDetTrackParticlesKey="InDetTrackParticles",
148 GSFConversionVerticesKey="GSFConversionVertices",
149 SelectionString="Photons.pt > 0*GeV",
150 BestMatchOnly=True,
151 ConeSize=0.3,
152 )
153 )
154 acc.addPublicTool(EGAM9PhotonTPThinningTool)
155 thinningTools.append(EGAM9PhotonTPThinningTool)
156
157 # Tracks from primary vertex
158 thinning_expression = " && ".join(
159 [
160 "(InDetTrackParticles.DFCommonTightPrimary)",
161 "(abs(InDetTrackParticles.DFCommonInDetTrackZ0AtPV)*sin(InDetTrackParticles.theta)<3*mm)",
162 "(InDetTrackParticles.pt > 10*GeV)",
163 ]
164 )
165 if TrackThinningKeepPVTracks:
166 from DerivationFrameworkInDet.InDetToolsConfig import (
167 TrackParticleThinningCfg,
168 )
169
170 EGAM9TPThinningTool = acc.getPrimaryAndMerge(
171 TrackParticleThinningCfg(
172 flags,
173 name="EGAM9TPThinningTool",
174 StreamName=streamName,
175 SelectionString=thinning_expression,
176 InDetTrackParticlesKey="InDetTrackParticles",
177 )
178 )
179 thinningTools.append(EGAM9TPThinningTool)
180
181 # truth thinning
182 if flags.Input.isMC:
183 # W, Z and Higgs
184 truth_cond_WZH = "(TruthParticles.isW || TruthParticles.isZ || TruthParticles.isHiggs)"
185 # Leptons
186 truth_cond_lep = "(TruthParticles.isLepton)"
187 # Top quark
188 truth_cond_top = "(TruthParticles.isTop)"
189 # Photon
190 truth_cond_gam = " && ".join(
191 ["(TruthParticles.isPhoton)", "(TruthParticles.pt > 1*GeV)"]
192 )
193 # stable particles
194 truth_cond_finalState = "(TruthParticles.isGenStable)"
195 truth_expression = (
196 "( "
197 + truth_cond_WZH
198 + " ) || "
199 + "( "
200 + truth_cond_lep
201 + " ) || "
202 + "( "
203 + truth_cond_top
204 + " ) || "
205 + "( "
206 + truth_cond_gam
207 + " ) || "
208 + "( "
209 + truth_cond_finalState
210 + " )"
211 )
212 print("EGAM9 truth thinning expression: ", truth_expression)
213
214 EGAM9TruthThinningTool = CompFactory.DerivationFramework.GenericTruthThinning(
215 name="EGAM9TruthThinningTool",
216 StreamName=streamName,
217 ParticleSelectionString=truth_expression,
218 PreserveDescendants=False,
219 PreserveGeneratorDescendants=True,
220 PreserveAncestors=True,
221 )
222 acc.addPublicTool(EGAM9TruthThinningTool)
223 thinningTools.append(EGAM9TruthThinningTool)
224
225 # Keep only calo cells associated with the egammaClusters collection
226 if thinCells:
227 from DerivationFrameworkCalo.CaloCellDFGetterConfig import thinCaloCellsForDFCfg
228
229 acc.merge(
230 thinCaloCellsForDFCfg(
231 flags,
232 inputClusterKeys=["egammaClusters"],
233 streamName="StreamDAOD_EGAM9",
234 inputCellKey="AllCalo",
235 outputCellKey="DFEGAMCellContainer",
236 )
237 )
238
239 # skimming
240 skimmingTool = acc.getPrimaryAndMerge(EGAM9SkimmingToolCfg(flags))
241
242 # setup the kernel
243 acc.addEventAlgo(
244 CompFactory.DerivationFramework.DerivationKernel(
245 name,
246 SkimmingTools=[skimmingTool],
247 AugmentationTools=augmentationTools,
248 ThinningTools=thinningTools,
249 )
250 )
251
252 return acc
253
254

◆ EGAM9SkimmingToolCfg()

EGAM9SkimmingToolCfg ( flags)
Configure the EGAM9 skimming tool

Definition at line 37 of file EGAM9.py.

37def EGAM9SkimmingToolCfg(flags):
38 """Configure the EGAM9 skimming tool"""
39 acc = ComponentAccumulator()
40
41 # criteria for off-line based selection
42 photon_selection = (
43 "(count(Photons.pt > 9.5*GeV && " + "Photons.DFCommonPhotonsIsEMLoose) > 0)"
44 )
45 electron_selection = (
46 "(count(Electrons.pt > 9.5*GeV && "
47 + "Electrons.DFCommonElectronsLHMedium) > 0)"
48 )
49 expression = photon_selection + " || " + electron_selection
50 skimmingTools = []
51
52 # trigger-based selection
53 MenuType = ""
54 if flags.Trigger.EDMVersion == 2:
55 MenuType = "Run2"
56 elif flags.Trigger.EDMVersion == 3:
57 MenuType = "Run3"
58
59 if MenuType:
60 triggers = BootstrapPhotonTriggers[MenuType]
61 triggers += noalgTriggers[MenuType]
62 print("EGAM9 trigger skimming list (OR): ", triggers)
63 EGAM9_TriggerSkimmingTool = CompFactory.DerivationFramework.TriggerSkimmingTool(
64 name="EGAM9_TriggerSkimmingTool", TriggerListOR=triggers
65 )
66 acc.addPublicTool(EGAM9_TriggerSkimmingTool)
67 skimmingTools += [EGAM9_TriggerSkimmingTool]
68
69 # off-line based selection
70 print("EGAM9 offline skimming expression: ", expression)
71 from DerivationFrameworkTools.DerivationFrameworkToolsConfig import (
72 xAODStringSkimmingToolCfg)
73 EGAM9_OfflineSkimmingTool = acc.getPrimaryAndMerge(xAODStringSkimmingToolCfg(
74 flags, name = "EGAM9_OfflineSkimmingTool", expression = expression))
75 skimmingTools += [EGAM9_OfflineSkimmingTool]
76
77 # do the AND of trigger-based and offline-based selection
78 print("EGAM9 skimming is logical AND of previous selections")
79 EGAM9_SkimmingTool = CompFactory.DerivationFramework.FilterCombinationAND(
80 name="EGAM9_SkimmingTool",
81 FilterList=skimmingTools
82 )
83
84 acc.addPublicTool(EGAM9_SkimmingTool, primary=True)
85 return acc
86
87

Variable Documentation

◆ keepCells

bool python.EGAM9.keepCells = False

Definition at line 33 of file EGAM9.py.

◆ saveJets

bool python.EGAM9.saveJets = False

Definition at line 34 of file EGAM9.py.

◆ thinCells

bool python.EGAM9.thinCells = False

Definition at line 32 of file EGAM9.py.