ATLAS Offline Software
Loading...
Searching...
No Matches
gTowerContainer.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4//***************************************************************************
5// gTowerContainer - Container for the gFEX towers
6// -------------------
7// begin : 01 04 2021
8// email : cecilia.tosciri@cern.ch
9//***************************************************************************
10
12#include "L1CaloFEXSim/gTower.h"
14#include "CLHEP/Geometry/Vector3D.h"
15#include <atomic>
16
17namespace LVL1{
18
25
26void gTowerContainer::push_back(int ieta, int iphi, int nphi, int keybase, int posneg)
27{
28 DataVector<LVL1::gTower>::push_back(std::make_unique<gTower>(ieta,iphi,nphi,keybase,posneg));
29}
30
32 REPORT_MESSAGE_WITH_CONTEXT (MSG::WARNING, "gTowerContainer") << "gTowerContainer::print not implemented";
33}
34
35
36const LVL1::gTower * gTowerContainer::findTower(int towerID) const
37{
38
39 const auto it = m_map_towerID_containerIndex.find(towerID);
40
41 if (it == m_map_towerID_containerIndex.end()) {
42 REPORT_MESSAGE_WITH_CONTEXT (MSG::WARNING, "gTowerContainer") << "Requested tower ID "
43 << towerID
44 << " not found in container.";
45 return nullptr;
46 }
47
48 const int container_index = it->second;
49
50 if (container_index < 0) {
51 return nullptr;
52 }
53
54 return (*this)[container_index];
55}
56
57
59{
60
61 const auto it = m_map_towerID_containerIndex.find(towerID);
62
63 if (it == m_map_towerID_containerIndex.end()) {
64 REPORT_MESSAGE_WITH_CONTEXT (MSG::WARNING, "gTowerContainer") << "Requested tower ID "
65 << towerID
66 << " not found in container.";
67 return nullptr;
68 }
69
70 const int container_index = it->second;
71
72 if (container_index < 0) {
73 return nullptr;
74 }
75
76 return (*this)[container_index];
77}
78
84
87 size_t ntowers = size();
88 for (size_t itower = 0; itower < ntowers; itower++) {
89 const gTower * theTower = (*this)[itower];
90 int towerID = theTower->getID();
91 int container_index = itower;
92 m_map_towerID_containerIndex.insert(std::pair<int,int>(towerID,container_index));
93 m_map_fwID_towerID.insert(std::pair<int,int>(theTower->getFWID(),towerID));
94 }
95 return true;
96}
97
99 const auto it = m_map_fwID_towerID.find(fwID);
100 if (it == m_map_fwID_towerID.end()) {
101 REPORT_MESSAGE_WITH_CONTEXT (MSG::WARNING, "gTowerContainer") << "Requested firmware ID "
102 << fwID
103 << " not found in container.";
104 return -1;
105 }
106
107 const int towerID = it->second;
108 return towerID;
109}
110
111}
Helpers for checking error return status codes and reporting errors.
#define REPORT_MESSAGE_WITH_CONTEXT(LVL, CONTEXT_NAME)
Report a message, with an explicitly specified context name.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
DataVector(SG::OwnershipPolicy ownPolicy=SG::OWN_ELEMENTS, SG::IndexTrackingPolicy trackIndices=SG::DEFAULT_TRACK_INDICES)
SG::OwnershipPolicy ownPolicy() const
size_type size() const noexcept
std::unordered_map< int, int > m_map_towerID_containerIndex
void print() const
dump (obsolete)
void push_back(int eta, int phi, int nphi, int keybase, int posneg)
reimplementation of const push_back
const LVL1::gTower * findTower(int towerID) const
fast find method given identifier.
bool fillContainerMap()
utility function to help speed up accessing towers
gTowerContainer(SG::OwnershipPolicy ownPolicy=SG::OWN_ELEMENTS)
Main constructor.
std::unordered_map< int, int > m_map_fwID_towerID
int getIDfromFWID(int fwID) const
given a firmware ID, it returns the simulation ID, it can be used to then find towers
void clearContainerMap()
clear map
The gTower class is an interface object for gFEX trigger algorithms The purposes are twofold:
Definition gTower.h:38
int getFWID(int &iPhiFW, int &iEtaFW) const
Calculates and returns the firmware ID, as well as iPhi and iEta in FT/global scheme.
Definition gTower.cxx:197
int getID() const
Add to ET.
Definition gTower.cxx:119
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...
OwnershipPolicy