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

Functions

 EGAM10SkimmingToolCfg (flags)
 EGAM10KernelCfg (flags, name="EGAM10Kernel", **kwargs)
 EGAM10Cfg (flags)

Variables

str electronRequirements
str photonRequirements
bool decorateCells = True

Function Documentation

◆ EGAM10Cfg()

python.EGAM10.EGAM10Cfg ( flags)

Definition at line 194 of file EGAM10.py.

194def EGAM10Cfg(flags):
195 acc = ComponentAccumulator()
196
197 # Get the lists of triggers needed for trigger matching.
198 # This is needed at this scope (for the slimming) and further down
199 # in the config chain for actually configuring the matching, so we create
200 # it here and pass it down
201 # TODO: this should ideally be called higher up to avoid it being run
202 # multiple times in a train.
203 # TODO: restrict it to relevant triggers
204 from DerivationFrameworkPhys.TriggerListsHelper import TriggerListsHelper
205
206 EGAM10TriggerListsHelper = TriggerListsHelper(flags)
207
208 # configure skimming/thinning/augmentation tools
209 acc.merge(
210 EGAM10KernelCfg(
211 flags,
212 name="EGAM10Kernel",
213 StreamName="StreamDAOD_EGAM10",
214 TriggerListsHelper=EGAM10TriggerListsHelper,
215 )
216 )
217
218 # configure slimming
219 from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
220 from xAODMetaDataCnv.InfileMetaDataConfig import SetupMetaDataForStreamCfg
221 from DerivationFrameworkCore.SlimmingHelper import SlimmingHelper
222
223 EGAM10SlimmingHelper = SlimmingHelper(
224 "EGAM10SlimmingHelper",
225 NamesAndTypes=flags.Input.TypedCollections,
226 flags=flags,
227 )
228
229 # ------------------------------------------
230 # containers for which we save all variables
231 # -------------------------------------------
232
233 # baseline
234 EGAM10SlimmingHelper.AllVariables = [
235 "CaloCalTopoClusters"
236 ]
237
238 # and on MC we also add:
239 if flags.Input.isMC:
240 EGAM10SlimmingHelper.AppendToDictionary.update(
241 {
242 "TruthIsoCentralEventShape": "xAOD::EventShape",
243 "TruthIsoCentralEventShapeAux": "xAOD::EventShapeAuxInfo",
244 "TruthIsoForwardEventShape": "xAOD::EventShape",
245 "TruthIsoForwardEventShapeAux": "xAOD::EventShapeAuxInfo",
246 }
247 )
248 EGAM10SlimmingHelper.AllVariables += [
249 "TruthEvents",
250 "TruthParticles",
251 "TruthVertices",
252 "TruthMuons",
253 "TruthElectrons",
254 "TruthPhotons",
255 "TruthNeutrinos",
256 "TruthTaus",
257 "AntiKt4TruthJets",
258 "AntiKt4TruthDressedWZJets",
259 "egammaTruthParticles",
260 "TruthIsoCentralEventShape",
261 "TruthIsoForwardEventShape",
262 ]
263
264 # -------------------------------------------
265 # containers that we slim
266 # -------------------------------------------
267
268 # first add variables from smart-slimming
269 # adding only also those for which we add all variables since
270 # the XXXCPContent.py files also bring in some extra variables
271 # for other collections
272 # muons, tau, MET, b-tagging could be switched off if not needed
273 # and use too much space
274 EGAM10SlimmingHelper.SmartCollections = [
275 "Electrons",
276 "Photons",
277 "InDetTrackParticles",
278 "PrimaryVertices",
279 "AntiKt4EMPFlowJets",
280 ]
281
282 if flags.Input.isMC:
283 EGAM10SlimmingHelper.SmartCollections += [
284 "AntiKt4TruthJets",
285 "AntiKt4TruthDressedWZJets",
286 ]
287
288 # then add extra variables:
289
290 # egamma clusters
291 EGAM10SlimmingHelper.ExtraVariables += [
292 "egammaClusters.PHI2CALOFRAME.ETA2CALOFRAME.phi_sampl",
293 ]
294
295 # photons
296 EGAM10SlimmingHelper.ExtraVariables += [
297 "Photons.ptcone30.ptcone40.f3.f3core",
298 "Photons.maxEcell_time.maxEcell_energy.maxEcell_gain.maxEcell_onlId",
299 "Photons.maxEcell_x.maxEcell_y.maxEcell_z",
300 "Photons.ptcone40_Nonprompt_All_MaxWeightTTVA_pt1000",
301 "Photons.ptcone40_Nonprompt_All_MaxWeightTTVA_pt500",
302 "Photons.ptcone20_Nonprompt_All_MaxWeightTTVA_pt500",
303 "Photons.ptvarcone30_Nonprompt_All_MaxWeightTTVA_pt1000",
304 "Photons.ptvarcone30_Nonprompt_All_MaxWeightTTVA_pt500",
305 ]
306
307 # electrons
308 EGAM10SlimmingHelper.ExtraVariables += [
309 "Electrons.topoetcone30.topoetcone40.ptcone20.ptcone30",
310 "Electrons.ptcone40.maxEcell_time.maxEcell_energy.maxEcell_gain",
311 "Electrons.maxEcell_onlId.maxEcell_x.maxEcell_y.maxEcell_z",
312 ]
313
314 # primary vertices
315 EGAM10SlimmingHelper.ExtraVariables += [
316 "PrimaryVertices.covariance.trackWeights.sumPt2.sumPt",
317 "PrimaryVertices.pt.eta.phi",
318 ]
319
320 # tracks
321 EGAM10SlimmingHelper.ExtraVariables += [
322 "InDetTrackParticles.TTVA_AMVFVertices.TTVA_AMVFWeights"
323 ]
324
325 # photons and electrons: detailed shower shape variables and track variables
326 EGAM10SlimmingHelper.ExtraVariables += PhotonsCPDetailedContent
327
328 # photons: gain and cluster energy per layer
329 from DerivationFrameworkCalo.DerivationFrameworkCaloConfig import (
330 getGainDecorations,
331 getClusterEnergyPerLayerDecorations,
332 )
333
334 gainDecorations = getGainDecorations(acc, flags, "EGAM10Kernel")
335 print("EGAM10 gain decorations: ", gainDecorations)
336 EGAM10SlimmingHelper.ExtraVariables.extend(gainDecorations)
337 clusterEnergyDecorations = getClusterEnergyPerLayerDecorations(acc, "EGAM10Kernel")
338 print("EGAM10 cluster energy decorations: ", clusterEnergyDecorations)
339 EGAM10SlimmingHelper.ExtraVariables.extend(clusterEnergyDecorations)
340
341 # photons: cell decorations
342 if decorateCells:
343 EGAM10SlimmingHelper.ExtraVariables += [
344 "Photons.cells_E.cells_time.cells_onlId",
345 "Photons.cells_eta.cells_phi.cells_layer",
346 "Photons.cells_x.cells_y.cells_z",
347 "Photons.cells_gain",
348 "Photons.cells_quality",
349 "Photons.ncells",
350 ]
351
352 # energy density
353 EGAM10SlimmingHelper.ExtraVariables += [
354 "TopoClusterIsoCentralEventShape.Density",
355 "TopoClusterIsoForwardEventShape.Density",
356 ]
357
358 from DerivationFrameworkEGamma import EGammaIsoConfig
359
360 (
361 pflowIsoVar,
362 densityList,
363 densityDict,
364 acc1,
365 ) = EGammaIsoConfig.makeEGammaCommonIsoCfg(flags)
366 acc.merge(acc1)
367 EGAM10SlimmingHelper.AppendToDictionary.update(densityDict)
368 EGAM10SlimmingHelper.ExtraVariables += densityList + [f"Photons{pflowIsoVar}"]
369
370 # To have ptcone40, needed for efficiency measurement with MM
371 from IsolationAlgs.DerivationTrackIsoConfig import DerivationTrackIsoCfg
372
373 acc.merge(
374 DerivationTrackIsoCfg(
375 flags, object_types=("Photons",), ptCuts=(500, 1000), postfix="Extra"
376 )
377 )
378
379 # truth
380 if flags.Input.isMC:
381 EGAM10SlimmingHelper.ExtraVariables += [
382 "Electrons.truthOrigin.truthType.truthParticleLink.truthPdgId",
383 "Electrons.lastEgMotherTruthType.lastEgMotherTruthOrigin",
384 "Electrons.lastEgMotherTruthParticleLink.lastEgMotherPdgId",
385 "Electrons.firstEgMotherTruthType.firstEgMotherTruthOrigin",
386 "Electrons.firstEgMotherTruthParticleLink.firstEgMotherPdgId",
387 ]
388
389 EGAM10SlimmingHelper.ExtraVariables += [
390 "Photons.truthOrigin.truthType.truthParticleLink"
391 ]
392
393 EGAM10SlimmingHelper.ExtraVariables += [
394 "TruthIsoCentralEventShape.DensitySigma.Density.DensityArea",
395 "TruthIsoForwardEventShape.DensitySigma.Density.DensityArea",
396 ]
397
398 # Add event info
399 if flags.Derivation.Egamma.doEventInfoSlimming:
400 EGAM10SlimmingHelper.SmartCollections.append("EventInfo")
401 else:
402 EGAM10SlimmingHelper.AllVariables += ["EventInfo"]
403
404 # Add egamma trigger objects
405 EGAM10SlimmingHelper.IncludeEGammaTriggerContent = True
406
407 # Trigger matching
408 # Run 2
409 if flags.Trigger.EDMVersion == 2:
410 from DerivationFrameworkPhys.TriggerMatchingCommonConfig import AddRun2TriggerMatchingToSlimmingHelper
411 AddRun2TriggerMatchingToSlimmingHelper(SlimmingHelper = EGAM10SlimmingHelper,
412 OutputContainerPrefix = "TrigMatch_",
413 TriggerList = EGAM10TriggerListsHelper.Run2TriggerNamesNoTau)
414 # Run 3, or Run 2 with navigation conversion
415 if flags.Trigger.EDMVersion == 3 or (flags.Trigger.EDMVersion == 2 and flags.Trigger.doEDMVersionConversion):
416 from TrigNavSlimmingMT.TrigNavSlimmingMTConfig import AddRun3TrigNavSlimmingCollectionsToSlimmingHelper
417 AddRun3TrigNavSlimmingCollectionsToSlimmingHelper(EGAM10SlimmingHelper)
418
419 EGAM10ItemList = EGAM10SlimmingHelper.GetItemList()
420 acc.merge(
421 OutputStreamCfg(
422 flags,
423 "DAOD_EGAM10",
424 ItemList=EGAM10ItemList,
425 AcceptAlgs=["EGAM10Kernel"],
426 )
427 )
428 acc.merge(
429 SetupMetaDataForStreamCfg(
430 flags,
431 "DAOD_EGAM10",
432 AcceptAlgs=["EGAM10Kernel"],
433 createMetadata=[
434 MetadataCategory.CutFlowMetaData,
435 MetadataCategory.TruthMetaData,
436 ],
437 )
438 )
439
440 return acc
void print(char *figname, TCanvas *c1)

