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()

EGAM8Cfg ( flags)

Definition at line 362 of file EGAM8.py.

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

◆ EGAM8KernelCfg()

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

Definition at line 120 of file EGAM8.py.

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

◆ EGAM8SkimmingToolCfg()

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
24 expression = " || ".join(
25 [
26 "(count(EGAM8_DiElectronMass >50.0*GeV) >=1)",
27 "(count(EGAM8_MuonElectronMass >50.0*GeV) >=1)",
28 ]
29 )
30 print("EGAM8 skimming expression: ", expression)
31
32 from DerivationFrameworkTools.DerivationFrameworkToolsConfig import (
33 xAODStringSkimmingToolCfg)
34 return xAODStringSkimmingToolCfg(flags, name = "EGAM8SkimmingTool",
35 expression = expression)
36
37

◆ EGAM8ZeeMassToolCfg()

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

Definition at line 38 of file EGAM8.py.

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

◆ EGAM8ZmueMassToolCfg()

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

Definition at line 77 of file EGAM8.py.

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