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

Functions

 EGAM5SkimmingToolCfg (flags)
 EGAM5enuTransverseMassToolCfg (flags)
 EGAM5KernelCfg (flags, name="EGAM5Kernel", **kwargs)
 EGAM5Cfg (flags)

Function Documentation

◆ EGAM5Cfg()

python.EGAM5.EGAM5Cfg ( flags)

Definition at line 316 of file EGAM5.py.

316def EGAM5Cfg(flags):
317 acc = ComponentAccumulator()
318
319 # Get the lists of triggers needed for trigger matching.
320 # This is needed at this scope (for the slimming) and further down
321 # in the config chain for actually configuring the matching, so we create
322 # it here and pass it down
323 # TODO: this should ideally be called higher up to avoid it being run
324 # multiple times in a train.
325 # DODO: restrict it to relevant triggers
326 from DerivationFrameworkPhys.TriggerListsHelper import TriggerListsHelper
327
328 EGAM5TriggerListsHelper = TriggerListsHelper(flags)
329
330 # configure skimming/thinning/augmentation tools
331 acc.merge(
332 EGAM5KernelCfg(
333 flags,
334 name="EGAM5Kernel",
335 StreamName="StreamDAOD_EGAM5",
336 TriggerListsHelper=EGAM5TriggerListsHelper,
337 )
338 )
339
340 # configure slimming
341 from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
342 from xAODMetaDataCnv.InfileMetaDataConfig import SetupMetaDataForStreamCfg
343 from DerivationFrameworkCore.SlimmingHelper import SlimmingHelper
344
345 EGAM5SlimmingHelper = SlimmingHelper(
346 "EGAM5SlimmingHelper",
347 NamesAndTypes=flags.Input.TypedCollections,
348 flags=flags,
349 )
350
351 # ------------------------------------------
352 # containers for which we save all variables
353 # -------------------------------------------
354
355 # baseline
356 EGAM5SlimmingHelper.AllVariables = [
357 "Electrons",
358 "GSFTrackParticles",
359 "egammaClusters",
360 ]
361
362 # for trigger studies we also add:
363 MenuType = ""
364 if flags.Trigger.EDMVersion == 2:
365 MenuType = "Run2"
366 elif flags.Trigger.EDMVersion == 3:
367 MenuType = "Run3"
368
369 if MenuType:
370 EGAM5SlimmingHelper.AllVariables += ExtraContainersTrigger[MenuType]
371 EGAM5SlimmingHelper.AllVariables += ExtraContainersElectronTrigger[MenuType]
372 if not flags.Input.isMC:
373 EGAM5SlimmingHelper.AllVariables += ExtraContainersTriggerDataOnly[MenuType]
374
375 # and on MC we also add:
376 if flags.Input.isMC:
377 EGAM5SlimmingHelper.AllVariables += [
378 "TruthEvents",
379 "TruthParticles",
380 "TruthVertices",
381 "egammaTruthParticles",
382 ]
383
384 # -------------------------------------------
385 # containers that we slim
386 # -------------------------------------------
387
388 # first add variables from smart-slimming
389 # adding only also those for which we add all variables since
390 # the XXXCPContent.py files also bring in some extra variables
391 # for other collections
392 EGAM5SlimmingHelper.SmartCollections = [
393 "Electrons",
394 "Photons",
395 "Muons",
396 "TauJets",
397 "InDetTrackParticles",
398 "PrimaryVertices",
399 "AntiKt4EMPFlowJets",
400 "MET_Baseline_AntiKt4EMPFlow",
401
402 ]
403 # muons, tau, MET, b-tagging could be switched off if not needed
404 # and use too much space
405 if flags.Input.isMC:
406 EGAM5SlimmingHelper.SmartCollections += [
407 "AntiKt4TruthJets",
408 "AntiKt4TruthDressedWZJets",
409 ]
410
411 # then add extra variables:
412
413 # muons
414 EGAM5SlimmingHelper.ExtraVariables += [
415 "Muons.ptcone20.ptcone30.ptcone40.etcone20.etcone30.etcone40"
416 ]
417
418 # conversion vertices
419 EGAM5SlimmingHelper.ExtraVariables += [
420 "GSFConversionVertices.x.y.z.px.py.pz.pt1.pt2.etaAtCalo.phiAtCalo",
421 "GSFConversionVertices.trackParticleLinks",
422 ]
423
424 # primary vertices
425 EGAM5SlimmingHelper.ExtraVariables += ["PrimaryVertices.x.y.sumPt2"]
426
427 # photons: detailed shower shape variables
428 EGAM5SlimmingHelper.ExtraVariables += PhotonsCPDetailedContent
429
430 # photons and electrons: gain and cluster energy per layer
431 from DerivationFrameworkCalo.DerivationFrameworkCaloConfig import (
432 getGainDecorations,
433 getClusterEnergyPerLayerDecorations,
434 )
435
436 gainDecorations = getGainDecorations(acc, flags, "EGAM5Kernel")
437 print("EGAM5 gain decorations: ", gainDecorations)
438 EGAM5SlimmingHelper.ExtraVariables.extend(gainDecorations)
439 clusterEnergyDecorations = getClusterEnergyPerLayerDecorations(acc, "EGAM5Kernel")
440 print("EGAM5 cluster energy decorations: ", clusterEnergyDecorations)
441 EGAM5SlimmingHelper.ExtraVariables.extend(clusterEnergyDecorations)
442
443 # energy density
444 EGAM5SlimmingHelper.ExtraVariables += [
445 "TopoClusterIsoCentralEventShape.Density",
446 "TopoClusterIsoForwardEventShape.Density",
447 "NeutralParticleFlowIsoCentralEventShape.Density",
448 "NeutralParticleFlowIsoForwardEventShape.Density",
449 ]
450
451 # truth
452 if flags.Input.isMC:
453 EGAM5SlimmingHelper.ExtraVariables += [
454 "MuonTruthParticles.e.px.py.pz.status.pdgId.truthOrigin.truthType"
455 ]
456
457 EGAM5SlimmingHelper.ExtraVariables += [
458 "Photons.truthOrigin.truthType.truthParticleLink"
459 ]
460
461 # Add event info
462 if flags.Derivation.Egamma.doEventInfoSlimming:
463 EGAM5SlimmingHelper.SmartCollections.append("EventInfo")
464 else:
465 EGAM5SlimmingHelper.AllVariables += ["EventInfo"]
466
467 # Add egamma trigger objects
468 EGAM5SlimmingHelper.IncludeEGammaTriggerContent = True
469
470 # Trigger matching
471 # Run 2
472 if flags.Trigger.EDMVersion == 2:
473 from DerivationFrameworkPhys.TriggerMatchingCommonConfig import AddRun2TriggerMatchingToSlimmingHelper
474 AddRun2TriggerMatchingToSlimmingHelper(SlimmingHelper = EGAM5SlimmingHelper,
475 OutputContainerPrefix = "TrigMatch_",
476 TriggerList = EGAM5TriggerListsHelper.Run2TriggerNamesNoTau)
477 # Run 3, or Run 2 with navigation conversion
478 if flags.Trigger.EDMVersion == 3 or (flags.Trigger.EDMVersion == 2 and flags.Trigger.doEDMVersionConversion):
479 from TrigNavSlimmingMT.TrigNavSlimmingMTConfig import AddRun3TrigNavSlimmingCollectionsToSlimmingHelper
480 AddRun3TrigNavSlimmingCollectionsToSlimmingHelper(EGAM5SlimmingHelper)
481
482 EGAM5ItemList = EGAM5SlimmingHelper.GetItemList()
483 acc.merge(
484 OutputStreamCfg(
485 flags,
486 "DAOD_EGAM5",
487 ItemList=EGAM5ItemList,
488 AcceptAlgs=["EGAM5Kernel"],
489 )
490 )
491 acc.merge(
492 SetupMetaDataForStreamCfg(
493 flags,
494 "DAOD_EGAM5",
495 AcceptAlgs=["EGAM5Kernel"],
496 createMetadata=[
497 MetadataCategory.CutFlowMetaData,
498 MetadataCategory.TruthMetaData,
499 ],
500 )
501 )
502
503 return acc
void print(char *figname, TCanvas *c1)

