ATLAS Offline Software
Loading...
Searching...
No Matches
GlobalSim::GlobalCellTowerAlgTool Class Reference

#include <GlobalCellTowerAlgTool.h>

Inheritance diagram for GlobalSim::GlobalCellTowerAlgTool:
Collaboration diagram for GlobalSim::GlobalCellTowerAlgTool:

Public Member Functions

 GlobalCellTowerAlgTool (const std::string &type, const std::string &name, const IInterface *parent)
 Main constructor.
 ~GlobalCellTowerAlgTool () override=default
 Main destructor (explicitly defaulted)
virtual StatusCode initialize () override
 Initialize function running before first event.
virtual StatusCode run (const EventContext &ctx) const override
 Main functional block running for each event.
virtual std::string toString () const override
 Overriding toString function from base class.

Private Attributes

SG::ReadHandleKey< GlobalSim::GlobalLArCellContainerm_gblLArCellContainerKey {this, "GlobalLArCellsKey", "GlobalLArCells", "Key for the output container of the LAr cells sent to Global"}
 Key to the GlobalLArCellContainer.
SG::WriteHandleKey< IOBitwise::CommonTOBContainerm_gblCellTowers {this, "GlobalCellTowersKey", "GlobalCellTowers", "Key to the container of generic TOBS containing the cell towers"}
 Write key for the output cell towers as a GenericTobContainer.

Detailed Description

Definition at line 30 of file GlobalCellTowerAlgTool.h.

Constructor & Destructor Documentation

◆ GlobalCellTowerAlgTool()

GlobalSim::GlobalCellTowerAlgTool::GlobalCellTowerAlgTool ( const std::string & type,
const std::string & name,
const IInterface * parent )

Main constructor.

Definition at line 16 of file GlobalCellTowerAlgTool.cxx.

16 :
17 base_class(type, name, parent) {
18 }

◆ ~GlobalCellTowerAlgTool()

GlobalSim::GlobalCellTowerAlgTool::~GlobalCellTowerAlgTool ( )
overridedefault

Main destructor (explicitly defaulted)

Member Function Documentation

◆ initialize()

StatusCode GlobalSim::GlobalCellTowerAlgTool::initialize ( )
overridevirtual

Initialize function running before first event.

Definition at line 22 of file GlobalCellTowerAlgTool.cxx.

22 {
23
24 CHECK(m_gblLArCellContainerKey.initialize());
25 CHECK(m_gblCellTowers.initialize());
26
27 return StatusCode::SUCCESS;
28 }
#define CHECK(...)
Evaluate an expression and check for errors.
SG::ReadHandleKey< GlobalSim::GlobalLArCellContainer > m_gblLArCellContainerKey
Key to the GlobalLArCellContainer.
SG::WriteHandleKey< IOBitwise::CommonTOBContainer > m_gblCellTowers
Write key for the output cell towers as a GenericTobContainer.

◆ run()

StatusCode GlobalSim::GlobalCellTowerAlgTool::run ( const EventContext & ctx) const
overridevirtual

Main functional block running for each event.

Definition at line 32 of file GlobalCellTowerAlgTool.cxx.

