ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
MuonSpectrometer
MuonPhaseII
MuonCnv
MuonBucketDump
src
CaloCellsDumperAlg.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 "
CaloCellsDumperAlg.h
"
6
7
#include "
StoreGate/ReadHandle.h
"
8
#include "CaloDetDescr/CaloDetDescrElement.h"
9
#include "
CaloEvent/CaloCell.h
"
10
#include "CaloEvent/CaloTower.h"
11
#include "
AthenaKernel/errorcheck.h
"
12
#include <cmath>
13
14
namespace
MuonR4
{
15
16
StatusCode
CaloCellsDumperAlg::initialize
() {
17
ATH_CHECK
(
m_cellKey
.initialize());
18
ATH_CHECK
(
m_towerKey
.initialize(
SG::AllowEmpty
));
19
20
// CaloCell_ID helper (to provide subCalo/sampling via Identifier decoding if desired)
21
ATH_CHECK
(
detStore
()->retrieve(
m_caloId
,
"CaloCell_ID"
));
22
23
// Event hash branch
24
m_evtHash
= std::make_shared<MuonVal::EventHashBranch>(
m_tree
.tree());
25
m_tree
.addBranch(
m_evtHash
);
26
27
ATH_CHECK
(
m_tree
.init(
this
));
28
ATH_MSG_INFO
(
"Initialized Calo dump with:"
29
<<
" CellContainerKey="
<<
m_cellKey
.key()
30
<<
" MinCellEnergyMeV="
<<
m_minE
31
<<
" MaxCells="
<<
m_maxCells
32
<<
" | TowerContainerKey="
<<
m_towerKey
.key()
33
<<
" MinTowerEnergyMeV="
<<
m_minTowerE
34
<<
" MaxTowers="
<<
m_maxTowers
);
35
return
StatusCode::SUCCESS;
36
}
37
38
StatusCode
CaloCellsDumperAlg::finalize
() {
39
ATH_CHECK
(
m_tree
.write());
40
return
StatusCode::SUCCESS;
41
}
42
43
StatusCode
CaloCellsDumperAlg::execute
(
const
EventContext& ctx) {
44
45
// -----------------------------
46
// Cells
47
// -----------------------------
48
const
CaloCellContainer
* cells{};
49
ATH_CHECK
(
SG::get
(cells,
m_cellKey
, ctx));
50
51
int
nStored = 0;
52
for
(
const
CaloCell
* cell : *cells) {
53
if
(!cell)
continue
;
54
55
// energy() is in MeV for CaloCell
56
const
float
eMeV = cell->energy();
57
if
(eMeV <
m_minE
)
continue
;
58
59
const
CaloDetDescrElement
* dde = cell->caloDDE();
60
if
(!dde)
continue
;
61
62
// Store Identifier
63
const
Identifier
&
id
= cell->ID();
64
m_cell_id
.push_back(
id
);
65
66
// Store position (x,y,z) in mm, eta/phi from DDE
67
const
Amg::Vector3D
pos(dde->
x
(), dde->
y
(), dde->
z
());
68
m_cell_pos
.push_back(pos);
69
m_cell_energy
.push_back(eMeV);
70
m_cell_eta
.push_back(dde->
eta
());
71
m_cell_phi
.push_back(dde->
phi
());
72
73
// Sampling / subCalo
74
// - dde->getSampling() gives CaloSampling::CaloSample enum (int)
75
// - CaloCell_ID can decode subCalo for the Identifier
76
m_cell_sampling
.push_back(
static_cast<
int
>
(dde->
getSampling
()));
77
m_cell_subCalo
.push_back(
static_cast<
int
>
(
m_caloId
->sub_calo(
id
)));
78
m_cell_isTile
.push_back(
static_cast<
unsigned
short
>
(dde->
is_tile
()));
79
80
++nStored;
81
if
(
m_maxCells
.value() > 0 && nStored >=
m_maxCells
.value())
break
;
82
}
83
84
// -----------------------------
85
// Towers
86
// -----------------------------
87
const
CaloTowerContainer
* towers{};
88
ATH_CHECK
(
SG::get
(towers,
m_towerKey
, ctx));
89
int
nTowStored = 0;
90
for
(
const
CaloTower
* tow : *towers) {
91
if
(!tow)
continue
;
92
93
// CaloTower energy is in MeV (same convention as cells)
94
const
float
eMeV = tow->energy();
95
if
(eMeV <
m_minTowerE
)
continue
;
96
97
const
float
eta
= tow->eta();
98
const
float
phi
= tow->phi();
99
const
float
etMeV = eMeV / std::cosh(
eta
);
100
101
m_tower_energy
.push_back(eMeV);
102
m_tower_et
.push_back(etMeV);
103
m_tower_eta
.push_back(
eta
);
104
m_tower_phi
.push_back(
phi
);
105
106
// Derived direction vector (unit length) from eta/phi
107
const
double
theta
= 2.0 * std::atan(std::exp(-
static_cast<
double
>
(
eta
)));
108
const
double
st = std::sin(
theta
);
109
const
double
ct = std::cos(
theta
);
110
const
double
cp = std::cos(
static_cast<
double
>
(
phi
));
111
const
double
sp
= std::sin(
static_cast<
double
>
(
phi
));
112
const
Amg::Vector3D
dir(st * cp, st *
sp
, ct);
113
m_tower_dir
.push_back(dir);
114
115
// Try to provide tower "size" (how many cells contribute)
116
m_tower_nCells
.push_back(
static_cast<
unsigned
int
>
(tow->size()));
117
118
++nTowStored;
119
if
(
m_maxTowers
.value() > 0 && nTowStored >=
m_maxTowers
.value())
break
;
120
}
121
122
if
(!
m_tree
.fill(ctx))
return
StatusCode::FAILURE;
123
return
StatusCode::SUCCESS;
124
}
125
126
}
// namespace MuonR4
eta
Scalar eta() const
pseudorapidity method
Definition
AmgMatrixBasePlugin.h:83
phi
Scalar phi() const
phi method
Definition
AmgMatrixBasePlugin.h:67
theta
Scalar theta() const
theta method
Definition
AmgMatrixBasePlugin.h:75
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
CaloCell.h
CaloCellsDumperAlg.h
errorcheck.h
Helpers for checking error return status codes and reporting errors.
sp
static Double_t sp
Definition
LArPhysWaveHECTool.cxx:37
ReadHandle.h
Handle class for reading from StoreGate.
AthCommonAlgorithm< Gaudi::Algorithm >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
Definition
AthCommonDataStore.h:95
CaloCellContainer
Container class for CaloCell.
Definition
CaloCellContainer.h:55
CaloCell
Data object for each calorimeter readout cell.
Definition
CaloCell.h:57
CaloDetDescrElement
This class groups all DetDescr information related to a CaloCell.
Definition
Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:66
CaloDetDescrElement::is_tile
bool is_tile() const
cell belongs to Tile
Definition
Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:442
CaloDetDescrElement::y
float y() const
cell y
Definition
Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:365
CaloDetDescrElement::getSampling
CaloCell_ID::CaloSample getSampling() const
cell sampling
Definition
Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:395
CaloDetDescrElement::eta
float eta() const
cell eta
Definition
Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:344
CaloDetDescrElement::phi
float phi() const
cell phi
Definition
Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:346
CaloDetDescrElement::x
float x() const
cell x
Definition
Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:363
CaloDetDescrElement::z
float z() const
cell z
Definition
Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:367
CaloTowerContainer
Storable container class for CaloTower.
Definition
Calorimeter/CaloEvent/CaloEvent/CaloTowerContainer.h:77
CaloTower
Data class for calorimeter cell towers.
Definition
Calorimeter/CaloEvent/CaloEvent/CaloTower.h:55
MuonR4::CaloCellsDumperAlg::m_cell_isTile
MuonVal::VectorBranch< unsigned short > & m_cell_isTile
Definition
CaloCellsDumperAlg.h:58
MuonR4::CaloCellsDumperAlg::m_towerKey
SG::ReadHandleKey< CaloTowerContainer > m_towerKey
Definition
CaloCellsDumperAlg.h:33
MuonR4::CaloCellsDumperAlg::m_cellKey
SG::ReadHandleKey< CaloCellContainer > m_cellKey
Definition
CaloCellsDumperAlg.h:31
MuonR4::CaloCellsDumperAlg::m_cell_eta
MuonVal::VectorBranch< float > & m_cell_eta
Definition
CaloCellsDumperAlg.h:54
MuonR4::CaloCellsDumperAlg::m_evtHash
std::shared_ptr< MuonVal::EventHashBranch > m_evtHash
Definition
CaloCellsDumperAlg.h:48
MuonR4::CaloCellsDumperAlg::finalize
StatusCode finalize() override final
Definition
CaloCellsDumperAlg.cxx:38
MuonR4::CaloCellsDumperAlg::m_tower_dir
MuonVal::ThreeVectorBranch m_tower_dir
Definition
CaloCellsDumperAlg.h:65
MuonR4::CaloCellsDumperAlg::m_caloId
const CaloCell_ID * m_caloId
Definition
CaloCellsDumperAlg.h:44
MuonR4::CaloCellsDumperAlg::m_minE
Gaudi::Property< float > m_minE
Definition
CaloCellsDumperAlg.h:35
MuonR4::CaloCellsDumperAlg::execute
StatusCode execute(const EventContext &ctx) override final
Execute method.
Definition
CaloCellsDumperAlg.cxx:43
MuonR4::CaloCellsDumperAlg::m_cell_phi
MuonVal::VectorBranch< float > & m_cell_phi
Definition
CaloCellsDumperAlg.h:55
MuonR4::CaloCellsDumperAlg::m_tower_energy
MuonVal::VectorBranch< float > & m_tower_energy
Definition
CaloCellsDumperAlg.h:61
MuonR4::CaloCellsDumperAlg::m_cell_subCalo
MuonVal::VectorBranch< int > & m_cell_subCalo
Definition
CaloCellsDumperAlg.h:57
MuonR4::CaloCellsDumperAlg::m_cell_pos
MuonVal::ThreeVectorBranch m_cell_pos
Definition
CaloCellsDumperAlg.h:52
MuonR4::CaloCellsDumperAlg::m_tower_et
MuonVal::VectorBranch< float > & m_tower_et
Definition
CaloCellsDumperAlg.h:62
MuonR4::CaloCellsDumperAlg::m_maxCells
Gaudi::Property< int > m_maxCells
Definition
CaloCellsDumperAlg.h:37
MuonR4::CaloCellsDumperAlg::m_minTowerE
Gaudi::Property< float > m_minTowerE
Definition
CaloCellsDumperAlg.h:39
MuonR4::CaloCellsDumperAlg::m_cell_sampling
MuonVal::VectorBranch< int > & m_cell_sampling
Definition
CaloCellsDumperAlg.h:56
MuonR4::CaloCellsDumperAlg::m_cell_energy
MuonVal::VectorBranch< float > & m_cell_energy
Definition
CaloCellsDumperAlg.h:53
MuonR4::CaloCellsDumperAlg::m_tower_phi
MuonVal::VectorBranch< float > & m_tower_phi
Definition
CaloCellsDumperAlg.h:64
MuonR4::CaloCellsDumperAlg::m_tower_nCells
MuonVal::VectorBranch< unsigned int > & m_tower_nCells
Definition
CaloCellsDumperAlg.h:66
MuonR4::CaloCellsDumperAlg::m_maxTowers
Gaudi::Property< int > m_maxTowers
Definition
CaloCellsDumperAlg.h:41
MuonR4::CaloCellsDumperAlg::initialize
StatusCode initialize() override final
Definition
CaloCellsDumperAlg.cxx:16
MuonR4::CaloCellsDumperAlg::m_tree
MuonVal::MuonTesterTree m_tree
Definition
CaloCellsDumperAlg.h:46
MuonR4::CaloCellsDumperAlg::m_tower_eta
MuonVal::VectorBranch< float > & m_tower_eta
Definition
CaloCellsDumperAlg.h:63
MuonR4::CaloCellsDumperAlg::m_cell_id
MuonVal::MuonIdentifierBranch m_cell_id
Definition
CaloCellsDumperAlg.h:51
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition
GeoPrimitives.h:47
Identifier
Definition
IdentifierFieldParser.cxx:14
MuonR4
This header ties the generic definitions in this package.
Definition
GlobalPattern.h:14
SG::AllowEmpty
@ AllowEmpty
Definition
StoreGate/StoreGate/VarHandleKey.h:27
SG::get
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
Definition
ReadCondHandle.h:282
Generated on
for ATLAS Offline Software by
1.17.0