ATLAS Offline Software
jTowerContainer.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // Code stolen shamelessly from Calorimeter/CaloEvent/src/CaloCellContainer.cxx and modified
6 
8 #include "L1CaloFEXSim/jTower.h"
10 #include "CLHEP/Geometry/Vector3D.h"
11 #include <atomic>
12 
13 namespace LVL1 {
14 
16  DataVector<LVL1::jTower>(ownPolicy)
17 {
19 }
20 
21 void jTowerContainer::push_back(float eta, float phi, int towerid, int posneg, float centre_eta, float centre_phi, int fcal_layer)
22 {
23  DataVector<LVL1::jTower>::push_back(std::make_unique<jTower>(eta,phi,towerid,posneg,centre_eta,centre_phi,fcal_layer));
24 }
25 
26 void jTowerContainer::print() const {
27  REPORT_MESSAGE_WITH_CONTEXT (MSG::WARNING, "jTowerContainer") << "jTowerContainer::print not implemented";
28 }
29 
30 
31 const LVL1::jTower * jTowerContainer::findTower(int towerID) const
32 {
33  const auto it = m_map_towerID_containerIndex.find(towerID);
34  if (it==m_map_towerID_containerIndex.cend()) {
35  return nullptr;
36  }
37  const int container_index = it->second;
38  if (container_index < 0) {
39  return nullptr;
40  }
41  return (*this)[container_index];
42 }
43 
45  const auto it = m_map_towerID_containerIndex.find(towerID);
46  if (it==m_map_towerID_containerIndex.cend()) {
47  return nullptr;
48  }
49  const int container_index = it->second;
50  if (container_index < 0) {
51  return nullptr;
52  }
53  return (*this)[container_index];
54 }
55 
57 {
59 }
60 
63  size_t ntowers = size();
64  for (size_t itower = 0; itower < ntowers; itower++) {
65  const jTower * theTower = (*this)[itower];
66  int towerID = theTower->constid();
67  int container_index = itower;
68  m_map_towerID_containerIndex.insert(std::pair<int,int>(towerID,container_index));
69  }
70  return true;
71 }
72 
73 }
LVL1::jTowerContainer::print
void print() const
dump (obsolete)
Definition: jTowerContainer.cxx:26
skel.it
it
Definition: skel.GENtoEVGEN.py:396
LVL1::jTowerContainer::findTower
const LVL1::jTower * findTower(int towerID) const
fast find method given identifier.
Definition: jTowerContainer.cxx:31
LVL1::jTowerContainer::fillContainerMap
bool fillContainerMap()
utility function to help speed up accessing towers
Definition: jTowerContainer.cxx:61
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::jTowerContainer::m_map_towerID_containerIndex
std::unordered_map< int, int > m_map_towerID_containerIndex
Definition: jTowerContainer.h:77
LVL1::jTowerContainer::jTowerContainer
jTowerContainer(SG::OwnershipPolicy ownPolicy=SG::OWN_ELEMENTS)
Main constructor.
Definition: jTowerContainer.cxx:15
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
LVL1::jTowerContainer::push_back
void push_back(float eta, float phi, int towerid, int posneg, float centre_et=0.0, float centre_phi=0.0, int fcal_layer=-1)
reimplementation of const push_back
Definition: jTowerContainer.cxx:21
jTowerContainer.h
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
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::jTower
The jTower class is an interface object for jFEX trigger algorithms The purposes are twofold:
Definition: jTower.h:40
LVL1::jTowerContainer::clearContainerMap
void clearContainerMap()
clear map
Definition: jTowerContainer.cxx:56
LVL1::jTower::constid
float constid() const
Definition: jTower.h:114
jTower.h
DataVector< LVL1::jTower >::size
size_type size() const noexcept
Returns the number of elements in the collection.