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

Functions

 EGAM7SkimmingToolCfg (flags)
 EGAM7KernelCfg (flags, name="EGAM7Kernel", **kwargs)
 EGAM7Cfg (flags)

Variables

bool thinCells = True

Function Documentation

◆ EGAM7Cfg()

python.EGAM7.EGAM7Cfg ( flags)

Definition at line 323 of file EGAM7.py.

323def EGAM7Cfg(flags):
324 acc = ComponentAccumulator()
325
326 # Get the lists of triggers needed for trigger matching.
327 # This is needed at this scope (for the slimming) and further down
328 # in the config chain for actually configuring the matching, so we create
329 # it here and pass it down
330 # TODO: this should ideally be called higher up to avoid it being run
331 # multiple times in a train.
332 # DODO: restrict it to relevant triggers
333 from DerivationFrameworkPhys.TriggerListsHelper import TriggerListsHelper
334
335 EGAM7TriggerListsHelper = TriggerListsHelper(flags)
336
337 # configure skimming/thinning/augmentation tools
338 acc.merge(
339 EGAM7KernelCfg(
340 flags,
341 name="EGAM7Kernel",
342 StreamName="StreamDAOD_EGAM7",
343 TriggerListsHelper=EGAM7TriggerListsHelper,
344 )
345 )
346
347 # configure slimming
348 from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
349 from xAODMetaDataCnv.InfileMetaDataConfig import SetupMetaDataForStreamCfg
350 from DerivationFrameworkCore.SlimmingHelper import SlimmingHelper
351
352 EGAM7SlimmingHelper = SlimmingHelper(
353 "EGAM7SlimmingHelper",
354 NamesAndTypes=flags.Input.TypedCollections,
355 flags=flags,
356 )
357
358 # ------------------------------------------
359 # containers for which we save all variables
360 # -------------------------------------------
361
362 # baseline
363 EGAM7SlimmingHelper.AllVariables = [
364 "Electrons",
365 "GSFTrackParticles",
366 "egammaClusters",
367 ]
368
369 # for trigger studies we also add:
370 MenuType = ""
371 if flags.Trigger.EDMVersion == 2:
372 MenuType = "Run2"
373 elif flags.Trigger.EDMVersion == 3:
374 MenuType = "Run3"
375
376 if MenuType:
377 EGAM7SlimmingHelper.AllVariables += ExtraContainersTrigger[MenuType]
378 EGAM7SlimmingHelper.AllVariables += ExtraContainersElectronTrigger[MenuType]
379 if not flags.Input.isMC:
380 EGAM7SlimmingHelper.AllVariables += ExtraContainersTriggerDataOnly[MenuType]
381
382 # and on MC we also add:
383 if flags.Input.isMC:
384 EGAM7SlimmingHelper.AllVariables += [
385 "TruthEvents",
386 "TruthParticles",
387 "TruthVertices",
388 "egammaTruthParticles",
389 ]
390
391 # -------------------------------------------
392 # containers that we slim
393 # -------------------------------------------
394
395 # first add variables from smart-slimming
396 # adding only also those for which we add all variables since
397 # the XXXCPContent.py files also bring in some extra variables
398 # for other collections
399 # muons, tau, MET, b-tagging could be switched off if not needed
400 # and use too much space
401 EGAM7SlimmingHelper.SmartCollections = [
402 "Electrons",
403 "Photons",
404 "Muons",
405 "TauJets",
406 "InDetTrackParticles",
407 "PrimaryVertices",
408 "AntiKt4EMPFlowJets",
409 "MET_Baseline_AntiKt4EMPFlow",
410
411 ]
412 if flags.Input.isMC:
413 EGAM7SlimmingHelper.SmartCollections += [
414 "AntiKt4TruthJets",
415 "AntiKt4TruthDressedWZJets",
416 ]
417
418 # then add extra variables:
419
420 # muons
421 EGAM7SlimmingHelper.ExtraVariables += [
422 "Muons.ptcone20.ptcone30.ptcone40.etcone20.etcone30.etcone40"
423 ]
424
425 # conversion vertices
426 EGAM7SlimmingHelper.ExtraVariables += [
427 "GSFConversionVertices.x.y.z.px.py.pz.pt1.pt2.etaAtCalo.phiAtCalo",
428 "GSFConversionVertices.trackParticleLinks",
429 ]
430
431 # primary vertices
432 EGAM7SlimmingHelper.ExtraVariables += ["PrimaryVertices.x.y.sumPt2"]
433
434 # track jets
435 EGAM7SlimmingHelper.ExtraVariables += [
436 "AntiKt4PV0TrackJets.pt.eta.phi.e.m.btaggingLink.constituentLinks"
437 ]
438
439 # photons: detailed shower shape variables
440 EGAM7SlimmingHelper.ExtraVariables += PhotonsCPDetailedContent
441
442 # photons: gain and cluster energy per layer
443 from DerivationFrameworkCalo.DerivationFrameworkCaloConfig import (
444 getGainDecorations,
445 getClusterEnergyPerLayerDecorations,
446 )
447
448 gainDecorations = getGainDecorations(acc, flags, "EGAM7Kernel")
449 print("EGAM7 gain decorations: ", gainDecorations)
450 EGAM7SlimmingHelper.ExtraVariables.extend(gainDecorations)
451 clusterEnergyDecorations = getClusterEnergyPerLayerDecorations(acc, "EGAM7Kernel")
452 print("EGAM7 cluster energy decorations: ", clusterEnergyDecorations)
453 EGAM7SlimmingHelper.ExtraVariables.extend(clusterEnergyDecorations)
454
455 # energy density
456 EGAM7SlimmingHelper.ExtraVariables += [
457 "TopoClusterIsoCentralEventShape.Density",
458 "TopoClusterIsoForwardEventShape.Density",
459 "NeutralParticleFlowIsoCentralEventShape.Density",
460 "NeutralParticleFlowIsoForwardEventShape.Density",
461 ]
462
463 # truth
464 if flags.Input.isMC:
465 EGAM7SlimmingHelper.ExtraVariables += [
466 "MuonTruthParticles.e.px.py.pz.status.pdgId.truthOrigin.truthType"
467 ]
468
469 EGAM7SlimmingHelper.ExtraVariables += [
470 "Photons.truthOrigin.truthType.truthParticleLink"
471 ]
472
473 # Add event info
474 if flags.Derivation.Egamma.doEventInfoSlimming:
475 EGAM7SlimmingHelper.SmartCollections.append("EventInfo")
476 else:
477 EGAM7SlimmingHelper.AllVariables += ["EventInfo"]
478
479 # Add egamma trigger objects
480 EGAM7SlimmingHelper.IncludeEGammaTriggerContent = True
481
482 # Trigger matching
483 # Run 2
484 if flags.Trigger.EDMVersion == 2:
485 from DerivationFrameworkPhys.TriggerMatchingCommonConfig import AddRun2TriggerMatchingToSlimmingHelper
486 AddRun2TriggerMatchingToSlimmingHelper(SlimmingHelper = EGAM7SlimmingHelper,
487 OutputContainerPrefix = "TrigMatch_",
488 TriggerList = EGAM7TriggerListsHelper.Run2TriggerNamesNoTau)
489 # Run 3, or Run 2 with navigation conversion
490 if flags.Trigger.EDMVersion == 3 or (flags.Trigger.EDMVersion == 2 and flags.Trigger.doEDMVersionConversion):
491 from TrigNavSlimmingMT.TrigNavSlimmingMTConfig import AddRun3TrigNavSlimmingCollectionsToSlimmingHelper
492 AddRun3TrigNavSlimmingCollectionsToSlimmingHelper(EGAM7SlimmingHelper)
493
494 # Add CellContainer and cluster->cell links
495 if thinCells:
496 EGAM7SlimmingHelper.StaticContent = [
497 "CaloCellContainer#DFEGAMCellContainer",
498 "CaloClusterCellLinkContainer#egammaClusters_links",
499 ]
500 else:
501 EGAM7SlimmingHelper.StaticContent = [
502 "CaloCellContainer#AllCalo",
503 "CaloClusterCellLinkContainer#egammaClusters_links",
504 ]
505
506 # PLIT variables
507 if flags.Derivation.Egamma.addPLITInputs:
508 from LeptonTaggers.LeptonTaggersConfig import DecorateImprovedPromptLeptonAlgsCfg, GetExtraImprovedPromptVariablesForDxAOD
509 acc.merge(DecorateImprovedPromptLeptonAlgsCfg(flags))
510 EGAM7SlimmingHelper.ExtraVariables += [ item for item in GetExtraImprovedPromptVariablesForDxAOD() if item.startswith("Electrons")]
511 if flags.Derivation.Egamma.addPLITOutputs:
512 from LeptonTaggers.LeptonTaggersConfig import DecoratePLITAlgsCfg, GetExtraPLITVariablesForDxAOD
513 acc.merge(DecoratePLITAlgsCfg(flags))
514 EGAM7SlimmingHelper.ExtraVariables += [ item for item in GetExtraPLITVariablesForDxAOD() if item.startswith("Electrons")]
515
516 EGAM7ItemList = EGAM7SlimmingHelper.GetItemList()
517 acc.merge(
518 OutputStreamCfg(
519 flags,
520 "DAOD_EGAM7",
521 ItemList=EGAM7ItemList,
522 AcceptAlgs=["EGAM7Kernel"],
523 )
524 )
525 acc.merge(
526 SetupMetaDataForStreamCfg(
527 flags,
528 "DAOD_EGAM7",
529 AcceptAlgs=["EGAM7Kernel"],
530 createMetadata=[
531 MetadataCategory.CutFlowMetaData,
532 MetadataCategory.TruthMetaData,
533 ],
534 )
535 )
536
537 return acc
void print(char *figname, TCanvas *c1)

