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

Functions

 EGAM4SkimmingToolCfg (flags)
 EGAM4mumuMassToolCfg (flags)
 EGAM4KernelCfg (flags, name="EGAM4Kernel", **kwargs)
 EGAM4Cfg (flags)

Function Documentation

◆ EGAM4Cfg()

python.EGAM4.EGAM4Cfg ( flags)

Definition at line 288 of file EGAM4.py.

288def EGAM4Cfg(flags):
289 acc = ComponentAccumulator()
290
291 # Get the lists of triggers needed for trigger matching.
292 # This is needed at this scope (for the slimming) and further down
293 # in the config chain for actually configuring the matching, so we create
294 # it here and pass it down
295 # TODO: this should ideally be called higher up to avoid it being run
296 # multiple times in a train
297 from DerivationFrameworkPhys.TriggerListsHelper import TriggerListsHelper
298
299 EGAM4TriggerListsHelper = TriggerListsHelper(flags)
300
301 # configure skimming/thinning/augmentation tools
302 acc.merge(
303 EGAM4KernelCfg(
304 flags,
305 name="EGAM4Kernel",
306 StreamName="StreamDAOD_EGAM4",
307 TriggerListsHelper=EGAM4TriggerListsHelper,
308 )
309 )
310
311 # To have ptcone40
312 from IsolationAlgs.DerivationTrackIsoConfig import DerivationTrackIsoCfg
313
314 acc.merge(
315 DerivationTrackIsoCfg(
316 flags, object_types=("Photons",), ptCuts=(500, 1000), postfix="Extra"
317 )
318 )
319
320 # configure slimming
321 from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
322 from xAODMetaDataCnv.InfileMetaDataConfig import SetupMetaDataForStreamCfg
323 from DerivationFrameworkCore.SlimmingHelper import SlimmingHelper
324
325 EGAM4SlimmingHelper = SlimmingHelper(
326 "EGAM4SlimmingHelper",
327 NamesAndTypes=flags.Input.TypedCollections,
328 flags=flags,
329 )
330
331 # ------------------------------------------
332 # containers for which we save all variables
333 # -------------------------------------------
334
335 # baseline
336 EGAM4SlimmingHelper.AllVariables = [
337 "Photons",
338 "GSFTrackParticles",
339 "egammaClusters",
340 ]
341
342 # for trigger studies we also add:
343 MenuType = ""
344 if flags.Trigger.EDMVersion == 2:
345 MenuType = "Run2"
346 elif flags.Trigger.EDMVersion == 3:
347 MenuType = "Run3"
348
349 if MenuType:
350 EGAM4SlimmingHelper.AllVariables += ExtraContainersTrigger[MenuType]
351 EGAM4SlimmingHelper.AllVariables += ExtraContainersPhotonTrigger[MenuType]
352 EGAM4SlimmingHelper.AllVariables += ExtraContainersMuonTrigger[MenuType]
353 if not flags.Input.isMC:
354 EGAM4SlimmingHelper.AllVariables += ExtraContainersTriggerDataOnly[MenuType]
355
356 # and on MC we also add:
357 if flags.Input.isMC:
358 EGAM4SlimmingHelper.AllVariables += [
359 "TruthEvents",
360 "TruthParticles",
361 "TruthVertices",
362 "egammaTruthParticles",
363 "MuonTruthParticles",
364 ]
365
366 # -------------------------------------------
367 # containers that we slim
368 # -------------------------------------------
369
370 # first add variables from smart-slimming
371 # adding only also those for which we add all variables since
372 # the XXXCPContent.py files also bring in some extra variables
373 # for other collections
374 EGAM4SlimmingHelper.SmartCollections = [
375 "Electrons",
376 "Photons",
377 "Muons",
378 "TauJets",
379 "PrimaryVertices",
380 "InDetTrackParticles",
381 "AntiKt4EMPFlowJets",
382
383 "MET_Baseline_AntiKt4EMPFlow",
384 ]
385 if flags.Input.isMC:
386 EGAM4SlimmingHelper.SmartCollections += [
387 "AntiKt4TruthJets",
388 "AntiKt4TruthDressedWZJets",
389 ]
390 if flags.Derivation.Egamma.addHLTJets:
391 EGAM4SlimmingHelper.SmartCollections += [
392 "HLT_AntiKt4EMPFlowJets_subresjesgscIS_ftf",
393 ]
394
395 # then add extra variables:
396
397 # electrons
398 EGAM4SlimmingHelper.ExtraVariables += ["Electrons.Loose.Medium.Tight"]
399
400 # muons
401 EGAM4SlimmingHelper.ExtraVariables += [
402 "Muons.ptcone20.ptcone30.ptcone40.etcone20.etcone30.etcone40"
403 ]
404
405 # conversion vertices
406 EGAM4SlimmingHelper.ExtraVariables += [
407 "GSFConversionVertices.x.y.z.px.py.pz.pt1.pt2.etaAtCalo.phiAtCalo",
408 "GSFConversionVertices.trackParticleLinks",
409 ]
410
411 # primary vertices
412 EGAM4SlimmingHelper.ExtraVariables += ["PrimaryVertices.x.y.sumPt2"]
413
414 # energy density
415 EGAM4SlimmingHelper.ExtraVariables += [
416 "TopoClusterIsoCentralEventShape.Density",
417 "TopoClusterIsoForwardEventShape.Density",
418 "NeutralParticleFlowIsoCentralEventShape.Density",
419 "NeutralParticleFlowIsoForwardEventShape.Density",
420 ]
421
422 # electrons: detailed shower shape and track variables
423 EGAM4SlimmingHelper.ExtraVariables += ElectronsCPDetailedContent
424 EGAM4SlimmingHelper.ExtraVariables += GSFTracksCPDetailedContent
425
426 # photons and electrons: gain and cluster energy per layer
427 # code would not be needed for photons since we save every photon variable
428 from DerivationFrameworkCalo.DerivationFrameworkCaloConfig import (
429 getGainDecorations,
430 getClusterEnergyPerLayerDecorations,
431 )
432
433 gainDecorations = getGainDecorations(acc, flags, "EGAM4Kernel")
434 print("EGAM4 gain decorations: ", gainDecorations)
435 EGAM4SlimmingHelper.ExtraVariables.extend(gainDecorations)
436 clusterEnergyDecorations = getClusterEnergyPerLayerDecorations(acc, "EGAM4Kernel")
437 print("EGAM4 cluster energy decorations: ", clusterEnergyDecorations)
438 EGAM4SlimmingHelper.ExtraVariables.extend(clusterEnergyDecorations)
439
440 # truth
441 if flags.Input.isMC:
442 EGAM4SlimmingHelper.ExtraVariables += [
443 "Electrons.truthOrigin.truthType.truthParticleLink"
444 ]
445
446 # Add event info
447 if flags.Derivation.Egamma.doEventInfoSlimming:
448 EGAM4SlimmingHelper.SmartCollections.append("EventInfo")
449 else:
450 EGAM4SlimmingHelper.AllVariables += ["EventInfo"]
451
452 # Add egamma trigger objects
453 EGAM4SlimmingHelper.IncludeEGammaTriggerContent = True
454 EGAM4SlimmingHelper.IncludeMuonTriggerContent = True
455
456 # Trigger matching
457 # Run 2
458 if flags.Trigger.EDMVersion == 2:
459 from DerivationFrameworkPhys.TriggerMatchingCommonConfig import AddRun2TriggerMatchingToSlimmingHelper
460 AddRun2TriggerMatchingToSlimmingHelper(SlimmingHelper = EGAM4SlimmingHelper,
461 OutputContainerPrefix = "TrigMatch_",
462 TriggerList = EGAM4TriggerListsHelper.Run2TriggerNamesNoTau)
463 # Run 3, or Run 2 with navigation conversion
464 if flags.Trigger.EDMVersion == 3 or (flags.Trigger.EDMVersion == 2 and flags.Trigger.doEDMVersionConversion):
465 from TrigNavSlimmingMT.TrigNavSlimmingMTConfig import AddRun3TrigNavSlimmingCollectionsToSlimmingHelper
466 AddRun3TrigNavSlimmingCollectionsToSlimmingHelper(EGAM4SlimmingHelper)
467
468 # Add full CellContainer
469 EGAM4SlimmingHelper.StaticContent = [
470 "CaloCellContainer#AllCalo",
471 "CaloClusterCellLinkContainer#egammaClusters_links",
472 ]
473
474 EGAM4ItemList = EGAM4SlimmingHelper.GetItemList()
475 acc.merge(
476 OutputStreamCfg(
477 flags,
478 "DAOD_EGAM4",
479 ItemList=EGAM4ItemList,
480 AcceptAlgs=["EGAM4Kernel"],
481 )
482 )
483 acc.merge(
484 SetupMetaDataForStreamCfg(
485 flags,
486 "DAOD_EGAM4",
487 AcceptAlgs=["EGAM4Kernel"],
488 createMetadata=[
489 MetadataCategory.CutFlowMetaData,
490 MetadataCategory.TruthMetaData,
491 ],
492 )
493 )
494
495 return acc
void print(char *figname, TCanvas *c1)

