58 StatusCode
sc =
detStore()->retrieve(caloIdMgr);
60 ATH_MSG_ERROR(
" Unable to retrieve CaloIdManager from DetectoreStore");
61 return StatusCode::FAILURE;
65 return StatusCode::SUCCESS;
78 return StatusCode::FAILURE;
83 CHECK(h_gblLArCells.isValid());
84 const auto & gblLArCells = *h_gblLArCells;
88 std::vector<const xAOD::eFexEMRoI*> rois_in;
93 std::vector<const xAOD::eFexEMRoI*> rois;
94 for(
auto roi:rois_in){
96 if(std::abs(roi->eta()) >= 1.37 && std::abs(roi->eta()) <= 1.52)
continue;
106 auto neighborhoodTOBs = std::make_unique<IOBitwise::eEmNbhoodTOBContainer>();
108 std::vector<bool> successes;
115 CHECK(h_eFEXeta.
record(std::make_unique<std::vector<float> >()));
117 CHECK(h_eFEXphi.
record(std::make_unique<std::vector<float> >()));
120 CHECK(h_FailedeFEXeta.
record(std::make_unique<std::vector<float> >()));
122 CHECK(h_FailedeFEXphi.
record(std::make_unique<std::vector<float> >()));
126 for(
int i=0;
auto success:successes){
128 h_eFEXeta->push_back(rois[i]->
eta());
129 h_eFEXphi->push_back(rois[i]->
phi());
131 h_FailedeFEXeta->push_back(rois[i]->
eta());
132 h_FailedeFEXphi->push_back(rois[i]->
phi());
144 CHECK(dumper.dump(name(), *eventInfo, *neighborhoodTOBs));
148 CHECK(dumper.dumpTerse(name(), *eventInfo, *neighborhoodTOBs));
153 CHECK(h_neighborhoodTOBs.
record(std::move(neighborhoodTOBs)));
155 return StatusCode::SUCCESS;
164 std::vector<bool>& successes,
167 for (
const auto& roi : rois) {
169 bool success =
false;
171 successes.push_back(success);
174 return StatusCode::SUCCESS;
219 auto window = std::vector<std::vector<std::shared_ptr<const GlobalLArCell>>>(3);
220 window[0].resize(17);
221 window[1].resize(17);
222 window[2].resize(17);
232 int iEta = roi->
iEta();
233 int iPhi = roi->
iPhi();
234 ATH_MSG_DEBUG(
"Where is this RoI? eta: " <<
eta <<
" phi: " <<
phi <<
" iEta" << iEta <<
" iPhi " << iPhi);
237 if(iEta == -25 || iEta == 24) {
242 else if((iEta > -25 && iEta <= -21) || (iEta < 24 && iEta >= 20)){
246 else if((iEta > -21 && iEta <= -19) || (iEta < 20 && iEta >= 18)) {
251 else if((iEta > -19 && iEta <=-1) || (iEta < 18 && iEta >=0)) {
265 int ibec = abs(
m_larem_id->barrel_ec(CellID));
271 ATH_MSG_DEBUG(
"Where is this Seed? B/E? " << ibec <<
" sampling " << sampling <<
" eta " <<
eta <<
" phi " <<
phi <<
" region " << region);
283 auto it = std::ranges::max_element(std::begin(window[1]),
285 [](
const auto& l,
const auto&
r) {
286 return l->getEnergy() <
r->getEnergy();
289 std::shared_ptr<const GlobalLArCell> max_cell{*it};
292 auto toStripData = [](
const auto& fromCells){
293 auto stripdata = std::vector<StripData>();
294 stripdata.reserve(fromCells.size());
295 std::ranges::transform(std::begin(fromCells),
297 back_inserter(stripdata),
306 auto max_neigh_cell_it = std::ranges::find(window[1],
308 if (max_neigh_cell_it == std::end(window[1])){
310 return StatusCode::FAILURE;
314 auto max_neigh_cell_pos{std::distance(std::begin(window[1]),
318 auto low = toStripData(window[0]);
319 auto center = toStripData(window[1]);
320 auto high = toStripData(window[2]);
324 Coords cell_c{max_cell->eta(), max_cell->phi()};
330 neighborhoodTOBs.
push_back(std::make_unique<IOBitwise::eEmNbhoodTOB>(*roi, neighborhood));
336 return StatusCode::SUCCESS;
349 float half_strip = 0.025/
strip/2;
353 int sign = std::copysign(1,
eta);
357 for(
int i=1;i<=halt;i+=2){
360 ATH_MSG_DEBUG(
"We found it! Going in by " << (i+1)/2 <<
" eta: " <<
eta-(i*half_strip) <<
" phi: " <<
phi);
366 for(
int i=1;i<=halt;i+=2){
369 ATH_MSG_DEBUG(
"We found it! Going out " << (i+1)/2 <<
" eta: " <<
eta+(i*half_strip) <<
" phi: " <<
phi);
389 if(cell->getSampling() == 1 || cell->getSampling() == 5) {
391 float etamin = cell->eta() - (0.5*cell->deta());
392 float etamax = cell->eta() + (0.5*cell->deta());
394 float phimin = cell->phi() - (0.5*cell->dphi());
395 float phimax = cell->phi() + (0.5*cell->dphi());
398 if(etamin <
eta &&
eta < etamax && phimin <
phi &&
phi < phimax){
400 CellID = cell->getID();
401 ATH_MSG_DEBUG(
"Found the seed " << CellID <<
" eta "<< cell->eta() <<
" phi " << cell->phi() <<
" sampling " <<
m_larem_id->sampling(CellID));
414 std::vector<std::vector<std::shared_ptr<const GlobalLArCell>>>& window)
const {
417 if(hashId ==
hashIdDummy)
return StatusCode::SUCCESS;
420 std::vector<IdentifierHash> neighbourList;
425 hashIdNext = hashIdPrev = hashId;
433 for(
int etaOffset = 0; etaOffset <=8; etaOffset++){
438 auto cell = cells.getCellFromHash(hashId);
443 ATH_MSG_DEBUG(
"Found the middle cell " << cell->getID() <<
" at eta " << cell->eta() <<
" phi " << cell->phi());
445 etaMax = cell->eta();
449 if(std::abs(etaMax) < 2.475 && hashIdNext !=
hashIdDummy){
452 ATH_MSG_DEBUG(
"Next in eta " << neighbourList[0] <<
" HashId " << hashId);
454 hashIdNext = neighbourList[0];
456 auto cellNext = cells.getCellFromHash(hashIdNext);
460 if(cellNext !=
nullptr){
461 ATH_MSG_DEBUG(
"Found a cell " << cellNext->getID() <<
" at eta " << cellNext->eta() <<
" phi " << cellNext->phi());
463 etaMax = cellNext->eta();
465 window[1][shift] = cellNext;
468 ATH_MSG_DEBUG(
"Putting in a next dummy with hashIdNext " << hashIdNext);
469 window[1][shift] = std::make_shared<GlobalLArCell>(hashIdNext,
"",0);
476 window[1][shift] = std::make_shared<GlobalLArCell>(
hashIdDummy,
"",0);
480 ATH_MSG_DEBUG(
"Previous in eta " << neighbourList[0] <<
" hashId " << hashId);
481 hashIdPrev = neighbourList[0];
482 auto cellPrev = cells.getCellFromHash(hashIdPrev);
484 if(cellPrev !=
nullptr){
485 ATH_MSG_DEBUG(
"Found a cell " << cellPrev->getID() <<
" at eta " << cellPrev->eta() <<
" phi " << cellPrev->phi());
486 window[1][shift] = cellPrev;
488 ATH_MSG_DEBUG(
"Putting in a previous dummy with hasIdPrev " << hashIdPrev);
489 window[1][shift] = std::make_shared<GlobalLArCell>(hashIdPrev,
"",0);
495 for(
int phiOffset = 0; phiOffset <=1; phiOffset++){
501 for(
auto& windowCell:window[1]){
502 ATH_MSG_DEBUG(
"Cell ID " << shift <<
" is " << windowCell->getID());
508 if(windowCell->getID() <=
maxIdentifierHash) hashIdCurrent = windowCell->getID();
511 ATH_MSG_DEBUG(
"Next in phi " << neighbourList[0] <<
" hashId " << hashIdCurrent);
513 hashIdCurrent = neighbourList[0];
514 auto cellCurrent = cells.getCellFromHash(hashIdCurrent);
516 if(cellCurrent !=
nullptr){
518 ATH_MSG_DEBUG(
"Found a cell " << cellCurrent->getID() <<
" at eta " << cellCurrent->eta() <<
" phi " << cellCurrent->phi());
519 window[0][shift] = cellCurrent;
522 ATH_MSG_DEBUG(
"No next in phi: Last HashIdCurrent " << hashIdCurrent);
523 window[0][shift] = std::make_shared<GlobalLArCell>(
hashIdDummy,
"",0);
529 window[0][shift] = std::make_shared<GlobalLArCell>(
hashIdDummy,
"",0);
536 for(
auto& windowCell:window[1]){
537 ATH_MSG_DEBUG(
"Cell ID " << shift <<
" is " << windowCell->getID());
540 if(windowCell->getID() <=
maxIdentifierHash) hashIdCurrent = windowCell->getID();
542 ATH_MSG_DEBUG(
"Previous in phi " << neighbourList[0] <<
" hashId " << hashIdCurrent);
543 hashIdCurrent = neighbourList[0];
544 auto cellCurrent = cells.getCellFromHash(hashIdCurrent);
545 if(cellCurrent !=
nullptr){
546 ATH_MSG_DEBUG(
"Found a cell " << cellCurrent->getID() <<
" at eta " << cellCurrent->eta() <<
" phi " << cellCurrent->phi());
547 window[2][shift] = cellCurrent;
550 window[2][shift] = std::make_shared<GlobalLArCell>(
hashIdDummy,
"",0);
555 window[2][shift] = std::make_shared<GlobalLArCell>(
hashIdDummy,
"",0);
561 return StatusCode::SUCCESS;
566 std::vector<std::vector<std::shared_ptr<const GlobalLArCell>>>& window)
const {
569 std::vector<std::shared_ptr<const GlobalLArCell>> maxima;
571 for(
uint row = 0;row < window.size();row++){
573 maxima.push_back(max_cell);
574 ATH_MSG_DEBUG(
"Found a max cell " << max_cell->getID() <<
" et " << max_cell->getEnergy() <<
" eta " << max_cell->eta() <<
" phi " << max_cell->phi());
577 if((maxima[0]->getEnergy() == maxima[1]->getEnergy() && maxima[1]->getEnergy() >= maxima[2]->getEnergy())
578 || (maxima[1]->getEnergy() == maxima[2]->getEnergy() && maxima[1]->getEnergy() >= maxima[0]->getEnergy())){
579 ATH_MSG_DEBUG(
"Found the max cell " << maxima[1]->getID() <<
" et " << maxima[1]->getEnergy() <<
" eta " << maxima[1]->
eta() <<
" phi " << maxima[1]->
phi());
581 return StatusCode::SUCCESS;
585 ATH_MSG_DEBUG(
"Found the max cell " << maximum_cell->getID() <<
" et " << maximum_cell->getEnergy() <<
" eta " << maximum_cell->eta() <<
" phi " << maximum_cell->phi());
587 return StatusCode::SUCCESS;
593 auto it = std::max_element(std::begin(row),
595 [](
const auto& l,
const auto&
r) {
596 return l->getEnergy() <
r->getEnergy();
599 std::shared_ptr<const GlobalLArCell> max_cell{*it};
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
#define CHECK(...)
Evaluate an expression and check for errors.
const ServiceHandle< StoreGateSvc > & detStore() const
An algorithm that can be simultaneously executed in multiple threads.
This class initializes the Calo (LAr and Tile) offline identifiers.
const LArEM_ID * getEM_ID(void) const
value_type push_back(value_type pElem)
Add an element to the end of the collection.
ToolHandle< eFexRoIAlgTool > m_roiAlgTool
ToolHandle for the eFexRoI AlgTool.
const CaloCell_ID * m_calocell_id
SG::WriteHandleKey< std::vector< float > > m_eFEXphiKey
WriteHandle Key for the eFexRoI's phi (for valid windows, for DEBUG).
Egamma1_OnlineMapNbhood(const std::string &name, ISvcLocator *pSvcLocator)
Gaudi::Property< bool > m_dumpTerse
Parameter to toggle dumping of brief information window information.
SG::WriteHandleKey< IOBitwise::eEmNbhoodTOBContainer > m_neighKey
WriteHandle Key for the resulting TOBs.
StatusCode findWindow(IdentifierHash, const GlobalSim::GlobalLArCellContainer &, std::vector< std::vector< std::shared_ptr< const GlobalSim::GlobalLArCell > > > &) const
Function to produce a window around an input seed cell.
std::shared_ptr< const GlobalLArCell > findMax(std::vector< std::shared_ptr< const GlobalLArCell > > &) const
Function to find the maximum energy cell in a vector of cells.
virtual StatusCode execute(const EventContext &) const override
execute function running for every event
SG::WriteHandleKey< std::vector< float > > m_eFEXetaKey
WriteHandle Key for the eFexRoI's eta (for valid windows, for DEBUG).
const LArEM_ID * m_larem_id
StatusCode findMaxima(IdentifierHash &, std::vector< std::vector< std::shared_ptr< const GlobalSim::GlobalLArCell > > > &) const
Function to find the maximum energy cell in a window.
SG::WriteHandleKey< std::vector< float > > m_FailedeFEXetaKey
WriteHandle Key for the eFexRoI's eta (for invalid windows, for DEBUG).
virtual StatusCode initialize() override
initialize function running before the first event
StatusCode findNeighborhoods_OnlineMap(const std::vector< const xAOD::eFexEMRoI * > &, const GlobalSim::GlobalLArCellContainer &, std::vector< bool > &, IOBitwise::eEmNbhoodTOBContainer &) const
Function to produce mutliple windows from a vector of incoming eFeX RoIs.
StatusCode findNeighborhood_OnlineMap(const xAOD::eFexEMRoI *, const GlobalSim::GlobalLArCellContainer &, bool &, IOBitwise::eEmNbhoodTOBContainer &) const
Function to produce a window from an incoming eFeX RoI.
SG::WriteHandleKey< std::vector< float > > m_FailedeFEXphiKey
WriteHandle Key for the eFexRoI's phi (for invalid windows, for DEBUG).
Gaudi::Property< bool > m_dump
Parameter to toggle dumping of full information window information.
SG::ReadHandleKey< GlobalSim::GlobalLArCellContainer > m_gblLArCellContainerKey
ReadHandle Key to the GlobalLArCellContainer.
bool findSeedCell(float, float, const GlobalSim::GlobalLArCellContainer &, Identifier &) const
Function to find the seed cell for a window from the eFeX RoI position.
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
ReadHandle Key for the EventInfo object.
bool findHalfStrips(int, float, float, const GlobalSim::GlobalLArCellContainer &, Identifier &) const
Function to search for seed cells according to local granularity.
Class to hold windows of LAr strip cells in a the neighbourhood of a eFexRoI.
This is a "hash" representation of an Identifier.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
float eta() const
setter for the above
int iPhi() const
Setter for the above.
float phi() const
Seed supercell index within central tower (0 -> 3).
int iEta() const
setter for the above
DataVector< GlobalSim::IOBitwise::eEmNbhoodTOB > eEmNbhoodTOBContainer
AlgTool that to test whether expected the TIP values generated by data supplied by eEmMultTestBench c...
constexpr int maxIdentifierHash
std::pair< double, double > Coords
constexpr IdentifierHash hashIdDummy
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
eFexEMRoI_v1 eFexEMRoI
Define the latest version of the eFexEMRoI class.