◆ EGAM5enuTransverseMassToolCfg()

python.EGAM5.EGAM5enuTransverseMassToolCfg ( flags)
Configure the EGAM5 enu transverse mass augmentation tool

Definition at line 102 of file EGAM5.py.

102def EGAM5enuTransverseMassToolCfg(flags):
103 """Configure the EGAM5 enu transverse mass augmentation tool"""
104 acc = ComponentAccumulator()
105
106 # ====================================================================
107 # enu transverse mass
108 #
109 # 1 tight electron with pT>25 GeV + MET > 25 GeV
110 # ====================================================================
111 electronPtRequirement = "(Electrons.pt > 24.5*GeV)"
112 electronQualityRequirement = "(Electrons.DFCommonElectronsLHTight)"
113 requirement_el = (
114 "(" + electronQualityRequirement + "&&" + electronPtRequirement + ")"
115 )
116
117 acc.setPrivateTools(
118 CompFactory.DerivationFramework.EGTransverseMassTool(
119 name="EGAM5_enuTransverseMassTool",
120 ObjectRequirements=requirement_el,
121 METmin=25 * GeV,
122 StoreGateEntryName="EGAM5_ENuTransverseMass",
123 ObjectMassHypothesis=0.511 * MeV,
124 ObjectContainerName="Electrons",
125 METContainerName="MET_Core_AntiKt4EMPFlow",
126 )
127 )
128
129 return acc
130
131

