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 293 of file EGAM4.py.

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

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

◆ EGAM4mumuMassToolCfg()

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

Definition at line 58 of file EGAM4.py.

58def EGAM4mumuMassToolCfg(flags):
59 """Configure the EGAM4 mumu invariant mass augmentation tool"""
60 acc = ComponentAccumulator()
61
62 # ====================================================================
63 # invariant mass of two OS muons with pT>10 GeV passing preselection
64 # ====================================================================
65
66 requirementMuons = " && ".join(
67 ["Muons.pt>9.5*GeV", "abs(Muons.eta)<2.7", "Muons.DFCommonMuonPassPreselection"]
68 )
69
70 acc.setPrivateTools(
71 CompFactory.DerivationFramework.EGInvariantMassTool(
72 name="EGAM4_MuMuMassTool",
73 Object1Requirements=requirementMuons,
74 Object2Requirements=requirementMuons,
75 StoreGateEntryName="EGAM4_DiMuonMass",
76 Mass1Hypothesis=105 * MeV,
77 Mass2Hypothesis=105 * MeV,
78 Container1Name="Muons",
79 Container2Name="Muons",
80 CheckCharge=True,
81 DoTransverseMass=False,
82 MinDeltaR=0.0,
83 )
84 )
85
86 return acc
87
88
89# 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 acc = ComponentAccumulator()
31
32 # mumugamma: one reco photon (ET>10 GeV) and OS muon pair w/ m>40 GeV
33 expression1a = " && ".join(
34 [
35 "(count(DFCommonPhotons_et>9.5*GeV)>=1)",
36 "(count(EGAM4_DiMuonMass > 40.0*GeV)>=1)",
37 ]
38 )
39
40 # mumue: one reco e (ET>10 GeV) and OS muon pair w/ m>40 GeV
41 expression1b = " && ".join(
42 ["(count(Electrons.pt>9.5*GeV)>=1)", "(count(EGAM4_DiMuonMass > 40.0*GeV)>=1)"]
43 )
44
45 # take OR of previous selections
46 expression = "( " + expression1a + " ) || ( " + expression1b + " )"
47 print("EGAM4 skimming expression: ", expression)
48
49 skimmingTool = CompFactory.DerivationFramework.xAODStringSkimmingTool(
50 name="EGAM4SkimmingTool", expression=expression)
51 if flags.Trigger.EDMVersion < 0:
52 skimmingTool.TrigDecisionTool=None
53
54 acc.setPrivateTools(skimmingTool)
55 return acc
56
57