ATLAS Offline Software
Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
DerivationFramework::GainDecorator Class Reference

#include <GainDecorator.h>

Inheritance diagram for DerivationFramework::GainDecorator:
Collaboration diagram for DerivationFramework::GainDecorator:

Classes

struct  calculation
 

Public Member Functions

 GainDecorator (const std::string &t, const std::string &n, const IInterface *p)
 
 ~GainDecorator ()
 
StatusCode initialize ()
 
StatusCode finalize ()
 
virtual StatusCode addBranches () const
 

Static Public Member Functions

static int getLayer (const CaloCell *cell)
 

Private Member Functions

calculation decorateObject (const xAOD::Egamma *&egamma) const
 

Private Attributes

SG::ReadHandleKey< xAOD::EgammaContainerm_SGKey_photons { this, "SGKey_photons", "", "SG key of photon container" }
 
SG::ReadHandleKey< xAOD::EgammaContainerm_SGKey_electrons
 
std::string m_decorationPattern
 
std::map< int, std::string > m_gainNames
 
std::vector< unsigned int > m_layers
 
std::map< std::pair< int, int >, std::string > m_names_E
 
std::map< std::pair< int, int >, std::string > m_names_rnoW
 
std::map< std::pair< int, int >, std::string > m_names_nCells
 
SG::WriteDecorHandleKeyArray< xAOD::EgammaContainerm_SGKey_photons_decorations
 
SG::WriteDecorHandleKeyArray< xAOD::EgammaContainerm_SGKey_electrons_decorations
 

Detailed Description

Definition at line 27 of file GainDecorator.h.

Constructor & Destructor Documentation

◆ GainDecorator()

DerivationFramework::GainDecorator::GainDecorator ( const std::string &  t,
const std::string &  n,
const IInterface *  p 
)

Definition at line 22 of file GainDecorator.cxx.

