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 366 of file EGAM8.py.

366def EGAM8Cfg(flags):
367 acc = ComponentAccumulator()
368
369 # Get the lists of triggers needed for trigger matching.
370 # This is needed at this scope (for the slimming) and further down
371 # in the config chain for actually configuring the matching, so we create
372 # it here and pass it down
373 # TODO: this should ideally be called higher up to avoid it being run
374 # multiple times in a train
375
376 from DerivationFrameworkPhys.TriggerListsHelper import TriggerListsHelper
377
378 EGAM8TriggerListsHelper = TriggerListsHelper(flags)
379
380 # configure skimming/thinning/augmentation tools
381 acc.merge(
382 EGAM8KernelCfg(
383 flags,
384 name="EGAM8Kernel",
385 StreamName="StreamDAOD_EGAM8",
386 TriggerListsHelper=EGAM8TriggerListsHelper,
387 )
388 )
389
390 # configure slimming
391 from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
392 from xAODMetaDataCnv.InfileMetaDataConfig import SetupMetaDataForStreamCfg
393 from DerivationFrameworkCore.SlimmingHelper import SlimmingHelper
394
395 EGAM8SlimmingHelper = SlimmingHelper(
396 "EGAM8SlimmingHelper",
397 NamesAndTypes=flags.Input.TypedCollections,
398 flags=flags,
399 )
400
401 # ------------------------------------------
402 # containers for which we save all variables
403 # -------------------------------------------
404
405 # baseline
406 EGAM8SlimmingHelper.AllVariables = [
407 "Electrons",
408 "ForwardElectrons",
409 "GSFTrackParticles",
410 "egammaClusters",
411 "ForwardElectronClusters",
412 ]
413
414 # for trigger studies we also add:
415 # EGAM8SlimmingHelper.AllVariables += [ ]
416
417 # and on MC we also add:
418 if flags.Input.isMC:
419 EGAM8SlimmingHelper.AllVariables += [
420 "TruthEvents",
421 "TruthParticles",
422 "TruthVertices",
423 "egammaTruthParticles",
424 ]
425
426 # -------------------------------------------
427 # containers that we slim
428 # -------------------------------------------
429
430 # first add variables from smart-slimming
431 # adding only also those for which we add all variables since
432 # the XXXCPContent.py files also bring in some extra variables
433 # for other collections
434 EGAM8SlimmingHelper.SmartCollections = [
435 "Electrons",
436 "Photons",
437 "Muons",
438 "TauJets",
439 "PrimaryVertices",
440 "InDetTrackParticles",
441 "AntiKt4EMPFlowJets",
442
443 "MET_Baseline_AntiKt4EMPFlow",
444 ]
445 if flags.Input.isMC:
446 EGAM8SlimmingHelper.SmartCollections += [
447 "AntiKt4TruthJets",
448 "AntiKt4TruthDressedWZJets",
449 ]
450
451 # then add extra variables:
452
453 # muons
454 EGAM8SlimmingHelper.ExtraVariables += [
455 "Muons.ptcone20.ptcone30.ptcone40.etcone20.etcone30.etcone40"
456 ]
457
458 # conversion vertices
459 EGAM8SlimmingHelper.ExtraVariables += [
460 "GSFConversionVertices.x.y.z.px.py.pz.pt1.pt2.etaAtCalo.phiAtCalo",
461 "GSFConversionVertices.trackParticleLinks",
462 ]
463
464 # primary vertices
465 EGAM8SlimmingHelper.ExtraVariables += ["PrimaryVertices.x.y.sumPt2"]
466
467 # track jets
468 EGAM8SlimmingHelper.ExtraVariables += [
469 "AntiKt4PV0TrackJets.pt.eta.phi.e.m.btaggingLink.constituentLinks"
470 ]
471
472 # energy density
473 EGAM8SlimmingHelper.ExtraVariables += [
474 "TopoClusterIsoCentralEventShape.Density",
475 "TopoClusterIsoForwardEventShape.Density",
476 "NeutralParticleFlowIsoCentralEventShape.Density",
477 "NeutralParticleFlowIsoForwardEventShape.Density",
478 ]
479
480 # photons: detailed shower shape variables
481 EGAM8SlimmingHelper.ExtraVariables += PhotonsCPDetailedContent
482
483 # photons: gain and cluster energy per layer
484 from DerivationFrameworkCalo.DerivationFrameworkCaloConfig import (
485 getGainDecorations,
486 getClusterEnergyPerLayerDecorations,
487 )
488
489 gainDecorations = getGainDecorations(acc, flags, "EGAM8Kernel")
490 print("EGAM8 gain decorations: ", gainDecorations)
491 EGAM8SlimmingHelper.ExtraVariables.extend(gainDecorations)
492 clusterEnergyDecorations = getClusterEnergyPerLayerDecorations(acc, "EGAM8Kernel")
493 print("EGAM8 cluster energy decorations: ", clusterEnergyDecorations)
494 EGAM8SlimmingHelper.ExtraVariables.extend(clusterEnergyDecorations)
495
496 # truth
497 if flags.Input.isMC:
498 EGAM8SlimmingHelper.ExtraVariables += [
499 "MuonTruthParticles.e.px.py.pz.status.pdgId.truthOrigin.truthType"
500 ]
501
502 EGAM8SlimmingHelper.ExtraVariables += [
503 "Photons.truthOrigin.truthType.truthParticleLink"
504 ]
505
506 # Add event info
507 if flags.Derivation.Egamma.doEventInfoSlimming:
508 EGAM8SlimmingHelper.SmartCollections.append("EventInfo")
509 else:
510 EGAM8SlimmingHelper.AllVariables += ["EventInfo"]
511
512 # Add egamma trigger objects
513 EGAM8SlimmingHelper.IncludeEGammaTriggerContent = True
514 EGAM8SlimmingHelper.IncludeMuonTriggerContent = True
515
516 # Trigger matching
517 # Run 2
518 if flags.Trigger.EDMVersion == 2:
519 from DerivationFrameworkPhys.TriggerMatchingCommonConfig import AddRun2TriggerMatchingToSlimmingHelper
520 AddRun2TriggerMatchingToSlimmingHelper(SlimmingHelper = EGAM8SlimmingHelper,
521 OutputContainerPrefix = "TrigMatch_",
522 TriggerList = EGAM8TriggerListsHelper.Run2TriggerNamesNoTau)
523 # Run 3, or Run 2 with navigation conversion
524 if flags.Trigger.EDMVersion == 3 or (flags.Trigger.EDMVersion == 2 and flags.Trigger.doEDMVersionConversion):
525 from TrigNavSlimmingMT.TrigNavSlimmingMTConfig import AddRun3TrigNavSlimmingCollectionsToSlimmingHelper
526 AddRun3TrigNavSlimmingCollectionsToSlimmingHelper(EGAM8SlimmingHelper)
527
528 # Add full CellContainer
529 EGAM8SlimmingHelper.StaticContent = [
530 "CaloCellContainer#AllCalo",
531 "CaloClusterCellLinkContainer#egammaClusters_links",
532 "CaloClusterCellLinkContainer#ForwardElectronClusters_links",
533 "xAOD::CaloClusterContainer#ForwardElectronCookieCutClusters",
534 "xAOD::CaloClusterAuxContainer#ForwardElectronCookieCutClustersAux.",
535 ]
536
537 EGAM8ItemList = EGAM8SlimmingHelper.GetItemList()
538 acc.merge(
539 OutputStreamCfg(
540 flags,
541 "DAOD_EGAM8",
542 ItemList=EGAM8ItemList,
543 AcceptAlgs=["EGAM8Kernel"],
544 )
545 )
546 acc.merge(
547 SetupMetaDataForStreamCfg(
548 flags,
549 "DAOD_EGAM8",
550 AcceptAlgs=["EGAM8Kernel"],
551 createMetadata=[
552 MetadataCategory.CutFlowMetaData,
553 MetadataCategory.TruthMetaData,
554 ],
555 )
556 )
557
558 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 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(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 = " && ".join(
304 ["(abs(TruthParticles.pdgId) >= 23)", "(abs(TruthParticles.pdgId) <= 25)"]
305 )
306 # Leptons
307 truth_cond_lep = " && ".join(
308 ["(abs(TruthParticles.pdgId) >= 11)", "(abs(TruthParticles.pdgId) <= 16)"]
309 )
310 # Top quark
311 truth_cond_top = "(abs(TruthParticles.pdgId) == 6)"
312 # Photon
313 truth_cond_gam = " && ".join(
314 ["(TruthParticles.isPhoton)", "(TruthParticles.pt > 1*GeV)"]
315 )
316 # stable particles
317 truth_cond_finalState = " && ".join(
318 ["(TruthParticles.isGenStable)", "(!TruthParticles.isSimulationParticle)"]
319 )
320 truth_expression = (
321 "( "
322 + truth_cond_WZH
323 + " ) || "
324 + "( "
325 + truth_cond_lep
326 + " ) || "
327 + "( "
328 + truth_cond_top
329 + " ) || "
330 + "( "
331 + truth_cond_gam
332 + " ) || "
333 + "( "
334 + truth_cond_finalState
335 + " )"
336 )
337 print("EGAM8 truth thinning expression: ", truth_expression)
338
339 EGAM8TruthThinningTool = CompFactory.DerivationFramework.GenericTruthThinning(
340 name="EGAM8TruthThinningTool",
341 StreamName=streamName,
342 ParticleSelectionString=truth_expression,
343 PreserveDescendants=False,
344 PreserveGeneratorDescendants=True,
345 PreserveAncestors=True,
346 )
347 acc.addPublicTool(EGAM8TruthThinningTool)
348 thinningTools.append(EGAM8TruthThinningTool)
349
350 # skimming
351 skimmingTool = acc.popToolsAndMerge(EGAM8SkimmingToolCfg(flags))
352
353 # setup the kernel
354 acc.addEventAlgo(
355 CompFactory.DerivationFramework.DerivationKernel(
356 name,
357 SkimmingTools=[skimmingTool],
358 AugmentationTools=augmentationTools,
359 ThinningTools=thinningTools,
360 )
361 )
362
363 return acc
364
365

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

python.EGAM8.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()

python.EGAM8.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