ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
DerivationFramework
DerivationFrameworkCalo
python
DerivationFrameworkCaloConfig.py
Go to the documentation of this file.
1
# Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
2
3
from
AthenaConfiguration.ComponentAccumulator
import
ComponentAccumulator
4
from
AthenaConfiguration.ComponentFactory
import
CompFactory
5
6
def
CaloCellDecoratorCfg
(flags, **kwargs):
7
acc = ComponentAccumulator()
8
kwargs.setdefault(
"SGKey_electrons"
, flags.Egamma.Keys.Output.Electrons)
9
kwargs.setdefault(
"SGKey_photons"
, flags.Egamma.Keys.Output.Photons)
10
kwargs.setdefault(
"SGKey_CaloCells"
, flags.Egamma.Keys.Input.CaloCells)
11
12
from
egammaCaloTools.egammaCaloToolsConfig
import
egammaLargeClusterCellRecoveryToolCfg
13
kwargs.setdefault(
"egammaLargeClusterCellRecoveryTool"
,
14
acc.popToolsAndMerge(egammaLargeClusterCellRecoveryToolCfg(flags)))
15
16
acc.setPrivateTools(CompFactory.DerivationFramework.CaloCellDecorator(**kwargs))
17
from
LArCabling.LArCablingConfig
import
LArOnOffIdMappingCfg
18
19
acc.merge(LArOnOffIdMappingCfg(flags))
20
return
acc
21
22
23
def
MaxCellDecoratorCfg
(flags, name="MaxCellDecorator", **kwargs):
24
acc = ComponentAccumulator()
25
kwargs.setdefault(
"SGKey_electrons"
, flags.Egamma.Keys.Output.Electrons)
26
baseDecorations =[
"maxEcell_time"
,
"maxEcell_energy"
,
"maxEcell_gain"
,
27
"maxEcell_onlId"
,
"maxEcell_x"
,
"maxEcell_y"
,
"maxEcell_z"
]
28
electronDecorations = baseDecorations
29
kwargs.setdefault(
"SGKey_egammaClusters"
,
""
)
30
if
kwargs[
"SGKey_egammaClusters"
] !=
''
:
31
electronDecorations += [
"dR"
]
32
kwargs.setdefault(
"SGKey_electrons_decorations"
, electronDecorations)
33
kwargs.setdefault(
"SGKey_photons"
, flags.Egamma.Keys.Output.Photons)
34
35
# MaxCellDecorator looks at cells, but accesses them only via links,
36
# so the scheduler doesn't see the dependency. Add it explicitly using
37
# ExtraInputs.
38
kwargs.setdefault(
"ExtraInputs"
, [(
"CaloCellContainer"
, flags.Egamma.Keys.Input.CaloCells)])
39
40
acc.setPrivateTools(CompFactory.DerivationFramework.MaxCellDecorator(name, **kwargs))
41
from
LArCabling.LArCablingConfig
import
LArOnOffIdMappingCfg
42
43
acc.merge(LArOnOffIdMappingCfg(flags))
44
return
acc
45
46
47
def
GainDecoratorCfg
(flags, **kwargs):
48
acc = ComponentAccumulator()
49
decorationPattern = kwargs.pop(
"decoration_pattern"
,
"{}_Lr{}_{}G"
)
50
kwargs.setdefault(
"gain_names"
, { 0 :
"Hi"
, 1 :
"Med"
, 2 :
"Low"
})
51
kwargs.setdefault(
"layers"
, [0, 1, 2, 3])
52
decorNames = []
53
for
x, gain
in
kwargs[
"gain_names"
].items():
54
for
layer
in
kwargs[
"layers"
]:
55
decorNames += [decorationPattern.format(
"E"
, layer, gain)]
56
decorNames += [decorationPattern.format(
"rnoW"
, layer, gain)]
57
decorNames += [decorationPattern.format(
"nCells"
, layer, gain)]
58
kwargs.setdefault(
"SGKey_electrons"
, flags.Egamma.Keys.Output.Electrons)
59
kwargs.setdefault(
"SGKey_electrons_decorations"
, decorNames)
60
kwargs.setdefault(
"SGKey_photons"
, flags.Egamma.Keys.Output.Photons)
61
kwargs.setdefault(
"SGKey_photons_decorations"
, decorNames)
62
kwargs.setdefault(
"name"
,
"GainDecor"
)
63
acc.setPrivateTools(CompFactory.DerivationFramework.GainDecorator(**kwargs))
64
return
acc
65
66
67
def
EgammaCoreCellRecoveryCfg
(flags, **kwargs):
68
acc = ComponentAccumulator()
69
# needed for reading cells, do not rely on other config to do that
70
from
LArGeoAlgsNV.LArGMConfig
import
LArGMCfg
71
acc.merge(LArGMCfg(flags))
72
from
TileGeoModel.TileGMConfig
import
TileGMCfg
73
acc.merge(TileGMCfg(flags))
74
#
75
acc.setPrivateTools(
76
CompFactory.DerivationFramework.EGammaClusterCoreCellRecovery(**kwargs)
77
)
78
return
acc
79
80
81
def
CaloFillRectangularClusterCfg
(flags, **kwargs):
82
acc = ComponentAccumulator()
83
kwargs.setdefault(
"cells_name"
, flags.Egamma.Keys.Input.CaloCells)
84
kwargs.setdefault(
"fill_cluster"
,
True
)
85
acc.setPrivateTools(CompFactory.CaloFillRectangularCluster(**kwargs))
86
return
acc
87
88
89
def
ClusterEnergyPerLayerDecoratorCfg
(flags, **kwargs):
90
acc = ComponentAccumulator()
91
kwargs.setdefault(
"SGKey_electrons"
, flags.Egamma.Keys.Output.Electrons)
92
kwargs.setdefault(
"SGKey_photons"
, flags.Egamma.Keys.Output.Photons)
93
kwargs.setdefault(
"SGKey_caloCells"
, flags.Egamma.Keys.Input.CaloCells)
94
neta = kwargs.pop(
"neta"
, 5)
95
nphi = kwargs.pop(
"nphi"
, 5)
96
kwargs.setdefault(
"layers"
, [ 0, 1, 2, 3 ])
97
decorBase =
"E{}x{}_Lr"
.format(neta, nphi)
98
kwargs.setdefault(
"SGKey_photons_decorations"
, [decorBase+str(layer)
for
layer
in
kwargs[
'layers'
]])
99
kwargs.setdefault(
"SGKey_electrons_decorations"
, [decorBase+str(layer)
for
layer
in
kwargs[
'layers'
]])
100
toolArgs = {}
101
toolArgs.update({
"eta_size"
: neta})
102
toolArgs.update({
"phi_size"
: nphi})
103
kwargs.setdefault(
104
"CaloFillRectangularClusterTool"
,
105
acc.popToolsAndMerge(
CaloFillRectangularClusterCfg
(flags, **toolArgs)),
106
)
107
acc.setPrivateTools(
108
CompFactory.DerivationFramework.ClusterEnergyPerLayerDecorator(**kwargs)
109
)
110
return
acc
111
112
113
def
CaloCellDecoratorKernelCfg
(flags, name="CaloCellDecoratorKernel", **kwargs):
114
acc = ComponentAccumulator()
115
116
augmentationTools = [
117
acc.addPublicTool(acc.popToolsAndMerge(
CaloCellDecoratorCfg
(flags)))
118
]
119
120
kwargs.setdefault(
"AugmentationTools"
, augmentationTools)
121
122
acc.addEventAlgo(CompFactory.DerivationFramework.DerivationKernel(name, **kwargs))
123
return
acc
124
125
126
def
MaxCellDecoratorKernelCfg
(flags, name="MaxCellDecoratorKernel", **kwargs):
127
acc = ComponentAccumulator()
128
129
augmentationTools = [
130
acc.addPublicTool(acc.popToolsAndMerge(
MaxCellDecoratorCfg
(flags)))
131
]
132
133
kwargs.setdefault(
"AugmentationTools"
, augmentationTools)
134
135
acc.addEventAlgo(CompFactory.DerivationFramework.DerivationKernel(name, **kwargs))
136
return
acc
137
138
139
def
CaloDecoratorKernelCfg
(flags, name="CaloDecoratorKernel", **kwargs):
140
acc =
MaxCellDecoratorKernelCfg
(flags)
141
142
augmentationTools = [
143
acc.addPublicTool(acc.popToolsAndMerge(
GainDecoratorCfg
(flags)))
144
]
145
146
# might need some modification if cell-level reweighting is implemented
147
cluster_sizes = (3, 7), (5, 5), (7, 11)
148
for
neta, nphi
in
cluster_sizes:
149
cename =
"ClusterEnergyPerLayerDecorator_%sx%s"
% (neta, nphi)
150
ClusterEnergyPerLayerDecorator = acc.popToolsAndMerge(
151
ClusterEnergyPerLayerDecoratorCfg
(flags, neta=neta, nphi=nphi, name=cename)
152
)
153
augmentationTools.append(acc.addPublicTool(ClusterEnergyPerLayerDecorator))
154
155
kwargs.setdefault(
"AugmentationTools"
, augmentationTools)
156
157
acc.addEventAlgo(CompFactory.DerivationFramework.DerivationKernel(name, **kwargs))
158
return
acc
159
160
161
def
CaloClusterThinningCfg
(flags, **kwargs):
162
acc = ComponentAccumulator()
163
CaloClusterThinning = CompFactory.DerivationFramework.CaloClusterThinning
164
acc.addPublicTool(CaloClusterThinning(**kwargs), primary=
True
)
165
return
acc
166
167
def
JetCaloClusterThinningCfg
(flags, **kwargs):
168
acc = ComponentAccumulator()
169
JetCaloClusterThinning = CompFactory.DerivationFramework.JetCaloClusterThinning
170
acc.addPublicTool(JetCaloClusterThinning(**kwargs), primary=
True
)
171
return
acc
172
173
176
177
178
def
getGainLayerNames
(tool):
179
"""getGainLayerNames( tool ) -> return a list of names of the decorations added to the
180
egamma tool, given the GainDecorator tool"""
181
return
[
182
tool.decoration_pattern.format(info=info, layer=layer, gain=gain)
183
for
info
in
[
"E"
,
"nCells"
]
184
for
layer
in
tool.layers
185
for
gain
in
tool.gain_names.values()
186
]
187
188
189
def
getGainDecorations
(
190
acc,
191
flags,
192
kernel,
193
collections=None,
194
info=["E", "nCells"],
195
):
196
"""getGainDecorations( acc, kernel collections=["Electrons", "Photons"] ) ->
197
Return a list with the 'ExtraContent' to be added to the decorations to save the gain
198
information per layer"""
199
200
if collections is None:
201
collections = [flags.Egamma.Keys.Output.Electrons, flags.Egamma.Keys.Output.Photons]
202
203
GainDecoratorTool = None
204
for tool in acc.getEventAlgo(kernel).AugmentationTools:
205
if tool.getType() == "DerivationFramework::GainDecorator":
206
GainDecoratorTool = tool
207
208
if GainDecoratorTool:
209
return [
210
"{part}.{info}".format(part=part, info=info)
211
for part in collections
212
for info in getGainLayerNames(GainDecoratorTool)
213
]
214
else:
215
return ""
216
217
218
def getClusterEnergyPerLayerDecorations(acc, kernel):
219
"""
getClusterEnergyPerLayerDecorationsLegacy( acc, kernel ) -> return a list of names of the
220
decorations added to the egamma object, given the ClusterEnergyPerLayerDecorations
221
object (e.g. Photons.E7x11_Lr0, ...)"""
222
properties = "SGKey_photons", "SGKey_electrons"
223
ClusterEnergyPerLayerDecorators = []
224
for tool in acc.getEventAlgo(kernel).AugmentationTools:
225
if tool.getType() == "DerivationFramework::ClusterEnergyPerLayerDecorator":
226
ClusterEnergyPerLayerDecorators.append(tool)
227
228
decorations = []
229
for tool in ClusterEnergyPerLayerDecorators:
230
collections = filter(bool, (getattr(tool, x) for x in properties))
231
for part in collections:
232
key = "SGKey_{}_decorations".format(str(part).lower())
233
decorations.extend(getattr(tool, key))
234
return decorations
DerivationFrameworkCaloConfig.JetCaloClusterThinningCfg
JetCaloClusterThinningCfg(flags, **kwargs)
Definition
DerivationFrameworkCaloConfig.py:167
DerivationFrameworkCaloConfig.GainDecoratorCfg
GainDecoratorCfg(flags, **kwargs)
Definition
DerivationFrameworkCaloConfig.py:47
DerivationFrameworkCaloConfig.MaxCellDecoratorKernelCfg
MaxCellDecoratorKernelCfg(flags, name="MaxCellDecoratorKernel", **kwargs)
Definition
DerivationFrameworkCaloConfig.py:126
DerivationFrameworkCaloConfig.ClusterEnergyPerLayerDecoratorCfg
ClusterEnergyPerLayerDecoratorCfg(flags, **kwargs)
Definition
DerivationFrameworkCaloConfig.py:89
DerivationFrameworkCaloConfig.CaloFillRectangularClusterCfg
CaloFillRectangularClusterCfg(flags, **kwargs)
Definition
DerivationFrameworkCaloConfig.py:81
DerivationFrameworkCaloConfig.MaxCellDecoratorCfg
MaxCellDecoratorCfg(flags, name="MaxCellDecorator", **kwargs)
Definition
DerivationFrameworkCaloConfig.py:23
DerivationFrameworkCaloConfig.CaloCellDecoratorKernelCfg
CaloCellDecoratorKernelCfg(flags, name="CaloCellDecoratorKernel", **kwargs)
Definition
DerivationFrameworkCaloConfig.py:113
DerivationFrameworkCaloConfig.getGainDecorations
getGainDecorations(acc, flags, kernel, collections=None, info=["E", "nCells"])
Definition
DerivationFrameworkCaloConfig.py:195
DerivationFrameworkCaloConfig.CaloCellDecoratorCfg
CaloCellDecoratorCfg(flags, **kwargs)
Definition
DerivationFrameworkCaloConfig.py:6
DerivationFrameworkCaloConfig.CaloDecoratorKernelCfg
CaloDecoratorKernelCfg(flags, name="CaloDecoratorKernel", **kwargs)
Definition
DerivationFrameworkCaloConfig.py:139
DerivationFrameworkCaloConfig.getGainLayerNames
getGainLayerNames(tool)
additional utilities to return the list of decorations added by the tools
Definition
DerivationFrameworkCaloConfig.py:178
DerivationFrameworkCaloConfig.CaloClusterThinningCfg
CaloClusterThinningCfg(flags, **kwargs)
Definition
DerivationFrameworkCaloConfig.py:161
DerivationFrameworkCaloConfig.EgammaCoreCellRecoveryCfg
EgammaCoreCellRecoveryCfg(flags, **kwargs)
Definition
DerivationFrameworkCaloConfig.py:67
Generated on
for ATLAS Offline Software by
1.17.0