◆ EGAM10KernelCfg()

python.EGAM10.EGAM10KernelCfg ( flags,
name = "EGAM10Kernel",
** kwargs )
Configure the derivation framework driving algorithm (kernel)
for EGAM10

Definition at line 85 of file EGAM10.py.

85def EGAM10KernelCfg(flags, name="EGAM10Kernel", **kwargs):
86 """Configure the derivation framework driving algorithm (kernel)
87 for EGAM10"""
88 acc = ComponentAccumulator()
89
90 # Common augmentations
91 from DerivationFrameworkPhys.PhysCommonConfig import PhysCommonAugmentationsCfg
92
93 acc.merge(
94 PhysCommonAugmentationsCfg(
95 flags, TriggerListsHelper=kwargs["TriggerListsHelper"]
96 )
97 )
98
99 # EGAM10 augmentations
100 augmentationTools = []
101
102 # ====================================================================
103 # PhotonVertexSelectionWrapper decoration tool - needs PhotonPointing tool
104 # ====================================================================
105 from DerivationFrameworkEGamma.EGammaToolsConfig import (
106 PhotonVertexSelectionWrapperKernelCfg)
107 acc.merge(PhotonVertexSelectionWrapperKernelCfg(flags))
108
109 # ====================================================================
110 # Common calo decoration tools
111 # ====================================================================
112 from DerivationFrameworkCalo.DerivationFrameworkCaloConfig import (
113 CaloDecoratorKernelCfg, CaloCellDecoratorKernelCfg)
114 acc.merge(CaloDecoratorKernelCfg(flags))
115 acc.merge(CaloCellDecoratorKernelCfg(flags))
116
117 # thinning tools
118 thinningTools = []
119 streamName = kwargs["StreamName"]
120
121 # Track thinning
122 if flags.Derivation.Egamma.doTrackThinning:
123 TrackThinningKeepElectronTracks = True
124 TrackThinningKeepPhotonTracks = True
125 TrackThinningKeepAllElectronTracks = True
126
127 # Tracks associated with high-pT Electrons (deltaR=0.6)
128 if TrackThinningKeepElectronTracks:
129 EGAM10ElectronTPThinningTool = (
130 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
131 name="EGAM10ElectronTPThinningTool",
132 StreamName=streamName,
133 SGKey="Electrons",
134 GSFTrackParticlesKey="GSFTrackParticles",
135 InDetTrackParticlesKey="InDetTrackParticles",
136 SelectionString=electronRequirements,
137 BestMatchOnly=True,
138 ConeSize=0.6,
139 )
140 )
141 acc.addPublicTool(EGAM10ElectronTPThinningTool)
142 thinningTools.append(EGAM10ElectronTPThinningTool)
143
144 # Tracks associated with Photons
145 if TrackThinningKeepPhotonTracks:
146 EGAM10PhotonTPThinningTool = (
147 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
148 name="EGAM10PhotonTPThinningTool",
149 StreamName=streamName,
150 SGKey="Photons",
151 GSFTrackParticlesKey="GSFTrackParticles",
152 InDetTrackParticlesKey="InDetTrackParticles",
153 GSFConversionVerticesKey="GSFConversionVertices",
154 SelectionString=photonRequirements,
155 BestMatchOnly=False,
156 ConeSize=0.6,
157 )
158 )
159 acc.addPublicTool(EGAM10PhotonTPThinningTool)
160 thinningTools.append(EGAM10PhotonTPThinningTool)
161
162 # Tracks associated with all Electrons (for ambiguity resolver tool)
163 if TrackThinningKeepAllElectronTracks:
164 EGAM10ElectronTPThinningToolAR = (
165 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
166 name="EGAM10ElectronTPThinningToolAR",
167 StreamName=streamName,
168 SGKey="Electrons",
169 GSFTrackParticlesKey="GSFTrackParticles",
170 InDetTrackParticlesKey="InDetTrackParticles",
171 SelectionString=electronRequirements,
172 BestMatchOnly=True,
173 )
174 )
175 acc.addPublicTool(EGAM10ElectronTPThinningToolAR)
176 thinningTools.append(EGAM10ElectronTPThinningToolAR)
177
178 # skimming
179 skimmingTool = acc.getPrimaryAndMerge(EGAM10SkimmingToolCfg(flags))
180
181 # setup the kernel
182 acc.addEventAlgo(
183 CompFactory.DerivationFramework.DerivationKernel(
184 name,
185 SkimmingTools=[skimmingTool],
186 AugmentationTools=augmentationTools,
187 ThinningTools=thinningTools,
188 )
189 )
190
191 return acc
192
193

