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);
282 if(hashIdMax != hashId){
287 auto it = std::ranges::max_element(std::begin(window[1]),
289 [](
const auto& l,
const auto&
r) {
290 return l->getEnergy() <
r->getEnergy();
293 std::shared_ptr<const GlobalLArCell> max_cell{*it};
296 auto toStripData = [](
const auto& fromCells){
297 auto stripdata = std::vector<StripData>();
298 stripdata.reserve(fromCells.size());
299 std::ranges::transform(std::begin(fromCells),
301 back_inserter(stripdata),
310 auto max_neigh_cell_it = std::ranges::find(window[1],
312 if (max_neigh_cell_it == std::end(window[1])){
314 return StatusCode::FAILURE;
318 auto max_neigh_cell_pos{std::distance(std::begin(window[1]),
322 auto low = toStripData(window[0]);
323 auto center = toStripData(window[1]);
324 auto high = toStripData(window[2]);
328 Coords cell_c{max_cell->eta(), max_cell->phi()};
334 neighborhoodTOBs.
push_back(std::make_unique<IOBitwise::eEmNbhoodTOB>(*roi, neighborhood));
340 return StatusCode::SUCCESS;
353 float half_strip = 0.025/
strip/2;
357 int sign = std::copysign(1,
eta);
361 for(
int i=1;i<=halt;i+=2){
364 ATH_MSG_DEBUG(
"We found it! Going in by " << (i+1)/2 <<
" eta: " <<
eta-(i*half_strip) <<
" phi: " <<
phi);
370 for(
int i=1;i<=halt;i+=2){
373 ATH_MSG_DEBUG(
"We found it! Going out " << (i+1)/2 <<
" eta: " <<
eta+(i*half_strip) <<
" phi: " <<
phi);
391 CellID = cells.getIDFromLoc(
eta,
phi);
405 std::vector<std::vector<std::shared_ptr<const GlobalLArCell>>>& window)
const {
408 if(hashId ==
hashIdDummy)
return StatusCode::SUCCESS;
411 std::vector<IdentifierHash> neighbourList;
416 hashIdNext = hashIdPrev = hashId;
424 for(
int etaOffset = 0; etaOffset <=8; etaOffset++){
429 auto cell = cells.getCellFromHash(hashId);
434 ATH_MSG_DEBUG(
"Found the middle cell " << cell->getID() <<
" at eta " << cell->eta() <<
" phi " << cell->phi());
436 etaMax = cell->eta();
439 ATH_MSG_DEBUG(
"Putting in a dummy middle cell with hashId " << hashId);
440 window[1][8] = std::make_shared<GlobalLArCell>(hashId,
"",0);
445 if(std::abs(etaMax) < 2.475 && hashIdNext !=
hashIdDummy){
448 ATH_MSG_DEBUG(
"Next in eta " << neighbourList[0] <<
" HashId " << hashId);
450 hashIdNext = neighbourList[0];
452 auto cellNext = cells.getCellFromHash(hashIdNext);
456 if(cellNext !=
nullptr){
457 ATH_MSG_DEBUG(
"Found a cell " << cellNext->getID() <<
" at eta " << cellNext->eta() <<
" phi " << cellNext->phi());
459 etaMax = cellNext->eta();
461 window[1][shift] = cellNext;
464 ATH_MSG_DEBUG(
"Putting in a next dummy with hashIdNext " << hashIdNext);
465 window[1][shift] = std::make_shared<GlobalLArCell>(hashIdNext,
"",0);
472 window[1][shift] = std::make_shared<GlobalLArCell>(
hashIdDummy,
"",0);
476 ATH_MSG_DEBUG(
"Previous in eta " << neighbourList[0] <<
" hashId " << hashId);
477 hashIdPrev = neighbourList[0];
478 auto cellPrev = cells.getCellFromHash(hashIdPrev);
480 if(cellPrev !=
nullptr){
481 ATH_MSG_DEBUG(
"Found a cell " << cellPrev->getID() <<
" at eta " << cellPrev->eta() <<
" phi " << cellPrev->phi());
482 window[1][shift] = cellPrev;
484 ATH_MSG_DEBUG(
"Putting in a previous dummy with hasIdPrev " << hashIdPrev);
485 window[1][shift] = std::make_shared<GlobalLArCell>(hashIdPrev,
"",0);
491 for(
int phiOffset = 0; phiOffset <=1; phiOffset++){
497 for(
auto& windowCell:window[1]){
498 ATH_MSG_DEBUG(
"Cell ID " << shift <<
" is " << windowCell->getID());
504 if(windowCell->getID() <=
maxIdentifierHash) hashIdCurrent = windowCell->getID();
507 ATH_MSG_DEBUG(
"Next in phi " << neighbourList[0] <<
" hashId " << hashIdCurrent);
509 hashIdCurrent = neighbourList[0];
510 auto cellCurrent = cells.getCellFromHash(hashIdCurrent);
512 if(cellCurrent !=
nullptr){
514 ATH_MSG_DEBUG(
"Found a cell " << cellCurrent->getID() <<
" at eta " << cellCurrent->eta() <<
" phi " << cellCurrent->phi());
515 window[0][shift] = cellCurrent;
518 ATH_MSG_DEBUG(
"No next in phi: Last HashIdCurrent " << hashIdCurrent);
519 window[0][shift] = std::make_shared<GlobalLArCell>(
hashIdDummy,
"",0);
525 window[0][shift] = std::make_shared<GlobalLArCell>(
hashIdDummy,
"",0);
532 for(
auto& windowCell:window[1]){
533 ATH_MSG_DEBUG(
"Cell ID " << shift <<
" is " << windowCell->getID());
536 if(windowCell->getID() <=
maxIdentifierHash) hashIdCurrent = windowCell->getID();
538 ATH_MSG_DEBUG(
"Previous in phi " << neighbourList[0] <<
" hashId " << hashIdCurrent);
539 hashIdCurrent = neighbourList[0];
540 auto cellCurrent = cells.getCellFromHash(hashIdCurrent);
541 if(cellCurrent !=
nullptr){
542 ATH_MSG_DEBUG(
"Found a cell " << cellCurrent->getID() <<
" at eta " << cellCurrent->eta() <<
" phi " << cellCurrent->phi());
543 window[2][shift] = cellCurrent;
546 window[2][shift] = std::make_shared<GlobalLArCell>(
hashIdDummy,
"",0);
551 window[2][shift] = std::make_shared<GlobalLArCell>(
hashIdDummy,
"",0);
557 return StatusCode::SUCCESS;
562 std::vector<std::vector<std::shared_ptr<const GlobalLArCell>>>& window)
const {
565 std::vector<std::shared_ptr<const GlobalLArCell>> maxima;
567 for(
uint row = 0;row < window.size();row++){
569 maxima.push_back(max_cell);
570 ATH_MSG_DEBUG(
"Found a max cell " << max_cell->getID() <<
" et " << max_cell->getEnergy() <<
" eta " << max_cell->eta() <<
" phi " << max_cell->phi());
573 if((maxima[0]->getEnergy() == maxima[1]->getEnergy() && maxima[1]->getEnergy() >= maxima[2]->getEnergy())
574 || (maxima[1]->getEnergy() == maxima[2]->getEnergy() && maxima[1]->getEnergy() >= maxima[0]->getEnergy())){
575 ATH_MSG_DEBUG(
"Found the max cell " << maxima[1]->getID() <<
" et " << maxima[1]->getEnergy() <<
" eta " << maxima[1]->
eta() <<
" phi " << maxima[1]->
phi());
577 return StatusCode::SUCCESS;
581 ATH_MSG_DEBUG(
"Found the max cell " << maximum_cell->getID() <<
" et " << maximum_cell->getEnergy() <<
" eta " << maximum_cell->eta() <<
" phi " << maximum_cell->phi());
583 return StatusCode::SUCCESS;
589 auto it = std::max_element(std::begin(row),
591 [](
const auto& l,
const auto&
r) {
592 return l->getEnergy() <
r->getEnergy();
595 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.
Identifier32 get_identifier32() const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.
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 to read in LArStripNeighborhoods, and run the eRatio Algorithm.
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.