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

Functions

 EGAM2SkimmingToolCfg (flags)
 EGAM2JpsieeMassTool1Cfg (flags)
 EGAM2JpsieeMassTool2Cfg (flags)
 EGAM2KernelCfg (flags, name="EGAM2Kernel", **kwargs)
 EGAM2Cfg (flags)

Function Documentation

◆ EGAM2Cfg()

python.EGAM2.EGAM2Cfg ( flags)

Definition at line 345 of file EGAM2.py.

345def EGAM2Cfg(flags):
346 acc = ComponentAccumulator()
347
348 # Get the lists of triggers needed for trigger matching.
349 # This is needed at this scope (for the slimming) and further down
350 # in the config chain for actually configuring the matching, so we create
351 # it here and pass it down
352 # TODO: this should ideally be called higher up to avoid it being run
353 # multiple times in a train.
354 # TODO: restrict it to relevant triggers
355 from DerivationFrameworkPhys.TriggerListsHelper import TriggerListsHelper
356
357 EGAM2TriggerListsHelper = TriggerListsHelper(flags)
358
359 # configure skimming/thinning/augmentation tools
360 acc.merge(
361 EGAM2KernelCfg(
362 flags,
363 name="EGAM2Kernel",
364 StreamName="StreamDAOD_EGAM2",
365 TriggerListsHelper=EGAM2TriggerListsHelper,
366 )
367 )
368
369 # configure slimming
370 from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
371 from xAODMetaDataCnv.InfileMetaDataConfig import SetupMetaDataForStreamCfg
372 from DerivationFrameworkCore.SlimmingHelper import SlimmingHelper
373
374 EGAM2SlimmingHelper = SlimmingHelper(
375 "EGAM2SlimmingHelper",
376 NamesAndTypes=flags.Input.TypedCollections,
377 flags=flags,
378 )
379
380 # ------------------------------------------
381 # containers for which we save all variables
382 # -------------------------------------------
383
384 # baseline
385 EGAM2SlimmingHelper.AllVariables = [
386 "Electrons",
387 "GSFTrackParticles",
388 "egammaClusters",
389 ]
390
391 # for trigger studies we also add:
392 MenuType = ""
393 if flags.Trigger.EDMVersion == 2:
394 MenuType = "Run2"
395 elif flags.Trigger.EDMVersion == 3:
396 MenuType = "Run3"
397
398 if MenuType:
399 EGAM2SlimmingHelper.AllVariables += ExtraContainersTrigger[MenuType]
400 EGAM2SlimmingHelper.AllVariables += ExtraContainersElectronTrigger[MenuType]
401
402 # and on MC we also add:
403 if flags.Input.isMC:
404 EGAM2SlimmingHelper.AllVariables += [
405 "TruthEvents",
406 "TruthParticles",
407 "TruthVertices",
408 "egammaTruthParticles",
409 ]
410
411 # -------------------------------------------
412 # containers that we slim
413 # -------------------------------------------
414
415 # first add variables from smart-slimming
416 # adding only also those for which we add all variables since
417 # the XXXCPContent.py files also bring in some extra variables
418 # for other collections
419 # muons, tau, MET, b-tagging could be switched off if not needed
420 # and use too much space
421 EGAM2SlimmingHelper.SmartCollections = [
422 "Electrons",
423 "Photons",
424 "Muons",
425 "TauJets",
426 "InDetTrackParticles",
427 "PrimaryVertices",
428 "AntiKt4EMPFlowJets",
429 "MET_Baseline_AntiKt4EMPFlow",
430
431 ]
432 if flags.Input.isMC:
433 EGAM2SlimmingHelper.SmartCollections += [
434 "AntiKt4TruthJets",
435 "AntiKt4TruthDressedWZJets",
436 ]
437
438 # then add extra variables:
439
440 # muons
441 EGAM2SlimmingHelper.ExtraVariables += [
442 "Muons.ptcone20.ptcone30.ptcone40.etcone20.etcone30.etcone40"
443 ]
444
445 # conversion vertices
446 EGAM2SlimmingHelper.ExtraVariables += [
447 "GSFConversionVertices.x.y.z.px.py.pz.pt1.pt2.etaAtCalo.phiAtCalo",
448 "GSFConversionVertices.trackParticleLinks",
449 ]
450
451 # primary vertices
452 EGAM2SlimmingHelper.ExtraVariables += ["PrimaryVertices.x.y.sumPt2"]
453
454 # photons: detailed shower shape variables
455 EGAM2SlimmingHelper.ExtraVariables += PhotonsCPDetailedContent
456
457 # photons: gain and cluster energy per layer
458 from DerivationFrameworkCalo.DerivationFrameworkCaloConfig import (
459 getGainDecorations,
460 getClusterEnergyPerLayerDecorations,
461 )
462
463 gainDecorations = getGainDecorations(acc, flags, "EGAM2Kernel")
464 print("EGAM2 gain decorations: ", gainDecorations)
465 EGAM2SlimmingHelper.ExtraVariables.extend(gainDecorations)
466 clusterEnergyDecorations = getClusterEnergyPerLayerDecorations(acc, "EGAM2Kernel")
467 print("EGAM2 cluster energy decorations: ", clusterEnergyDecorations)
468 EGAM2SlimmingHelper.ExtraVariables.extend(clusterEnergyDecorations)
469
470 # energy density
471 EGAM2SlimmingHelper.ExtraVariables += [
472 "TopoClusterIsoCentralEventShape.Density",
473 "TopoClusterIsoForwardEventShape.Density",
474 "NeutralParticleFlowIsoCentralEventShape.Density",
475 "NeutralParticleFlowIsoForwardEventShape.Density",
476 ]
477
478 # truth
479 if flags.Input.isMC:
480 EGAM2SlimmingHelper.ExtraVariables += [
481 "MuonTruthParticles.e.px.py.pz.status.pdgId.truthOrigin.truthType"
482 ]
483
484 EGAM2SlimmingHelper.ExtraVariables += [
485 "Photons.truthOrigin.truthType.truthParticleLink"
486 ]
487
488 # Add event info
489 if flags.Derivation.Egamma.doEventInfoSlimming:
490 EGAM2SlimmingHelper.SmartCollections.append("EventInfo")
491 else:
492 EGAM2SlimmingHelper.AllVariables += ["EventInfo"]
493
494 # Add egamma trigger objects
495 EGAM2SlimmingHelper.IncludeEGammaTriggerContent = True
496
497 # Trigger matching
498 # Run 2
499 if flags.Trigger.EDMVersion == 2:
500 from DerivationFrameworkPhys.TriggerMatchingCommonConfig import AddRun2TriggerMatchingToSlimmingHelper
501 AddRun2TriggerMatchingToSlimmingHelper(SlimmingHelper = EGAM2SlimmingHelper,
502 OutputContainerPrefix = "TrigMatch_",
503 TriggerList = EGAM2TriggerListsHelper.Run2TriggerNamesNoTau)
504
505 # add some single-leg trigger matching info needed for Jpsi triggers
506 # This is scheduling an instance of TriggerMatchingCommonRun2Cfg which is in addition to the ones from PhysCommonAugmentationsCfg
507 # And adding the output branches to the SlimmingHelper in addition
508 from DerivationFrameworkPhys.TriggerMatchingCommonConfig import (
509 TriggerMatchingCommonRun2Cfg
510 )
511 EGAM2TrigMatchList = [
512 "HLT_e5_lhtight_nod0",
513 "HLT_e9_lhtight_nod0",
514 "HLT_e14_lhtight_nod0",
515 ]
516 acc.merge(TriggerMatchingCommonRun2Cfg(
517 flags,
518 name="EGAM2TrigMatch",
519 OutputContainerPrefix="TrigMatch_",
520 ChainNames=EGAM2TrigMatchList)
521 )
522 AddRun2TriggerMatchingToSlimmingHelper(
523 SlimmingHelper=EGAM2SlimmingHelper,
524 OutputContainerPrefix="TrigMatch_",
525 TriggerList=EGAM2TrigMatchList
526 )
527
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(EGAM2SlimmingHelper)
532
533
534 EGAM2ItemList = EGAM2SlimmingHelper.GetItemList()
535 acc.merge(
536 OutputStreamCfg(
537 flags,
538 "DAOD_EGAM2",
539 ItemList=EGAM2ItemList,
540 AcceptAlgs=["EGAM2Kernel"],
541 )
542 )
543 acc.merge(
544 SetupMetaDataForStreamCfg(
545 flags,
546 "DAOD_EGAM2",
547 AcceptAlgs=["EGAM2Kernel"],
548 createMetadata=[
549 MetadataCategory.CutFlowMetaData,
550 MetadataCategory.TruthMetaData,
551 ],
552 )
553 )
554
555 return acc
void print(char *figname, TCanvas *c1)

