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

Functions

 EGAM8SkimmingToolCfg (flags)
 EGAM8ZeeMassToolCfg (flags)
 EGAM8ZmueMassToolCfg (flags)
 EGAM8KernelCfg (flags, name="EGAM8Kernel", **kwargs)
 EGAM8Cfg (flags)

Function Documentation

◆ EGAM8Cfg()

python.EGAM8.EGAM8Cfg ( flags)

Definition at line 371 of file EGAM8.py.

371def EGAM8Cfg(flags):
372 acc = ComponentAccumulator()
373
374 # Get the lists of triggers needed for trigger matching.
375 # This is needed at this scope (for the slimming) and further down
376 # in the config chain for actually configuring the matching, so we create
377 # it here and pass it down
378 # TODO: this should ideally be called higher up to avoid it being run
379 # multiple times in a train
380
381 from DerivationFrameworkPhys.TriggerListsHelper import TriggerListsHelper
382
383 EGAM8TriggerListsHelper = TriggerListsHelper(flags)
384
385 # configure skimming/thinning/augmentation tools
386 acc.merge(
387 EGAM8KernelCfg(
388 flags,
389 name="EGAM8Kernel",
390 StreamName="StreamDAOD_EGAM8",
391 TriggerListsHelper=EGAM8TriggerListsHelper,
392 )
393 )
394
395 # configure slimming
396 from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
397 from xAODMetaDataCnv.InfileMetaDataConfig import SetupMetaDataForStreamCfg
398 from DerivationFrameworkCore.SlimmingHelper import SlimmingHelper
399
400 EGAM8SlimmingHelper = SlimmingHelper(
401 "EGAM8SlimmingHelper",
402 NamesAndTypes=flags.Input.TypedCollections,
403 flags=flags,
404 )
405
406 # ------------------------------------------
407 # containers for which we save all variables
408 # -------------------------------------------
409
410 # baseline
411 EGAM8SlimmingHelper.AllVariables = [
412 "Electrons",
413 "ForwardElectrons",
414 "GSFTrackParticles",
415 "egammaClusters",
416 "ForwardElectronClusters",
417 ]
418
419 # for trigger studies we also add:
420 # EGAM8SlimmingHelper.AllVariables += [ ]
421
422 # and on MC we also add:
423 if flags.Input.isMC:
424 EGAM8SlimmingHelper.AllVariables += [
425 "TruthEvents",
426 "TruthParticles",
427 "TruthVertices",
428 "egammaTruthParticles",
429 ]
430
431 # -------------------------------------------
432 # containers that we slim
433 # -------------------------------------------
434
435 # first add variables from smart-slimming
436 # adding only also those for which we add all variables since
437 # the XXXCPContent.py files also bring in some extra variables
438 # for other collections
439 EGAM8SlimmingHelper.SmartCollections = [
440 "Electrons",
441 "Photons",
442 "Muons",
443 "TauJets",
444 "PrimaryVertices",
445 "InDetTrackParticles",
446 "AntiKt4EMPFlowJets",
447
448 "MET_Baseline_AntiKt4EMPFlow",
449 ]
450 if flags.Input.isMC:
451 EGAM8SlimmingHelper.SmartCollections += [
452 "AntiKt4TruthJets",
453 "AntiKt4TruthDressedWZJets",
454 ]
455
456 # then add extra variables:
457
458 # muons
459 EGAM8SlimmingHelper.ExtraVariables += [
460 "Muons.ptcone20.ptcone30.ptcone40.etcone20.etcone30.etcone40"
461 ]
462
463 # conversion vertices
464 EGAM8SlimmingHelper.ExtraVariables += [
465 "GSFConversionVertices.x.y.z.px.py.pz.pt1.pt2.etaAtCalo.phiAtCalo",
466 "GSFConversionVertices.trackParticleLinks",
467 ]
468
469 # primary vertices
470 EGAM8SlimmingHelper.ExtraVariables += ["PrimaryVertices.x.y.sumPt2"]
471
472 # track jets
473 EGAM8SlimmingHelper.ExtraVariables += [
474 "AntiKt4PV0TrackJets.pt.eta.phi.e.m.btaggingLink.constituentLinks"
475 ]
476
477 # energy density
478 EGAM8SlimmingHelper.ExtraVariables += [
479 "TopoClusterIsoCentralEventShape.Density",
480 "TopoClusterIsoForwardEventShape.Density",
481 "NeutralParticleFlowIsoCentralEventShape.Density",
482 "NeutralParticleFlowIsoForwardEventShape.Density",
483 ]
484
485 # photons: detailed shower shape variables
486 EGAM8SlimmingHelper.ExtraVariables += PhotonsCPDetailedContent
487
488 # photons: gain and cluster energy per layer
489 from DerivationFrameworkCalo.DerivationFrameworkCaloConfig import (
490 getGainDecorations,
491 getClusterEnergyPerLayerDecorations,
492 )
493
494 gainDecorations = getGainDecorations(acc, flags, "EGAM8Kernel")
495 print("EGAM8 gain decorations: ", gainDecorations)
496 EGAM8SlimmingHelper.ExtraVariables.extend(gainDecorations)
497 clusterEnergyDecorations = getClusterEnergyPerLayerDecorations(acc, "EGAM8Kernel")
498 print("EGAM8 cluster energy decorations: ", clusterEnergyDecorations)
499 EGAM8SlimmingHelper.ExtraVariables.extend(clusterEnergyDecorations)
500
501 # truth
502 if flags.Input.isMC:
503 EGAM8SlimmingHelper.ExtraVariables += [
504 "MuonTruthParticles.e.px.py.pz.status.pdgId.truthOrigin.truthType"
505 ]
506
507 EGAM8SlimmingHelper.ExtraVariables += [
508 "Photons.truthOrigin.truthType.truthParticleLink"
509 ]
510
511 # Add event info
512 if flags.Derivation.Egamma.doEventInfoSlimming:
513 EGAM8SlimmingHelper.SmartCollections.append("EventInfo")
514 else:
515 EGAM8SlimmingHelper.AllVariables += ["EventInfo"]
516
517 # Add egamma trigger objects
518 EGAM8SlimmingHelper.IncludeEGammaTriggerContent = True
519 EGAM8SlimmingHelper.IncludeMuonTriggerContent = True
520
521 # Trigger matching
522 # Run 2
523 if flags.Trigger.EDMVersion == 2:
524 from DerivationFrameworkPhys.TriggerMatchingCommonConfig import AddRun2TriggerMatchingToSlimmingHelper
525 AddRun2TriggerMatchingToSlimmingHelper(SlimmingHelper = EGAM8SlimmingHelper,
526 OutputContainerPrefix = "TrigMatch_",
527 TriggerList = EGAM8TriggerListsHelper.Run2TriggerNamesNoTau)
528 # Run 3, or Run 2 with navigation conversion
529 if flags.Trigger.EDMVersion == 3 or (flags.Trigger.EDMVersion == 2 and flags.Trigger.doEDMVersionConversion):
530 from TrigNavSlimmingMT.TrigNavSlimmingMTConfig import AddRun3TrigNavSlimmingCollectionsToSlimmingHelper
531 AddRun3TrigNavSlimmingCollectionsToSlimmingHelper(EGAM8SlimmingHelper)
532
533 # Add full CellContainer
534 EGAM8SlimmingHelper.StaticContent = [
535 "CaloCellContainer#AllCalo",
536 "CaloClusterCellLinkContainer#egammaClusters_links",
537 "CaloClusterCellLinkContainer#ForwardElectronClusters_links",
538 "xAOD::CaloClusterContainer#ForwardElectronCookieCutClusters",
539 "xAOD::CaloClusterAuxContainer#ForwardElectronCookieCutClustersAux.",
540 ]
541
542 EGAM8ItemList = EGAM8SlimmingHelper.GetItemList()
543 acc.merge(
544 OutputStreamCfg(
545 flags,
546 "DAOD_EGAM8",
547 ItemList=EGAM8ItemList,
548 AcceptAlgs=["EGAM8Kernel"],
549 )
550 )
551 acc.merge(
552 SetupMetaDataForStreamCfg(
553 flags,
554 "DAOD_EGAM8",
555 AcceptAlgs=["EGAM8Kernel"],
556 createMetadata=[
557 MetadataCategory.CutFlowMetaData,
558 MetadataCategory.TruthMetaData,
559 ],
560 )
561 )
562
563 return acc
void print(char *figname, TCanvas *c1)

