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

Functions

 EGAM12SkimmingToolCfg (flags)
 EGAM12KernelCfg (flags, name="EGAM12Kernel", **kwargs)
 EGAM12Cfg (flags)

Variables

bool addCaloDecorations = False

Function Documentation

◆ EGAM12Cfg()

python.EGAM12.EGAM12Cfg ( flags)

Definition at line 382 of file EGAM12.py.

382def EGAM12Cfg(flags):
383 acc = ComponentAccumulator()
384
385 JetKey = "AntiKt4EMTopoJets"
386 EGAM12TriggerListsHelper = None
387
388 # configure skimming/thinning/augmentation tools
389 acc.merge(
390 EGAM12KernelCfg(
391 flags,
392 name="EGAM12Kernel",
393 StreamName="StreamDAOD_EGAM12",
394 TriggerListsHelper=EGAM12TriggerListsHelper,
395 )
396 )
397
398 # configure slimming
399 from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
400 from xAODMetaDataCnv.InfileMetaDataConfig import SetupMetaDataForStreamCfg
401 from DerivationFrameworkCore.SlimmingHelper import SlimmingHelper
402
403 EGAM12SlimmingHelper = SlimmingHelper(
404 "EGAM12SlimmingHelper",
405 NamesAndTypes=flags.Input.TypedCollections,
406 flags=flags,
407 )
408
409 # ------------------------------------------
410 # containers for which we save all variables
411 # -------------------------------------------
412
413 # baseline
414 EGAM12SlimmingHelper.AllVariables = [
415 "Electrons",
416 "GSFTrackParticles",
417 "egammaClusters",
418 ]
419
420 # on MC we also add:
421 if flags.Input.isMC:
422 EGAM12SlimmingHelper.AllVariables += [
423 "TruthEvents",
424 "TruthParticles",
425 "TruthVertices",
426 "egammaTruthParticles",
427 ]
428
429 # -------------------------------------------
430 # containers that we slim
431 # -------------------------------------------
432
433 # first add variables from smart-slimming
434 # adding only also those for which we add all variables since
435 # the XXXCPContent.py files also bring in some extra variables
436 # for other collections
437 # muons, tau, MET, b-tagging could be switched off if not needed
438 # and use too much space
439 EGAM12SlimmingHelper.SmartCollections = [
440 "Electrons",
441 "Photons",
442 "Muons",
443 "TauJets",
444 "InDetTrackParticles",
445 "PrimaryVertices",
446 JetKey,
447 ]
448
449 if flags.Input.isMC:
450 EGAM12SlimmingHelper.SmartCollections += [
451 "AntiKt4TruthJets",
452 "AntiKt4TruthDressedWZJets",
453 ]
454
455 # then add extra variables:
456
457 # muons
458 EGAM12SlimmingHelper.ExtraVariables += [
459 "Muons.ptcone20.ptcone30.ptcone40.etcone20.etcone30.etcone40"
460 ]
461
462 # conversion vertices
463 EGAM12SlimmingHelper.ExtraVariables += [
464 "GSFConversionVertices.x.y.z.px.py.pz.pt1.pt2.etaAtCalo.phiAtCalo",
465 "GSFConversionVertices.trackParticleLinks",
466 ]
467
468 # primary vertices
469 EGAM12SlimmingHelper.ExtraVariables += ["PrimaryVertices.x.y.sumPt2"]
470
471 # track jets
472 EGAM12SlimmingHelper.ExtraVariables += [
473 "AntiKt4PV0TrackJets.pt.eta.phi.e.m.btaggingLink.constituentLinks"
474 ]
475
476 # photons: detailed shower shape variables
477 EGAM12SlimmingHelper.ExtraVariables += PhotonsCPDetailedContent
478
479 # photons: gain and cluster energy per layer
480 if addCaloDecorations:
481 from DerivationFrameworkCalo.DerivationFrameworkCaloConfig import (
482 getGainDecorations,
483 getClusterEnergyPerLayerDecorations,
484 )
485
486 gainDecorations = getGainDecorations(acc, flags, "EGAM12Kernel")
487 print("EGAM12 gain decorations: ", gainDecorations)
488 EGAM12SlimmingHelper.ExtraVariables.extend(gainDecorations)
489 clusterEnergyDecorations = getClusterEnergyPerLayerDecorations(
490 acc, "EGAM12Kernel"
491 )
492 print("EGAM12 cluster energy decorations: ", clusterEnergyDecorations)
493 EGAM12SlimmingHelper.ExtraVariables.extend(clusterEnergyDecorations)
494
495 # energy density
496 EGAM12SlimmingHelper.ExtraVariables += [
497 "TopoClusterIsoCentralEventShape.Density",
498 "TopoClusterIsoForwardEventShape.Density",
499 ]
500
501 # truth
502 if flags.Input.isMC:
503 EGAM12SlimmingHelper.ExtraVariables += [
504 "MuonTruthParticles.e.px.py.pz.status.pdgId.truthOrigin.truthType"
505 ]
506
507 EGAM12SlimmingHelper.ExtraVariables += [
508 "Photons.truthOrigin.truthType.truthParticleLink"
509 ]
510
511 # Add event info
512 if flags.Derivation.Egamma.doEventInfoSlimming:
513 EGAM12SlimmingHelper.SmartCollections.append("EventInfo")
514 else:
515 EGAM12SlimmingHelper.AllVariables += ["EventInfo"]
516
517 # Add HIEventShape and CaloSums variables for heavy ions
518 EGAM12SlimmingHelper.AllVariables += ["HIEventShape"]
519 EGAM12SlimmingHelper.AllVariables += ["CaloSums"]
520
521 EGAM12ItemList = EGAM12SlimmingHelper.GetItemList()
522 acc.merge(
523 OutputStreamCfg(
524 flags,
525 "DAOD_EGAM12",
526 ItemList=EGAM12ItemList,
527 AcceptAlgs=["EGAM12Kernel"],
528 )
529 )
530 acc.merge(
531 SetupMetaDataForStreamCfg(
532 flags,
533 "DAOD_EGAM12",
534 AcceptAlgs=["EGAM12Kernel"],
535 createMetadata=[
536 MetadataCategory.CutFlowMetaData,
537 MetadataCategory.TruthMetaData,
538 ],
539 )
540 )
541
542 return acc
void print(char *figname, TCanvas *c1)

