ATLAS Offline Software
Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
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. More...
 
 ~GlobalCellTowerAlgTool () override=default
 Main destructor (explicitly defaulted) More...
 
virtual StatusCode initialize () override
 Initialize function running before first event. More...
 
virtual StatusCode run (const EventContext &ctx) const override
 Main functional block running for each event. More...
 
virtual std::string toString () const override
 Overriding toString function from base class. More...
 

Static Public Member Functions

static std::string toBinary (int value, int width)
 Helper function to convert floating point values into a bitstream. More...
 
static std::string makeTowerBits (int energy, int etaBin, int phiBin)
 Function which assembles the TOB bitstream for a tower. More...
 

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. More...
 
SG::WriteHandleKey< GenericTobContainerm_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. More...
 

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 12 of file GlobalCellTowerAlgTool.cxx.

12  :
13  base_class(type, name, parent) {
14  }

◆ ~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 18 of file GlobalCellTowerAlgTool.cxx.

18  {
19 
22 
23  return StatusCode::SUCCESS;
24  }

◆ makeTowerBits()

std::string GlobalSim::GlobalCellTowerAlgTool::makeTowerBits ( int  energy,
int  etaBin,
int  phiBin 
)
static

Function which assembles the TOB bitstream for a tower.

Definition at line 81 of file GlobalCellTowerAlgTool.cxx.

81  {
85  std::string(3, '0');
86  }

◆ run()

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

Main functional block running for each event.

Definition at line 28 of file GlobalCellTowerAlgTool.cxx.

28  {
29 
30  ATH_MSG_DEBUG("Building cell towers");
31 
32  // Read in GlobalLArCellContainer
33  auto h_gblLArCells = SG::makeHandle(m_gblLArCellContainerKey, ctx);
34  CHECK(h_gblLArCells.isValid());
35  const auto & gblLArCells = *h_gblLArCells;
36 
37  // Define tower array (98 eta bins x 64 phi bins)
38  static constexpr int nEta{98};
39  static constexpr int nPhi{64};
40 
41  std::array<std::array<float, nPhi>, nEta> towerEnergies{};
42 
43  for (const auto& cell : gblLArCells) {
44 
45  // Compute eta and phi indices (binning in steps of 0.1)
46  int eta_index = static_cast<int>(std::floor(cell->eta() * 10)) + 49;
47  int phi_index = static_cast<int>(std::floor(cell->phi() * 10)) + 32;
48 
49  // Ensure indices are within bounds
50  if (eta_index < 0 || eta_index >= nEta || phi_index < 0 || phi_index >= nPhi) continue;
51 
52  // Add cell energy to the corresponding tower
53  towerEnergies[eta_index][phi_index] += cell->getEnergy();
54  }
55 
56  auto h_towerTOBs = SG::makeHandle(m_gblCellTowers, ctx);
57  auto towers = std::make_unique<GenericTobContainer>();
58  towers->reserve(nEta * nPhi);
59 
60  for (int etaBin = 0; etaBin < nEta; ++etaBin) {
61  for (int phiBin = 0; phiBin < nPhi; ++phiBin) {
62 
63  if (towerEnergies[etaBin][phiBin] == 0) continue;
64  int energyBits = std::clamp(static_cast<int>(towerEnergies[etaBin][phiBin]), 0, (1 << 13) - 1);
65 
66  std::string bit_string = makeTowerBits(energyBits, etaBin, phiBin);
67 
68  towers->emplace_back(std::make_shared<GenericTob>(bit_string));
69  }
70  }
71 
72  ATH_MSG_DEBUG("Built " << towers->size() << " cell towers and stored them as GenericTobs");
73 
74  CHECK(h_towerTOBs.record(std::move(towers)));
75 
76  return StatusCode::SUCCESS;
77  }

◆ toBinary()

static std::string GlobalSim::GlobalCellTowerAlgTool::toBinary ( int  value,
int  width 
)
inlinestatic

Helper function to convert floating point values into a bitstream.

Definition at line 47 of file GlobalCellTowerAlgTool.h.

47  {
48  assert(width <= 32);
49  return std::bitset<32>(value).to_string().substr(32 - width);
50  }

◆ toString()

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

Overriding toString function from base class.

Definition at line 90 of file GlobalCellTowerAlgTool.cxx.

90  {
91  return {};
92  }

Member Data Documentation

◆ m_gblCellTowers

SG::WriteHandleKey<GenericTobContainer> 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 64 of file GlobalCellTowerAlgTool.h.

◆ 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 61 of file GlobalCellTowerAlgTool.h.


The documentation for this class was generated from the following files:
ReadCellNoiseFromCool.cell
cell
Definition: ReadCellNoiseFromCool.py:53
GlobalSim::GlobalCellTowerAlgTool::m_gblLArCellContainerKey
SG::ReadHandleKey< GlobalSim::GlobalLArCellContainer > m_gblLArCellContainerKey
Key to the GlobalLArCellContainer.
Definition: GlobalCellTowerAlgTool.h:61
GlobalSim::GlobalCellTowerAlgTool::toBinary
static std::string toBinary(int value, int width)
Helper function to convert floating point values into a bitstream.
Definition: GlobalCellTowerAlgTool.h:47
athena.value
value
Definition: athena.py:124
TrigVSI::AlgConsts::nPhi
constexpr int nPhi
Default bin number of phi for vertex map.
Definition: Trigger/TrigTools/TrigVrtSecInclusive/TrigVrtSecInclusive/Constants.h:27
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:274
xAOD::etaBin
setSAddress setEtaMS setDirPhiMS setDirZMS setBarrelRadius setEndcapAlpha setEndcapRadius setInterceptInner setEtaMap etaBin
Definition: L2StandAloneMuon_v1.cxx:149
ParticleGun_FastCalo_ChargeFlip_Config.energy
energy
Definition: ParticleGun_FastCalo_ChargeFlip_Config.py:78
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
test_pyathena.parent
parent
Definition: test_pyathena.py:15
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
createCablingJSON.eta_index
int eta_index
Definition: createCablingJSON.py:14
GlobalSim::GlobalCellTowerAlgTool::m_gblCellTowers
SG::WriteHandleKey< GenericTobContainer > m_gblCellTowers
Write key for the output cell towers as a GenericTobContainer.
Definition: GlobalCellTowerAlgTool.h:64
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
xAOD::phiBin
setSAddress setEtaMS setDirPhiMS setDirZMS setBarrelRadius setEndcapAlpha setEndcapRadius setPhiMap phiBin
Definition: L2StandAloneMuon_v2.cxx:145
GlobalSim::GlobalCellTowerAlgTool::makeTowerBits
static std::string makeTowerBits(int energy, int etaBin, int phiBin)
Function which assembles the TOB bitstream for a tower.
Definition: GlobalCellTowerAlgTool.cxx:81
Base_Fragment.width
width
Definition: Sherpa_i/share/common/Base_Fragment.py:59
RunTileMonitoring.towers
towers
Definition: RunTileMonitoring.py:133
TrigVSI::AlgConsts::nEta
constexpr int nEta
Default bin number of eta for vertex map.
Definition: Trigger/TrigTools/TrigVrtSecInclusive/TrigVrtSecInclusive/Constants.h:26