◆ EGAM7KernelCfg()

python.EGAM7.EGAM7KernelCfg ( flags,
name = "EGAM7Kernel",
** kwargs )
Configure the derivation framework driving algorithm (kernel)
for EGAM7

Definition at line 77 of file EGAM7.py.

77def EGAM7KernelCfg(flags, name="EGAM7Kernel", **kwargs):
78 """Configure the derivation framework driving algorithm (kernel)
79 for EGAM7"""
80 acc = ComponentAccumulator()
81
82 # Schedule extra jets collections
83 from JetRecConfig.StandardSmallRJets import AntiKt4PV0Track
84 from JetRecConfig.JetRecConfig import JetRecCfg
85
86 jetList = [AntiKt4PV0Track]
87 for jd in jetList:
88 acc.merge(JetRecCfg(flags, jd))
89
90 # Common augmentations
91 from DerivationFrameworkPhys.PhysCommonConfig import PhysCommonAugmentationsCfg
92
93 acc.merge(
94 PhysCommonAugmentationsCfg(
95 flags, TriggerListsHelper=kwargs["TriggerListsHelper"]
96 )
97 )
98
99 # EGAM7 augmentations
100 augmentationTools = []
101
102 # ====================================================================
103 # Common calo decoration tools
104 # ====================================================================
105 from DerivationFrameworkCalo.DerivationFrameworkCaloConfig import (
106 CaloDecoratorKernelCfg)
107 acc.merge(CaloDecoratorKernelCfg(flags))
108
109 # thinning tools
110 thinningTools = []
111
112 streamName = kwargs["StreamName"]
113
114 # Track thinning
115 if flags.Derivation.Egamma.doTrackThinning:
116 from DerivationFrameworkInDet.InDetToolsConfig import (
117 TrackParticleThinningCfg,
118 MuonTrackParticleThinningCfg,
119 TauTrackParticleThinningCfg,
120 )
121
122 TrackThinningKeepElectronTracks = True
123 TrackThinningKeepPhotonTracks = True
124 TrackThinningKeepAllElectronTracks = False
125 TrackThinningKeepJetTracks = False
126 TrackThinningKeepMuonTracks = False
127 TrackThinningKeepTauTracks = False
128 TrackThinningKeepPVTracks = False
129
130 # Tracks associated with Electrons
131 if TrackThinningKeepElectronTracks:
132 EGAM7ElectronTPThinningTool = (
133 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
134 name="EGAM7ElectronTPThinningTool",
135 StreamName=streamName,
136 SGKey="Electrons",
137 GSFTrackParticlesKey="GSFTrackParticles",
138 InDetTrackParticlesKey="InDetTrackParticles",
139 SelectionString="Electrons.pt > 0*GeV",
140 BestMatchOnly=True,
141 ConeSize=0.3,
142 )
143 )
144 acc.addPublicTool(EGAM7ElectronTPThinningTool)
145 thinningTools.append(EGAM7ElectronTPThinningTool)
146
147 # Tracks associated with Electrons (all tracks, large cone, for track
148 # isolation studies of the selected electrons)
149 if TrackThinningKeepAllElectronTracks:
150 EGAM7ElectronTPThinningTool2 = (
151 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
152 name="EGAM7ElectronTPThinningTool2",
153 StreamName=streamName,
154 SGKey="Electrons",
155 GSFTrackParticlesKey="GSFTrackParticles",
156 InDetTrackParticlesKey="InDetTrackParticles",
157 SelectionString="Electrons.pt > 4*GeV",
158 BestMatchOnly=False,
159 ConeSize=0.6,
160 )
161 )
162 acc.addPublicTool(EGAM7ElectronTPThinningTool2)
163 thinningTools.append(EGAM7ElectronTPThinningTool2)
164
165 # Tracks associated with Photons
166 if TrackThinningKeepPhotonTracks:
167 EGAM7PhotonTPThinningTool = (
168 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
169 name="EGAM7PhotonTPThinningTool",
170 StreamName=streamName,
171 SGKey="Photons",
172 GSFTrackParticlesKey="GSFTrackParticles",
173 InDetTrackParticlesKey="InDetTrackParticles",
174 GSFConversionVerticesKey="GSFConversionVertices",
175 SelectionString="Photons.pt > 0*GeV",
176 BestMatchOnly=True,
177 ConeSize=0.3,
178 )
179 )
180 acc.addPublicTool(EGAM7PhotonTPThinningTool)
181 thinningTools.append(EGAM7PhotonTPThinningTool)
182
183 # Tracks associated with Jets
184 if TrackThinningKeepJetTracks:
185 EGAM7JetTPThinningTool = (
186 CompFactory.DerivationFramework.JetTrackParticleThinning(
187 name="EGAM7JetTPThinningTool",
188 StreamName=streamName,
189 JetKey="AntiKt4EMPFlowJets",
190 InDetTrackParticlesKey="InDetTrackParticles",
191 )
192 )
193 acc.addPublicTool(EGAM7JetTPThinningTool)
194 thinningTools.append(EGAM7JetTPThinningTool)
195
196 # Tracks associated with Muons
197 if TrackThinningKeepMuonTracks:
198 EGAM7MuonTPThinningTool = acc.getPrimaryAndMerge(
199 MuonTrackParticleThinningCfg(
200 flags,
201 name="EGAM7MuonTPThinningTool",
202 StreamName=streamName,
203 MuonKey="Muons",
204 InDetTrackParticlesKey="InDetTrackParticles",
205 )
206 )
207 thinningTools.append(EGAM7MuonTPThinningTool)
208
209 # Tracks associated with Taus
210 if TrackThinningKeepTauTracks:
211 EGAM7TauTPThinningTool = acc.getPrimaryAndMerge(
212 TauTrackParticleThinningCfg(
213 flags,
214 name="EGAM7TauTPThinningTool",
215 StreamName=streamName,
216 TauKey="TauJets",
217 ConeSize=0.6,
218 InDetTrackParticlesKey="InDetTrackParticles",
219 DoTauTracksThinning=True,
220 TauTracksKey="TauTracks",
221 )
222 )
223 thinningTools.append(EGAM7TauTPThinningTool)
224
225 # Tracks from primary vertex
226 thinning_expression = " && ".join(
227 [
228 "(InDetTrackParticles.DFCommonTightPrimary)",
229 "(abs(DFCommonInDetTrackZ0AtPV)*sin(InDetTrackParticles.theta)<3*mm)",
230 "(InDetTrackParticles.pt>10*GeV)",
231 ]
232 )
233 if TrackThinningKeepPVTracks:
234 EGAM7TPThinningTool = acc.getPrimaryAndMerge(
235 TrackParticleThinningCfg(
236 flags,
237 name="EGAM7TPThinningTool",
238 StreamName=streamName,
239 SelectionString=thinning_expression,
240 InDetTrackParticlesKey="InDetTrackParticles",
241 )
242 )
243 thinningTools.append(EGAM7TPThinningTool)
244
245 # truth thinning
246 if flags.Input.isMC:
247 # W, Z and Higgs
248 truth_cond_WZH = " && ".join(
249 ["(abs(TruthParticles.pdgId) >= 23)", "(abs(TruthParticles.pdgId) <= 25)"]
250 )
251 # Leptons
252 truth_cond_lep = " && ".join(
253 ["(abs(TruthParticles.pdgId) >= 11)", "(abs(TruthParticles.pdgId) <= 16)"]
254 )
255 # Top quark
256 truth_cond_top = "(abs(TruthParticles.pdgId) == 6)"
257 # Photon
258 truth_cond_gam = " && ".join(
259 ["(abs(TruthParticles.pdgId) == 22)", "(TruthParticles.pt > 1*GeV)"]
260 )
261 # stable particles
262 truth_cond_finalState = "(TruthParticles.isGenStable)"
263 truth_expression = (
264 "( "
265 + truth_cond_WZH
266 + " ) || "
267 + "( "
268 + truth_cond_lep
269 + " ) || "
270 + "( "
271 + truth_cond_top
272 + " ) || "
273 + "( "
274 + truth_cond_gam
275 + " ) || "
276 + "( "
277 + truth_cond_finalState
278 + " )"
279 )
280 print("EGAM7 truth thinning expression: ", truth_expression)
281
282 EGAM7TruthThinningTool = CompFactory.DerivationFramework.GenericTruthThinning(
283 name="EGAM7TruthThinningTool",
284 StreamName=streamName,
285 ParticleSelectionString=truth_expression,
286 PreserveDescendants=False,
287 PreserveGeneratorDescendants=True,
288 PreserveAncestors=True,
289 )
290 acc.addPublicTool(EGAM7TruthThinningTool)
291 thinningTools.append(EGAM7TruthThinningTool)
292
293 # Keep only calo cells associated with the egammaClusters collection
294 if thinCells:
295 from DerivationFrameworkCalo.CaloCellDFGetterConfig import thinCaloCellsForDFCfg
296
297 acc.merge(
298 thinCaloCellsForDFCfg(
299 flags,
300 inputClusterKeys=["egammaClusters"],
301 streamName="StreamDAOD_EGAM7",
302 inputCellKey="AllCalo",
303 outputCellKey="DFEGAMCellContainer",
304 )
305 )
306
307 # skimming
308 skimmingTool = acc.getPrimaryAndMerge(EGAM7SkimmingToolCfg(flags))
309
310 # setup the kernel
311 acc.addEventAlgo(
312 CompFactory.DerivationFramework.DerivationKernel(
313 name,
314 SkimmingTools=[skimmingTool],
315 AugmentationTools=augmentationTools,
316 ThinningTools=thinningTools,
317 )
318 )
319
320 return acc
321
322

