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-2020 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
,
m_tileID
(0)
52
,
m_dumpCells
(false)
53
,
m_sortFlag
(false)
54
55
{
56
declareProperty
(
"DumpCells"
,
m_dumpCells
);
57
declareProperty
(
"SortFlag"
,
m_sortFlag
);
58
}
59
60
TileCellVerify::~TileCellVerify
() {
61
}
62
63
// Alg standard interfacw function
64
StatusCode
TileCellVerify::initialize
() {
65
66
// retrieve TileID helper from det store
67
CHECK
(
detStore
()->retrieve(
m_tileID
) );
68
69
ATH_CHECK
(
m_cellContainer1Key
.initialize() );
70
ATH_CHECK
(
m_cellContainer2Key
.initialize() );
71
72
ATH_MSG_INFO
(
"TileCellVerify initialization completed"
);
73
74
return
StatusCode::SUCCESS;
75
}
76
77
StatusCode
TileCellVerify::execute
(
const
EventContext& ctx) {
78
79
// step1: read two cell containers from TES
80
SG::ReadHandle<CaloCellContainer>
cellContainer1(
m_cellContainer1Key
, ctx);
81
ATH_CHECK
(cellContainer1.
isValid
());
82
83
SG::ReadHandle<CaloCellContainer>
cellContainer2(
m_cellContainer2Key
, ctx);
84
ATH_CHECK
(cellContainer2.
isValid
());
85
86
// step2: first compare the number of cells in the two containers
87
int
nCells1 = cellContainer1->size();
88
int
nCells2 = cellContainer2->size();
89
ATH_MSG_INFO
(
"The number of cells in "
<<
m_cellContainer1Key
.key() <<
" is "
<< nCells1 );
90
ATH_MSG_INFO
(
"The number of cells in "
<<
m_cellContainer2Key
.key() <<
" is "
<< nCells2 );
91
92
if
(nCells1 != nCells2) {
93
ATH_MSG_ERROR
(
"The number of cells is not equal in the two cell "
94
<<
"containers: "
<<
m_cellContainer1Key
.key()
95
<<
" and "
<<
m_cellContainer2Key
.key() );
96
97
return
(StatusCode::SUCCESS);
98
}
99
100
// step3: to sort the cells in the container read above by energy
101
vector<const CaloCell*> cells1;
102
vector<const CaloCell*> cells2;
103
const
CaloCell
* cell1(
nullptr
);
104
const
CaloCell
* cell2(
nullptr
);
105
if
(
m_sortFlag
) {
106
107
for
(
const
CaloCell
* cell : *cellContainer1) {
108
cells1.push_back(cell);
109
}
110
111
for
(
const
CaloCell
* cell : *cellContainer2) {
112
cells2.push_back(cell);
113
}
114
115
sort
(cells1.begin(), cells1.end(),
CompCell
());
116
sort
(cells2.begin(), cells2.end(),
CompCell
());
117
}
118
119
// step4: then compare every cell-pair in the containers
120
bool
bErrorFlag =
false
;
121
bool
bOnlyOnceFlag =
false
;
122
bool
lVerbose =
msgLvl
(MSG::VERBOSE);
123
for
(
int
i = 0; i < nCells1; ++i) {
124
125
if
(
m_sortFlag
) {
126
cell1 = cells1[i];
127
cell2 = cells2[i];
128
}
else
{
129
cell1 = (*cellContainer1)[i];
130
cell2 = (*cellContainer2)[i];
131
}
132
133
Identifier
id1 = cell1->
ID
();
134
Identifier
id2 = cell2->
ID
();
135
if
(id1 != id2) bErrorFlag =
true
;
136
if
(lVerbose && (
m_dumpCells
|| bErrorFlag)) {
137
138
if
(!bOnlyOnceFlag) {
139
msg
(MSG::VERBOSE) <<
" ==="
<<
m_cellContainer1Key
.key() <<
"=== ==="
<<
m_cellContainer2Key
.key() <<
"==="
<<
endmsg
;
140
msg
(MSG::VERBOSE) <<
" Index e1 id1 | e2 id2"
<<
endmsg
;
141
msg
(MSG::VERBOSE) <<
"--------------------------------------------------------------------------------"
<<
endmsg
;
142
bOnlyOnceFlag =
true
;
143
}
144
145
msg
(MSG::VERBOSE) << setw(5) << i <<
" "
<< setw(12) << cell1->
energy
() <<
" ["
;
146
msg
(MSG::VERBOSE) <<
m_tileID
->to_string(id1, -2) <<
"]"
;
147
msg
(MSG::VERBOSE) <<
" | "
<< setw(12) << cell2->
energy
() <<
" ["
;
148
msg
(MSG::VERBOSE) <<
m_tileID
->to_string(id2, -2) <<
"]"
;
149
150
if
(bErrorFlag)
msg
(MSG::VERBOSE) <<
" * "
;
151
152
msg
(MSG::VERBOSE) <<
endmsg
;
153
154
}
else
if
(bErrorFlag){
155
break
;
156
}
157
}
158
if
(bOnlyOnceFlag) {
159
msg
(MSG::VERBOSE) <<
"--------------------------------------------------------------------------------"
<<
endmsg
;
160
}
161
if
(!bErrorFlag) {
162
ATH_MSG_INFO
(
"The two cellContainers ("
<<
m_cellContainer1Key
.key()
163
<<
" and "
<<
m_cellContainer2Key
.key() <<
") are same!!!"
);
164
}
else
{
165
ATH_MSG_INFO
(
"The two cellContainers ("
<<
m_cellContainer1Key
.key()
166
<<
" and "
<<
m_cellContainer2Key
.key() <<
") are not same!!!"
);
167
}
168
169
// Execution completed.
170
ATH_MSG_INFO
(
"TileCellVerify execution completed successfully"
);
171
172
return
StatusCode::SUCCESS;
173
}
174
175
StatusCode
TileCellVerify::finalize
() {
176
177
ATH_MSG_INFO
(
"TileCellVerify::finalize() end"
);
178
179
return
StatusCode::SUCCESS;
180
}
181
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:33
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
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 >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Definition
AthCommonDataStore.h:145
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:67
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
TileCellVerify::~TileCellVerify
virtual ~TileCellVerify()
Definition
TileCellVerify.cxx:60
TileCellVerify::m_cellContainer2Key
SG::ReadHandleKey< CaloCellContainer > m_cellContainer2Key
Definition
TileCellVerify.h:65
TileCellVerify::finalize
StatusCode finalize()
Definition
TileCellVerify.cxx:175
TileCellVerify::m_tileID
const TileID * m_tileID
Definition
TileCellVerify.h:70
TileCellVerify::m_cellContainer1Key
SG::ReadHandleKey< CaloCellContainer > m_cellContainer1Key
Definition
TileCellVerify.h:61
TileCellVerify::initialize
StatusCode initialize()
Definition
TileCellVerify.cxx:64
TileCellVerify::m_sortFlag
bool m_sortFlag
Definition
TileCellVerify.h:73
TileCellVerify::m_dumpCells
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:77
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