27 declareInterface<DerivationFramework::IAugmentationTool>(
this);
38 ATH_CHECK(m_egammaCellRecoveryTool.retrieve());
40 if (m_SGKey_photons.key().empty() && m_SGKey_electrons.key().empty()) {
41 ATH_MSG_FATAL(
"No e-gamma collection provided for thinning. At least one "
42 "egamma collection (photons/electrons) must be provided!");
43 return StatusCode::FAILURE;
46 if (!m_SGKey_electrons.key().empty()) {
47 ATH_MSG_DEBUG(
"Using " << m_SGKey_electrons <<
" for electrons");
48 ATH_CHECK(m_SGKey_electrons.initialize());
50 const std::string containerKey = m_SGKey_electrons.key();
51 for (
int i = 2;
i <= 3;
i++) {
52 for (
int t = 0;
t <=1 ;
t++) {
53 m_SGKey_electrons_decorations.emplace_back(
54 Form(
"%s.%sadded_Lr%d", containerKey.c_str(), (
t == 0 ?
"n" :
"E"),
i));
57 ATH_CHECK(m_SGKey_electrons_decorations.initialize());
60 for (
const auto&
s : m_SGKey_electrons_decorations)
66 ATH_CHECK(m_SGKey_CaloCells.initialize());
68 if (!m_SGKey_photons.key().empty()) {
72 const std::string containerKey = m_SGKey_photons.key();
73 for (
int i = 2;
i <= 3;
i++) {
74 for (
int t = 0;
t <= 1 ;
t++) {
75 m_SGKey_photons_decorations.emplace_back(
76 Form(
"%s.%sadded_Lr%d", containerKey.c_str(), (
t == 0 ?
"n" :
"E"),
i));
79 ATH_CHECK(m_SGKey_photons_decorations.initialize());
82 for (
const auto&
s : m_SGKey_photons_decorations)
87 return StatusCode::SUCCESS;
95 const EventContext& ctx = Gaudi::Hive::currentContext();
97 std::vector<SG::WriteDecorHandle<xAOD::EgammaContainer, char>> decon;
98 std::vector<SG::WriteDecorHandle<xAOD::EgammaContainer, float>> decoE;
103 if (!m_SGKey_photons.key().empty()) {
105 for (
int i = 0;
i < 2;
i++) {
106 decon.emplace_back(m_SGKey_photons_decorations[
i * 2], ctx);
107 decoE.emplace_back(m_SGKey_photons_decorations[
i * 2 + 1], ctx);
116 for (
int i = 0;
i < 2;
i++) {
117 decon[
i](*photon) =
res.nCells[
i];
118 decoE[
i](*photon) =
res.eCells[
i];
124 if (!m_SGKey_electrons.key().empty()) {
126 decon.clear(); decon.reserve(2);
127 decoE.clear(); decoE.reserve(2);
129 for (
int i = 0;
i < 2;
i++) {
130 decon.emplace_back(m_SGKey_electrons_decorations[
i * 2], ctx);
131 decoE.emplace_back(m_SGKey_electrons_decorations[
i * 2 + 1], ctx);
141 for (
int i = 0;
i < 2;
i++) {
142 decon[
i](*electron) =
res.nCells[
i];
143 decoE[
i](*electron) =
res.eCells[
i];
148 return StatusCode::SUCCESS;
169 double etamax = -999., phimax = -999.;
170 if (findMaxECell(clus,etamax,phimax).isFailure()) {
175 info.etamax = etamax;
176 info.phimax = phimax;
177 if (m_egammaCellRecoveryTool->execute(*clus,
info).isFailure()) {
190 return StatusCode::FAILURE;
198 return StatusCode::FAILURE;
205 return StatusCode::FAILURE;
209 it_cell_e = cellLinks->
end();
213 std::pair<const CaloCell*,double> maxcell{
nullptr,0};
214 for(; it_cell != it_cell_e; ++it_cell) {
217 if (!
cell->caloDDE()) {
219 <<
cell->eta() <<
" phi = " <<
cell->phi());
222 int layer =
cell->caloDDE()->getSampling();
225 double eCell =
cell->energy();
226 if (m_UseWeightForMaxCell) eCell *=
w;
229 maxcell.first =
cell;
237 etamax = maxcell.first->caloDDE()->eta_raw();
238 phimax = maxcell.first->caloDDE()->phi_raw();
241 double etaAmax = clus->
etamax(sam);
242 double phiAmax = clus->
phimax(sam);
245 <<
" maximum layer 2 energy cell, E = " << maxcell.first->energy()
246 <<
" check E = " << vemax
247 <<
" w = " << maxcell.second <<
"\n"
248 <<
" in calo frame, eta = " << etamax <<
" phi = " << phimax <<
"\n"
249 <<
" in ATLAS frame, eta = " << etaAmax <<
" phi = " << phiAmax);
252 ATH_MSG_WARNING(
"No layer 2 cell with positive energy ! Should never happen");
253 return StatusCode::FAILURE;
255 return StatusCode::SUCCESS;