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

#include <EGammaClusterCoreCellRecovery.h>

Inheritance diagram for DerivationFramework::EGammaClusterCoreCellRecovery:
Collaboration diagram for DerivationFramework::EGammaClusterCoreCellRecovery:

Public Member Functions

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

Private Member Functions

IegammaCellRecoveryTool::Info decorateObject (const xAOD::Egamma *&egamma) const
 
StatusCode findMaxECell (const xAOD::CaloCluster *clus, double &etamax, double &phimax) const
 

Private Attributes

SG::ReadHandleKey< xAOD::EgammaContainerm_SGKey_photons { this, "SGKey_photons", "Photons", "SG key of photon container" }
 
SG::ReadHandleKey< xAOD::EgammaContainerm_SGKey_electrons { this, "SGKey_electrons", "Electrons", "SG key of electron container" }
 
SG::ReadHandleKey< CaloCellContainerm_SGKey_CaloCells { this, "SGKey_CaloCells", "AllCalo", "SG key of calo cell container" }
 
SG::WriteDecorHandleKeyArray< xAOD::EgammaContainerm_SGKey_photons_decorations
 
SG::WriteDecorHandleKeyArray< xAOD::EgammaContainerm_SGKey_electrons_decorations
 
Gaudi::Property< bool > m_UseWeightForMaxCell
 
ToolHandle< IegammaCellRecoveryToolm_egammaCellRecoveryTool
 Pointer to the egammaCellRecoveryTool. More...
 

Detailed Description

Definition at line 28 of file EGammaClusterCoreCellRecovery.h.

Constructor & Destructor Documentation

◆ EGammaClusterCoreCellRecovery()

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

Definition at line 22 of file EGammaClusterCoreCellRecovery.cxx.

25  : base_class(t, n, p)
26 {
27 }

◆ ~EGammaClusterCoreCellRecovery()

DerivationFramework::EGammaClusterCoreCellRecovery::~EGammaClusterCoreCellRecovery ( )
default

Member Function Documentation

◆ addBranches()

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

Definition at line 92 of file EGammaClusterCoreCellRecovery.cxx.

93 {
94  const EventContext& ctx = Gaudi::Hive::currentContext();
95 
96  std::vector<SG::WriteDecorHandle<xAOD::EgammaContainer, char>> decon;
97  std::vector<SG::WriteDecorHandle<xAOD::EgammaContainer, float>> decoE;
98  decon.reserve(2);
99  decoE.reserve(2);
100 
101  // Photon decorations
102  if (!m_SGKey_photons.key().empty()) {
103 
104  for (int i = 0; i < 2; i++) {
105  decon.emplace_back(m_SGKey_photons_decorations[i * 2], ctx);
106  decoE.emplace_back(m_SGKey_photons_decorations[i * 2 + 1], ctx);
107  }
108 
109  // Retrieve photon container
111 
112  // Decorate photons
113  for (const auto* photon : *photonContainer.ptr()) {
115  for (int i = 0; i < 2; i++) {
116  decon[i](*photon) = res.nCells[i];
117  decoE[i](*photon) = res.eCells[i];
118  }
119  }
120  }
121 
122  // Electron decorations
123  if (!m_SGKey_electrons.key().empty()) {
124 
125  decon.clear(); decon.reserve(2);
126  decoE.clear(); decoE.reserve(2);
127 
128  for (int i = 0; i < 2; i++) {
129  decon.emplace_back(m_SGKey_electrons_decorations[i * 2], ctx);
130  decoE.emplace_back(m_SGKey_electrons_decorations[i * 2 + 1], ctx);
131  }
132 
133  // Retrieve electron container
135  ctx);
136 
137  // Decorate electrons
138  for (const auto* electron : *electronContainer.ptr()) {
140  for (int i = 0; i < 2; i++) {
141  decon[i](*electron) = res.nCells[i];
142  decoE[i](*electron) = res.eCells[i];
143  }
144  }
145  }
146 
147  return StatusCode::SUCCESS;
148 }

◆ decorateObject()

IegammaCellRecoveryTool::Info DerivationFramework::EGammaClusterCoreCellRecovery::decorateObject ( const xAOD::Egamma *&  egamma) const
private

Definition at line 151 of file EGammaClusterCoreCellRecovery.cxx.

