ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
TileCalorimeter
TileRecAlgs
src
TileCellVerify.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
//*****************************************************************************
6
// Filename : TileCellVerify.cxx
7
// Author : Zhifang
8
// Created : May, 2002
9
//
10
// DESCRIPTION:
11
// Implement the TileCellVerify class
12
//
13
// HISTORY:
14
//
15
// BUGS:
16
//
17
//*****************************************************************************
18
19
// Tile includes
20
#include "
TileCellVerify.h
"
21
#include "
TileEvent/TileCell.h
"
22
23
// Calo includes
24
#include "
CaloIdentifier/TileID.h
"
25
26
// Atlas includes
27
#include "
StoreGate/ReadHandle.h
"
28
#include "
AthenaKernel/errorcheck.h
"
29
30
31
//C++ STL includes
32
#include <vector>
33
#include <algorithm>
34
35
using namespace
std
;
36
37
class
CompCell
{
38
public
:
39
bool
operator()
(
const
CaloCell
* p1,
const
CaloCell
* p2) {
40
return
p1->energy() < p2->energy();
41
}
42
};
43
44
//==========================================================================
45
// TileCellVerify's implementations
46
//==========================================================================
47
48
// Constructor
49
TileCellVerify::TileCellVerify
(
const
std::string& name, ISvcLocator* pSvcLocator)
50
:
AthAlgorithm
(name, pSvcLocator)
51
{
52
}
53
54
TileCellVerify::~TileCellVerify
() {
55
}
56
57
// Alg standard interfacw function
58
StatusCode
TileCellVerify::initialize
() {
59
60
// retrieve TileID helper from det store
61
CHECK
(
detStore
()->retrieve(
m_tileID
) );
62
63
ATH_CHECK
(
m_cellContainer1Key
.initialize() );
64
ATH_CHECK
(
m_cellContainer2Key
.initialize() );
65
66
ATH_MSG_INFO
(
"TileCellVerify initialization completed"
);
67
68
return
StatusCode::SUCCESS;
69
}
70
71
StatusCode
TileCellVerify::execute
(
const
EventContext& ctx) {
72
73
// step1: read two cell containers from TES
74
SG::ReadHandle<CaloCellContainer>
cellContainer1(
m_cellContainer1Key
, ctx);
75
ATH_CHECK
(cellContainer1.
isValid
());
76
77
SG::ReadHandle<CaloCellContainer>
cellContainer2(
m_cellContainer2Key
, ctx);
78
ATH_CHECK
(cellContainer2.
isValid
());
79
80
// step2: first compare the number of cells in the two containers
81
int
nCells1 = cellContainer1->size();
82
int
nCells2 = cellContainer2->size();
83
ATH_MSG_INFO
(
"The number of cells in "
<<
m_cellContainer1Key
.key() <<
" is "
<< nCells1 );
84
ATH_MSG_INFO
(
"The number of cells in "
<<
m_cellContainer2Key
.key() <<
" is "
<< nCells2 );
85
86
if
(nCells1 != nCells2) {
87
ATH_MSG_ERROR
(
"The number of cells is not equal in the two cell "
88
<<
"containers: "
<<
m_cellContainer1Key
.key()
89
<<
" and "
<<
m_cellContainer2Key
.key() );
90
91
return
(StatusCode::SUCCESS);
92
}
93
94
// step3: to sort the cells in the container read above by energy
95
vector<const CaloCell*> cells1;
96
vector<const CaloCell*> cells2;
97
const
CaloCell
* cell1(
nullptr
);
98
const
CaloCell
* cell2(
nullptr
);
99
if
(
m_sortFlag
) {
100
101
for
(
const
CaloCell
* cell : *cellContainer1) {
102
cells1.push_back(cell);
103
}
104
105
for
(
const
CaloCell
* cell : *cellContainer2) {
106
cells2.push_back(cell);
107
}
108
109
sort
(cells1.begin(), cells1.end(),
CompCell
());
110
sort
(cells2.begin(), cells2.end(),
CompCell
());
111
}
112
113
// step4: then compare every cell-pair in the containers
114
bool
bErrorFlag =
false
;
115
bool
bOnlyOnceFlag =
false
;
116
bool
lVerbose =
msgLvl
(MSG::VERBOSE);
117
for
(
int
i = 0; i < nCells1; ++i) {
118
119
if
(
m_sortFlag
) {
120
cell1 = cells1[i];
121
cell2 = cells2[i];
122
}
else
{
123
cell1 = (*cellContainer1)[i];
124
cell2 = (*cellContainer2)[i];
125
}
126
127
Identifier
id1 = cell1->
ID
();
128
Identifier
id2 = cell2->
ID
();
129
if
(id1 != id2) bErrorFlag =
true
;
130
if
(lVerbose && (
m_dumpCells
|| bErrorFlag)) {
131
132
if
(!bOnlyOnceFlag) {
133
msg
(MSG::VERBOSE) <<
" ==="
<<
m_cellContainer1Key
.key() <<
"=== ==="
<<
m_cellContainer2Key
.key() <<
"==="
<<
endmsg
;
134
msg
(MSG::VERBOSE) <<
" Index e1 id1 | e2 id2"
<<
endmsg
;
135
msg
(MSG::VERBOSE) <<
"--------------------------------------------------------------------------------"
<<
endmsg
;
136
bOnlyOnceFlag =
true
;
137
}
138
139
msg
(MSG::VERBOSE) << setw(5) << i <<
" "
<< setw(12) << cell1->
energy
() <<
" ["
;
140
msg
(MSG::VERBOSE) <<
m_tileID
->to_string(id1, -2) <<
"]"
;
141
msg
(MSG::VERBOSE) <<
" | "
<< setw(12) << cell2->
energy
() <<
" ["
;
142
msg
(MSG::VERBOSE) <<
m_tileID
->to_string(id2, -2) <<
"]"
;
143
144
if
(bErrorFlag)
msg
(MSG::VERBOSE) <<
" * "
;
145
146
msg
(MSG::VERBOSE) <<
endmsg
;
147
148
}
else
if
(bErrorFlag){
149
break
;
150
}
151
}
152
if
(bOnlyOnceFlag) {
153
msg
(MSG::VERBOSE) <<
"--------------------------------------------------------------------------------"
<<
endmsg
;
154
}
155
if
(!bErrorFlag) {
156
ATH_MSG_INFO
(
"The two cellContainers ("
<<
m_cellContainer1Key
.key()
157
<<
" and "
<<
m_cellContainer2Key
.key() <<
") are same!!!"
);
158
}
else
{
159
ATH_MSG_INFO
(
"The two cellContainers ("
<<
m_cellContainer1Key
.key()
160
<<
" and "
<<
m_cellContainer2Key
.key() <<
") are not same!!!"
);
161
}
162
163
// Execution completed.
164
ATH_MSG_INFO
(
"TileCellVerify execution completed successfully"
);
165
166
return
StatusCode::SUCCESS;
167
}
168
169
StatusCode
TileCellVerify::finalize
() {
170
171
ATH_MSG_INFO
(
"TileCellVerify::finalize() end"
);
172
173
return
StatusCode::SUCCESS;
174
}
175
endmsg
#define endmsg
Definition
AnalysisConfig_Ntuple.cxx:54
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x,...)
Definition
AthMsgStreamMacros.h:47
ATH_MSG_INFO
#define ATH_MSG_INFO(x,...)
Definition
AthMsgStreamMacros.h:45
errorcheck.h
Helpers for checking error return status codes and reporting errors.
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition
Control/AthenaKernel/AthenaKernel/errorcheck.h:422
ReadHandle.h
Handle class for reading from StoreGate.
TileCellVerify.h
TileCell.h
TileID.h
AthAlgorithm::AthAlgorithm
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition
AthAlgorithm.cxx:10
AthCommonAlgorithm< Gaudi::Algorithm >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
Definition
AthCommonDataStore.h:95
AthCommonAlgorithm< Gaudi::Algorithm >::msgLvl
bool msgLvl(const MSG::Level lvl) const
Definition
AthCommonMsg.h:30
AthCommonAlgorithm< Gaudi::Algorithm >::msg
MsgStream & msg() const
Definition
AthCommonMsg.h:24
CaloCell
Data object for each calorimeter readout cell.
Definition
CaloCell.h:57
CaloCell::energy
double energy() const
get energy (data member)
Definition
CaloCell.h:327
CaloCell::ID
Identifier ID() const
get ID (from cached data member) non-virtual and inline for fast access
Definition
CaloCell.h:295
CompCell
Definition
TileCellVerify.cxx:37
CompCell::operator()
bool operator()(const CaloCell *p1, const CaloCell *p2)
Definition
TileCellVerify.cxx:39
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:66
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
TileCellVerify::~TileCellVerify
virtual ~TileCellVerify()
Definition
TileCellVerify.cxx:54
TileCellVerify::m_cellContainer2Key
SG::ReadHandleKey< CaloCellContainer > m_cellContainer2Key
Definition
TileCellVerify.h:65
TileCellVerify::finalize
StatusCode finalize()
Definition
TileCellVerify.cxx:169
TileCellVerify::m_tileID
const TileID * m_tileID
Definition
TileCellVerify.h:70
TileCellVerify::m_sortFlag
Gaudi::Property< bool > m_sortFlag
Definition
TileCellVerify.h:73
TileCellVerify::m_cellContainer1Key
SG::ReadHandleKey< CaloCellContainer > m_cellContainer1Key
Definition
TileCellVerify.h:61
TileCellVerify::initialize
StatusCode initialize()
Definition
TileCellVerify.cxx:58
TileCellVerify::m_dumpCells
Gaudi::Property< bool > m_dumpCells
Definition
TileCellVerify.h:72
TileCellVerify::TileCellVerify
TileCellVerify(const std::string &name, ISvcLocator *pSvcLocator)
Definition
TileCellVerify.cxx:49
TileCellVerify::execute
StatusCode execute(const EventContext &ctx)
Execute method.
Definition
TileCellVerify.cxx:71
Identifier
Definition
IdentifierFieldParser.cxx:14
std
STL namespace.
std::sort
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
Definition
DVL_algorithms.h:554
Generated on
for ATLAS Offline Software by
1.17.0