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 209 of file EGAM10.py.

209def EGAM10Cfg(flags):
210 acc = ComponentAccumulator()
211
212 # Get the lists of triggers needed for trigger matching.
213 # This is needed at this scope (for the slimming) and further down
214 # in the config chain for actually configuring the matching, so we create
215 # it here and pass it down
216 # TODO: this should ideally be called higher up to avoid it being run
217 # multiple times in a train.
218 # TODO: restrict it to relevant triggers
219 from DerivationFrameworkPhys.TriggerListsHelper import TriggerListsHelper
220
221 EGAM10TriggerListsHelper = TriggerListsHelper(flags)
222
223 # configure skimming/thinning/augmentation tools
224 acc.merge(
225 EGAM10KernelCfg(
226 flags,
227 name="EGAM10Kernel",
228 StreamName="StreamDAOD_EGAM10",
229 TriggerListsHelper=EGAM10TriggerListsHelper,
230 )
231 )
232
233 # configure slimming
234 from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
235 from xAODMetaDataCnv.InfileMetaDataConfig import SetupMetaDataForStreamCfg
236 from DerivationFrameworkCore.SlimmingHelper import SlimmingHelper
237
238 EGAM10SlimmingHelper = SlimmingHelper(
239 "EGAM10SlimmingHelper",
240 NamesAndTypes=flags.Input.TypedCollections,
241 flags=flags,
242 )
243
244 # ------------------------------------------
245 # containers for which we save all variables
246 # -------------------------------------------
247
248 # baseline
249 EGAM10SlimmingHelper.AllVariables = [
250 "CaloCalTopoClusters"
251 ]
252
253 # and on MC we also add:
254 if flags.Input.isMC:
255 EGAM10SlimmingHelper.AppendToDictionary.update(
256 {
257 "TruthIsoCentralEventShape": "xAOD::EventShape",
258 "TruthIsoCentralEventShapeAux": "xAOD::EventShapeAuxInfo",
259 "TruthIsoForwardEventShape": "xAOD::EventShape",
260 "TruthIsoForwardEventShapeAux": "xAOD::EventShapeAuxInfo",
261 }
262 )
263 EGAM10SlimmingHelper.AllVariables += [
264 "TruthEvents",
265 "TruthParticles",
266 "TruthVertices",
267 "TruthMuons",
268 "TruthElectrons",
269 "TruthPhotons",
270 "TruthNeutrinos",
271 "TruthTaus",
272 "AntiKt4TruthJets",
273 "AntiKt4TruthDressedWZJets",
274 "egammaTruthParticles",
275 "TruthIsoCentralEventShape",
276 "TruthIsoForwardEventShape",
277 ]
278
279 # -------------------------------------------
280 # containers that we slim
281 # -------------------------------------------
282
283 # first add variables from smart-slimming
284 # adding only also those for which we add all variables since
285 # the XXXCPContent.py files also bring in some extra variables
286 # for other collections
287 # muons, tau, MET, b-tagging could be switched off if not needed
288 # and use too much space
289 EGAM10SlimmingHelper.SmartCollections = [
290 "Electrons",
291 "Photons",
292 "InDetTrackParticles",
293 "PrimaryVertices",
294 "AntiKt4EMPFlowJets",
295 ]
296
297 if flags.Input.isMC:
298 EGAM10SlimmingHelper.SmartCollections += [
299 "AntiKt4TruthJets",
300 "AntiKt4TruthDressedWZJets",
301 ]
302
303 # then add extra variables:
304
305 # egamma clusters
306 EGAM10SlimmingHelper.ExtraVariables += [
307 "egammaClusters.PHI2CALOFRAME.ETA2CALOFRAME.phi_sampl",
308 ]
309
310 # photons
311 EGAM10SlimmingHelper.ExtraVariables += [
312 "Photons.ptcone30.ptcone40.f3.f3core",
313 "Photons.maxEcell_time.maxEcell_energy.maxEcell_gain.maxEcell_onlId",
314 "Photons.maxEcell_x.maxEcell_y.maxEcell_z",
315 "Photons.ptcone40_Nonprompt_All_MaxWeightTTVA_pt1000",
316 "Photons.ptcone40_Nonprompt_All_MaxWeightTTVA_pt500",
317 "Photons.ptcone20_Nonprompt_All_MaxWeightTTVA_pt500",
318 "Photons.ptvarcone30_Nonprompt_All_MaxWeightTTVA_pt1000",
319 "Photons.ptvarcone30_Nonprompt_All_MaxWeightTTVA_pt500",
320 ]
321
322 # electrons
323 EGAM10SlimmingHelper.ExtraVariables += [
324 "Electrons.topoetcone30.topoetcone40.ptcone20.ptcone30",
325 "Electrons.ptcone40.maxEcell_time.maxEcell_energy.maxEcell_gain",
326 "Electrons.maxEcell_onlId.maxEcell_x.maxEcell_y.maxEcell_z",
327 ]
328
329 # primary vertices
330 EGAM10SlimmingHelper.ExtraVariables += [
331 "PrimaryVertices.covariance.trackWeights.sumPt2.sumPt",
332 "PrimaryVertices.pt.eta.phi",
333 ]
334
335 # tracks
336 EGAM10SlimmingHelper.ExtraVariables += [
337 "InDetTrackParticles.TTVA_AMVFVertices.TTVA_AMVFWeights"
338 ]
339
340 # photons and electrons: detailed shower shape variables and track variables
341 EGAM10SlimmingHelper.ExtraVariables += PhotonsCPDetailedContent
342
343 # photons: gain and cluster energy per layer
344 from DerivationFrameworkCalo.DerivationFrameworkCaloConfig import (
345 getGainDecorations,
346 getClusterEnergyPerLayerDecorations,
347 )
348
349 gainDecorations = getGainDecorations(acc, flags, "EGAM10Kernel")
350 print("EGAM10 gain decorations: ", gainDecorations)
351 EGAM10SlimmingHelper.ExtraVariables.extend(gainDecorations)
352 clusterEnergyDecorations = getClusterEnergyPerLayerDecorations(acc, "EGAM10Kernel")
353 print("EGAM10 cluster energy decorations: ", clusterEnergyDecorations)
354 EGAM10SlimmingHelper.ExtraVariables.extend(clusterEnergyDecorations)
355
356 # photons: cell decorations
357 if decorateCells:
358 EGAM10SlimmingHelper.ExtraVariables += [
359 "Photons.cells_E.cells_time.cells_onlId",
360 "Photons.cells_eta.cells_phi.cells_layer",
361 "Photons.cells_x.cells_y.cells_z",
362 "Photons.cells_gain",
363 "Photons.cells_quality",
364 "Photons.cells_clusterOriginInfo",
365 ]
366
367 # energy density
368 EGAM10SlimmingHelper.ExtraVariables += [
369 "TopoClusterIsoCentralEventShape.Density",
370 "TopoClusterIsoForwardEventShape.Density",
371 ]
372
373 from DerivationFrameworkEGamma import EGammaIsoConfig
374
375 (
376 pflowIsoVar,
377 densityList,
378 densityDict,
379 acc1,
380 ) = EGammaIsoConfig.makeEGammaCommonIsoCfg(flags)
381 acc.merge(acc1)
382 EGAM10SlimmingHelper.AppendToDictionary.update(densityDict)
383 EGAM10SlimmingHelper.ExtraVariables += densityList + [f"Photons{pflowIsoVar}"]
384
385 # To have ptcone40, needed for efficiency measurement with MM
386 from IsolationAlgs.DerivationTrackIsoConfig import DerivationTrackIsoCfg
387
388 acc.merge(
389 DerivationTrackIsoCfg(
390 flags, object_types=("Photons",), ptCuts=(500, 1000), postfix="Extra"
391 )
392 )
393
394 # truth
395 if flags.Input.isMC:
396 EGAM10SlimmingHelper.ExtraVariables += [
397 "Electrons.truthClassification.truthOrigin.truthType.truthParticleLink.truthPdgId",
398 "Electrons.lastEgMotherTruthClassification.lastEgMotherTruthType.lastEgMotherTruthOrigin",
399 "Electrons.lastEgMotherTruthParticleLink.lastEgMotherPdgId",
400 "Electrons.firstEgMotherTruthClassification.firstEgMotherTruthType.firstEgMotherTruthOrigin",
401 "Electrons.firstEgMotherTruthParticleLink.firstEgMotherPdgId",
402 ]
403
404 EGAM10SlimmingHelper.ExtraVariables += [
405 "Photons.truthClassification.truthOrigin.truthType.truthParticleLink"
406 ]
407
408 EGAM10SlimmingHelper.ExtraVariables += [
409 "TruthIsoCentralEventShape.DensitySigma.Density.DensityArea",
410 "TruthIsoForwardEventShape.DensitySigma.Density.DensityArea",
411 ]
412
413 # Add event info
414 if flags.Derivation.Egamma.doEventInfoSlimming:
415 EGAM10SlimmingHelper.SmartCollections.append("EventInfo")
416 else:
417 EGAM10SlimmingHelper.AllVariables += ["EventInfo"]
418
419 # Add egamma trigger objects
420 EGAM10SlimmingHelper.IncludeEGammaTriggerContent = True
421
422 # Trigger matching
423 # Run 2
424 if flags.Trigger.EDMVersion == 2:
425 from DerivationFrameworkPhys.TriggerMatchingCommonConfig import AddRun2TriggerMatchingToSlimmingHelper
426 AddRun2TriggerMatchingToSlimmingHelper(SlimmingHelper = EGAM10SlimmingHelper,
427 OutputContainerPrefix = "TrigMatch_",
428 TriggerList = EGAM10TriggerListsHelper.Run2TriggerNamesNoTau)
429 # Run 3, or Run 2 with navigation conversion
430 if flags.Trigger.EDMVersion == 3 or (flags.Trigger.EDMVersion == 2 and flags.Trigger.doEDMVersionConversion):
431 from TrigNavSlimmingMT.TrigNavSlimmingMTConfig import AddRun3TrigNavSlimmingCollectionsToSlimmingHelper
432 AddRun3TrigNavSlimmingCollectionsToSlimmingHelper(EGAM10SlimmingHelper)
433
434 EGAM10ItemList = EGAM10SlimmingHelper.GetItemList()
435 acc.merge(
436 OutputStreamCfg(
437 flags,
438 "DAOD_EGAM10",
439 ItemList=EGAM10ItemList,
440 AcceptAlgs=["EGAM10Kernel"],
441 )
442 )
443 acc.merge(
444 SetupMetaDataForStreamCfg(
445 flags,
446 "DAOD_EGAM10",
447 AcceptAlgs=["EGAM10Kernel"],
448 createMetadata=[
449 MetadataCategory.CutFlowMetaData,
450 MetadataCategory.TruthMetaData,
451 ],
452 )
453 )
454
455 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, CaloCellDecoratorCfg)
114 acc.merge(CaloDecoratorKernelCfg(flags))
115
116 if decorateCells:
117 # For EGAM10, we want the to decorate only the photons
118 EGAM10CaloCellDecoratorTool = (
119 acc.popToolsAndMerge(
120 CaloCellDecoratorCfg(
121 flags,
122 name="EGAM10CaloCellDecoratorTool",
123 SGKey_photons="Photons",
124 SGKey_electrons="", # do not decorate electrons
125 SGKey_CaloCells="AllCalo",
126 )
127 )
128 )
129 acc.addPublicTool(EGAM10CaloCellDecoratorTool)
130 augmentationTools.append(EGAM10CaloCellDecoratorTool)
131
132 # thinning tools
133 thinningTools = []
134 streamName = kwargs["StreamName"]
135
136 # Track thinning
137 if flags.Derivation.Egamma.doTrackThinning:
138 TrackThinningKeepElectronTracks = True
139 TrackThinningKeepPhotonTracks = True
140 TrackThinningKeepAllElectronTracks = True
141
142 # Tracks associated with high-pT Electrons (deltaR=0.6)
143 if TrackThinningKeepElectronTracks:
144 EGAM10ElectronTPThinningTool = (
145 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
146 name="EGAM10ElectronTPThinningTool",
147 StreamName=streamName,
148 SGKey="Electrons",
149 GSFTrackParticlesKey="GSFTrackParticles",
150 InDetTrackParticlesKey="InDetTrackParticles",
151 SelectionString=electronRequirements,
152 BestMatchOnly=True,
153 ConeSize=0.6,
154 )
155 )
156 acc.addPublicTool(EGAM10ElectronTPThinningTool)
157 thinningTools.append(EGAM10ElectronTPThinningTool)
158
159 # Tracks associated with Photons
160 if TrackThinningKeepPhotonTracks:
161 EGAM10PhotonTPThinningTool = (
162 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
163 name="EGAM10PhotonTPThinningTool",
164 StreamName=streamName,
165 SGKey="Photons",
166 GSFTrackParticlesKey="GSFTrackParticles",
167 InDetTrackParticlesKey="InDetTrackParticles",
168 GSFConversionVerticesKey="GSFConversionVertices",
169 SelectionString=photonRequirements,
170 BestMatchOnly=False,
171 ConeSize=0.6,
172 )
173 )
174 acc.addPublicTool(EGAM10PhotonTPThinningTool)
175 thinningTools.append(EGAM10PhotonTPThinningTool)
176
177 # Tracks associated with all Electrons (for ambiguity resolver tool)
178 if TrackThinningKeepAllElectronTracks:
179 EGAM10ElectronTPThinningToolAR = (
180 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
181 name="EGAM10ElectronTPThinningToolAR",
182 StreamName=streamName,
183 SGKey="Electrons",
184 GSFTrackParticlesKey="GSFTrackParticles",
185 InDetTrackParticlesKey="InDetTrackParticles",
186 SelectionString=electronRequirements,
187 BestMatchOnly=True,
188 )
189 )
190 acc.addPublicTool(EGAM10ElectronTPThinningToolAR)
191 thinningTools.append(EGAM10ElectronTPThinningToolAR)
192
193 # skimming
194 skimmingTool = acc.getPrimaryAndMerge(EGAM10SkimmingToolCfg(flags))
195
196 # setup the kernel
197 acc.addEventAlgo(
198 CompFactory.DerivationFramework.DerivationKernel(
199 name,
200 SkimmingTools=[skimmingTool],
201 AugmentationTools=augmentationTools,
202 ThinningTools=thinningTools,
203 )
204 )
205
206 return acc
207
208

◆ 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.