◆ EGAM8KernelCfg()

python.EGAM8.EGAM8KernelCfg ( flags,
name = "EGAM8Kernel",
** kwargs )
Configure the derivation framework driving algorithm (kernel)
for EGAM8

Definition at line 124 of file EGAM8.py.

124def EGAM8KernelCfg(flags, name="EGAM8Kernel", **kwargs):
125 """Configure the derivation framework driving algorithm (kernel)
126 for EGAM8"""
127 acc = ComponentAccumulator()
128
129 # Common augmentations
130 from DerivationFrameworkPhys.PhysCommonConfig import PhysCommonAugmentationsCfg
131
132 acc.merge(
133 PhysCommonAugmentationsCfg(
134 flags, TriggerListsHelper=kwargs["TriggerListsHelper"]
135 )
136 )
137
138 # EGAM8 augmentations
139 augmentationTools = []
140
141 # ====================================================================
142 # ee and mue invariant masses
143 # ====================================================================
144 EGAM8ZeeMassTool = acc.popToolsAndMerge(EGAM8ZeeMassToolCfg(flags))
145 acc.addPublicTool(EGAM8ZeeMassTool)
146 augmentationTools.append(EGAM8ZeeMassTool)
147
148 EGAM8ZmueMassTool = acc.popToolsAndMerge(EGAM8ZmueMassToolCfg(flags))
149 acc.addPublicTool(EGAM8ZmueMassTool)
150 augmentationTools.append(EGAM8ZmueMassTool)
151
152 # ====================================================================
153 # Common calo decoration tools
154 # ====================================================================
155 from DerivationFrameworkCalo.DerivationFrameworkCaloConfig import (
156 CaloDecoratorKernelCfg)
157 acc.merge(CaloDecoratorKernelCfg(flags))
158
159 from DerivationFrameworkEGamma.EGammaToolsConfig import (
160 EGammaCookieCutClusterToolCfg)
161 cookieCutTool = acc.popToolsAndMerge(
162 EGammaCookieCutClusterToolCfg(flags,
163 name,
164 StoreInputMoments=True,
165 StoreCookedMoments=True))
166 acc.addPublicTool(cookieCutTool)
167 augmentationTools.append(cookieCutTool)
168
169 # thinning tools
170 thinningTools = []
171 streamName = kwargs["StreamName"]
172
173 # Track thinning
174 if flags.Derivation.Egamma.doTrackThinning:
175 from DerivationFrameworkInDet.InDetToolsConfig import (
176 TrackParticleThinningCfg,
177 MuonTrackParticleThinningCfg,
178 TauTrackParticleThinningCfg,
179 )
180
181 TrackThinningKeepElectronTracks = True
182 TrackThinningKeepPhotonTracks = True
183 TrackThinningKeepAllElectronTracks = False
184 TrackThinningKeepJetTracks = False
185 TrackThinningKeepMuonTracks = True
186 TrackThinningKeepTauTracks = False
187 TrackThinningKeepPVTracks = False
188
189 # Tracks associated with Electrons
190 if TrackThinningKeepElectronTracks:
191 EGAM8ElectronTPThinningTool = (
192 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
193 name="EGAM8ElectronTPThinningTool",
194 StreamName=streamName,
195 SGKey="Electrons",
196 GSFTrackParticlesKey="GSFTrackParticles",
197 InDetTrackParticlesKey="InDetTrackParticles",
198 SelectionString="Electrons.pt > 0*GeV",
199 BestMatchOnly=True,
200 ConeSize=0.3,
201 )
202 )
203 acc.addPublicTool(EGAM8ElectronTPThinningTool)
204 thinningTools.append(EGAM8ElectronTPThinningTool)
205
206 # Tracks associated with Electrons (all tracks, large cone, for track
207 # isolation studies of the selected electrons)
208 if TrackThinningKeepAllElectronTracks:
209 EGAM8ElectronTPThinningTool2 = (
210 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
211 name="EGAM8ElectronTPThinningTool2",
212 StreamName=streamName,
213 SGKey="Electrons",
214 GSFTrackParticlesKey="GSFTrackParticles",
215 InDetTrackParticlesKey="InDetTrackParticles",
216 SelectionString="Electrons.pt > 4*GeV",
217 BestMatchOnly=False,
218 ConeSize=0.6,
219 )
220 )
221 acc.addPublicTool(EGAM8ElectronTPThinningTool2)
222 thinningTools.append(EGAM8ElectronTPThinningTool2)
223
224 # Tracks associated with Photons
225 if TrackThinningKeepPhotonTracks:
226 EGAM8PhotonTPThinningTool = (
227 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
228 name="EGAM8PhotonTPThinningTool",
229 StreamName=streamName,
230 SGKey="Photons",
231 GSFTrackParticlesKey="GSFTrackParticles",
232 InDetTrackParticlesKey="InDetTrackParticles",
233 GSFConversionVerticesKey="GSFConversionVertices",
234 SelectionString="Photons.pt > 0*GeV",
235 BestMatchOnly=True,
236 ConeSize=0.3,
237 )
238 )
239 acc.addPublicTool(EGAM8PhotonTPThinningTool)
240 thinningTools.append(EGAM8PhotonTPThinningTool)
241
242 # Tracks associated with Jets
243 if TrackThinningKeepJetTracks:
244 EGAM8JetTPThinningTool = (
245 CompFactory.DerivationFramework.JetTrackParticleThinning(
246 name="EGAM8JetTPThinningTool",
247 StreamName=streamName,
248 JetKey="AntiKt4EMPFlowJets",
249 InDetTrackParticlesKey="InDetTrackParticles",
250 )
251 )
252 acc.addPublicTool(EGAM8JetTPThinningTool)
253 thinningTools.append(EGAM8JetTPThinningTool)
254
255 # Tracks associated with Muons
256 if TrackThinningKeepMuonTracks:
257 EGAM8MuonTPThinningTool = acc.getPrimaryAndMerge(
258 MuonTrackParticleThinningCfg(
259 flags,
260 name="EGAM8MuonTPThinningTool",
261 StreamName=streamName,
262 MuonKey="Muons",
263 InDetTrackParticlesKey="InDetTrackParticles",
264 )
265 )
266 thinningTools.append(EGAM8MuonTPThinningTool)
267
268 # Tracks associated with Taus
269 if TrackThinningKeepTauTracks:
270 EGAM8TauTPThinningTool = acc.getPrimaryAndMerge(
271 TauTrackParticleThinningCfg(
272 flags,
273 name="EGAM8TauTPThinningTool",
274 StreamName=streamName,
275 TauKey="TauJets",
276 ConeSize=0.6,
277 InDetTrackParticlesKey="InDetTrackParticles",
278 DoTauTracksThinning=True,
279 TauTracksKey="TauTracks",
280 )
281 )
282 thinningTools.append(EGAM8TauTPThinningTool)
283
284 # Tracks from primary vertex
285 thinning_expression = " && ".join(
286 [
287 "(InDetTrackParticles.DFCommonTightPrimary)",
288 "(abs(DFCommonInDetTrackZ0AtPV)*sin(InDetTrackParticles.theta)<3.0*mm)",
289 "(InDetTrackParticles.pt>10*GeV)",
290 ]
291 )
292 if TrackThinningKeepPVTracks:
293 EGAM8TPThinningTool = acc.getPrimaryAndMerge(
294 TrackParticleThinningCfg(
295 flags,
296 name="EGAM8TPThinningTool",
297 StreamName=streamName,
298 SelectionString=thinning_expression,
299 InDetTrackParticlesKey="InDetTrackParticles",
300 )
301 )
302 thinningTools.append(EGAM8TPThinningTool)
303
304 # truth thinning
305 if flags.Input.isMC:
306 # W, Z and Higgs
307 truth_cond_WZH = " && ".join(
308 ["(abs(TruthParticles.pdgId) >= 23)", "(abs(TruthParticles.pdgId) <= 25)"]
309 )
310 # Leptons
311 truth_cond_lep = " && ".join(
312 ["(abs(TruthParticles.pdgId) >= 11)", "(abs(TruthParticles.pdgId) <= 16)"]
313 )
314 # Top quark
315 truth_cond_top = "(abs(TruthParticles.pdgId) == 6)"
316 # Photon
317 truth_cond_gam = " && ".join(
318 ["(TruthParticles.isPhoton)", "(TruthParticles.pt > 1*GeV)"]
319 )
320 # stable particles
321 truth_cond_finalState = " && ".join(
322 ["(TruthParticles.isGenStable)", "(!TruthParticles.isSimulationParticle)"]
323 )
324 truth_expression = (
325 "( "
326 + truth_cond_WZH
327 + " ) || "
328 + "( "
329 + truth_cond_lep
330 + " ) || "
331 + "( "
332 + truth_cond_top
333 + " ) || "
334 + "( "
335 + truth_cond_gam
336 + " ) || "
337 + "( "
338 + truth_cond_finalState
339 + " )"
340 )
341 print("EGAM8 truth thinning expression: ", truth_expression)
342
343 EGAM8TruthThinningTool = CompFactory.DerivationFramework.GenericTruthThinning(
344 name="EGAM8TruthThinningTool",
345 StreamName=streamName,
346 ParticleSelectionString=truth_expression,
347 PreserveDescendants=False,
348 PreserveGeneratorDescendants=True,
349 PreserveAncestors=True,
350 )
351 acc.addPublicTool(EGAM8TruthThinningTool)
352 thinningTools.append(EGAM8TruthThinningTool)
353
354 # skimming
355 skimmingTool = acc.popToolsAndMerge(EGAM8SkimmingToolCfg(flags))
356 acc.addPublicTool(skimmingTool)
357
358 # setup the kernel
359 acc.addEventAlgo(
360 CompFactory.DerivationFramework.DerivationKernel(
361 name,
362 SkimmingTools=[skimmingTool],
363 AugmentationTools=augmentationTools,
364 ThinningTools=thinningTools,
365 )
366 )
367
368 return acc
369
370