◆ EGAM2JpsieeMassTool1Cfg()

python.EGAM2.EGAM2JpsieeMassTool1Cfg ( flags)
Configure the EGAM2 ee invariant mass augmentation tool 1

Definition at line 82 of file EGAM2.py.

82def EGAM2JpsieeMassTool1Cfg(flags):
83 """Configure the EGAM2 ee invariant mass augmentation tool 1"""
84 acc = ComponentAccumulator()
85
86 # ====================================================================
87 # 1. di-electron invariant mass for events passing the J/psi->ee
88 # selection for e/gamma calibration
89 #
90 # 2 tight or medium e (depends on Run2 triggers..), pT>4.5 GeV, OS
91 # 1<Mee<5 GeV (applied in skimming step later)
92 # ====================================================================
93 electronPtRequirement = "(Electrons.pt > 4.5*GeV)"
94 electronQualityRequirement = "(Electrons.DFCommonElectronsLHMedium)"
95 requirement_el = (
96 "(" + electronQualityRequirement + "&&" + electronPtRequirement + ")"
97 )
98
99 acc.setPrivateTools(
100 CompFactory.DerivationFramework.EGInvariantMassTool(
101 name="EGAM2_JpsieeMassTool1",
102 Object1Requirements=requirement_el,
103 Object2Requirements=requirement_el,
104 StoreGateEntryName="EGAM2_DiElectronMass1",
105 Mass1Hypothesis=0.511 * MeV,
106 Mass2Hypothesis=0.511 * MeV,
107 Container1Name="Electrons",
108 Container2Name="Electrons",
109 CheckCharge=True,
110 DoTransverseMass=False,
111 MinDeltaR=0.0,
112 )
113 )
114
115 return acc
116
117