◆ EGAM10SkimmingToolCfg()

python.EGAM10.EGAM10SkimmingToolCfg ( flags)
Configure the EGAM10 skimming tool

Definition at line 38 of file EGAM10.py.

38def EGAM10SkimmingToolCfg(flags):
39 """Configure the EGAM10 skimming tool"""
40 acc = ComponentAccumulator()
41
42 # off-line based selection
43 photonSelection = "(count(" + photonRequirements + ") >= 1)"
44 print("EGAM10 offline skimming expression: ", photonSelection)
45 from DerivationFrameworkTools.DerivationFrameworkToolsConfig import (
46 xAODStringSkimmingToolCfg)
47 EGAM10_OfflineSkimmingTool = acc.getPrimaryAndMerge(xAODStringSkimmingToolCfg(
48 flags, name="EGAM10_OfflineSkimmingTool", expression=photonSelection))
49 filterList = [EGAM10_OfflineSkimmingTool]
50
51 # trigger-based selection
52 MenuType = None
53 if flags.Trigger.EDMVersion == 2:
54 MenuType = "Run2"
55 elif flags.Trigger.EDMVersion == 3:
56 MenuType = "Run3"
57 if MenuType:
58 allTriggers = (
59 singlePhotonTriggers[MenuType]
60 + diPhotonTriggers[MenuType]
61 + triPhotonTriggers[MenuType]
62 + noalgTriggers[MenuType]
63 )
64 # remove duplicates
65 allTriggers = list(set(allTriggers))
66 print("EGAM10 trigger skimming list (OR): ", allTriggers)
67 EGAM10_TriggerSkimmingTool = CompFactory.DerivationFramework.TriggerSkimmingTool(
68 name="EGAM10_TriggerSkimmingTool", TriggerListOR=allTriggers
69 )
70 acc.addPublicTool(EGAM10_TriggerSkimmingTool)
71 filterList += [EGAM10_TriggerSkimmingTool]
72 else:
73 print("Unknown Trigger.EDMVersion ", flags.Trigger.EDMVersion)
74 print("Will not apply trigger-based skimming")
75
76 # do the AND of trigger-based and offline-based selection
77 print("EGAM10 skimming is logical AND of previous selections")
78 EGAM10_SkimmingTool = CompFactory.DerivationFramework.FilterCombinationAND(
79 name="EGAM10_SkimmingTool", FilterList=filterList)
80
81 acc.addPublicTool(EGAM10_SkimmingTool, primary=True)
82 return acc
83
84
STL class.

Variable Documentation

◆ decorateCells

bool python.EGAM10.decorateCells = True

Definition at line 36 of file EGAM10.py.

◆ electronRequirements

str python.EGAM10.electronRequirements
Initial value:
1= " && ".join(
2 [
3 "(Electrons.pt > 15*GeV)",
4 "(abs(Electrons.eta) < 2.5)",
5 "(Electrons.DFCommonElectronsLHLoose)",
6 ]
7)

Definition at line 25 of file EGAM10.py.

◆ photonRequirements

str python.EGAM10.photonRequirements
Initial value:
1= " && ".join(
2 ["(DFCommonPhotons_et >= 15*GeV)", "(abs(DFCommonPhotons_eta) < 2.5)"]
3)

Definition at line 32 of file EGAM10.py.