153 {
155 
156  ATH_MSG_DEBUG("Trying to recover cell for object of type " << egamma->type()
157  << " pT = " << egamma->pt()
158  << " eta = " << egamma->eta()
159  << " phi = " << egamma->phi());
160 
161  const xAOD::CaloCluster *clus = egamma->caloCluster();
162  if (!clus) {
163  ATH_MSG_WARNING("No associated egamma cluster. Do nothing");
164  return info;
165  }
166 
167  // Find max energy cell in layer 2
168  double etamax = -999., phimax = -999.;
169  if (findMaxECell(clus,etamax,phimax).isFailure()) {
170  ATH_MSG_WARNING("Problem in finding maximum energy cell in layer 2");
171  return info;
172  }
173 
174  info.etamax = etamax;
175  info.phimax = phimax;
176  if (m_egammaCellRecoveryTool->execute(*clus,info).isFailure()) {
177  ATH_MSG_WARNING("Issue trying to recover cells");
178  }
179  return info;
180 }

◆ finalize()

StatusCode DerivationFramework::EGammaClusterCoreCellRecovery::finalize ( )
inline

Definition at line 36 of file EGammaClusterCoreCellRecovery.h.

36 { return StatusCode::SUCCESS; }

◆ findMaxECell()

StatusCode DerivationFramework::EGammaClusterCoreCellRecovery::findMaxECell ( const xAOD::CaloCluster clus,
double &  etamax,
double &  phimax 
) const
private

Definition at line 183 of file EGammaClusterCoreCellRecovery.cxx.

185 {
186  const CaloClusterCellLink* cellLinks = clus->getCellLinks();
187  if (!cellLinks) {
188  ATH_MSG_WARNING("No cell link for cluster. Do nothing");
189  return StatusCode::FAILURE;
190  }
191 
192  // First check :
193  // if we run in MT, this would be nullptr without initializing a ReadHandleKey
194  const CaloCellContainer *caloCells = cellLinks->getCellContainer();
195  if (!caloCells) {
196  ATH_MSG_WARNING("No cells for cluster. Do nothing");
197  return StatusCode::FAILURE;
198  }
199 
200  // Second check :
201  // one might have used a custom cell container for the linked cells
202  if (cellLinks->getCellContainerLink().dataID() != m_SGKey_CaloCells.key()) {
203  ATH_MSG_ERROR("Wrong key for the calo cells");
204  return StatusCode::FAILURE;
205  }
206 
207  CaloClusterCellLink::const_iterator it_cell = cellLinks->begin(),
208  it_cell_e = cellLinks->end();
209 
210  // find maximum cell energy in layer 2
211  double emax = 0.;
212  std::pair<const CaloCell*,double> maxcell{nullptr,0}; //just for debug
213  for(; it_cell != it_cell_e; ++it_cell) {
214  const CaloCell* cell = (*it_cell);
215  if (cell) {
216  if (!cell->caloDDE()) {
217  ATH_MSG_WARNING("Calo cell without detector element ?? eta = "
218  << cell->eta() << " phi = " << cell->phi());
219  continue;
220  }
221  int layer = cell->caloDDE()->getSampling();
223  double w = it_cell.weight();
224  double eCell = cell->energy();
225  if (m_UseWeightForMaxCell) eCell *= w;
226  if (eCell > emax) {
227  emax = eCell;
228  maxcell.first = cell;
229  maxcell.second = w;
230  }
231  }
232  }
233  }
234 
235  if (emax > 0) {
236  etamax = maxcell.first->caloDDE()->eta_raw();
237  phimax = maxcell.first->caloDDE()->phi_raw();
238  if (msgLvl(MSG::DEBUG)) {
239  CaloSampling::CaloSample sam = maxcell.first->caloDDE()->getSampling();
240  double etaAmax = clus->etamax(sam);
241  double phiAmax = clus->phimax(sam);
242  double vemax = clus->energy_max(sam);
243  ATH_MSG_DEBUG("Cluster energy in sampling 2 = " << clus->energyBE(2)
244  << " maximum layer 2 energy cell, E = " << maxcell.first->energy()
245  << " check E = " << vemax
246  << " w = " << maxcell.second << "\n"
247  << " in calo frame, eta = " << etamax << " phi = " << phimax << "\n"
248  << " in ATLAS frame, eta = " << etaAmax << " phi = " << phiAmax);
249  }
250  } else {
251  ATH_MSG_WARNING("No layer 2 cell with positive energy ! Should never happen");
252  return StatusCode::FAILURE;
253  }
254  return StatusCode::SUCCESS;
255 }

◆ initialize()

StatusCode DerivationFramework::EGammaClusterCoreCellRecovery::initialize ( )

Definition at line 32 of file EGammaClusterCoreCellRecovery.cxx.

