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 342 of file EGAM2.py.

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

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

◆ EGAM2JpsieeMassTool2Cfg()

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

Definition at line 115 of file EGAM2.py.

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

◆ EGAM2KernelCfg()

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

Definition at line 154 of file EGAM2.py.

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

◆ 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 from DerivationFrameworkTools.DerivationFrameworkToolsConfig import (
45 xAODStringSkimmingToolCfg)
46 EGAM2_OfflineSkimmingTool = acc.getPrimaryAndMerge(xAODStringSkimmingToolCfg(
47 flags, name = "EGAM2_OfflineSkimmingTool", expression = expression))
48 skimmingTools += [EGAM2_OfflineSkimmingTool]
49
50 # trigger-based selection
51 MenuType = ""
52 if flags.Trigger.EDMVersion == 2:
53 MenuType = "Run2"
54 elif flags.Trigger.EDMVersion == 3:
55 MenuType = "Run3"
56
57 if MenuType:
58 triggers = JPsiTriggers[MenuType]
59 print("EGAM2 trigger skimming list (OR): ", triggers)
60
61 EGAM2_TriggerSkimmingTool = CompFactory.DerivationFramework.TriggerSkimmingTool(
62 name="EGAM2_TriggerSkimmingTool", TriggerListOR=triggers
63 )
64 acc.addPublicTool(EGAM2_TriggerSkimmingTool)
65 skimmingTools += [EGAM2_TriggerSkimmingTool]
66
67 # do the OR of trigger-based and offline-based selection
68 print("EGAM2 skimming is logical OR of previous selections")
69 EGAM2_SkimmingTool = CompFactory.DerivationFramework.FilterCombinationOR(
70 name="EGAM2_SkimmingTool",
71 FilterList=skimmingTools,
72 )
73
74 acc.addPublicTool(EGAM2_SkimmingTool, primary=True)
75
76 return acc
77
78