ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
TrigT1
Global
GlobalSimulation
src
Lar_Preproc
GlobalCellTowerAlgTool.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
GlobalCellTowerAlgTool.h
"
6
7
#include "
../IO/GlobalLArCell.h
"
8
#include "
../IO/CommonTOB.h
"
9
10
#include <bitset>
11
12
13
namespace
GlobalSim
{
14
15
// Main constructor
16
GlobalCellTowerAlgTool::GlobalCellTowerAlgTool
(
const
std::string&
type
,
const
std::string& name,
const
IInterface* parent) :
17
base_class(
type
, name, parent) {
18
}
19
20
21
// Initialize function running before first event
22
StatusCode
GlobalCellTowerAlgTool::initialize
() {
23
24
CHECK
(
m_gblLArCellContainerKey
.initialize());
25
CHECK
(
m_gblCellTowers
.initialize());
26
27
return
StatusCode::SUCCESS;
28
}
29
30
31
// Main functional block running for each event
32
StatusCode
33
GlobalCellTowerAlgTool::run
(
const
std::unique_ptr<IDataCollector>& dc,
34
const
EventContext& ctx)
const
{
35
36
ATH_MSG_DEBUG
(
"Building cell towers"
);
37
if
(dc){dc->collect(*
this
,
"start"
);}
38
39
// Read in GlobalLArCellContainer
40
auto
h_gblLArCells =
SG::makeHandle
(
m_gblLArCellContainerKey
, ctx);
41
CHECK
(h_gblLArCells.isValid());
42
const
auto
& gblLArCells = *h_gblLArCells;
43
44
// Define tower array (98 eta bins x 64 phi bins)
45
static
constexpr
int
nEta{98};
46
static
constexpr
int
nPhi{64};
47
48
auto
pTowerEnergies = std::make_unique<std::array<std::array<float, nPhi>, nEta>>();
49
auto
& towerEnergies = *pTowerEnergies;
50
for
(
const
GlobalSim::GlobalLArCell
* cell : gblLArCells) {
51
52
// Compute eta and phi indices (binning in steps of 0.1)
53
int
eta_index =
static_cast<
int
>
(std::floor(cell->eta() * 10)) + 49;
54
int
phi_index =
static_cast<
int
>
(std::floor(cell->phi() * 10)) + 32;
55
56
// Ensure indices are within bounds
57
if
(eta_index < 0 || eta_index >= nEta || phi_index < 0 || phi_index >= nPhi)
continue
;
58
59
// Add cell energy to the corresponding tower
60
towerEnergies[eta_index][phi_index] += cell->getEnergy();
61
}
62
63
auto
h_towerTOBs =
SG::makeHandle
(
m_gblCellTowers
, ctx);
64
auto
towers = std::make_unique<IOBitwise::CommonTOBContainer>();
65
towers->reserve(nEta * nPhi);
66
67
for
(
int
etaBin = 0; etaBin < nEta; ++etaBin) {
68
for
(
int
phiBin = 0; phiBin < nPhi; ++phiBin) {
69
70
if
(towerEnergies[etaBin][phiBin] == 0)
continue
;
71
int
energyBits = std::clamp(
static_cast<
int
>
(towerEnergies[etaBin][phiBin]), 0, (1 <<
IOBitwise::CommonTOB::s_et_width
) - 1);
72
73
74
towers->emplace_back(
new
IOBitwise::CommonTOB
(std::bitset<IOBitwise::CommonTOB::s_et_width>(energyBits),
75
std::bitset<IOBitwise::CommonTOB::s_eta_width>(etaBin),
76
std::bitset<IOBitwise::CommonTOB::s_phi_width>(phiBin)));
77
}
78
}
79
80
ATH_MSG_DEBUG
(
"Built "
<< towers->size() <<
" cell towers and stored them as GenericTobs"
);
81
82
CHECK
(h_towerTOBs.record(std::move(towers)));
83
84
if
(dc){dc->collect(*
this
,
"end"
);}
85
86
return
StatusCode::SUCCESS;
87
}
88
89
// Overrides toString() function from base class, unused here
90
std::string
GlobalCellTowerAlgTool::toString
()
const
{
91
return
{};
92
}
93
94
}
//namespace GlobalSim
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
CommonTOB.h
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition
Control/AthenaKernel/AthenaKernel/errorcheck.h:422
GlobalCellTowerAlgTool.h
GlobalLArCell.h
GlobalSim::GlobalCellTowerAlgTool::run
virtual StatusCode run(const std::unique_ptr< IDataCollector > &, const EventContext &ctx) const override
Main functional block running for each event.
Definition
GlobalCellTowerAlgTool.cxx:33
GlobalSim::GlobalCellTowerAlgTool::GlobalCellTowerAlgTool
GlobalCellTowerAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Main constructor.
Definition
GlobalCellTowerAlgTool.cxx:16
GlobalSim::GlobalCellTowerAlgTool::m_gblLArCellContainerKey
SG::ReadHandleKey< GlobalSim::GlobalLArCellContainer > m_gblLArCellContainerKey
Key to the GlobalLArCellContainer.
Definition
GlobalCellTowerAlgTool.h:55
GlobalSim::GlobalCellTowerAlgTool::initialize
virtual StatusCode initialize() override
Initialize function running before first event.
Definition
GlobalCellTowerAlgTool.cxx:22
GlobalSim::GlobalCellTowerAlgTool::m_gblCellTowers
SG::WriteHandleKey< IOBitwise::CommonTOBContainer > m_gblCellTowers
Write key for the output cell towers as a GenericTobContainer.
Definition
GlobalCellTowerAlgTool.h:58
GlobalSim::GlobalCellTowerAlgTool::toString
virtual std::string toString() const override
Overriding toString function from base class.
Definition
GlobalCellTowerAlgTool.cxx:90
GlobalSim::GlobalLArCell
Definition
GlobalLArCell.h:14
GlobalSim::IOBitwise::CommonTOB
Definition
CommonTOB.h:22
GlobalSim::IOBitwise::CommonTOB::s_et_width
static constexpr std::size_t s_et_width
Size of the eT bitset.
Definition
CommonTOB.h:28
GlobalSim
AlgTool to read in LArStripNeighborhoods, and run the BDT Algorithm.
Definition
Trigger/TrigT1/Global/GlobalSimulation/src/Egamma1BDT/Egamma1BDT/BDT.h:11
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition
ReadCondHandle.h:269
type
Generated on
for ATLAS Offline Software by
1.17.0