◆ EGAM2JpsieeMassTool2Cfg()

python.EGAM2.EGAM2JpsieeMassTool2Cfg ( flags)
Configure the EGAM2 ee invariant mass augmentation tool 2

Definition at line 118 of file EGAM2.py.

118def EGAM2JpsieeMassTool2Cfg(flags):
119 """Configure the EGAM2 ee invariant mass augmentation tool 2"""
120 acc = ComponentAccumulator()
121
122 # ====================================================================
123 # 2. di-electron invariant mass for events passing the J/psi->ee
124 # selection based on Jpsi->e+cluster trigger, for low pT (7-20 GeV)
125 # central photon efficiencies with tag and probe
126 #
127 # Tag: 1 tight e, central, pT>4.5 GeV
128 # Probe: 1 e, central, pT>4.5 GeV
129 # OS+SS
130 # dR>0.15
131 # 1<mee<6 GeV (applied in skimming step later)
132 # ====================================================================
133 requirement_el_tag = " && ".join(
134 ["(Electrons.DFCommonElectronsLHTight)", "(Electrons.pt > 4.5*GeV)"]
135 )
136 requirement_el_probe = "Electrons.pt > 4.5*GeV"
137
138 acc.setPrivateTools(
139 CompFactory.DerivationFramework.EGInvariantMassTool(
140 name="EGAM2_JpsieeMassTool2",
141 Object1Requirements=requirement_el_tag,
142 Object2Requirements=requirement_el_probe,
143 StoreGateEntryName="EGAM2_DiElectronMass2",
144 Mass1Hypothesis=0.511 * MeV,
145 Mass2Hypothesis=0.511 * MeV,
146 Container1Name="Electrons",
147 Container2Name="Electrons",
148 CheckCharge=False,
149 DoTransverseMass=False,
150 MinDeltaR=0.15,
151 )
152 )
153
154 return acc
155
156

◆ EGAM2KernelCfg()

python.EGAM2.EGAM2KernelCfg ( flags,
name = "EGAM2Kernel",
** kwargs )
Configure the derivation framework driving algorithm (kernel)
for EGAM2

Definition at line 157 of file EGAM2.py.