25  : base_class(t, n, p)
26 {
27  declareProperty("decoration_pattern",
28  m_decorationPattern = "{info}_Lr{layer}_{gain}G");
29  declareProperty("gain_names",
30  m_gainNames = { { CaloGain::LARHIGHGAIN, "Hi" },
31  { CaloGain::LARMEDIUMGAIN, "Med" },
32  { CaloGain::LARLOWGAIN, "Low" } });
33  declareProperty("layers", m_layers = { 0, 1, 2, 3 });
34 
35  // Define the names for the decorations
36  for (const auto& kv : m_gainNames)
37  for (const auto layer : m_layers) {
38  std::string name = m_decorationPattern;
39  name.replace(name.find("{layer}"),
40  std::string("{layer}").size(),
42  name.replace(
43  name.find("{gain}"), std::string("{gain}").size(), kv.second);
44  std::string name_E(name), name_rnoW(name), name_nCells(name);
45  name_E.replace(name_E.find("{info}"), std::string("{info}").size(), "E");
46  name_rnoW.replace(name_rnoW.find("{info}"), std::string("{info}").size(), "rnoW");
47  name_nCells.replace(
48  name_nCells.find("{info}"), std::string("{info}").size(), "nCells");
49 
50  std::pair<int, int> key(kv.first, layer);
51  m_names_E[key] = name_E;
52  m_names_rnoW[key] = name_rnoW;
53  m_names_nCells[key] = name_nCells;
54  }
55 
56  for (const auto& kv : m_names_E) {
57  ATH_MSG_DEBUG("Decorating (layer, gain): " << kv.first << " " << kv.second);
58  }
59  for (const auto& kv : m_names_nCells) {
60  ATH_MSG_DEBUG("Decorating (layer, gain): " << kv.first << " " << kv.second);
61  }
62 }

◆ ~GainDecorator()

DerivationFramework::GainDecorator::~GainDecorator ( )
default

Member Function Documentation

◆ addBranches()

StatusCode DerivationFramework::GainDecorator::addBranches ( ) const
virtual

Definition at line 129 of file GainDecorator.cxx.

130 {
131  const EventContext& ctx = Gaudi::Hive::currentContext();
132 
133  // Photon decorations
134 
135  if (!m_SGKey_photons.key().empty()) {
136 
137  // Retrieve photon container
139  const xAOD::EgammaContainer* importedPhotons = photonContainer.ptr();
140 
141  // Setup vectors of photon decorations
142  std::vector<SG::WriteDecorHandle<xAOD::EgammaContainer, float>>
143  decorations_E;
144  std::vector<SG::WriteDecorHandle<xAOD::EgammaContainer, float>>
145  decorations_rnoW;
146  std::vector<SG::WriteDecorHandle<xAOD::EgammaContainer, char>>
147  decorations_nCells;
148  int i(0);
149  for (const auto& kv : m_gainNames) {
150  for (const auto layer : m_layers) {
151  std::pair<int, int> key(kv.first, layer);
152  decorations_E.emplace_back(
153 
154  m_SGKey_photons_decorations[i * 3], ctx);
155  decorations_rnoW.emplace_back(
156 
157  m_SGKey_photons_decorations[i * 3 + 1], ctx);
158  decorations_nCells.emplace_back(
159 
160  m_SGKey_photons_decorations[i * 3 + 2], ctx);
161  i++;
162  }
163  }
164 
165  // Decorate photons
166  for (const auto* photon : *importedPhotons) {
169  i = 0;
170  for (const auto& kv : m_gainNames) {
171  for (const auto layer : m_layers) {
172  std::pair<int, int> key(kv.first, layer);
173  decorations_E[i](*photon) = res.E[key];
174  decorations_rnoW[i](*photon) =
175  res.EnoW[key] != 0 ? res.E[key]/res.EnoW[key] : 1;
176  decorations_nCells[i](*photon) = res.nCells[key];
177  i++;
178  }
179  }
180  }
181  }
182 
183  // Electron decorations
184 
185  if (!m_SGKey_electrons.key().empty()) {
186 
187  // Retrieve electron container
189  ctx);
190  const xAOD::EgammaContainer* importedElectrons = electronContainer.ptr();
191 
192  // Setup vectors of electron decorations
193  std::vector<SG::WriteDecorHandle<xAOD::EgammaContainer, float>>
194  decorations_E;
195  std::vector<SG::WriteDecorHandle<xAOD::EgammaContainer, float>>
196  decorations_rnoW;
197  std::vector<SG::WriteDecorHandle<xAOD::EgammaContainer, char>>
198  decorations_nCells;
199  int i(0);
200  for (const auto& kv : m_gainNames) {
201  for (const auto layer : m_layers) {
202  std::pair<int, int> key(kv.first, layer);
203  decorations_E.emplace_back(
204 
205  m_SGKey_electrons_decorations[i * 3], ctx);
206  decorations_rnoW.emplace_back(
207 
208  m_SGKey_electrons_decorations[i * 3 + 1], ctx);
209  decorations_nCells.emplace_back(
210 
211  m_SGKey_electrons_decorations[i * 3 + 2], ctx);
212  i++;
213  }
214  }
215 
216  // Decorate electrons
217  for (const auto* electron : *importedElectrons) {
220  i = 0;
221  for (const auto& kv : m_gainNames) {
222  for (const auto layer : m_layers) {
223  std::pair<int, int> key(kv.first, layer);
224  decorations_E[i](*electron) = res.E[key];
225  decorations_rnoW[i](*electron) =
226  res.EnoW[key] != 0 ? res.E[key]/res.EnoW[key] : 1;
227  decorations_nCells[i](*electron) = res.nCells[key];
228  i++;
229  }
230  }
231  }
232  }
233 
234  return StatusCode::SUCCESS;
235 }

◆ decorateObject()

DerivationFramework::GainDecorator::calculation DerivationFramework::GainDecorator::decorateObject ( const xAOD::Egamma *&  egamma) const
private

Definition at line 238 of file GainDecorator.cxx.

240 {
241 
242  // Compute energy and number of cells per gain per layer
243  // Set the initial values to 0 (needed?)
245  for (const auto& kv : m_names_E) {
246  result.E[kv.first] = 0.;
247  result.EnoW[kv.first] = 0.;
248  result.nCells[kv.first] = 0;
249  }
250 
251  // Skip the computation for missing cell links (like topo-seeded photons)
252  // but decorate anyway
253  const CaloClusterCellLink* cellLinks =
254  egamma->caloCluster() ? egamma->caloCluster()->getCellLinks() : nullptr;
255  if (cellLinks) {
257  itE = cellLinks->end();
258  for (; it != itE; ++it) {
259  const CaloCell *cell = *it;
260  if (!cell)
261  continue;
262  std::pair<int, int> key(static_cast<int>(cell->gain()), getLayer(cell));
263  // Increment the corresponding entry (not important if it is not
264  // initialised)
265  double weight = it.weight();
266  result.E[key] += cell->energy()*weight;
267  result.EnoW[key] += cell->energy();
268  result.nCells[key]++;
269  }
270  }
271 
272  return result;
273 }

◆ finalize()

StatusCode DerivationFramework::GainDecorator::finalize ( )

Definition at line 121 of file GainDecorator.cxx.

122 {
123 
124  return StatusCode::SUCCESS;
125 }

◆ getLayer()

int DerivationFramework::GainDecorator::getLayer ( const CaloCell cell)
static

Definition at line 276 of file GainDecorator.cxx.

