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()

python.EGAM9.EGAM9Cfg ( flags)

Definition at line 264 of file EGAM9.py.

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

◆ EGAM9KernelCfg()

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

Definition at line 93 of file EGAM9.py.

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

◆ EGAM9SkimmingToolCfg()

python.EGAM9.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 EGAM9_OfflineSkimmingTool = (
72 CompFactory.DerivationFramework.xAODStringSkimmingTool(
73 name="EGAM9_OfflineSkimmingTool", expression=expression
74 )
75 )
76 if flags.Trigger.EDMVersion < 0:
77 EGAM9_OfflineSkimmingTool.TrigDecisionTool=None
78
79 acc.addPublicTool(EGAM9_OfflineSkimmingTool)
80 skimmingTools += [EGAM9_OfflineSkimmingTool]
81
82 # do the AND of trigger-based and offline-based selection
83 print("EGAM9 skimming is logical AND of previous selections")
84 EGAM9_SkimmingTool = CompFactory.DerivationFramework.FilterCombinationAND(
85 name="EGAM9_SkimmingTool",
86 FilterList=skimmingTools
87 )
88
89 acc.addPublicTool(EGAM9_SkimmingTool, primary=True)
90 return acc
91
92

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.