◆ EGAM8SkimmingToolCfg()

python.EGAM8.EGAM8SkimmingToolCfg ( flags)
Configure the EGAM8 skimming tool

Definition at line 21 of file EGAM8.py.

21def EGAM8SkimmingToolCfg(flags):
22 """Configure the EGAM8 skimming tool"""
23 acc = ComponentAccumulator()
24
25 expression = " || ".join(
26 [
27 "(count(EGAM8_DiElectronMass >50.0*GeV) >=1)",
28 "(count(EGAM8_MuonElectronMass >50.0*GeV) >=1)",
29 ]
30 )
31 print("EGAM8 skimming expression: ", expression)
32
33 skimmingTool = CompFactory.DerivationFramework.xAODStringSkimmingTool(
34 name="EGAM8SkimmingTool", expression=expression)
35 if flags.Trigger.EDMVersion < 0:
36 skimmingTool.TrigDecisionTool=None
37
38 acc.setPrivateTools(skimmingTool)
39 return acc
40
41

◆ EGAM8ZeeMassToolCfg()

python.EGAM8.EGAM8ZeeMassToolCfg ( flags)
Configure the EGAM8 ee invariant mass augmentation tool

Definition at line 42 of file EGAM8.py.

42def EGAM8ZeeMassToolCfg(flags):
43 """Configure the EGAM8 ee invariant mass augmentation tool"""
44 acc = ComponentAccumulator()
45
46 # ====================================================================
47 # di-electron invariant mass for events passing the Z->ee
48 # selection based on single e trigger, for reco (central) and ID
49 # SF(central+fwd)
50 #
51 # 1 medium e, central, pT>25 GeV
52 # 1 forward e, pT>20 GeV
53 # OS+SS
54 # mee>50 GeV (cut applied in skimming step later)
55 # ====================================================================
56
57 requirement_tag = " && ".join(
58 ["(Electrons.DFCommonElectronsLHMedium)", "(Electrons.pt > 24.5*GeV)"]
59 )
60 requirement_probe = "ForwardElectrons.pt > 19.5*GeV"
61
62 acc.setPrivateTools(
63 CompFactory.DerivationFramework.EGInvariantMassTool(
64 name="EGAM8_ZEEMassTool",
65 Object1Requirements=requirement_tag,
66 Object2Requirements=requirement_probe,
67 StoreGateEntryName="EGAM8_DiElectronMass",
68 Mass1Hypothesis=0.511 * MeV,
69 Mass2Hypothesis=0.511 * MeV,
70 Container1Name="Electrons",
71 Container2Name="ForwardElectrons",
72 CheckCharge=False,
73 DoTransverseMass=False,
74 MinDeltaR=0.0,
75 )
76 )
77
78 return acc
79
80