◆ EGAM5KernelCfg()

python.EGAM5.EGAM5KernelCfg ( flags,
name = "EGAM5Kernel",
** kwargs )
Configure the derivation framework driving algorithm (kernel)
for EGAM5

Definition at line 132 of file EGAM5.py.

132def EGAM5KernelCfg(flags, name="EGAM5Kernel", **kwargs):
133 """Configure the derivation framework driving algorithm (kernel)
134 for EGAM5"""
135 acc = ComponentAccumulator()
136
137 # Common augmentations
138 from DerivationFrameworkPhys.PhysCommonConfig import PhysCommonAugmentationsCfg
139
140 acc.merge(
141 PhysCommonAugmentationsCfg(
142 flags, TriggerListsHelper=kwargs["TriggerListsHelper"]
143 )
144 )
145
146 # EGAM5 augmentations
147 augmentationTools = []
148
149 # ====================================================================
150 # enu transverse mass
151 # ====================================================================
152 EGAM5enuTransverseMassTool = acc.popToolsAndMerge(
153 EGAM5enuTransverseMassToolCfg(flags)
154 )
155 acc.addPublicTool(EGAM5enuTransverseMassTool)
156 augmentationTools.append(EGAM5enuTransverseMassTool)
157
158 # ====================================================================
159 # Common calo decoration tools
160 # ====================================================================
161 from DerivationFrameworkCalo.DerivationFrameworkCaloConfig import (
162 CaloDecoratorKernelCfg)
163 acc.merge(CaloDecoratorKernelCfg(flags))
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 = False
182 TrackThinningKeepTauTracks = False
183 TrackThinningKeepPVTracks = True
184
185 # Tracks associated with Electrons
186 if TrackThinningKeepElectronTracks:
187 EGAM5ElectronTPThinningTool = (
188 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
189 name="EGAM5ElectronTPThinningTool",
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(EGAM5ElectronTPThinningTool)
200 thinningTools.append(EGAM5ElectronTPThinningTool)
201
202 # Tracks associated with Electrons (all tracks, large cone, for track
203 # isolation studies of the selected electrons)
204 if TrackThinningKeepAllElectronTracks:
205 EGAM5ElectronTPThinningTool2 = (
206 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
207 name="EGAM5ElectronTPThinningTool2",
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(EGAM5ElectronTPThinningTool2)
218 thinningTools.append(EGAM5ElectronTPThinningTool2)
219
220 # Tracks associated with Photons
221 if TrackThinningKeepPhotonTracks:
222 EGAM5PhotonTPThinningTool = (
223 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
224 name="EGAM5PhotonTPThinningTool",
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(EGAM5PhotonTPThinningTool)
236 thinningTools.append(EGAM5PhotonTPThinningTool)
237
238 # Tracks associated with Jets
239 if TrackThinningKeepJetTracks:
240 EGAM5JetTPThinningTool = (
241 CompFactory.DerivationFramework.JetTrackParticleThinning(
242 name="EGAM5JetTPThinningTool",
243 StreamName=streamName,
244 JetKey="AntiKt4EMPFlowJets",
245 InDetTrackParticlesKey="InDetTrackParticles",
246 )
247 )
248 acc.addPublicTool(EGAM5JetTPThinningTool)
249 thinningTools.append(EGAM5JetTPThinningTool)
250
251 # Tracks associated with Muons
252 if TrackThinningKeepMuonTracks:
253 EGAM5MuonTPThinningTool = acc.getPrimaryAndMerge(
254 MuonTrackParticleThinningCfg(
255 flags,
256 name="EGAM5MuonTPThinningTool",
257 StreamName=streamName,
258 MuonKey="Muons",
259 InDetTrackParticlesKey="InDetTrackParticles",
260 )
261 )
262 thinningTools.append(EGAM5MuonTPThinningTool)
263
264 # Tracks associated with Taus
265 if TrackThinningKeepTauTracks:
266 EGAM5TauTPThinningTool = acc.getPrimaryAndMerge(
267 TauTrackParticleThinningCfg(
268 flags,
269 name="EGAM5TauTPThinningTool",
270 StreamName=streamName,
271 TauKey="TauJets",
272 ConeSize=0.6,
273 InDetTrackParticlesKey="InDetTrackParticles",
274 DoTauTracksThinning=True,
275 TauTracksKey="TauTracks",
276 )
277 )
278 thinningTools.append(EGAM5TauTPThinningTool)
279
280 # Tracks from primary vertex
281 thinning_expression = " && ".join(
282 [
283 "(InDetTrackParticles.DFCommonTightPrimary)",
284 "(abs(DFCommonInDetTrackZ0AtPV)*sin(InDetTrackParticles.theta)<3*mm)",
285 "(InDetTrackParticles.pt>10*GeV)",
286 ]
287 )
288 if TrackThinningKeepPVTracks:
289 EGAM5TPThinningTool = acc.getPrimaryAndMerge(
290 TrackParticleThinningCfg(
291 flags,
292 name="EGAM5TPThinningTool",
293 StreamName=streamName,
294 SelectionString=thinning_expression,
295 InDetTrackParticlesKey="InDetTrackParticles",
296 )
297 )
298 thinningTools.append(EGAM5TPThinningTool)
299
300 # skimming
301 skimmingTool = acc.getPrimaryAndMerge(EGAM5SkimmingToolCfg(flags))
302
303 # setup the kernel
304 acc.addEventAlgo(
305 CompFactory.DerivationFramework.DerivationKernel(
306 name,
307 SkimmingTools=[skimmingTool],
308 AugmentationTools=augmentationTools,
309 ThinningTools=thinningTools,
310 )
311 )
312
313 return acc
314
315

◆ EGAM5SkimmingToolCfg()

python.EGAM5.EGAM5SkimmingToolCfg ( flags)
Configure the EGAM5 skimming tool

Definition at line 27 of file EGAM5.py.

27def EGAM5SkimmingToolCfg(flags):
28 """Configure the EGAM5 skimming tool"""
29 acc = ComponentAccumulator()
30
31 skimmingTools = []
32
33 # 1st selection: trigger-based (WTP triggers)
34 MenuType = ""
35 if flags.Trigger.EDMVersion == 2:
36 MenuType = "Run2"
37 elif flags.Trigger.EDMVersion == 3:
38 MenuType = "Run3"
39
40 if MenuType:
41 triggers = WTnPTriggers[MenuType]
42 print("EGAM5 trigger skimming list (OR): ", triggers)
43
44 EGAM5_TriggerSkimmingTool = CompFactory.DerivationFramework.TriggerSkimmingTool(
45 name="EGAM5_TriggerSkimmingTool", TriggerListOR=triggers
46 )
47
48 acc.addPublicTool(EGAM5_TriggerSkimmingTool)
49 skimmingTools += [EGAM5_TriggerSkimmingTool]
50
51 # 2nd selection: off-line, based on mT(enu)
52 expression2 = "count(EGAM5_ENuTransverseMass > 40*GeV)>=1"
53 print("EGAM5 offline skimming expression: ", expression2)
54 EGAM5_OfflineSkimmingTool = CompFactory.DerivationFramework.xAODStringSkimmingTool(
55 name="EGAM5_OfflineSkimmingTool", expression=expression2
56 )
57 if flags.Trigger.EDMVersion < 0:
58 EGAM5_OfflineSkimmingTool.TrigDecisionTool=None
59
60 acc.addPublicTool(EGAM5_OfflineSkimmingTool)
61 skimmingTools += [EGAM5_OfflineSkimmingTool]
62
63 # 3rd selection: mix of off-line and on-line criteria
64 if flags.Trigger.EDMVersion >=0:
65 expression3a = " || ".join(
66 [
67 "HLT_e60_lhloose_xe60noL1",
68 "HLT_e120_lhloose",
69 "HLT_j80_xe80",
70 "HLT_xe70",
71 "HLT_xe80_tc_lcw_L1XE50",
72 "HLT_xe90_mht_L1XE50",
73 "HLT_xe90_tc_lcw_wEFMu_L1XE50",
74 "HLT_xe90_mht_wEFMu_L1XE50",
75 ]
76 )
77 expression3b = "count(Electrons.pt > 14.5*GeV) >= 1"
78 expression3 = "( " + expression3a + " ) && ( " + expression3b + " )"
79 print("EGAM5 mixed offline-online skimming expression: ", expression3)
80
81 EGAM5_OnlineOfflineSkimmingTool = (
82 CompFactory.DerivationFramework.xAODStringSkimmingTool(
83 name="EGAM5_OnlineOfflineSkimmingTool", expression=expression3
84 )
85 )
86
87 acc.addPublicTool(EGAM5_OnlineOfflineSkimmingTool)
88 skimmingTools += [EGAM5_OnlineOfflineSkimmingTool]
89
90 # do the OR of previous selections
91 print("EGAM5 skimming is logical OR of previous selections")
92 EGAM5_SkimmingTool = CompFactory.DerivationFramework.FilterCombinationOR(
93 name="EGAM5_SkimmingTool",
94 FilterList=skimmingTools
95 )
96
97 acc.addPublicTool(EGAM5_SkimmingTool, primary=True)
98
99 return acc
100
101