◆ EGAM4KernelCfg()

python.EGAM4.EGAM4KernelCfg ( flags,
name = "EGAM4Kernel",
** kwargs )
Configure the derivation framework driving algorithm (kernel)
for EGAM4

Definition at line 86 of file EGAM4.py.

86def EGAM4KernelCfg(flags, name="EGAM4Kernel", **kwargs):
87 """Configure the derivation framework driving algorithm (kernel)
88 for EGAM4"""
89 acc = ComponentAccumulator()
90
91 # Common augmentations
92 from DerivationFrameworkPhys.PhysCommonConfig import PhysCommonAugmentationsCfg
93
94 acc.merge(
95 PhysCommonAugmentationsCfg(
96 flags, TriggerListsHelper=kwargs["TriggerListsHelper"]
97 )
98 )
99
100 # EGAM4 augmentations
101 augmentationTools = []
102
103 # ====================================================================
104 # ee and egamma invariant masses
105 # ====================================================================
106 EGAM4mumuMassTool = acc.popToolsAndMerge(EGAM4mumuMassToolCfg(flags))
107 acc.addPublicTool(EGAM4mumuMassTool)
108 augmentationTools.append(EGAM4mumuMassTool)
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 from DerivationFrameworkInDet.InDetToolsConfig import (
124 TrackParticleThinningCfg,
125 MuonTrackParticleThinningCfg,
126 TauTrackParticleThinningCfg,
127 )
128
129 TrackThinningKeepElectronTracks = True
130 TrackThinningKeepAllElectronTracks = False
131 TrackThinningKeepPhotonTracks = True
132 TrackThinningKeepAllPhotonTracks = True
133 TrackThinningKeepJetTracks = False
134 TrackThinningKeepMuonTracks = False
135 TrackThinningKeepTauTracks = False
136 TrackThinningKeepPVTracks = True
137
138 # Tracks associated with Electrons
139 if TrackThinningKeepElectronTracks:
140 EGAM4ElectronTPThinningTool = (
141 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
142 name="EGAM4ElectronTPThinningTool",
143 StreamName=streamName,
144 SGKey="Electrons",
145 GSFTrackParticlesKey="GSFTrackParticles",
146 InDetTrackParticlesKey="InDetTrackParticles",
147 SelectionString="Electrons.pt > 0*GeV",
148 BestMatchOnly=True,
149 ConeSize=0.3,
150 )
151 )
152 acc.addPublicTool(EGAM4ElectronTPThinningTool)
153 thinningTools.append(EGAM4ElectronTPThinningTool)
154
155 # Tracks associated with Electrons (all tracks, large cone, for track
156 # isolation studies of the selected electrons)
157 if TrackThinningKeepAllElectronTracks:
158 EGAM4ElectronTPThinningTool2 = (
159 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
160 name="EGAM4ElectronTPThinningTool2",
161 StreamName=streamName,
162 SGKey="Electrons",
163 GSFTrackParticlesKey="GSFTrackParticles",
164 InDetTrackParticlesKey="InDetTrackParticles",
165 SelectionString="Electrons.pt > 4*GeV",
166 BestMatchOnly=False,
167 ConeSize=0.6,
168 )
169 )
170 acc.addPublicTool(EGAM4ElectronTPThinningTool2)
171 thinningTools.append(EGAM4ElectronTPThinningTool2)
172
173 # Tracks associated with Photons
174 if TrackThinningKeepPhotonTracks:
175 EGAM4PhotonTPThinningTool = (
176 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
177 name="EGAM4PhotonTPThinningTool",
178 StreamName=streamName,
179 SGKey="Photons",
180 GSFTrackParticlesKey="GSFTrackParticles",
181 InDetTrackParticlesKey="InDetTrackParticles",
182 GSFConversionVerticesKey="GSFConversionVertices",
183 SelectionString="Photons.pt > 0*GeV",
184 BestMatchOnly=True,
185 ConeSize=0.3,
186 )
187 )
188 acc.addPublicTool(EGAM4PhotonTPThinningTool)
189 thinningTools.append(EGAM4PhotonTPThinningTool)
190
191 # Tracks associated with Photons (all tracks, large cone,
192 # for track isolation studies of the selected photons)
193 if TrackThinningKeepAllPhotonTracks:
194 EGAM4PhotonTPThinningTool2 = (
195 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
196 name="EGAM4PhotonTPThinningTool2",
197 StreamName=streamName,
198 SGKey="Photons",
199 GSFTrackParticlesKey="GSFTrackParticles",
200 InDetTrackParticlesKey="InDetTrackParticles",
201 GSFConversionVerticesKey="GSFConversionVertices",
202 SelectionString="Photons.pt > 9.5*GeV",
203 BestMatchOnly=False,
204 ConeSize=0.6,
205 )
206 )
207 acc.addPublicTool(EGAM4PhotonTPThinningTool2)
208 thinningTools.append(EGAM4PhotonTPThinningTool2)
209
210 # Tracks associated with Jets
211 if TrackThinningKeepJetTracks:
212 EGAM4JetTPThinningTool = (
213 CompFactory.DerivationFramework.JetTrackParticleThinning(
214 name="EGAM4JetTPThinningTool",
215 StreamName=streamName,
216 JetKey="AntiKt4EMPFlowJets",
217 InDetTrackParticlesKey="InDetTrackParticles",
218 )
219 )
220 acc.addPublicTool(EGAM4JetTPThinningTool)
221 thinningTools.append(EGAM4JetTPThinningTool)
222
223 # Tracks associated with Muons
224 if TrackThinningKeepMuonTracks:
225 EGAM4MuonTPThinningTool = acc.getPrimaryAndMerge(
226 MuonTrackParticleThinningCfg(
227 flags,
228 name="EGAM4MuonTPThinningTool",
229 StreamName=streamName,
230 MuonKey="Muons",
231 InDetTrackParticlesKey="InDetTrackParticles",
232 )
233 )
234 thinningTools.append(EGAM4MuonTPThinningTool)
235
236 # Tracks associated with Taus
237 if TrackThinningKeepTauTracks:
238 EGAM4TauTPThinningTool = acc.getPrimaryAndMerge(
239 TauTrackParticleThinningCfg(
240 flags,
241 name="EGAM4TauTPThinningTool",
242 StreamName=streamName,
243 TauKey="TauJets",
244 ConeSize=0.6,
245 InDetTrackParticlesKey="InDetTrackParticles",
246 DoTauTracksThinning=True,
247 TauTracksKey="TauTracks",
248 )
249 )
250 thinningTools.append(EGAM4TauTPThinningTool)
251
252 # Tracks from primary vertex
253 thinning_expression = " && ".join(
254 [
255 "(InDetTrackParticles.DFCommonTightPrimary)",
256 "(abs(DFCommonInDetTrackZ0AtPV)*sin(InDetTrackParticles.theta)<3*mm)",
257 "(InDetTrackParticles.pt>10*GeV)",
258 ]
259 )
260 if TrackThinningKeepPVTracks:
261 EGAM4TPThinningTool = acc.getPrimaryAndMerge(
262 TrackParticleThinningCfg(
263 flags,
264 name="EGAM4TPThinningTool",
265 StreamName=streamName,
266 SelectionString=thinning_expression,
267 InDetTrackParticlesKey="InDetTrackParticles",
268 )
269 )
270 thinningTools.append(EGAM4TPThinningTool)
271
272 # skimming
273 skimmingTool = acc.getPrimaryAndMerge(EGAM4SkimmingToolCfg(flags))
274
275 # setup the kernel
276 acc.addEventAlgo(
277 CompFactory.DerivationFramework.DerivationKernel(
278 name,
279 SkimmingTools=[skimmingTool],
280 AugmentationTools=augmentationTools,
281 ThinningTools=thinningTools,
282 )
283 )
284
285 return acc
286
287