157def EGAM2KernelCfg(flags, name="EGAM2Kernel", **kwargs):
158 """Configure the derivation framework driving algorithm (kernel)
159 for EGAM2"""
160 acc = ComponentAccumulator()
161
162 # Common augmentations
163 from DerivationFrameworkPhys.PhysCommonConfig import PhysCommonAugmentationsCfg
164
165 acc.merge(
166 PhysCommonAugmentationsCfg(
167 flags, TriggerListsHelper=kwargs["TriggerListsHelper"]
168 )
169 )
170
171 # EGAM2 augmentations
172 augmentationTools = []
173
174 # ====================================================================
175 # ee invariant masses
176 # ====================================================================
177 EGAM2JpsieeMassTool1 = acc.popToolsAndMerge(EGAM2JpsieeMassTool1Cfg(flags))
178 acc.addPublicTool(EGAM2JpsieeMassTool1)
179 augmentationTools.append(EGAM2JpsieeMassTool1)
180
181 EGAM2JpsieeMassTool2 = acc.popToolsAndMerge(EGAM2JpsieeMassTool2Cfg(flags))
182 acc.addPublicTool(EGAM2JpsieeMassTool2)
183 augmentationTools.append(EGAM2JpsieeMassTool2)
184
185 # ====================================================================
186 # Gain and cluster energies per layer decoration tool
187 # ====================================================================
188 from DerivationFrameworkCalo.DerivationFrameworkCaloConfig import (
189 CaloDecoratorKernelCfg,
190 )
191
192 acc.merge(CaloDecoratorKernelCfg(flags))
193
194 # thinning tools
195 thinningTools = []
196 streamName = kwargs["StreamName"]
197
198 # Track thinning
199 if flags.Derivation.Egamma.doTrackThinning:
200 from DerivationFrameworkInDet.InDetToolsConfig import (
201 TrackParticleThinningCfg,
202 MuonTrackParticleThinningCfg,
203 TauTrackParticleThinningCfg,
204 )
205
206 TrackThinningKeepElectronTracks = True
207 TrackThinningKeepPhotonTracks = True
208 TrackThinningKeepAllElectronTracks = False
209 TrackThinningKeepJetTracks = False
210 TrackThinningKeepMuonTracks = False
211 TrackThinningKeepTauTracks = False
212 TrackThinningKeepPVTracks = False
213
214 # Tracks associated with Electrons
215 if TrackThinningKeepElectronTracks:
216 EGAM2ElectronTPThinningTool = (
217 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
218 name="EGAM2ElectronTPThinningTool",
219 StreamName=streamName,
220 SGKey="Electrons",
221 GSFTrackParticlesKey="GSFTrackParticles",
222 InDetTrackParticlesKey="InDetTrackParticles",
223 SelectionString="Electrons.pt > 0*GeV",
224 BestMatchOnly=True,
225 ConeSize=0.3,
226 )
227 )
228 acc.addPublicTool(EGAM2ElectronTPThinningTool)
229 thinningTools.append(EGAM2ElectronTPThinningTool)
230
231 # Tracks associated with Electrons (all tracks, large cone, for track
232 # isolation studies of the selected electrons)
233 if TrackThinningKeepAllElectronTracks:
234 EGAM2ElectronTPThinningTool2 = (
235 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
236 name="EGAM2ElectronTPThinningTool2",
237 StreamName=streamName,
238 SGKey="Electrons",
239 GSFTrackParticlesKey="GSFTrackParticles",
240 InDetTrackParticlesKey="InDetTrackParticles",
241 SelectionString="Electrons.pt > 4*GeV",
242 BestMatchOnly=False,
243 ConeSize=0.6,
244 )
245 )
246 acc.addPublicTool(EGAM2ElectronTPThinningTool2)
247 thinningTools.append(EGAM2ElectronTPThinningTool2)
248
249 # Tracks associated with Photons
250 if TrackThinningKeepPhotonTracks:
251 EGAM2PhotonTPThinningTool = (
252 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
253 name="EGAM2PhotonTPThinningTool",
254 StreamName=streamName,
255 SGKey="Photons",
256 GSFTrackParticlesKey="GSFTrackParticles",
257 InDetTrackParticlesKey="InDetTrackParticles",
258 GSFConversionVerticesKey="GSFConversionVertices",
259 SelectionString="Photons.pt > 0*GeV",
260 BestMatchOnly=True,
261 ConeSize=0.3,
262 )
263 )
264 acc.addPublicTool(EGAM2PhotonTPThinningTool)
265 thinningTools.append(EGAM2PhotonTPThinningTool)
266
267 # Tracks associated with Jets
268 if TrackThinningKeepJetTracks:
269 EGAM2JetTPThinningTool = (
270 CompFactory.DerivationFramework.JetTrackParticleThinning(
271 name="EGAM2JetTPThinningTool",
272 StreamName=streamName,
273 JetKey="AntiKt4EMPFlowJets",
274 InDetTrackParticlesKey="InDetTrackParticles",
275 )
276 )
277 acc.addPublicTool(EGAM2JetTPThinningTool)
278 thinningTools.append(EGAM2JetTPThinningTool)
279
280 # Tracks associated with Muons
281 if TrackThinningKeepMuonTracks:
282 EGAM2MuonTPThinningTool = acc.getPrimaryAndMerge(
283 MuonTrackParticleThinningCfg(
284 flags,
285 name="EGAM2MuonTPThinningTool",
286 StreamName=streamName,
287 MuonKey="Muons",
288 InDetTrackParticlesKey="InDetTrackParticles",
289 )
290 )
291 thinningTools.append(EGAM2MuonTPThinningTool)
292
293 # Tracks associated with Taus
294 if TrackThinningKeepTauTracks:
295 EGAM2TauTPThinningTool = acc.getPrimaryAndMerge(
296 TauTrackParticleThinningCfg(
297 flags,
298 name="EGAM2TauTPThinningTool",
299 StreamName=streamName,
300 TauKey="TauJets",
301 ConeSize=0.6,
302 InDetTrackParticlesKey="InDetTrackParticles",
303 DoTauTracksThinning=True,
304 TauTracksKey="TauTracks",
305 )
306 )
307 thinningTools.append(EGAM2TauTPThinningTool)
308
309 # Tracks from primary vertex
310 thinning_expression = " && ".join(
311 [
312 "(InDetTrackParticles.DFCommonTightPrimary)",
313 "(abs(DFCommonInDetTrackZ0AtPV)*sin(InDetTrackParticles.theta)<3*mm)",
314 "(InDetTrackParticles.pt > 10*GeV)",
315 ]
316 )
317 if TrackThinningKeepPVTracks:
318 EGAM2TPThinningTool = acc.getPrimaryAndMerge(
319 TrackParticleThinningCfg(
320 flags,
321 name="EGAM2TPThinningTool",
322 StreamName=streamName,
323 SelectionString=thinning_expression,
324 InDetTrackParticlesKey="InDetTrackParticles",
325 )
326 )
327 thinningTools.append(EGAM2TPThinningTool)
328
329 # skimming
330 skimmingTool = acc.getPrimaryAndMerge(EGAM2SkimmingToolCfg(flags))
331
332 # setup the kernel
333 acc.addEventAlgo(
334 CompFactory.DerivationFramework.DerivationKernel(
335 name,
336 SkimmingTools=[skimmingTool],
337 AugmentationTools=augmentationTools,
338 ThinningTools=thinningTools,
339 )
340 )
341
342 return acc
343
344

