ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Calorimeter
CaloCnv
CaloJiveXML
src
CaloClusterRetriever.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 "
CaloClusterRetriever.h
"
6
7
#include "
AthenaKernel/Units.h
"
8
9
using
Athena::Units::GeV;
10
11
namespace
JiveXML
{
12
13
StatusCode
CaloClusterRetriever::initialize
()
14
{
15
16
ATH_MSG_DEBUG
(
"Initialising Tool"
);
17
18
ATH_CHECK
(
m_sgKeyFavourite
.initialize());
19
20
return
StatusCode::SUCCESS;
21
}
22
28
StatusCode
CaloClusterRetriever::retrieve
(ToolHandle<IFormatTool> &FormatTool) {
29
30
ATH_MSG_DEBUG
(
"in retrieveAll()"
);
31
32
//obtain the default collection first
33
ATH_MSG_DEBUG
(
"Trying to retrieve "
<<
dataTypeName
() <<
" ("
<<
m_sgKeyFavourite
.key() <<
")"
);
34
35
SG::ReadHandle<xAOD::CaloClusterContainer>
ccc_primary(
m_sgKeyFavourite
);
36
if
(ccc_primary.
isValid
()) {
37
DataMap
data =
getData
(&(*ccc_primary));
38
if
(FormatTool->AddToEvent(
dataTypeName
(),
m_sgKeyFavourite
.key() +
"_ESD"
, &data).isFailure()) {
39
ATH_MSG_WARNING
(
"Failed to retrieve favourite Collection "
<<
m_sgKeyFavourite
.key() );
40
}
41
else
{
42
ATH_MSG_DEBUG
(
dataTypeName
() <<
" ("
<<
m_sgKeyFavourite
.key() <<
") CaloCluster retrieved"
);
43
}
44
}
45
else
{
46
ATH_MSG_WARNING
(
"Favourite Collection "
<<
m_sgKeyFavourite
.key() <<
" not found in SG "
);
47
}
48
49
if
(
m_otherKeys
.empty() ) {
50
//obtain all other collections from StoreGate
51
std::vector<std::string> allkeys;
52
evtStore()->keys(
static_cast<
CLID
>
(
ClassID_traits<xAOD::CaloClusterContainer>::ID
() ), allkeys);
53
for
(
const
auto
& key : allkeys) {
54
if
(key!=
m_sgKeyFavourite
.key()) {
55
ATH_MSG_DEBUG
(
"Trying to retrieve all "
<<
dataTypeName
() <<
" ("
<< key <<
")"
);
56
SG::ReadHandle<xAOD::CaloClusterContainer>
containerRH(key);
57
if
(!containerRH.
isValid
()) {
58
ATH_MSG_DEBUG
(
"Unable to retrieve CaloCluster collection "
<< key );
59
}
else
{
60
std::string::size_type position = key.find(
"HLTAutoKey"
,0);
61
if
(
m_doWriteHLT
){ position = 99; }
// override SG key find
62
if
( position != 0 ){
// SG key doesn't contain HLTAutoKey
63
DataMap
data =
getData
(&*containerRH);
64
if
( FormatTool->AddToEvent(
dataTypeName
(), containerRH.
key
()+
"_ESD"
, &data).isFailure()){
65
ATH_MSG_WARNING
(
"Collection "
<< containerRH.
key
() <<
" not found in SG "
);
66
}
else
{
67
ATH_MSG_DEBUG
(
dataTypeName
() <<
" ("
<< containerRH.
key
() <<
") CaloCluster retrieved"
);
68
}
69
}
70
}
71
}
72
}
73
}
else
{
74
//obtain all collections with keys provided by user: m_otherKeys
75
for
(
const
auto
& key :
m_otherKeys
) {
76
if
(key!=
m_sgKeyFavourite
.key()) {
77
ATH_MSG_DEBUG
(
"Trying to retrieve selected "
<<
dataTypeName
() <<
" ("
<< key <<
")"
);
78
SG::ReadHandle<xAOD::CaloClusterContainer>
containerRH(key);
79
if
(!containerRH.
isValid
()) {
80
ATH_MSG_DEBUG
(
"Unable to retrieve CaloCluster collection "
<< key );
81
}
else
{
82
DataMap
data =
getData
(&*containerRH);
83
if
( FormatTool->AddToEvent(
dataTypeName
(), containerRH.
key
()+
"_ESD"
, &data).isFailure()){
84
ATH_MSG_WARNING
(
"Collection "
<< containerRH.
key
() <<
" not found in SG "
);
85
}
else
{
86
ATH_MSG_DEBUG
(
dataTypeName
() <<
" ("
<< containerRH.
key
() <<
") retrieved"
);
87
}
88
}
89
}
90
}
91
}
92
//All collections retrieved okay
93
return
StatusCode::SUCCESS;
94
}
95
96
103
const
DataMap
CaloClusterRetriever::getData
(
const
xAOD::CaloClusterContainer
* ccc) {
104
105
ATH_MSG_DEBUG
(
"getData()"
);
106
107
DataMap
DataMap
;
108
109
DataVect
phi
;
phi
.reserve(ccc->
size
());
110
DataVect
eta
;
eta
.reserve(ccc->
size
());
111
DataVect
et
;
et
.reserve(ccc->
size
());
112
DataVect
idVec; idVec.reserve(ccc->
size
());
113
DataVect
numCellsVec; numCellsVec.reserve(ccc->
size
());
114
DataVect
cells; cells.reserve( ccc->
size
() );
115
116
int
noClu = ccc->
size
();
117
int
noCells = 0;
118
119
int
id
= 0;
120
for
(
const
auto
cluster : *ccc) {
121
phi
.emplace_back(cluster->phi());
122
eta
.emplace_back(cluster->eta());
123
et
.emplace_back(cluster->et()*(1./
GeV
));
124
idVec.emplace_back( ++
id
);
125
126
int
numCells = cluster->size();
127
numCellsVec.emplace_back( numCells );
128
noCells += numCells;
129
130
for
(
const
auto
cell : *cluster) {
131
cells.push_back(cell->ID().get_compact());
132
}
133
}
134
135
std::string tagCells;
136
if
(noClu){
137
tagCells =
"cells multiple=\""
+
DataType
(noCells/(noClu*1.0)).toString()+
"\""
;
138
}
else
{
139
tagCells =
"cells multiple=\"1.0\""
;
140
}
141
142
// Start with mandatory entries
143
const
auto
nEntries =
phi
.size();
144
DataMap
[
"phi"
] = std::move(
phi
);
145
DataMap
[
"eta"
] = std::move(
eta
);
146
DataMap
[
"et"
] = std::move(
et
);
147
DataMap
[tagCells] = std::move(cells);
148
DataMap
[
"numCells"
] = std::move(numCellsVec);
149
DataMap
[
"id"
] = std::move(idVec);
150
151
//Be verbose
152
ATH_MSG_DEBUG
(
dataTypeName
() <<
" , collection: "
<<
dataTypeName
()
153
<<
" retrieved with "
<< nEntries <<
" entries"
);
154
155
//All collections retrieved okay
156
return
DataMap
;
157
158
}
// retrieve
159
160
//--------------------------------------------------------------------------
161
162
}
// JiveXML namespace
eta
Scalar eta() const
pseudorapidity method
Definition
AmgMatrixBasePlugin.h:83
phi
Scalar phi() const
phi method
Definition
AmgMatrixBasePlugin.h:67
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition
AthMsgStreamMacros.h:32
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
DataType
OFFLINE_FRAGMENTS_NAMESPACE::PointerType DataType
Definition
CTPResultByteStreamTool.cxx:22
CaloClusterRetriever.h
CLID
uint32_t CLID
The Class ID type.
Definition
Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
GeV
#define GeV
Definition
PhysicsAnalysis/TauID/TauAnalysisTools/Root/HelperFunctions.cxx:17
Units.h
Wrapper to avoid constant divisions when using units.
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
JiveXML::CaloClusterRetriever::m_otherKeys
Gaudi::Property< std::vector< std::string > > m_otherKeys
Definition
CaloClusterRetriever.h:53
JiveXML::CaloClusterRetriever::initialize
virtual StatusCode initialize() override
Default AthAlgTool methods.
Definition
CaloClusterRetriever.cxx:13
JiveXML::CaloClusterRetriever::m_sgKeyFavourite
SG::ReadHandleKey< xAOD::CaloClusterContainer > m_sgKeyFavourite
Definition
CaloClusterRetriever.h:51
JiveXML::CaloClusterRetriever::retrieve
virtual StatusCode retrieve(ToolHandle< IFormatTool > &FormatTool) override
Retrieve all the data.
Definition
CaloClusterRetriever.cxx:28
JiveXML::CaloClusterRetriever::m_doWriteHLT
Gaudi::Property< bool > m_doWriteHLT
Definition
CaloClusterRetriever.h:55
JiveXML::CaloClusterRetriever::dataTypeName
virtual std::string dataTypeName() const override
Return the name of the data type.
Definition
CaloClusterRetriever.h:45
JiveXML::CaloClusterRetriever::getData
const DataMap getData(const xAOD::CaloClusterContainer *)
Retrieve basic parameters, mainly four-vectors.
Definition
CaloClusterRetriever.cxx:103
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
SG::VarHandleBase::key
virtual const std::string & key() const override final
Return the StoreGate ID for the referenced object.
Definition
AthToolSupport/AsgDataHandles/Root/VarHandleBase.cxx:64
JiveXML
This header is shared inbetween the C-style server thread and the C++ Athena ServerSvc.
Definition
BadLArRetriever.cxx:22
JiveXML::DataMap
std::map< std::string, DataVect > DataMap
Definition
DataType.h:59
JiveXML::DataVect
std::vector< DataType > DataVect
Defines a map with a key and a vector of DataType objects e.g.
Definition
DataType.h:58
xAOD::CaloClusterContainer
CaloClusterContainer_v1 CaloClusterContainer
Define the latest version of the calorimeter cluster container.
Definition
Event/xAOD/xAODCaloEvent/xAODCaloEvent/CaloClusterContainer.h:17
ClassID_traits::ID
static constexpr CLID ID()
Definition
Control/AthenaKernel/AthenaKernel/ClassID_traits.h:44
et
Extra patterns decribing particle interation process.
Generated on
for ATLAS Offline Software by
1.17.0