33 {
34  ATH_MSG_VERBOSE("initialize() ...");
35 
36  // The main tool
38 
39  if (m_SGKey_photons.key().empty() && m_SGKey_electrons.key().empty()) {
40  ATH_MSG_FATAL("No e-gamma collection provided for thinning. At least one "
41  "egamma collection (photons/electrons) must be provided!");
42  return StatusCode::FAILURE;
43  }
44 
45  if (!m_SGKey_electrons.key().empty()) {
46  ATH_MSG_DEBUG("Using " << m_SGKey_electrons << " for electrons");
47  ATH_CHECK(m_SGKey_electrons.initialize());
48 
49  const std::string containerKey = m_SGKey_electrons.key();
50  for (int i = 2; i <= 3; i++) {
51  for (int t = 0; t <=1 ; t++) {
52  m_SGKey_electrons_decorations.emplace_back(
53  Form("%s.%sadded_Lr%d", containerKey.c_str(), (t == 0 ? "n" : "E"), i));
54  }
55  }
57  if (msgLvl(MSG::DEBUG)) {
58  ATH_MSG_DEBUG("Decorations for " << containerKey);
59  for (const auto& s : m_SGKey_electrons_decorations)
60  { ATH_MSG_DEBUG(s.key()); }
61  }
62  }
63 
64  // This tool needs the calo cells linked to the clusters...
66 
67  if (!m_SGKey_photons.key().empty()) {
68  ATH_MSG_DEBUG("Using " << m_SGKey_photons << " for photons");
69  ATH_CHECK(m_SGKey_photons.initialize());
70 
71  const std::string containerKey = m_SGKey_photons.key();
72  for (int i = 2; i <= 3; i++) {
73  for (int t = 0; t <= 1 ; t++) {
74  m_SGKey_photons_decorations.emplace_back(
75  Form("%s.%sadded_Lr%d", containerKey.c_str(), (t == 0 ? "n" : "E"), i));
76  }
77  }
79  if (msgLvl(MSG::DEBUG)) {
80  ATH_MSG_DEBUG("Decorations for " << containerKey);
81  for (const auto& s : m_SGKey_photons_decorations)
82  { ATH_MSG_DEBUG(s.key()); }
83  }
84  }
85 
86  return StatusCode::SUCCESS;
87 }

Member Data Documentation

◆ m_egammaCellRecoveryTool

ToolHandle<IegammaCellRecoveryTool> DerivationFramework::EGammaClusterCoreCellRecovery::m_egammaCellRecoveryTool
private
Initial value:
{
this,
"egammaCellRecoveryTool",
"egammaCellRecoveryTool/egammaCellRecoveryTool",
"Optional tool that adds cells in L2 or L3 "
"that could have been rejected by timing cut"
}

Pointer to the egammaCellRecoveryTool.

Definition at line 78 of file EGammaClusterCoreCellRecovery.h.

◆ m_SGKey_CaloCells

SG::ReadHandleKey<CaloCellContainer> DerivationFramework::EGammaClusterCoreCellRecovery::m_SGKey_CaloCells { this, "SGKey_CaloCells", "AllCalo", "SG key of calo cell container" }
private

Definition at line 46 of file EGammaClusterCoreCellRecovery.h.

◆ m_SGKey_electrons

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

Definition at line 43 of file EGammaClusterCoreCellRecovery.h.

◆ m_SGKey_electrons_decorations

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

Definition at line 58 of file EGammaClusterCoreCellRecovery.h.

◆ m_SGKey_photons

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

Definition at line 40 of file EGammaClusterCoreCellRecovery.h.

◆ m_SGKey_photons_decorations

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

Definition at line 50 of file EGammaClusterCoreCellRecovery.h.

◆ m_UseWeightForMaxCell

Gaudi::Property<bool> DerivationFramework::EGammaClusterCoreCellRecovery::m_UseWeightForMaxCell
private
Initial value:
{
this,
"UseWeightForMaxCell",
false,
"Use the cell weights when finding the L2 max energy cell"
}

Definition at line 65 of file EGammaClusterCoreCellRecovery.h.