◆ EGAM7SkimmingToolCfg()

python.EGAM7.EGAM7SkimmingToolCfg ( flags)
Configure the EGAM7 skimming tool

Definition at line 30 of file EGAM7.py.

30def EGAM7SkimmingToolCfg(flags):
31 """Configure the EGAM7 skimming tool"""
32 acc = ComponentAccumulator()
33 skimmingTools = []
34
35 # off-line based selection
36 expression = "count(Electrons.pt > 4.5*GeV) >= 1"
37 print("EGAM7 offline skimming expression: ", expression)
38 EGAM7_OfflineSkimmingTool = CompFactory.DerivationFramework.xAODStringSkimmingTool(
39 name="EGAM7_OfflineSkimmingTool", expression=expression
40 )
41 if flags.Trigger.EDMVersion < 0:
42 EGAM7_OfflineSkimmingTool.TrigDecisionTool=None
43
44 acc.addPublicTool(EGAM7_OfflineSkimmingTool)
45 skimmingTools += [EGAM7_OfflineSkimmingTool]
46
47 # trigger-based selection
48 MenuType = ""
49 if flags.Trigger.EDMVersion == 2:
50 MenuType = "Run2"
51 elif flags.Trigger.EDMVersion == 3:
52 MenuType = "Run3"
53
54 if MenuType:
55 triggers = BkgElectronTriggers[MenuType]
56 print("EGAM7 trigger skimming list (OR): ", triggers)
57
58 EGAM7_TriggerSkimmingTool = CompFactory.DerivationFramework.TriggerSkimmingTool(
59 name="EGAM7_TriggerSkimmingTool", TriggerListOR=triggers
60 )
61
62 acc.addPublicTool(EGAM7_TriggerSkimmingTool)
63 skimmingTools += [EGAM7_TriggerSkimmingTool]
64
65 # do the AND of trigger-based and offline-based selection
66 print("EGAM7 skimming is logical AND of previous selections")
67 EGAM7_SkimmingTool = CompFactory.DerivationFramework.FilterCombinationAND(
68 name="EGAM7_SkimmingTool",
69 FilterList=skimmingTools
70 )
71
72 acc.addPublicTool(EGAM7_SkimmingTool, primary=True)
73
74 return acc
75
76

Variable Documentation

◆ thinCells

bool python.EGAM7.thinCells = True

Definition at line 27 of file EGAM7.py.