277 {
278  int sampling =
279  (cell && cell->caloDDE() ? cell->caloDDE()->getSampling() : -1);
280  if (sampling == CaloSampling::PreSamplerB ||
281  sampling == CaloSampling::PreSamplerE)
282  return 0;
283  if (sampling == CaloSampling::EMB1 || sampling == CaloSampling::EME1)
284  return 1;
285  if (sampling == CaloSampling::EMB2 || sampling == CaloSampling::EME2)
286  return 2;
287  if (sampling == CaloSampling::EMB3 || sampling == CaloSampling::EME3)
288  return 3;
289  return -1;
290 }

◆ initialize()

StatusCode DerivationFramework::GainDecorator::initialize ( )

Definition at line 69 of file GainDecorator.cxx.

70 {
71  ATH_MSG_VERBOSE("initialize() ...");
72 
73  if (m_SGKey_photons.key().empty() && m_SGKey_electrons.key().empty()) {
74  ATH_MSG_FATAL("No e-gamma collection provided for thinning. At least one "
75  "egamma collection (photons/electrons) must be provided!");
76  return StatusCode::FAILURE;
77  }
78 
79  if (!m_SGKey_electrons.key().empty()) {
80  ATH_MSG_DEBUG("Using " << m_SGKey_electrons << " for electrons");
81  ATH_CHECK(m_SGKey_electrons.initialize());
82 
83  const std::string containerKey = m_SGKey_electrons.key();
84  for (const auto& kv : m_gainNames) {
85  for (const auto layer : m_layers) {
86  std::pair<int, int> key(kv.first, layer);
87  m_SGKey_electrons_decorations.emplace_back(containerKey + "." +
88  m_names_E[key]);
89  m_SGKey_electrons_decorations.emplace_back(containerKey + "." +
90  m_names_rnoW[key]);
91  m_SGKey_electrons_decorations.emplace_back(containerKey + "." +
93  }
94  }
96  }
97 
98  if (!m_SGKey_photons.key().empty()) {
99  ATH_MSG_DEBUG("Using " << m_SGKey_photons << " for photons");
100  ATH_CHECK(m_SGKey_photons.initialize());
101 
102  const std::string containerKey = m_SGKey_photons.key();
103  for (const auto& kv : m_gainNames) {
104  for (const auto layer : m_layers) {
105  std::pair<int, int> key(kv.first, layer);
106  m_SGKey_photons_decorations.emplace_back(containerKey + "." +
107  m_names_E[key]);
108  m_SGKey_photons_decorations.emplace_back(containerKey + "." +
109  m_names_rnoW[key]);
110  m_SGKey_photons_decorations.emplace_back(containerKey + "." +
112  }
113  }
115  }
116 
117  return StatusCode::SUCCESS;
118 }

Member Data Documentation

◆ m_decorationPattern

std::string DerivationFramework::GainDecorator::m_decorationPattern
private

Definition at line 57 of file GainDecorator.h.

◆ m_gainNames

std::map<int, std::string> DerivationFramework::GainDecorator::m_gainNames
private

Definition at line 58 of file GainDecorator.h.

◆ m_layers

std::vector<unsigned int> DerivationFramework::GainDecorator::m_layers
private

Definition at line 59 of file GainDecorator.h.

◆ m_names_E

std::map<std::pair<int, int>, std::string> DerivationFramework::GainDecorator::m_names_E
private

Definition at line 62 of file GainDecorator.h.

◆ m_names_nCells

std::map<std::pair<int, int>, std::string> DerivationFramework::GainDecorator::m_names_nCells
private

Definition at line 64 of file GainDecorator.h.

◆ m_names_rnoW

std::map<std::pair<int, int>, std::string> DerivationFramework::GainDecorator::m_names_rnoW
private

Definition at line 63 of file GainDecorator.h.

◆ m_SGKey_electrons

SG::ReadHandleKey<xAOD::EgammaContainer> DerivationFramework::GainDecorator::m_SGKey_electrons
private
Initial value:
{
this,
"SGKey_electrons",
"",
"SG key of electron container"
}

Definition at line 50 of file GainDecorator.h.

◆ m_SGKey_electrons_decorations

SG::WriteDecorHandleKeyArray<xAOD::EgammaContainer> DerivationFramework::GainDecorator::m_SGKey_electrons_decorations
private
Initial value:
{
this,
"SGKey_electrons_decorations_noConf",
{},
"SG keys for electrons decorations not really configurable"
}

Definition at line 75 of file GainDecorator.h.

◆ m_SGKey_photons

SG::ReadHandleKey<xAOD::EgammaContainer> DerivationFramework::GainDecorator::m_SGKey_photons { this, "SGKey_photons", "", "SG key of photon container" }
private

Definition at line 48 of file GainDecorator.h.

◆ m_SGKey_photons_decorations

SG::WriteDecorHandleKeyArray<xAOD::EgammaContainer> DerivationFramework::GainDecorator::m_SGKey_photons_decorations
private
Initial value:
{
this,
"SGKey_photons_decorations_noConf",
{},
"SG keys for photon decorations not really configurable"
}

Definition at line 67 of file GainDecorator.h.


The documentation for this class was generated from the following files:
electronContainer
xAOD::ElectronContainer * electronContainer
Definition: TrigGlobEffCorrValidation.cxx:187
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
get_generator_info.result
result
Definition: get_generator_info.py:21
constants.EMB1
int EMB1
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:53
ReadCellNoiseFromCool.cell
cell
Definition: ReadCellNoiseFromCool.py:53
DerivationFramework::GainDecorator::m_SGKey_photons_decorations
SG::WriteDecorHandleKeyArray< xAOD::EgammaContainer > m_SGKey_photons_decorations
Definition: GainDecorator.h:67
DerivationFramework::GainDecorator::m_SGKey_electrons_decorations
SG::WriteDecorHandleKeyArray< xAOD::EgammaContainer > m_SGKey_electrons_decorations
Definition: GainDecorator.h:75
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
skel.it
it
Definition: skel.GENtoEVGEN.py:407
DerivationFramework::GainDecorator::m_names_E
std::map< std::pair< int, int >, std::string > m_names_E
Definition: GainDecorator.h:62
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
TruthTest.itE
itE
Definition: TruthTest.py:25
egamma
Definition: egamma.h:58
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:189
DerivationFramework::GainDecorator::calculation
Definition: GainDecorator.h:40
DerivationFramework::GainDecorator::m_names_rnoW
std::map< std::pair< int, int >, std::string > m_names_rnoW
Definition: GainDecorator.h:63
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
DerivationFramework::GainDecorator::getLayer
static int getLayer(const CaloCell *cell)
Definition: GainDecorator.cxx:276
DerivationFramework::GainDecorator::m_decorationPattern
std::string m_decorationPattern
Definition: GainDecorator.h:57
constants.EMB2
int EMB2
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:54
lumiFormat.i
int i
Definition: lumiFormat.py:85
DerivationFramework::GainDecorator::m_SGKey_photons
SG::ReadHandleKey< xAOD::EgammaContainer > m_SGKey_photons
Definition: GainDecorator.h:48
beamspotman.n
n
Definition: beamspotman.py:731
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
res
std::pair< std::vector< unsigned int >, bool > res
Definition: JetGroupProductTest.cxx:11
constants.EME1
int EME1
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:55
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
photonContainer
xAOD::PhotonContainer * photonContainer
Definition: TrigGlobEffCorrValidation.cxx:189
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
DerivationFramework::GainDecorator::m_names_nCells
std::map< std::pair< int, int >, std::string > m_names_nCells
Definition: GainDecorator.h:64
DerivationFramework::GainDecorator::m_gainNames
std::map< int, std::string > m_gainNames
Definition: GainDecorator.h:58
CaloCell_ID_FCS::EME3
@ EME3
Definition: FastCaloSim_CaloCell_ID.h:26
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
CaloGain::LARHIGHGAIN
@ LARHIGHGAIN
Definition: CaloGain.h:18
CaloGain::LARMEDIUMGAIN
@ LARMEDIUMGAIN
Definition: CaloGain.h:18
xAOD::photon
@ photon
Definition: TrackingPrimitives.h:200
CaloCell
Data object for each calorimeter readout cell.
Definition: CaloCell.h:57
CaloCell_ID_FCS::PreSamplerE
@ PreSamplerE
Definition: FastCaloSim_CaloCell_ID.h:23
CaloCell_ID_FCS::PreSamplerB
@ PreSamplerB
Definition: FastCaloSim_CaloCell_ID.h:19
xAOD::EgammaParameters::electron
@ electron
Definition: EgammaEnums.h:18
DerivationFramework::GainDecorator::m_SGKey_electrons
SG::ReadHandleKey< xAOD::EgammaContainer > m_SGKey_electrons
Definition: GainDecorator.h:50
CaloGain::LARLOWGAIN
@ LARLOWGAIN
Definition: CaloGain.h:18
DerivationFramework::GainDecorator::m_layers
std::vector< unsigned int > m_layers
Definition: GainDecorator.h:59
CaloCell_ID_FCS::EMB3
@ EMB3
Definition: FastCaloSim_CaloCell_ID.h:22
DerivationFramework::GainDecorator::decorateObject
calculation decorateObject(const xAOD::Egamma *&egamma) const
Definition: GainDecorator.cxx:238
constants.EME2
int EME2
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:56
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37