ATLAS Offline Software
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 
17 namespace LVL1{
18 
20  DataVector<LVL1::gTower>(ownPolicy)
21 {
23  m_map_fwID_towerID.clear();
24 }
25 
26 void 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 
31 void gTowerContainer::print() const {
32  REPORT_MESSAGE_WITH_CONTEXT (MSG::WARNING, "gTowerContainer") << "gTowerContainer::print not implemented";
33 }
34 
35 
36 const 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 
80 {
82  m_map_fwID_towerID.clear();
83 }
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 
98 int gTowerContainer::getIDfromFWID(int fwID) const{
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 }
LVL1::gTowerContainer::m_map_fwID_towerID
std::unordered_map< int, int > m_map_fwID_towerID
Definition: gTowerContainer.h:75
LVL1::gTower::getFWID
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:202
gTowerContainer.h
LVL1::gTower
The gTower class is an interface object for gFEX trigger algorithms The purposes are twofold:
Definition: gTower.h:38
skel.it
it
Definition: skel.GENtoEVGEN.py:423
LVL1
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...
Definition: ICMMCPHitsCnvTool.h:18
SG::OwnershipPolicy
OwnershipPolicy
describes the possible element ownership policies (see e.g. DataVector)
Definition: OwnershipPolicy.h:16
LVL1::gTowerContainer::fillContainerMap
bool fillContainerMap()
utility function to help speed up accessing towers
Definition: gTowerContainer.cxx:85
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
REPORT_MESSAGE_WITH_CONTEXT
#define REPORT_MESSAGE_WITH_CONTEXT(LVL, CONTEXT_NAME)
Report a message, with an explicitly specified context name.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:345
LVL1::gTowerContainer::print
void print() const
dump (obsolete)
Definition: gTowerContainer.cxx:31
errorcheck.h
Helpers for checking error return status codes and reporting errors.
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
LVL1::gTowerContainer::getIDfromFWID
int getIDfromFWID(int fwID) const
given a firmware ID, it returns the simulation ID, it can be used to then find towers
Definition: gTowerContainer.cxx:98
LVL1::gTowerContainer::clearContainerMap
void clearContainerMap()
clear map
Definition: gTowerContainer.cxx:79
LVL1::gTowerContainer::push_back
void push_back(int eta, int phi, int nphi, int keybase, int posneg)
reimplementation of const push_back
Definition: gTowerContainer.cxx:26
LVL1::gTowerContainer::gTowerContainer
gTowerContainer(SG::OwnershipPolicy ownPolicy=SG::OWN_ELEMENTS)
Main constructor.
Definition: gTowerContainer.cxx:19
gTower.h
DataVector< LVL1::gTower >::size
size_type size() const noexcept
Returns the number of elements in the collection.
LVL1::gTowerContainer::m_map_towerID_containerIndex
std::unordered_map< int, int > m_map_towerID_containerIndex
Definition: gTowerContainer.h:72
LVL1::gTower::getID
int getID() const
Add to ET
Definition: gTower.cxx:124
LVL1::gTowerContainer::findTower
const LVL1::gTower * findTower(int towerID) const
fast find method given identifier.
Definition: gTowerContainer.cxx:36