◆ EGAM4mumuMassToolCfg()

python.EGAM4.EGAM4mumuMassToolCfg ( flags)
Configure the EGAM4 mumu invariant mass augmentation tool

Definition at line 54 of file EGAM4.py.

54def EGAM4mumuMassToolCfg(flags):
55 """Configure the EGAM4 mumu invariant mass augmentation tool"""
56 acc = ComponentAccumulator()
57
58 # ====================================================================
59 # invariant mass of two OS muons with pT>10 GeV passing preselection
60 # ====================================================================
61
62 requirementMuons = " && ".join(
63 ["Muons.pt>9.5*GeV", "abs(Muons.eta)<2.7", "Muons.DFCommonMuonPassPreselection"]
64 )
65
66 acc.setPrivateTools(
67 CompFactory.DerivationFramework.EGInvariantMassTool(
68 name="EGAM4_MuMuMassTool",
69 Object1Requirements=requirementMuons,
70 Object2Requirements=requirementMuons,
71 StoreGateEntryName="EGAM4_DiMuonMass",
72 Mass1Hypothesis=105 * MeV,
73 Mass2Hypothesis=105 * MeV,
74 Container1Name="Muons",
75 Container2Name="Muons",
76 CheckCharge=True,
77 DoTransverseMass=False,
78 MinDeltaR=0.0,
79 )
80 )
81
82 return acc
83
84
85# Main algorithm config