◆ EGAM8ZmueMassToolCfg()

python.EGAM8.EGAM8ZmueMassToolCfg ( flags)
Configure the EGAM8 mue invariant mass augmentation tool

Definition at line 81 of file EGAM8.py.

81def EGAM8ZmueMassToolCfg(flags):
82 """Configure the EGAM8 mue invariant mass augmentation tool"""
83 acc = ComponentAccumulator()
84
85 # ====================================================================
86 # mue invariant mass for events passing the Z->mue selection based
87 # on single muon trigger, for ID SF(central+fwd) background studies
88 #
89 # 1 medium muon, central, pT>25 GeV
90 # 1 forward e, pT>20 GeV
91 # OS+SS
92 # m(mue)>50 GeV (cut applied in skimming step later)
93 # ====================================================================
94
95 requirement_muon = " && ".join(
96 [
97 "Muons.pt>24.5*GeV",
98 "abs(Muons.eta)<2.7",
99 "Muons.DFCommonMuonPassPreselection",
100 ]
101 )
102 requirement_electron = "ForwardElectrons.pt > 19.5*GeV"
103
104 acc.setPrivateTools(
105 CompFactory.DerivationFramework.EGInvariantMassTool(
106 name="EGAM8_ZMuEMassTool",
107 Object1Requirements=requirement_muon,
108 Object2Requirements=requirement_electron,
109 StoreGateEntryName="EGAM8_MuonElectronMass",
110 Mass1Hypothesis=105 * MeV,
111 Mass2Hypothesis=0.511 * MeV,
112 Container1Name="Muons",
113 Container2Name="ForwardElectrons",
114 CheckCharge=False,
115 DoTransverseMass=False,
116 MinDeltaR=0.0,
117 )
118 )
119
120 return acc
121
122
123# Main algorithm config