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