The documentation for this class was generated from the following files:
xAOD::CaloCluster_v1::phimax
float phimax(const CaloSample sampling) const
Retrieve of cell with maximum energy in given sampling.
Definition: CaloCluster_v1.cxx:582
electronContainer
xAOD::ElectronContainer * electronContainer
Definition: TrigGlobEffCorrValidation.cxx:187
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
ReadCellNoiseFromCool.cell
cell
Definition: ReadCellNoiseFromCool.py:53
ParticleImpl::pt
virtual double pt() const
transverse momentum
Definition: ParticleImpl.h:554
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
IegammaCellRecoveryTool::Info
Definition: IegammaCellRecoveryTool.h:36
DerivationFramework::EGammaClusterCoreCellRecovery::m_SGKey_electrons_decorations
SG::WriteDecorHandleKeyArray< xAOD::EgammaContainer > m_SGKey_electrons_decorations
Definition: EGammaClusterCoreCellRecovery.h:58
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
DerivationFramework::EGammaClusterCoreCellRecovery::decorateObject
IegammaCellRecoveryTool::Info decorateObject(const xAOD::Egamma *&egamma) const
Definition: EGammaClusterCoreCellRecovery.cxx:151
DerivationFramework::EGammaClusterCoreCellRecovery::m_SGKey_CaloCells
SG::ReadHandleKey< CaloCellContainer > m_SGKey_CaloCells
Definition: EGammaClusterCoreCellRecovery.h:47
xAOD::CaloCluster_v1::etamax
float etamax(const CaloSample sampling) const
Retrieve of cell with maximum energy in given sampling.
Definition: CaloCluster_v1.cxx:569
egamma
Definition: egamma.h:58
xAOD::CaloCluster_v1
Description of a calorimeter cluster.
Definition: CaloCluster_v1.h:62
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:209
DerivationFramework::EGammaClusterCoreCellRecovery::m_SGKey_photons_decorations
SG::WriteDecorHandleKeyArray< xAOD::EgammaContainer > m_SGKey_photons_decorations
Definition: EGammaClusterCoreCellRecovery.h:50
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
constants.EMB2
int EMB2
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:54
lumiFormat.i
int i
Definition: lumiFormat.py:85
CaloSampling::CaloSample
CaloSample
Definition: Calorimeter/CaloGeoHelpers/CaloGeoHelpers/CaloSampling.h:22
xAOD::CaloCluster_v1::energy_max
float energy_max(const CaloSample sampling) const
Retrieve maximum cell energy in given sampling.
Definition: CaloCluster_v1.cxx:556
beamspotman.n
n
Definition: beamspotman.py:727
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
ParticleImpl::phi
virtual double phi() const
phi in [-pi,pi[
Definition: ParticleImpl.h:524
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
ParticleImpl::eta
virtual double eta() const
pseudo rapidity
Definition: ParticleImpl.h:514
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
xAOD::CaloCluster_v1::getCellLinks
const CaloClusterCellLink * getCellLinks() const
Get a pointer to the CaloClusterCellLink object (const version)
Definition: CaloCluster_v1.cxx:859
photonContainer
xAOD::PhotonContainer * photonContainer
Definition: TrigGlobEffCorrValidation.cxx:189
DerivationFramework::EGammaClusterCoreCellRecovery::m_egammaCellRecoveryTool
ToolHandle< IegammaCellRecoveryTool > m_egammaCellRecoveryTool
Pointer to the egammaCellRecoveryTool.
Definition: EGammaClusterCoreCellRecovery.h:78
CaloCellContainer
Container class for CaloCell.
Definition: CaloCellContainer.h:55
xAOD::photon
@ photon
Definition: TrackingPrimitives.h:200
CaloCell
Data object for each calorimeter readout cell.
Definition: CaloCell.h:57
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
DerivationFramework::EGammaClusterCoreCellRecovery::findMaxECell
StatusCode findMaxECell(const xAOD::CaloCluster *clus, double &etamax, double &phimax) const
Definition: EGammaClusterCoreCellRecovery.cxx:183
DEBUG
#define DEBUG
Definition: page_access.h:11
xAOD::CaloCluster_v1::energyBE
float energyBE(const unsigned layer) const
Get the energy in one layer of the EM Calo.
Definition: CaloCluster_v1.cxx:623
xAOD::EgammaParameters::electron
@ electron
Definition: EgammaEnums.h:18
python.SystemOfUnits.s
float s
Definition: SystemOfUnits.py:147
DerivationFramework::EGammaClusterCoreCellRecovery::m_SGKey_photons
SG::ReadHandleKey< xAOD::EgammaContainer > m_SGKey_photons
Definition: EGammaClusterCoreCellRecovery.h:41
DerivationFramework::EGammaClusterCoreCellRecovery::m_UseWeightForMaxCell
Gaudi::Property< bool > m_UseWeightForMaxCell
Definition: EGammaClusterCoreCellRecovery.h:65
python.IoTestsLib.w
def w
Definition: IoTestsLib.py:198
DerivationFramework::EGammaClusterCoreCellRecovery::m_SGKey_electrons
SG::ReadHandleKey< xAOD::EgammaContainer > m_SGKey_electrons
Definition: EGammaClusterCoreCellRecovery.h:44
python.ParticleTypeUtil.info
def info
Definition: ParticleTypeUtil.py:87
constants.EME2
int EME2
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:56