ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
TileCalorimeter
TileRecUtils
src
TileRawChannelVerify.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 : TileRawChannelVerify.cxx
7
// Author : Zhifang
8
// Created : May, 2002
9
//
10
// DESCRIPTION:
11
// Implement the TileRawChannelVerify class
12
//
13
// HISTORY:
14
//
15
// BUGS:
16
//
17
//*****************************************************************************
18
19
// Tile includes
20
#include "
TileRecUtils/TileRawChannelVerify.h
"
21
#include "
TileIdentifier/TileHWID.h
"
22
#include "
StoreGate/ReadHandle.h
"
23
24
// Atlas includes
25
// access all RawChannels inside container
26
#include "
EventContainers/SelectAllObject.h
"
27
#include "
AthenaKernel/errorcheck.h
"
28
29
// Gaudi includes
30
#include "GaudiKernel/Bootstrap.h"
31
#include "GaudiKernel/ISvcLocator.h"
32
33
// C++ STL includes
34
#include <vector>
35
#include <algorithm>
36
37
// C includes
38
#include <cmath>
39
40
using namespace
std
;
41
42
48
class
CompRawChannel
{
49
public
:
50
bool
operator()
(
const
TileRawChannel
* p1,
const
TileRawChannel
* p2) {
51
return
p1->amplitude() < p2->amplitude();
52
}
53
};
54
55
//==========================================================================
56
// TileRawChannelVerify's implementations
57
//==========================================================================
58
59
// Constructor
60
TileRawChannelVerify::TileRawChannelVerify
(
const
std::string& name, ISvcLocator* pSvcLocator)
61
:
AthAlgorithm
(name, pSvcLocator)
62
,
m_tileHWID
(0)
63
{
64
}
65
66
TileRawChannelVerify::~TileRawChannelVerify
() {
67
}
68
69
// Alg standard interfacw function
70
StatusCode
TileRawChannelVerify::initialize
() {
71
72
// retrieve TileHWID helper from det store
73
CHECK
(
detStore
()->retrieve(
m_tileHWID
) );
74
75
ATH_CHECK
(
m_rawChannelContainer1Key
.initialize() );
76
ATH_CHECK
(
m_rawChannelContainer2Key
.initialize() );
77
78
ATH_MSG_INFO
(
"TileRawChannelVerify initialization completed"
);
79
80
return
StatusCode::SUCCESS;
81
}
82
83
StatusCode
TileRawChannelVerify::execute
(
const
EventContext& ctx) {
84
85
// step1: read two cell containers from TES
86
SG::ReadHandle<TileRawChannelContainer>
rawChannelContainer1(
m_rawChannelContainer1Key
, ctx);
87
SG::ReadHandle<TileRawChannelContainer>
rawChannelContainer2(
m_rawChannelContainer2Key
, ctx);
88
89
SelectAllObject<TileRawChannelContainer>
selAll1(rawChannelContainer1.
cptr
());
90
SelectAllObject<TileRawChannelContainer>::const_iterator rawItr1 = selAll1.
begin
();
91
SelectAllObject<TileRawChannelContainer>::const_iterator end1 = selAll1.
end
();
92
93
SelectAllObject<TileRawChannelContainer>
selAll2(rawChannelContainer2.
cptr
());
94
SelectAllObject<TileRawChannelContainer>::const_iterator rawItr2 = selAll2.
begin
();
95
SelectAllObject<TileRawChannelContainer>::const_iterator end2 = selAll2.
end
();
96
97
// step2: first compare the number of cells in the two containers
98
int
nSize1 = 0;
99
for
(; rawItr1 != end1; ++rawItr1) ++nSize1;
100
101
int
nSize2 = 0;
102
for
(; rawItr2 != end2; ++rawItr2) ++nSize2;
103
104
ATH_MSG_INFO
(
"The number of cells in "
<<
m_rawChannelContainer1Key
.key() <<
" is "
<< nSize1 );
105
ATH_MSG_INFO
(
"The number of cells in "
<<
m_rawChannelContainer2Key
.key() <<
" is "
<< nSize2 );
106
107
if
(nSize1 != nSize2) {
108
ATH_MSG_ERROR
(
"The number of rawChannels is not equal in the two containers"
);
109
return
(StatusCode::SUCCESS);
110
}
111
112
// step3: to sort the cells in the containers by amplitude
113
vector<const TileRawChannel*> rawChannels1;
114
vector<const TileRawChannel*> rawChannels2;
115
const
TileRawChannel
* rawChannel1;
116
const
TileRawChannel
* rawChannel2;
117
if
(
m_sortFlag
) {
118
rawItr1 = selAll1.
begin
();
119
end1 = selAll1.
end
();
120
for
(; rawItr1 != end1; ++rawItr1)
121
rawChannels1.push_back((*rawItr1));
122
123
sort
(rawChannels1.begin(), rawChannels1.end(),
CompRawChannel
());
124
125
rawItr2 = selAll2.
begin
();
126
end2 = selAll2.
end
();
127
for
(; rawItr2 != end2; ++rawItr2)
128
rawChannels2.push_back((*rawItr2));
129
130
sort
(rawChannels2.begin(), rawChannels2.end(),
CompRawChannel
());
131
}
132
133
rawItr1 = selAll1.
begin
();
134
end1 = selAll1.
end
();
135
136
rawItr2 = selAll2.
begin
();
137
end2 = selAll2.
end
();
138
139
// step4: then compare every cell-pair in the containers
140
bool
bErrorFlag =
false
;
141
bool
bHeaderFlag =
true
;
142
for
(
int
i = 0; i < nSize1; ++i) {
143
if
(
m_sortFlag
) {
144
rawChannel1 = rawChannels1[i];
145
rawChannel2 = rawChannels2[i];
146
}
else
{
147
rawChannel1 = (*rawItr1);
148
++rawItr1;
149
rawChannel2 = (*rawItr2);
150
++rawItr2;
151
}
152
HWIdentifier
id1 = rawChannel1->
adc_HWID
();
153
HWIdentifier
id2 = rawChannel2->
adc_HWID
();
154
double
amp1 = rawChannel1->
amplitude
();
155
double
amp2 = rawChannel2->
amplitude
();
156
double
diff
= fabs(amp1 - amp2);
157
if
(id1 != id2 ||
diff
>
m_precision
) bErrorFlag =
true
;
158
if
(
msgLvl
(MSG::VERBOSE) && (
m_dumpRawChannels
|| bErrorFlag)) {
159
if
(bHeaderFlag) {
160
msg
(MSG::VERBOSE) <<
" ==="
<<
m_rawChannelContainer1Key
.key()
161
<<
"=== ==="
<<
m_rawChannelContainer2Key
.key() <<
"==="
<<
endmsg
;
162
msg
(MSG::VERBOSE) <<
" Index e1 id1 | e2 id2"
<<
endmsg
;
163
msg
(MSG::VERBOSE) <<
"--------------------------------------------------------------------------------"
<<
endmsg
;
164
bHeaderFlag =
false
;
165
}
166
msg
(MSG::VERBOSE) << setw(5) << i
167
<<
" "
<< setw(12) << amp1
168
<<
" ["
<<
m_tileHWID
->to_string(id1) <<
"]"
169
<<
" | "
<< setw(12) << amp2
170
<<
" ["
<<
m_tileHWID
->to_string(id2) <<
"]"
;
171
if
(
diff
>
m_precision
) {
172
msg
(MSG::VERBOSE) <<
" A* "
;
173
}
174
if
(id1 != id2) {
175
msg
(MSG::VERBOSE) <<
" I* "
;
176
}
177
msg
(MSG::VERBOSE) <<
endmsg
;
178
}
else
if
(bErrorFlag) {
179
break
;
180
}
181
}
182
if
(!bHeaderFlag) {
183
msg
(MSG::VERBOSE) <<
"--------------------------------------------------------------------------------"
<<
endmsg
;
184
}
185
if
(!bErrorFlag) {
186
ATH_MSG_INFO
(
"The two cellContainers ("
<<
m_rawChannelContainer1Key
.key()
187
<<
" and "
<<
m_rawChannelContainer2Key
.key() <<
") are the same!!!"
);
188
}
else
{
189
ATH_MSG_INFO
(
"The two cellContainers ("
<<
m_rawChannelContainer1Key
.key()
190
<<
" and "
<<
m_rawChannelContainer2Key
.key() <<
") are not the same!!!"
);
191
}
192
193
// Execution completed.
194
ATH_MSG_INFO
(
"TileRawChannelVerify execution completed successfully"
);
195
196
return
StatusCode::SUCCESS;
197
}
198
199
StatusCode
TileRawChannelVerify::finalize
() {
200
201
ATH_MSG_INFO
(
"TileRawChannelVerify finalized successfully"
);
202
203
return
StatusCode::SUCCESS;
204
}
205
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
SelectAllObject.h
SelectAllObject
SelectAllObjectMT< DCC, OBJECT > SelectAllObject
Definition
SelectAllObject.h:11
ReadHandle.h
Handle class for reading from StoreGate.
TileHWID.h
TileRawChannelVerify.h
diff
void diff(const TrigInDetTrack &a, const TrigInDetTrack &b, std::map< std::string, double > &variableChange)
comparison with feedback Function compares two objects and returns "semi verbose" output in the form ...
Definition
TrigInDetTrack.cxx:112
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
CompRawChannel
Small class holding a single method to compare two different TileRawChannel.
Definition
TileRawChannelVerify.cxx:48
CompRawChannel::operator()
bool operator()(const TileRawChannel *p1, const TileRawChannel *p2)
Definition
TileRawChannelVerify.cxx:50
HWIdentifier
Definition
HWIdentifier.h:13
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:66
SG::ReadHandle::cptr
const_pointer_type cptr()
Dereference the pointer.
SelectAllObjectMT::end
const_iterator end()
Definition
SelectAllObjectMT.h:131
SelectAllObjectMT::begin
const_iterator begin()
Definition
SelectAllObjectMT.h:115
TileRawChannelVerify::finalize
StatusCode finalize()
finalize method
Definition
TileRawChannelVerify.cxx:199
TileRawChannelVerify::m_rawChannelContainer1Key
SG::ReadHandleKey< TileRawChannelContainer > m_rawChannelContainer1Key
Definition
TileRawChannelVerify.h:65
TileRawChannelVerify::m_rawChannelContainer2Key
SG::ReadHandleKey< TileRawChannelContainer > m_rawChannelContainer2Key
Definition
TileRawChannelVerify.h:69
TileRawChannelVerify::m_precision
Gaudi::Property< double > m_precision
Definition
TileRawChannelVerify.h:73
TileRawChannelVerify::execute
StatusCode execute(const EventContext &ctx)
execute method
Definition
TileRawChannelVerify.cxx:83
TileRawChannelVerify::m_dumpRawChannels
Gaudi::Property< bool > m_dumpRawChannels
Definition
TileRawChannelVerify.h:76
TileRawChannelVerify::m_sortFlag
Gaudi::Property< bool > m_sortFlag
Definition
TileRawChannelVerify.h:78
TileRawChannelVerify::~TileRawChannelVerify
virtual ~TileRawChannelVerify()
Destructor.
Definition
TileRawChannelVerify.cxx:66
TileRawChannelVerify::m_tileHWID
const TileHWID * m_tileHWID
Pointer to TileHWID.
Definition
TileRawChannelVerify.h:63
TileRawChannelVerify::TileRawChannelVerify
TileRawChannelVerify(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition
TileRawChannelVerify.cxx:60
TileRawChannelVerify::initialize
StatusCode initialize()
initialize method
Definition
TileRawChannelVerify.cxx:70
TileRawChannel
Definition
TileRawChannel.h:35
TileRawChannel::amplitude
float amplitude(int ind=0) const
Definition
TileRawChannel.h:101
TileRawData::adc_HWID
HWIdentifier adc_HWID(void) const
Definition
TileRawData.h:53
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