37 ATH_CHECK(m_egammaCellRecoveryTool.retrieve());
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;
45 if (!m_SGKey_electrons.key().empty()) {
46 ATH_MSG_DEBUG(
"Using " << m_SGKey_electrons <<
" for electrons");
47 ATH_CHECK(m_SGKey_electrons.initialize());
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));
56 ATH_CHECK(m_SGKey_electrons_decorations.initialize());
59 for (
const auto&
s : m_SGKey_electrons_decorations)
65 ATH_CHECK(m_SGKey_CaloCells.initialize());
67 if (!m_SGKey_photons.key().empty()) {
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));
78 ATH_CHECK(m_SGKey_photons_decorations.initialize());
81 for (
const auto&
s : m_SGKey_photons_decorations)
86 return StatusCode::SUCCESS;
94 const EventContext& ctx = Gaudi::Hive::currentContext();
96 std::vector<SG::WriteDecorHandle<xAOD::EgammaContainer, char>> decon;
97 std::vector<SG::WriteDecorHandle<xAOD::EgammaContainer, float>> decoE;
102 if (!m_SGKey_photons.key().empty()) {
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);
115 for (
int i = 0;
i < 2;
i++) {
116 decon[
i](*photon) =
res.nCells[
i];
117 decoE[
i](*photon) =
res.eCells[
i];
123 if (!m_SGKey_electrons.key().empty()) {
125 decon.clear(); decon.reserve(2);
126 decoE.clear(); decoE.reserve(2);
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);
140 for (
int i = 0;
i < 2;
i++) {
141 decon[
i](*electron) =
res.nCells[
i];
142 decoE[
i](*electron) =
res.eCells[
i];
147 return StatusCode::SUCCESS;
168 double etamax = -999., phimax = -999.;
169 if (findMaxECell(clus,etamax,phimax).isFailure()) {
174 info.etamax = etamax;
175 info.phimax = phimax;
176 if (m_egammaCellRecoveryTool->execute(*clus,
info).isFailure()) {
189 return StatusCode::FAILURE;
197 return StatusCode::FAILURE;
204 return StatusCode::FAILURE;
208 it_cell_e = cellLinks->
end();
212 std::pair<const CaloCell*,double> maxcell{
nullptr,0};
213 for(; it_cell != it_cell_e; ++it_cell) {
216 if (!
cell->caloDDE()) {
218 <<
cell->eta() <<
" phi = " <<
cell->phi());
221 int layer =
cell->caloDDE()->getSampling();
224 double eCell =
cell->energy();
225 if (m_UseWeightForMaxCell) eCell *=
w;
228 maxcell.first =
cell;
236 etamax = maxcell.first->caloDDE()->eta_raw();
237 phimax = maxcell.first->caloDDE()->phi_raw();
240 double etaAmax = clus->
etamax(sam);
241 double phiAmax = clus->
phimax(sam);
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);
251 ATH_MSG_WARNING(
"No layer 2 cell with positive energy ! Should never happen");
252 return StatusCode::FAILURE;
254 return StatusCode::SUCCESS;