◆ EGAM2SkimmingToolCfg()

python.EGAM2.EGAM2SkimmingToolCfg ( flags)
Configure the EGAM2 skimming tool

Definition at line 26 of file EGAM2.py.

26def EGAM2SkimmingToolCfg(flags):
27 """Configure the EGAM2 skimming tool"""
28 acc = ComponentAccumulator()
29
30 skimmingTools = []
31
32 # off-line based selection
33 expression_calib = (
34 "(count(EGAM2_DiElectronMass1 > 1.0*GeV && "
35 + "EGAM2_DiElectronMass1 < 5.0*GeV)>=1)"
36 )
37 expression_TP = (
38 "(count(EGAM2_DiElectronMass2 > 1.0*GeV && "
39 + "EGAM2_DiElectronMass2 < 6.0*GeV)>=1)"
40 )
41 expression = expression_calib + " || " + expression_TP
42 print("EGAM2 offline skimming expression: ", expression)
43
44 EGAM2_OfflineSkimmingTool = CompFactory.DerivationFramework.xAODStringSkimmingTool(
45 name="EGAM2_OfflineSkimmingTool", expression=expression
46 )
47 if flags.Trigger.EDMVersion < 0:
48 EGAM2_OfflineSkimmingTool.TrigDecisionTool = None
49
50 acc.addPublicTool(EGAM2_OfflineSkimmingTool)
51 skimmingTools += [EGAM2_OfflineSkimmingTool]
52
53 # trigger-based selection
54 MenuType = ""
55 if flags.Trigger.EDMVersion == 2:
56 MenuType = "Run2"
57 elif flags.Trigger.EDMVersion == 3:
58 MenuType = "Run3"
59
60 if MenuType:
61 triggers = JPsiTriggers[MenuType]
62 print("EGAM2 trigger skimming list (OR): ", triggers)
63
64 EGAM2_TriggerSkimmingTool = CompFactory.DerivationFramework.TriggerSkimmingTool(
65 name="EGAM2_TriggerSkimmingTool", TriggerListOR=triggers
66 )
67 acc.addPublicTool(EGAM2_TriggerSkimmingTool)
68 skimmingTools += [EGAM2_TriggerSkimmingTool]
69
70 # do the OR of trigger-based and offline-based selection
71 print("EGAM2 skimming is logical OR of previous selections")
72 EGAM2_SkimmingTool = CompFactory.DerivationFramework.FilterCombinationOR(
73 name="EGAM2_SkimmingTool",
74 FilterList=skimmingTools,
75 )
76
77 acc.addPublicTool(EGAM2_SkimmingTool, primary=True)
78
79 return acc
80
81