133 {
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162 auto cells_near_roi = std::vector<const CaloCell*>();
163
165
166
167 auto phi_ind = [](
const auto&
c) {
168 constexpr double dphi = std::numbers::pi/32;
169 std::size_t iphi = 32 +
int(std::floor(
c->phi()/dphi));
170 return iphi > 63 ?
171 std::optional<std::size_t>() : std::make_optional(iphi);
172 };
173
174 const std::optional<std::size_t> roi_phi_index_opt = phi_ind(roi);
175 if (not roi_phi_index_opt.has_value()) {
176 return StatusCode::FAILURE;
177 }
178 const std::size_t roi_phi_index = *roi_phi_index_opt;
179
180
181 auto roi_phi_indices = *
wrap5(roi_phi_index);
182
183
184 auto close = std::deque<std::vector<const CaloCell*>>(5);
185 for (
auto& v :close) {
v.reserve(100);}
186
187
188 constexpr double half_deta_roi{0.05};
189
190 constexpr double half_deta_neigh{8.5*0.003125};
191
192 constexpr double half_deta_fid{half_deta_roi + half_deta_neigh};
193
194
195 double etalim_low = std::max(roi->
eta()-half_deta_fid, -1.4);
196 double etalim_high = std::min(roi->
eta()+half_deta_fid, 1.4);
197
198
199
200 for (const auto& cell : cells) {
201 auto icell = *phi_ind(cell);
203 for(const auto& iroi : roi_phi_indices) {
204 auto c_eta =
cell->eta();
205 if (iroi == icell and c_eta >= etalim_low and c_eta < etalim_high) {
207 if(totalNoise <= 0.0) totalNoise = 0.001;
208 float sigma =
cell->energy() / totalNoise;
209 if(sigma >= 2){
210 close[
pos].push_back(cell);
211 } else {
212 close[
pos].push_back(
new CaloCell(
cell->caloDDE(), 0.0,
cell->time(),
cell->quality(),
cell->provenance(),
cell->gain()));
213 }
214 break;
215 }
217 }
218 }
219
220
221
222 auto roi_cells = std::deque<std::vector<const CaloCell*>>(5);
223 auto roi_max_it = std::vector<std::vector<const CaloCell*>::iterator>();
224
225 for (std::size_t i{0
ul};
i != close.size(); ++
i) {
226 roi_cells[
i].reserve(close[i].
size());
227 std::copy_if(std::begin(close[i]),
228 std::end(close[i]),
229 std::back_inserter(roi_cells[i]),
230 [&roi](const auto& c) {
231 return std::abs(
c->eta() - roi->
eta()) < half_deta_roi;
232 });
233
234 if(i > 0 && i < 4){
235 auto it = std::max_element(std::begin(roi_cells[i]),
236 std::end(roi_cells[i]),
237 [](
const auto& l,
const auto&
r) {
238 return l->e() <
r->e();
239 });
241 << i << " position "
242 << std::distance(std::begin(roi_cells[i]), it)
243 << " :" << **it);
244 roi_max_it.push_back(it);
245 }
246 }
247
248 auto max_row = std::max_element(std::begin(roi_max_it),
249 std::end(roi_max_it),
250 [](
const auto& l,
const auto&
r) {
251 return (*l)->e() < (*r)->e();
252 });
253
254 int max_row_pos = std::distance( roi_max_it.begin(), max_row );
255
257 << ' ' << std::distance( roi_max_it.begin(), max_row )+1);
258
259
260 switch(max_row_pos)
261 {
262 case 0:
263 {
264 close.pop_back();
265 close.pop_back();
266 break;
267 }
268 case 1:
269 {
270 close.pop_front();
271 close.pop_back();
272 break;
273 }
274 case 2:
275 {
276 close.pop_front();
277 close.pop_front();
278 break;
279 }
280 }
281
283
284
285
286 auto neigh_cells = std::vector<std::vector<const CaloCell*>>(3);
287
289
290 const CaloCell* max_cell{*(*max_row)};
291 const auto max_cell_eta = max_cell->
eta();
292
294
295 for (std::size_t iv{0
ul}; iv != close.size(); ++iv) {
296 std::copy_if(std::begin(close[iv]),
297 std::end(close[iv]),
298 std::back_inserter(neigh_cells[iv]),
299 [&max_cell_eta, &half_deta_neigh](const auto& c){
300 return abs(
c->eta()-max_cell_eta) < half_deta_neigh;
301 });
302 }
303
305
306 auto max_neigh_cell_it = std::find(std::begin(neigh_cells[1]),
307 std::end(neigh_cells[1]),
308 max_cell);
309 if (max_neigh_cell_it == std::end(neigh_cells[1])){
311 return StatusCode::FAILURE;
312 }
313
314 auto max_neigh_cell_pos{std::distance(std::begin(neigh_cells[1]),
315 max_neigh_cell_it)};
316
318
319 auto toStripData = [](const auto& fromCells){
320 auto stripdata = std::vector<StripData>();
321 stripdata.reserve(fromCells.size());
322 std::transform(std::begin(fromCells),
323 std::end(fromCells),
324 back_inserter(stripdata),
325 [](const auto& c) {
326 return StripData(
c->eta(),
329 return stripdata;
330 };
331
332 auto low = toStripData(neigh_cells[0]);
333 auto center = toStripData(neigh_cells[1]);
334 auto high = toStripData(neigh_cells[2]);
335
338
340
341 LArStripNeighborhood neighborhood = LArStripNeighborhood(low, center, high, roi_c, cell_c, max_neigh_cell_pos);
342
343 neighborhoodTOBs.push_back(std::make_unique<IOBitwise::eEmNbhoodTOB>(*roi, neighborhood));
344
345 return StatusCode::SUCCESS;
346 }
size_t size() const
Number of registered mappings.
virtual double phi() const override final
get phi (through CaloDetDescrElement)
virtual double eta() const override final
get eta (through CaloDetDescrElement)
float eta() const
setter for the above
float phi() const
Seed supercell index within central tower (0 -> 3).
std::optional< std::vector< std::size_t > > wrap5(std::size_t center)
std::pair< double, double > Coords
l
Printing final latex table to .tex output file.