ATLAS Offline Software
DerivationFrameworkCaloConfig.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2025 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):
8  kwargs.setdefault("SGKey_electrons", flags.Egamma.Keys.Output.Electrons)
9  kwargs.setdefault("SGKey_photons", flags.Egamma.Keys.Output.Photons)
10  acc.setPrivateTools(CompFactory.DerivationFramework.CaloCellDecorator(**kwargs))
11  from LArCabling.LArCablingConfig import LArOnOffIdMappingCfg
12 
13  acc.merge(LArOnOffIdMappingCfg(flags))
14  return acc
15 
16 
17 def MaxCellDecoratorCfg(flags, **kwargs):
18  acc = ComponentAccumulator()
19  kwargs.setdefault("SGKey_electrons", flags.Egamma.Keys.Output.Electrons)
20  kwargs.setdefault("SGKey_photons", flags.Egamma.Keys.Output.Photons)
21  acc.setPrivateTools(CompFactory.DerivationFramework.MaxCellDecorator(**kwargs))
22  from LArCabling.LArCablingConfig import LArOnOffIdMappingCfg
23 
24  acc.merge(LArOnOffIdMappingCfg(flags))
25  return acc
26 
27 
28 def GainDecoratorCfg(flags, **kwargs):
29  acc = ComponentAccumulator()
30  kwargs.setdefault("SGKey_electrons", flags.Egamma.Keys.Output.Electrons)
31  kwargs.setdefault("SGKey_photons", flags.Egamma.Keys.Output.Photons)
32  kwargs.setdefault("name", "GainDecor")
33  acc.setPrivateTools(CompFactory.DerivationFramework.GainDecorator(**kwargs))
34  return acc
35 
36 
37 def EgammaCoreCellRecoveryCfg(flags, **kwargs):
38  acc = ComponentAccumulator()
39  # needed for reading cells, do not rely on other config to do that
40  from LArGeoAlgsNV.LArGMConfig import LArGMCfg
41  acc.merge(LArGMCfg(flags))
42  from TileGeoModel.TileGMConfig import TileGMCfg
43  acc.merge(TileGMCfg(flags))
44  #
45  acc.setPrivateTools(
46  CompFactory.DerivationFramework.EGammaClusterCoreCellRecovery(**kwargs)
47  )
48  return acc
49 
50 
51 def CaloFillRectangularClusterCfg(flags, **kwargs):
52  acc = ComponentAccumulator()
53  kwargs.setdefault("cells_name", flags.Egamma.Keys.Input.CaloCells)
54  kwargs.setdefault("fill_cluster", True)
55  acc.setPrivateTools(CompFactory.CaloFillRectangularCluster(**kwargs))
56  return acc
57 
58 
59 def ClusterEnergyPerLayerDecoratorCfg(flags, **kwargs):
60  acc = ComponentAccumulator()
61  kwargs.setdefault("SGKey_electrons", flags.Egamma.Keys.Output.Electrons)
62  kwargs.setdefault("SGKey_photons", flags.Egamma.Keys.Output.Photons)
63  kwargs.setdefault("SGKey_caloCells", flags.Egamma.Keys.Input.CaloCells)
64  kwargs.setdefault("neta", 5)
65  kwargs.setdefault("nphi", 5)
66  toolArgs = {}
67  toolArgs.update({"eta_size": kwargs["neta"]})
68  toolArgs.update({"phi_size": kwargs["nphi"]})
69  kwargs.setdefault(
70  "CaloFillRectangularClusterTool",
71  acc.popToolsAndMerge(CaloFillRectangularClusterCfg(flags, **toolArgs)),
72  )
73  acc.setPrivateTools(
74  CompFactory.DerivationFramework.ClusterEnergyPerLayerDecorator(**kwargs)
75  )
76  return acc
77 
78 
79 def CaloCellDecoratorKernelCfg(flags, name="CaloCellDecoratorKernel", **kwargs):
80  acc = ComponentAccumulator()
81 
82  augmentationTools = [
83  acc.addPublicTool(acc.popToolsAndMerge(CaloCellDecoratorCfg(flags)))
84  ]
85 
86  kwargs.setdefault("AugmentationTools", augmentationTools)
87 
88  acc.addEventAlgo(CompFactory.DerivationFramework.DerivationKernel(name, **kwargs))
89  return acc
90 
91 
92 def MaxCellDecoratorKernelCfg(flags, name="MaxCellDecoratorKernel", **kwargs):
93  acc = ComponentAccumulator()
94 
95  augmentationTools = [
96  acc.addPublicTool(acc.popToolsAndMerge(MaxCellDecoratorCfg(flags)))
97  ]
98 
99  kwargs.setdefault("AugmentationTools", augmentationTools)
100 
101  acc.addEventAlgo(CompFactory.DerivationFramework.DerivationKernel(name, **kwargs))
102  return acc
103 
104 
105 def CaloDecoratorKernelCfg(flags, name="CaloDecoratorKernel", **kwargs):
106  acc = MaxCellDecoratorKernelCfg(flags)
107 
108  augmentationTools = [
109  acc.addPublicTool(acc.popToolsAndMerge(GainDecoratorCfg(flags)))
110  ]
111 
112  # might need some modification if cell-level reweighting is implemented
113  cluster_sizes = (3, 7), (5, 5), (7, 11)
114  for neta, nphi in cluster_sizes:
115  cename = "ClusterEnergyPerLayerDecorator_%sx%s" % (neta, nphi)
116  ClusterEnergyPerLayerDecorator = acc.popToolsAndMerge(
117  ClusterEnergyPerLayerDecoratorCfg(flags, neta=neta, nphi=nphi, name=cename)
118  )
119  augmentationTools.append(acc.addPublicTool(ClusterEnergyPerLayerDecorator))
120 
121  kwargs.setdefault("AugmentationTools", augmentationTools)
122 
123  acc.addEventAlgo(CompFactory.DerivationFramework.DerivationKernel(name, **kwargs))
124  return acc
125 
126 
127 def CaloClusterThinningCfg(flags, **kwargs):
128  acc = ComponentAccumulator()
129  CaloClusterThinning = CompFactory.DerivationFramework.CaloClusterThinning
130  acc.addPublicTool(CaloClusterThinning(**kwargs), primary=True)
131  return acc
132 
133 def JetCaloClusterThinningCfg(flags, **kwargs):
134  acc = ComponentAccumulator()
135  JetCaloClusterThinning = CompFactory.DerivationFramework.JetCaloClusterThinning
136  acc.addPublicTool(JetCaloClusterThinning(**kwargs), primary=True)
137  return acc
138 
139 
142 
143 
145  """getGainLayerNames( tool ) -> return a list of names of the decorations added to the
146  egamma tool, given the GainDecorator tool"""
147  return [
148  tool.decoration_pattern.format(info=info, layer=layer, gain=gain)
149  for info in ["E", "nCells"]
150  for layer in tool.layers
151  for gain in tool.gain_names.values()
152  ]
153 
154 
156  acc,
157  flags,
158  kernel,
159  collections=None,
160  info=["E", "nCells"],
161 ):
162  """getGainDecorations( acc, kernel collections=["Electrons", "Photons"] ) ->
163  Return a list with the 'ExtraContent' to be added to the decorations to save the gain
164  information per layer"""
165 
166  if collections is None:
167  collections = [flags.Egamma.Keys.Output.Electrons, flags.Egamma.Keys.Output.Photons]
168 
169  GainDecoratorTool = None
170  for tool in acc.getEventAlgo(kernel).AugmentationTools:
171  if tool.getType() == "DerivationFramework::GainDecorator":
172  GainDecoratorTool = tool
173 
174  if GainDecoratorTool:
175  return [
176  "{part}.{info}".format(part=part, info=info)
177  for part in collections
178  for info in getGainLayerNames(GainDecoratorTool)
179  ]
180  else:
181  return ""
182 
183 
185  """getClusterEnergyPerLayerDecorationsLegacy( acc, kernel ) -> return a list of names of the
186  decorations added to the egamma object, given the ClusterEnergyPerLayerDecorations
187  object (e.g. Photons.E7x11_Lr0, ...)"""
188  properties = "SGKey_photons", "SGKey_electrons"
189  ClusterEnergyPerLayerDecorators = []
190  for tool in acc.getEventAlgo(kernel).AugmentationTools:
191  if tool.getType() == "DerivationFramework::ClusterEnergyPerLayerDecorator":
192  ClusterEnergyPerLayerDecorators.append(tool)
193 
194  decorations = []
195  for tool in ClusterEnergyPerLayerDecorators:
196  collections = filter(bool, (getattr(tool, x) for x in properties))
197  for part in collections:
198  for layer in tool.layers:
199  decorations.extend(
200  [
201  "{part}.E{neta}x{nphi}_Lr{layer}".format(
202  part=part,
203  neta=tool.neta,
204  nphi=tool.nphi,
205  layer=layer,
206  )
207  ]
208  )
209  return decorations
DerivationFrameworkCaloConfig.CaloClusterThinningCfg
def CaloClusterThinningCfg(flags, **kwargs)
Definition: DerivationFrameworkCaloConfig.py:127
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
vtune_athena.format
format
Definition: vtune_athena.py:14
DerivationFrameworkCaloConfig.JetCaloClusterThinningCfg
def JetCaloClusterThinningCfg(flags, **kwargs)
Definition: DerivationFrameworkCaloConfig.py:133
DerivationFrameworkCaloConfig.CaloCellDecoratorKernelCfg
def CaloCellDecoratorKernelCfg(flags, name="CaloCellDecoratorKernel", **kwargs)
Definition: DerivationFrameworkCaloConfig.py:79
DerivationFrameworkCaloConfig.MaxCellDecoratorCfg
def MaxCellDecoratorCfg(flags, **kwargs)
Definition: DerivationFrameworkCaloConfig.py:17
covarianceTool.filter
filter
Definition: covarianceTool.py:514
DerivationFrameworkCaloConfig.EgammaCoreCellRecoveryCfg
def EgammaCoreCellRecoveryCfg(flags, **kwargs)
Definition: DerivationFrameworkCaloConfig.py:37
DerivationFrameworkCaloConfig.GainDecoratorCfg
def GainDecoratorCfg(flags, **kwargs)
Definition: DerivationFrameworkCaloConfig.py:28
DerivationFrameworkCaloConfig.getGainLayerNames
def getGainLayerNames(tool)
additional utilities to return the list of decorations added by the tools
Definition: DerivationFrameworkCaloConfig.py:144
DerivationFrameworkCaloConfig.ClusterEnergyPerLayerDecoratorCfg
def ClusterEnergyPerLayerDecoratorCfg(flags, **kwargs)
Definition: DerivationFrameworkCaloConfig.py:59
DerivationFrameworkCaloConfig.MaxCellDecoratorKernelCfg
def MaxCellDecoratorKernelCfg(flags, name="MaxCellDecoratorKernel", **kwargs)
Definition: DerivationFrameworkCaloConfig.py:92
LArCablingConfig.LArOnOffIdMappingCfg
def LArOnOffIdMappingCfg(configFlags)
Definition: LArCablingConfig.py:62
LArGMConfig.LArGMCfg
def LArGMCfg(flags)
Definition: LArGMConfig.py:8
DerivationFrameworkCaloConfig.CaloCellDecoratorCfg
def CaloCellDecoratorCfg(flags, **kwargs)
Definition: DerivationFrameworkCaloConfig.py:6
DerivationFrameworkCaloConfig.CaloDecoratorKernelCfg
def CaloDecoratorKernelCfg(flags, name="CaloDecoratorKernel", **kwargs)
Definition: DerivationFrameworkCaloConfig.py:105
DerivationFrameworkCaloConfig.getClusterEnergyPerLayerDecorations
def getClusterEnergyPerLayerDecorations(acc, kernel)
Definition: DerivationFrameworkCaloConfig.py:184
DerivationFrameworkCaloConfig.getGainDecorations
def getGainDecorations(acc, flags, kernel, collections=None, info=["E", "nCells"])
Definition: DerivationFrameworkCaloConfig.py:155
DerivationFrameworkCaloConfig.CaloFillRectangularClusterCfg
def CaloFillRectangularClusterCfg(flags, **kwargs)
Definition: DerivationFrameworkCaloConfig.py:51
TileGMConfig.TileGMCfg
def TileGMCfg(flags)
Definition: TileGMConfig.py:7