◆ EGAM12KernelCfg()

python.EGAM12.EGAM12KernelCfg ( flags,
name = "EGAM12Kernel",
** kwargs )
Configure the derivation framework driving algorithm (kernel)
for EGAM12

Definition at line 41 of file EGAM12.py.

41def EGAM12KernelCfg(flags, name="EGAM12Kernel", **kwargs):
42 """Configure the derivation framework driving algorithm (kernel)
43 for EGAM12"""
44 acc = ComponentAccumulator()
45
46 # Schedule extra jets collections
47 from JetRecConfig.StandardSmallRJets import (
48 AntiKt4EMTopo,
49 AntiKt4PV0Track,
50 AntiKt4Truth,
51 )
52 from JetRecConfig.JetRecConfig import JetRecCfg
53
54 jetList = [AntiKt4EMTopo, AntiKt4PV0Track, AntiKt4Truth]
55 for jd in jetList:
56 acc.merge(JetRecCfg(flags, jd))
57 JetKey = "AntiKt4EMTopoJets"
58
59 # Common augmentations
60 # cannot use PhysCommon sequence because
61 # - no triggers
62 # - no TauJets
63 # so we have to use a modified version here
64 from DerivationFrameworkInDet.InDetCommonConfig import InDetCommonCfg
65 from DerivationFrameworkMuons.MuonsCommonConfig import MuonsCommonCfg
66 from DerivationFrameworkEGamma.EGammaCommonConfig import EGammaCommonCfg
67
68 TrackingFlags = flags.Tracking
69
70 acc.merge(
71 InDetCommonCfg(
72 flags,
73 DoVertexFinding=TrackingFlags.doVertexFinding,
74 AddPseudoTracks=TrackingFlags.doPseudoTracking,
75 DecoLRTTTVA=False,
76 DoR3LargeD0=TrackingFlags.doLargeD0,
77 StoreSeparateLargeD0Container=TrackingFlags.storeSeparateLargeD0Container,
78 MergeLRT=False,
79 )
80 )
81 acc.merge(MuonsCommonCfg(flags))
82 acc.merge(EGammaCommonCfg(flags))
83 # jet cleaning
84 # standard way in PhysCommon is
85 # - calculate tau ID (needed for default jet OR)
86 # - decorate jets with overlap removal
87 # - do event cleaning
88 # but taus are missing in HI derivations so need to do differently
89
90 # Decorate if jet passed JVT criteria
91 from JetJvtEfficiency.JetJvtEfficiencyToolConfig import getJvtSelToolCfg
92
93 algName = "DFJet_EventCleaning_passJvtAlg"
94 passJvtTool = acc.popToolsAndMerge(getJvtSelToolCfg(flags, "AntiKt4EMTopoJets"))
95 passJvtTool.PassFlagName = "DFCommonJets_passJvt"
96 acc.addEventAlgo(
97 CompFactory.JetDecorationAlg(
98 algName, JetContainer="AntiKt4EMTopoJets", Decorators=[passJvtTool]
99 )
100 )
101
102 # Decorate if jet passes OR and save decoration DFCommonJets_passOR
103 # Use modified OR that does not check overlaps with tauls
104 from AssociationUtils.AssociationUtilsConfig import OverlapRemovalToolCfg
105
106 outputLabel = "DFCommonJets_passOR_EMTopo"
107 bJetLabel = "" # default
108 tauLabel = "" # workaround for missing taus
109 tauKey = "" # workaround for missing taus
110 orTool = acc.popToolsAndMerge(
111 OverlapRemovalToolCfg(
112 flags, outputLabel=outputLabel, bJetLabel=bJetLabel, doTaus=False
113 )
114 )
115 algOR = CompFactory.OverlapRemovalGenUseAlg(
116 "OverlapRemovalGenUseAlg",
117 OverlapLabel=outputLabel,
118 OverlapRemovalTool=orTool,
119 TauKey=tauKey,
120 TauLabel=tauLabel,
121 BJetLabel=bJetLabel,
122 )
123 acc.addEventAlgo(algOR)
124
125 # Do the cleaning
126 from JetSelectorTools.JetSelectorToolsConfig import (
127 EventCleaningToolCfg,
128 JetCleaningToolCfg,
129 )
130
131 workingPoints = ["Loose"]
132 prefix = "DFCommonJets_"
133
134 for wp in workingPoints:
135 cleaningLevel = wp + "Bad"
136 # LLP WPs have a slightly different name format
137 if "LLP" in wp:
138 cleaningLevel = wp.replace("LLP", "BadLLP")
139
140 jetCleaningTool = acc.popToolsAndMerge(
141 JetCleaningToolCfg(
142 flags,
143 "JetCleaningTool_" + cleaningLevel,
144 "AntiKt4EMTopoJets",
145 cleaningLevel,
146 False,
147 )
148 )
149 acc.addPublicTool(jetCleaningTool)
150
151 ecTool = acc.popToolsAndMerge(
152 EventCleaningToolCfg(flags, "EventCleaningTool_" + wp, cleaningLevel)
153 )
154 ecTool.JetCleanPrefix = prefix
155 ecTool.OrDecorator = "passOR_EMTopo"
156 ecTool.JetContainer = "AntiKt4EMTopoJets"
157 ecTool.JetCleaningTool = jetCleaningTool
158 acc.addPublicTool(ecTool)
159
160 # Alg to calculate event-level and jet-level cleaning variables
161 # Only store event-level flags for Loose* WPs
162 eventCleanAlg = CompFactory.EventCleaningTestAlg(
163 "EventCleaningTestAlg_" + wp,
164 EventCleaningTool=ecTool,
165 JetCollectionName="AntiKt4EMTopoJets",
166 EventCleanPrefix=prefix,
167 CleaningLevel=cleaningLevel,
168 doEvent=("Loose" in wp),
169 )
170 acc.addEventAlgo(eventCleanAlg)
171
172 # EGAM12 augmentations
173 augmentationTools = []
174
175 # ====================================================================
176 # Common calo decoration tools
177 # ====================================================================
178 if addCaloDecorations:
179 from DerivationFrameworkCalo.DerivationFrameworkCaloConfig import (
180 CaloDecoratorKernelCfg)
181 acc.merge(CaloDecoratorKernelCfg(flags))
182
183 # thinning tools
184 thinningTools = []
185 streamName = kwargs["StreamName"]
186
187 # Track thinning
188 if flags.Derivation.Egamma.doTrackThinning:
189 from DerivationFrameworkInDet.InDetToolsConfig import (
190 TrackParticleThinningCfg,
191 MuonTrackParticleThinningCfg,
192 TauTrackParticleThinningCfg,
193 )
194
195 TrackThinningKeepElectronTracks = True
196 TrackThinningKeepPhotonTracks = True
197 TrackThinningKeepAllElectronTracks = False
198 TrackThinningKeepJetTracks = False
199 TrackThinningKeepMuonTracks = False
200 TrackThinningKeepTauTracks = False
201 TrackThinningKeepPVTracks = False
202
203 # Tracks associated with Electrons
204 if TrackThinningKeepElectronTracks:
205 EGAM12ElectronTPThinningTool = (
206 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
207 name="EGAM12ElectronTPThinningTool",
208 StreamName=streamName,
209 SGKey="Electrons",
210 GSFTrackParticlesKey="GSFTrackParticles",
211 InDetTrackParticlesKey="InDetTrackParticles",
212 SelectionString="Electrons.pt > 0*GeV",
213 BestMatchOnly=True,
214 ConeSize=0.3,
215 )
216 )
217 acc.addPublicTool(EGAM12ElectronTPThinningTool)
218 thinningTools.append(EGAM12ElectronTPThinningTool)
219
220 # Tracks associated with Electrons (all tracks, large cone, for track
221 # isolation studies of the selected electrons)
222 if TrackThinningKeepAllElectronTracks:
223 EGAM12ElectronTPThinningTool2 = (
224 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
225 name="EGAM12ElectronTPThinningTool2",
226 StreamName=streamName,
227 SGKey="Electrons",
228 GSFTrackParticlesKey="GSFTrackParticles",
229 InDetTrackParticlesKey="InDetTrackParticles",
230 SelectionString="Electrons.pt > 4*GeV",
231 BestMatchOnly=False,
232 ConeSize=0.6,
233 )
234 )
235 acc.addPublicTool(EGAM12ElectronTPThinningTool2)
236 thinningTools.append(EGAM12ElectronTPThinningTool2)
237
238 # Tracks associated with Photons
239 if TrackThinningKeepPhotonTracks:
240 EGAM12PhotonTPThinningTool = (
241 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
242 name="EGAM12PhotonTPThinningTool",
243 StreamName=streamName,
244 SGKey="Photons",
245 GSFTrackParticlesKey="GSFTrackParticles",
246 InDetTrackParticlesKey="InDetTrackParticles",
247 GSFConversionVerticesKey="GSFConversionVertices",
248 SelectionString="Photons.pt > 0*GeV",
249 BestMatchOnly=True,
250 ConeSize=0.3,
251 )
252 )
253 acc.addPublicTool(EGAM12PhotonTPThinningTool)
254 thinningTools.append(EGAM12PhotonTPThinningTool)
255
256 # Tracks associated with Jets
257 if TrackThinningKeepJetTracks:
258 EGAM12JetTPThinningTool = (
259 CompFactory.DerivationFramework.JetTrackParticleThinning(
260 name="EGAM12JetTPThinningTool",
261 StreamName=streamName,
262 JetKey=JetKey,
263 InDetTrackParticlesKey="InDetTrackParticles",
264 )
265 )
266 acc.addPublicTool(EGAM12JetTPThinningTool)
267 thinningTools.append(EGAM12JetTPThinningTool)
268
269 # Tracks associated with Muons
270 if TrackThinningKeepMuonTracks:
271 EGAM12MuonTPThinningTool = acc.getPrimaryAndMerge(
272 MuonTrackParticleThinningCfg(
273 flags,
274 name="EGAM12MuonTPThinningTool",
275 StreamName=streamName,
276 MuonKey="Muons",
277 InDetTrackParticlesKey="InDetTrackParticles",
278 )
279 )
280 thinningTools.append(EGAM12MuonTPThinningTool)
281
282 # Tracks associated with Taus
283 if TrackThinningKeepTauTracks:
284 EGAM12TauTPThinningTool = acc.getPrimaryAndMerge(
285 TauTrackParticleThinningCfg(
286 flags,
287 name="EGAM12TauTPThinningTool",
288 StreamName=streamName,
289 TauKey="TauJets",
290 ConeSize=0.6,
291 InDetTrackParticlesKey="InDetTrackParticles",
292 DoTauTracksThinning=True,
293 TauTracksKey="TauTracks",
294 )
295 )
296 thinningTools.append(EGAM12TauTPThinningTool)
297
298 # Tracks from primary vertex
299 thinning_expression = " && ".join(
300 [
301 "(InDetTrackParticles.DFCommonTightPrimary)",
302 "(abs(DFCommonInDetTrackZ0AtPV)*sin(InDetTrackParticles.theta)<3*mm)",
303 "(InDetTrackParticles.pt>10*GeV)",
304 ]
305 )
306 if TrackThinningKeepPVTracks:
307 EGAM12TPThinningTool = acc.getPrimaryAndMerge(
308 TrackParticleThinningCfg(
309 flags,
310 name="EGAM12TPThinningTool",
311 StreamName=streamName,
312 SelectionString=thinning_expression,
313 InDetTrackParticlesKey="InDetTrackParticles",
314 )
315 )
316 thinningTools.append(EGAM12TPThinningTool)
317
318 # truth thinning
319 if flags.Input.isMC:
320 # W, Z and Higgs
321 truth_cond_WZH = " && ".join(
322 ["(abs(TruthParticles.pdgId) >= 23)", "(abs(TruthParticles.pdgId) <= 25)"]
323 )
324 # Leptons
325 truth_cond_lep = " && ".join(
326 ["(abs(TruthParticles.pdgId) >= 11)", "(abs(TruthParticles.pdgId) <= 16)"]
327 )
328 # Top quark
329 truth_cond_top = "(abs(TruthParticles.pdgId) == 6)"
330 # Photon
331 truth_cond_gam = " && ".join(
332 ["(abs(TruthParticles.pdgId) == 22)", "(TruthParticles.pt > 1*GeV)"]
333 )
334 # stable particles
335 truth_cond_finalState = "(TruthParticles.isGenStable)"
336 truth_expression = (
337 "( "
338 + truth_cond_WZH
339 + " ) || "
340 + "( "
341 + truth_cond_lep
342 + " ) || "
343 + "( "
344 + truth_cond_top
345 + " ) || "
346 + "( "
347 + truth_cond_gam
348 + " ) || "
349 + "( "
350 + truth_cond_finalState
351 + " )"
352 )
353 print("EGAM12 truth thinning expression: ", truth_expression)
354
355 EGAM12TruthThinningTool = CompFactory.DerivationFramework.GenericTruthThinning(
356 name="EGAM12TruthThinningTool",
357 StreamName=streamName,
358 ParticleSelectionString=truth_expression,
359 PreserveDescendants=False,
360 PreserveGeneratorDescendants=True,
361 PreserveAncestors=True,
362 )
363 acc.addPublicTool(EGAM12TruthThinningTool)
364 thinningTools.append(EGAM12TruthThinningTool)
365
366 # skimming
367 skimmingTool = acc.getPrimaryAndMerge(EGAM12SkimmingToolCfg(flags))
368
369 # setup the kernel
370 acc.addEventAlgo(
371 CompFactory.DerivationFramework.DerivationKernel(
372 name,
373 SkimmingTools=[skimmingTool],
374 AugmentationTools=augmentationTools,
375 ThinningTools=thinningTools,
376 )
377 )
378
379 return acc
380
381

◆ EGAM12SkimmingToolCfg()

python.EGAM12.EGAM12SkimmingToolCfg ( flags)
Configure the EGAM12 skimming tool

Definition at line 25 of file EGAM12.py.

25def EGAM12SkimmingToolCfg(flags):
26 """Configure the EGAM12 skimming tool"""
27 acc = ComponentAccumulator()
28
29 # off-line based selection
30 expression = "count(Electrons.pt > 4.5*GeV) >= 1"
31 print("EGAM12 offline skimming expression: ", expression)
32 EGAM12_OfflineSkimmingTool = CompFactory.DerivationFramework.xAODStringSkimmingTool(
33 name="EGAM12_OfflineSkimmingTool", expression=expression, TrigDecisionTool=""
34 )
35
36 acc.addPublicTool(EGAM12_OfflineSkimmingTool, primary=True)
37
38 return acc
39
40

Variable Documentation

◆ addCaloDecorations

bool python.EGAM12.addCaloDecorations = False

Definition at line 22 of file EGAM12.py.