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)
65 if (!m_SGKey_photons.key().empty()) {
69 const std::string containerKey = m_SGKey_photons.key();
70 for (
int i = 2;
i <= 3;
i++) {
71 for (
int t = 0;
t <= 1 ;
t++) {
72 m_SGKey_photons_decorations.emplace_back(
73 Form(
"%s.%sadded_Lr%d", containerKey.c_str(), (
t == 0 ?
"n" :
"E"),
i));
76 ATH_CHECK(m_SGKey_photons_decorations.initialize());
79 for (
const auto&
s : m_SGKey_photons_decorations)
84 return StatusCode::SUCCESS;
92 const EventContext& ctx = Gaudi::Hive::currentContext();
94 std::vector<SG::WriteDecorHandle<xAOD::EgammaContainer, char>> decon;
95 std::vector<SG::WriteDecorHandle<xAOD::EgammaContainer, float>> decoE;
100 if (!m_SGKey_photons.key().empty()) {
102 for (
int i = 0;
i < 2;
i++) {
103 decon.emplace_back(m_SGKey_photons_decorations[
i * 2], ctx);
104 decoE.emplace_back(m_SGKey_photons_decorations[
i * 2 + 1], ctx);
113 for (
int i = 0;
i < 2;
i++) {
114 decon[
i](*photon) =
res.nCells[
i];
115 decoE[
i](*photon) =
res.eCells[
i];
121 if (!m_SGKey_electrons.key().empty()) {
123 decon.clear(); decon.reserve(2);
124 decoE.clear(); decoE.reserve(2);
126 for (
int i = 0;
i < 2;
i++) {
127 decon.emplace_back(m_SGKey_electrons_decorations[
i * 2], ctx);
128 decoE.emplace_back(m_SGKey_electrons_decorations[
i * 2 + 1], ctx);
138 for (
int i = 0;
i < 2;
i++) {
139 decon[
i](*electron) =
res.nCells[
i];
140 decoE[
i](*electron) =
res.eCells[
i];
145 return StatusCode::SUCCESS;
166 double etamax = -999., phimax = -999.;
167 if (findMaxECell(clus,etamax,phimax).isFailure()) {
172 info.etamax = etamax;
173 info.phimax = phimax;
174 if (m_egammaCellRecoveryTool->execute(*clus,
info).isFailure()) {
187 return StatusCode::FAILURE;
191 it_cell_e = cellLinks->
end();
195 std::pair<const CaloCell*,double> maxcell{
nullptr,0};
196 for(; it_cell != it_cell_e; ++it_cell) {
199 if (!
cell->caloDDE()) {
201 <<
cell->eta() <<
" phi = " <<
cell->phi());
204 int layer =
cell->caloDDE()->getSampling();
207 double eCell =
cell->energy();
208 if (m_UseWeightForMaxCell) eCell *=
w;
211 maxcell.first =
cell;
219 etamax = maxcell.first->caloDDE()->eta_raw();
220 phimax = maxcell.first->caloDDE()->phi_raw();
223 double etaAmax = clus->
etamax(sam);
224 double phiAmax = clus->
phimax(sam);
227 <<
" maximum layer 2 energy cell, E = " << maxcell.first->energy()
228 <<
" check E = " << vemax
229 <<
" w = " << maxcell.second <<
"\n"
230 <<
" in calo frame, eta = " << etamax <<
" phi = " << phimax <<
"\n"
231 <<
" in ATLAS frame, eta = " << etaAmax <<
" phi = " << phiAmax);
234 ATH_MSG_WARNING(
"No layer 2 cell with positive energy ! Should never happen");
235 return StatusCode::FAILURE;
237 return StatusCode::SUCCESS;