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 377 of file EGAM12.py.

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

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

◆ 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 # off-line based selection
28 expression = "count(Electrons.pt > 4.5*GeV) >= 1"
29 print("EGAM12 offline skimming expression: ", expression)
30 from DerivationFrameworkTools.DerivationFrameworkToolsConfig import (
31 xAODStringSkimmingToolCfg)
32 return xAODStringSkimmingToolCfg(flags, name="EGAM12_OfflineSkimmingTool",
33 expression=expression, TrigDecisionTool=None)
34
35

Variable Documentation

◆ addCaloDecorations

bool python.EGAM12.addCaloDecorations = False

Definition at line 22 of file EGAM12.py.