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 259 of file EGAM9.py.

259def EGAM9Cfg(flags):
260 acc = ComponentAccumulator()
261
262 # Get the lists of triggers needed for trigger matching.
263 # This is needed at this scope (for the slimming) and further down
264 # in the config chain for actually configuring the matching, so we create
265 # it here and pass it down
266 # TODO: this should ideally be called higher up to avoid it being run
267 # multiple times in a train.
268 # TODO: restrict it to relevant triggers
269 from DerivationFrameworkPhys.TriggerListsHelper import TriggerListsHelper
270
271 EGAM9TriggerListsHelper = TriggerListsHelper(flags)
272
273 # configure skimming/thinning/augmentation tools
274 acc.merge(
275 EGAM9KernelCfg(
276 flags,
277 name="EGAM9Kernel",
278 StreamName="StreamDAOD_EGAM9",
279 TriggerListsHelper=EGAM9TriggerListsHelper,
280 )
281 )
282
283 # configure slimming
284 from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
285 from xAODMetaDataCnv.InfileMetaDataConfig import SetupMetaDataForStreamCfg
286 from DerivationFrameworkCore.SlimmingHelper import SlimmingHelper
287
288 EGAM9SlimmingHelper = SlimmingHelper(
289 "EGAM9SlimmingHelper",
290 NamesAndTypes=flags.Input.TypedCollections,
291 flags=flags,
292 )
293
294 # ------------------------------------------
295 # containers for which we save all variables
296 # -------------------------------------------
297
298 # baseline
299 EGAM9SlimmingHelper.AllVariables = [
300 "Electrons",
301 "Photons",
302 "GSFTrackParticles",
303 "egammaClusters",
304 ]
305
306 # for trigger studies we also add:
307 MenuType = ""
308 if flags.Trigger.EDMVersion == 2:
309 MenuType = "Run2"
310 elif flags.Trigger.EDMVersion == 3:
311 MenuType = "Run3"
312
313 if MenuType:
314 EGAM9SlimmingHelper.AllVariables += ExtraContainersTrigger[MenuType]
315 EGAM9SlimmingHelper.AllVariables += ExtraContainersPhotonTrigger[MenuType]
316 if not flags.Input.isMC:
317 EGAM9SlimmingHelper.AllVariables += ExtraContainersTriggerDataOnly[MenuType]
318
319 # and on MC we also add:
320 if flags.Input.isMC:
321 EGAM9SlimmingHelper.AllVariables += [
322 "TruthEvents",
323 "TruthParticles",
324 "TruthVertices",
325 "egammaTruthParticles",
326 ]
327
328 # -------------------------------------------
329 # containers that we slim
330 # -------------------------------------------
331
332 # first add variables from smart-slimming
333 # adding only also those for which we add all variables since
334 # the XXXCPContent.py files also bring in some extra variables
335 # for other collections
336 EGAM9SlimmingHelper.SmartCollections = [
337 "Electrons",
338 "Photons",
339 "InDetTrackParticles",
340 "PrimaryVertices",
341 ]
342 if saveJets:
343 EGAM9SlimmingHelper.SmartCollections += ["AntiKt4EMPFlowJets"]
344 if flags.Input.isMC:
345 EGAM9SlimmingHelper.SmartCollections += [
346 "AntiKt4TruthJets",
347 "AntiKt4TruthDressedWZJets",
348 ]
349
350 # then add extra variables:
351
352 # photons
353 EGAM9SlimmingHelper.ExtraVariables += ["Photons.DFCommonLoosePrime5"]
354
355 # conversion vertices
356 EGAM9SlimmingHelper.ExtraVariables += [
357 "GSFConversionVertices.x.y.z.px.py.pz.pt1.pt2.etaAtCalo.phiAtCalo",
358 "GSFConversionVertices.trackParticleLinks",
359 ]
360
361 # primary vertices
362 EGAM9SlimmingHelper.ExtraVariables += ["PrimaryVertices.x.y.sumPt2"]
363
364 # track jets
365 if saveJets:
366 EGAM9SlimmingHelper.ExtraVariables += [
367 "AntiKt4PV0TrackJets.pt.eta.phi.e.m.btaggingLink.constituentLinks"
368 ]
369
370 # photons and electrons: detailed shower shape variables and track variables
371 EGAM9SlimmingHelper.ExtraVariables += PhotonsCPDetailedContent
372 EGAM9SlimmingHelper.ExtraVariables += ElectronsCPDetailedContent
373 EGAM9SlimmingHelper.ExtraVariables += GSFTracksCPDetailedContent
374
375 # photons: gain and cluster energy per layer
376 from DerivationFrameworkCalo.DerivationFrameworkCaloConfig import (
377 getGainDecorations,
378 getClusterEnergyPerLayerDecorations,
379 )
380
381 gainDecorations = getGainDecorations(acc, flags, "EGAM9Kernel")
382 print("EGAM9 gain decorations: ", gainDecorations)
383 EGAM9SlimmingHelper.ExtraVariables.extend(gainDecorations)
384 clusterEnergyDecorations = getClusterEnergyPerLayerDecorations(acc, "EGAM9Kernel")
385 print("EGAM9 cluster energy decorations: ", clusterEnergyDecorations)
386 EGAM9SlimmingHelper.ExtraVariables.extend(clusterEnergyDecorations)
387
388 # energy density
389 EGAM9SlimmingHelper.ExtraVariables += [
390 "TopoClusterIsoCentralEventShape.Density",
391 "TopoClusterIsoForwardEventShape.Density",
392 "NeutralParticleFlowIsoCentralEventShape.Density",
393 "NeutralParticleFlowIsoForwardEventShape.Density",
394 ]
395
396 # truth
397 if flags.Input.isMC:
398 EGAM9SlimmingHelper.ExtraVariables += [
399 "Photons.truthOrigin.truthType.truthParticleLink"
400 ]
401
402 # Add event info
403 if flags.Derivation.Egamma.doEventInfoSlimming:
404 EGAM9SlimmingHelper.SmartCollections.append("EventInfo")
405 else:
406 EGAM9SlimmingHelper.AllVariables += ["EventInfo"]
407
408 # Add egamma trigger objects
409 EGAM9SlimmingHelper.IncludeEGammaTriggerContent = True
410
411 # Trigger matching
412 # Run 2
413 if flags.Trigger.EDMVersion == 2:
414 from DerivationFrameworkPhys.TriggerMatchingCommonConfig import AddRun2TriggerMatchingToSlimmingHelper
415 AddRun2TriggerMatchingToSlimmingHelper(SlimmingHelper = EGAM9SlimmingHelper,
416 OutputContainerPrefix = "TrigMatch_",
417 TriggerList = EGAM9TriggerListsHelper.Run2TriggerNamesNoTau)
418 # Run 3, or Run 2 with navigation conversion
419 if flags.Trigger.EDMVersion == 3 or (flags.Trigger.EDMVersion == 2 and flags.Trigger.doEDMVersionConversion):
420 from TrigNavSlimmingMT.TrigNavSlimmingMTConfig import AddRun3TrigNavSlimmingCollectionsToSlimmingHelper
421 AddRun3TrigNavSlimmingCollectionsToSlimmingHelper(EGAM9SlimmingHelper)
422
423 # Add CellContainer and cluster->cell links
424 if keepCells:
425 if thinCells:
426 EGAM9SlimmingHelper.StaticContent = [
427 "CaloCellContainer#DFEGAMCellContainer",
428 "CaloClusterCellLinkContainer#egammaClusters_links",
429 ]
430 else:
431 EGAM9SlimmingHelper.StaticContent = [
432 "CaloCellContainer#AllCalo",
433 "CaloClusterCellLinkContainer#egammaClusters_links",
434 ]
435
436 EGAM9ItemList = EGAM9SlimmingHelper.GetItemList()
437 acc.merge(
438 OutputStreamCfg(
439 flags,
440 "DAOD_EGAM9",
441 ItemList=EGAM9ItemList,
442 AcceptAlgs=["EGAM9Kernel"],
443 )
444 )
445 acc.merge(
446 SetupMetaDataForStreamCfg(
447 flags,
448 "DAOD_EGAM9",
449 AcceptAlgs=["EGAM9Kernel"],
450 createMetadata=[
451 MetadataCategory.CutFlowMetaData,
452 MetadataCategory.TruthMetaData,
453 ],
454 )
455 )
456
457 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 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(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 = " && ".join(
185 ["(abs(TruthParticles.pdgId) >= 23)", "(abs(TruthParticles.pdgId) <= 25)"]
186 )
187 # Leptons
188 truth_cond_lep = " && ".join(
189 ["(abs(TruthParticles.pdgId) >= 11)", "(abs(TruthParticles.pdgId) <= 16)"]
190 )
191 # Top quark
192 truth_cond_top = "(abs(TruthParticles.pdgId) == 6)"
193 # Photon
194 truth_cond_gam = " && ".join(
195 ["(abs(TruthParticles.pdgId) == 22)", "(TruthParticles.pt > 1*GeV)"]
196 )
197 # stable particles
198 truth_cond_finalState = "(TruthParticles.isGenStable)"
199 truth_expression = (
200 "( "
201 + truth_cond_WZH
202 + " ) || "
203 + "( "
204 + truth_cond_lep
205 + " ) || "
206 + "( "
207 + truth_cond_top
208 + " ) || "
209 + "( "
210 + truth_cond_gam
211 + " ) || "
212 + "( "
213 + truth_cond_finalState
214 + " )"
215 )
216 print("EGAM9 truth thinning expression: ", truth_expression)
217
218 EGAM9TruthThinningTool = CompFactory.DerivationFramework.GenericTruthThinning(
219 name="EGAM9TruthThinningTool",
220 StreamName=streamName,
221 ParticleSelectionString=truth_expression,
222 PreserveDescendants=False,
223 PreserveGeneratorDescendants=True,
224 PreserveAncestors=True,
225 )
226 acc.addPublicTool(EGAM9TruthThinningTool)
227 thinningTools.append(EGAM9TruthThinningTool)
228
229 # Keep only calo cells associated with the egammaClusters collection
230 if thinCells:
231 from DerivationFrameworkCalo.CaloCellDFGetterConfig import thinCaloCellsForDFCfg
232
233 acc.merge(
234 thinCaloCellsForDFCfg(
235 flags,
236 inputClusterKeys=["egammaClusters"],
237 streamName="StreamDAOD_EGAM9",
238 inputCellKey="AllCalo",
239 outputCellKey="DFEGAMCellContainer",
240 )
241 )
242
243 # skimming
244 skimmingTool = acc.getPrimaryAndMerge(EGAM9SkimmingToolCfg(flags))
245
246 # setup the kernel
247 acc.addEventAlgo(
248 CompFactory.DerivationFramework.DerivationKernel(
249 name,
250 SkimmingTools=[skimmingTool],
251 AugmentationTools=augmentationTools,
252 ThinningTools=thinningTools,
253 )
254 )
255
256 return acc
257
258

◆ 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 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.