32 {
33
34 ATH_MSG_DEBUG("Building cell towers");
35
36 // Read in GlobalLArCellContainer
37 auto h_gblLArCells = SG::makeHandle(m_gblLArCellContainerKey, ctx);
38 CHECK(h_gblLArCells.isValid());
39 const auto & gblLArCells = *h_gblLArCells;
40
41 // Define tower array (98 eta bins x 64 phi bins)
42 static constexpr int nEta{98};
43 static constexpr int nPhi{64};
44
45 auto pTowerEnergies = std::make_unique<std::array<std::array<float, nPhi>, nEta>>();
46 auto & towerEnergies = *pTowerEnergies;
47 for (const GlobalSim::GlobalLArCell* cell : gblLArCells) {
48
49 // Compute eta and phi indices (binning in steps of 0.1)
50 int eta_index = static_cast<int>(std::floor(cell->eta() * 10)) + 49;
51 int phi_index = static_cast<int>(std::floor(cell->phi() * 10)) + 32;
52
53 // Ensure indices are within bounds
54 if (eta_index < 0 || eta_index >= nEta || phi_index < 0 || phi_index >= nPhi) continue;
55
56 // Add cell energy to the corresponding tower
57 towerEnergies[eta_index][phi_index] += cell->getEnergy();
58 }
59
60 auto h_towerTOBs = SG::makeHandle(m_gblCellTowers, ctx);
61 auto towers = std::make_unique<IOBitwise::CommonTOBContainer>();
62 towers->reserve(nEta * nPhi);
63
64 for (int etaBin = 0; etaBin < nEta; ++etaBin) {
65 for (int phiBin = 0; phiBin < nPhi; ++phiBin) {
66
67 if (towerEnergies[etaBin][phiBin] == 0) continue;
68 int energyBits = std::clamp(static_cast<int>(towerEnergies[etaBin][phiBin]), 0, (1 << IOBitwise::CommonTOB::s_et_width) - 1);
69
70
71 towers->emplace_back(new IOBitwise::CommonTOB(std::bitset<IOBitwise::CommonTOB::s_et_width>(energyBits),
72 std::bitset<IOBitwise::CommonTOB::s_eta_width>(etaBin),
73 std::bitset<IOBitwise::CommonTOB::s_phi_width>(phiBin)));
74 }
75 }
76
77 ATH_MSG_DEBUG("Built " << towers->size() << " cell towers and stored them as GenericTobs");
78
79 CHECK(h_towerTOBs.record(std::move(towers)));
80
81 return StatusCode::SUCCESS;
82 }
#define ATH_MSG_DEBUG(x)
static constexpr std::size_t s_et_width
Size of the eT bitset.
Definition CommonTOB.h:28
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
constexpr int nEta
Default bin number of eta for vertex map.
constexpr int nPhi
Default bin number of phi for vertex map.
setSAddress setEtaMS setDirPhiMS setDirZMS setBarrelRadius setEndcapAlpha setEndcapRadius setPhiMap phiBin
setSAddress setEtaMS setDirPhiMS setDirZMS setBarrelRadius setEndcapAlpha setEndcapRadius setInterceptInner setEtaMap etaBin

◆ toString()

std::string GlobalSim::GlobalCellTowerAlgTool::toString ( ) const
overridevirtual

Overriding toString function from base class.

Definition at line 85 of file GlobalCellTowerAlgTool.cxx.

85 {
86 return {};
87 }

Member Data Documentation

◆ m_gblCellTowers

SG::WriteHandleKey<IOBitwise::CommonTOBContainer> GlobalSim::GlobalCellTowerAlgTool::m_gblCellTowers {this, "GlobalCellTowersKey", "GlobalCellTowers", "Key to the container of generic TOBS containing the cell towers"}
private

Write key for the output cell towers as a GenericTobContainer.

Definition at line 55 of file GlobalCellTowerAlgTool.h.

55{this, "GlobalCellTowersKey", "GlobalCellTowers", "Key to the container of generic TOBS containing the cell towers"};

◆ m_gblLArCellContainerKey

SG::ReadHandleKey<GlobalSim::GlobalLArCellContainer> GlobalSim::GlobalCellTowerAlgTool::m_gblLArCellContainerKey {this, "GlobalLArCellsKey", "GlobalLArCells", "Key for the output container of the LAr cells sent to Global"}
private

Key to the GlobalLArCellContainer.

Definition at line 52 of file GlobalCellTowerAlgTool.h.

52{this, "GlobalLArCellsKey", "GlobalLArCells", "Key for the output container of the LAr cells sent to Global"};

The documentation for this class was generated from the following files: