11 #include "../IO/LArStripNeighborhoodDumper.h"
12 #include "../IO/eEmNbhoodTOB.h"
25 std::optional<std::vector<std::size_t>>
wrap5(std::size_t center) {
27 return std::optional<std::vector<std::size_t>>{};
31 return std::make_optional(std::vector<std::size_t>({61
ul, 62
ul, 63
ul, 0
ul, 1
ul}));
35 return std::make_optional(std::vector<std::size_t>({62
ul, 63
ul, 0
ul, 1
ul, 2
ul}));
38 return std::make_optional(std::vector<std::size_t>(
60 return StatusCode::SUCCESS;
73 return StatusCode::FAILURE;
76 std::vector<const CaloCell*>
cells;
80 std::vector<const xAOD::eFexEMRoI*>
rois;
88 auto neighborhoodTOBs = std::make_unique<IOBitwise::IeEmNbhoodTOBContainer>();
89 auto phimax = std::make_unique<std::vector<int>>();
99 CHECK(dumper.dump(
name(), *eventInfo, *neighborhoodTOBs));
103 CHECK(dumper.dumpTerse(
name(), *eventInfo, *neighborhoodTOBs));
107 CHECK(h_neighborhoodTOBs.
record(std::move(neighborhoodTOBs)));
110 return StatusCode::SUCCESS;
115 const std::vector<const CaloCell*>&
cells,
117 std::vector<int>& phimax)
const{
119 for (
const auto& roi :
rois) {
123 return StatusCode::SUCCESS;
129 const std::vector<const CaloCell*>&
cells,
131 std::vector<int>& phimax)
const {
160 auto cells_near_roi = std::vector<const CaloCell*>();
165 auto phi_ind = [](
const auto&
c) {
167 std::size_t iphi = 32 +
int(std::floor(
c->phi()/dphi));
169 std::optional<std::size_t>() : std::make_optional(iphi);
172 const std::optional<std::size_t> roi_phi_index_opt = phi_ind(roi);
173 if (not roi_phi_index_opt.has_value()) {
174 return StatusCode::FAILURE;
176 const std::size_t roi_phi_index = *roi_phi_index_opt;
179 auto roi_phi_indices = *
wrap5(roi_phi_index);
182 auto close = std::deque<std::vector<const CaloCell*>>(5);
183 for (
auto&
v :close) {
v.reserve(100);}
186 constexpr
double half_deta_roi{0.05};
188 constexpr
double half_deta_neigh{8.5*0.003125};
190 constexpr
double half_deta_fid{half_deta_roi + half_deta_neigh};
193 double etalim_low =
std::max(roi->
eta()-half_deta_fid, -1.4);
194 double etalim_high =
std::min(roi->
eta()+half_deta_fid, 1.4);
201 for(
const auto& iroi : roi_phi_indices) {
202 auto c_eta =
cell->eta();
203 if (iroi ==
icell and c_eta >= etalim_low and c_eta < etalim_high) {
213 auto roi_cells = std::deque<std::vector<const CaloCell*>>(5);
216 for (std::size_t
i{0
ul};
i != close.size(); ++
i) {
217 roi_cells[
i].reserve(close[
i].
size());
220 std::back_inserter(roi_cells[
i]),
221 [&roi](
const auto&
c) {
222 return std::abs(
c->eta() - roi->
eta()) < half_deta_roi;
228 [](
const auto&
l,
const auto&
r) {
229 return l->e() <
r->e();
235 roi_max_it.push_back(
it);
239 auto max_row = std::max_element(
std::begin(roi_max_it),
241 [](
const auto&
l,
const auto&
r) {
242 return (*l)->e() < (*r)->e();
245 int max_row_pos =
std::distance( roi_max_it.begin(), max_row );
247 phimax.push_back(max_row_pos);
279 auto neigh_cells = std::vector<std::vector<const CaloCell*>>(3);
281 const CaloCell* max_cell{*(*max_row)};
282 const auto max_cell_eta = max_cell->
eta();
286 for (std::size_t iv{0
ul}; iv != close.size(); ++iv) {
289 std::back_inserter(neigh_cells[iv]),
290 [&max_cell_eta, &half_deta_neigh](
const auto&
c){
291 return abs(
c->eta()-max_cell_eta) < half_deta_neigh;
300 if (max_neigh_cell_it ==
std::end(neigh_cells[1])){
302 return StatusCode::FAILURE;
310 auto toStripData = [](
const auto& fromCells){
311 auto stripdata = std::vector<StripData>();
312 stripdata.reserve(fromCells.size());
315 back_inserter(stripdata),
323 auto low = toStripData(neigh_cells[0]);
324 auto center = toStripData(neigh_cells[1]);
325 auto high = toStripData(neigh_cells[2]);
328 Coords cell_c{max_cell->eta(), max_cell->phi()};
334 neighborhoodTOBs.
push_back(std::make_unique<IOBitwise::eEmNbhoodTOB>(*roi, neighborhood));
336 return StatusCode::SUCCESS;