◆ EGAM4SkimmingToolCfg()

python.EGAM4.EGAM4SkimmingToolCfg ( flags)
Configure the EGAM4 skimming tool

Definition at line 28 of file EGAM4.py.

28def EGAM4SkimmingToolCfg(flags):
29 """Configure the EGAM4 skimming tool"""
30
31 # mumugamma: one reco photon (ET>10 GeV) and OS muon pair w/ m>40 GeV
32 expression1a = " && ".join(
33 [
34 "(count(DFCommonPhotons_et>9.5*GeV)>=1)",
35 "(count(EGAM4_DiMuonMass > 40.0*GeV)>=1)",
36 ]
37 )
38
39 # mumue: one reco e (ET>10 GeV) and OS muon pair w/ m>40 GeV
40 expression1b = " && ".join(
41 ["(count(Electrons.pt>9.5*GeV)>=1)", "(count(EGAM4_DiMuonMass > 40.0*GeV)>=1)"]
42 )
43
44 # take OR of previous selections
45 expression = "( " + expression1a + " ) || ( " + expression1b + " )"
46 print("EGAM4 skimming expression: ", expression)
47
48 from DerivationFrameworkTools.DerivationFrameworkToolsConfig import (
49 xAODStringSkimmingToolCfg)
50 return xAODStringSkimmingToolCfg(flags, name = "EGAM4SkimmingTool",
51 expression = expression)
52
53