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-2020 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
declareProperty
(
"Precision"
,
m_precision
= 0);
65
declareProperty
(
"DumpRawChannels"
,
m_dumpRawChannels
=
false
);
66
declareProperty
(
"SortFlag"
,
m_sortFlag
=
false
);
67
}
68
69
TileRawChannelVerify::~TileRawChannelVerify
() {
70
}
71
72
// Alg standard interfacw function
73
StatusCode
TileRawChannelVerify::initialize
() {
74
75
// retrieve TileHWID helper from det store
76
CHECK
(
detStore
()->retrieve(
m_tileHWID
) );
77
78
ATH_CHECK
(
m_rawChannelContainer1Key
.initialize() );
79
ATH_CHECK
(
m_rawChannelContainer2Key
.initialize() );
80
81
ATH_MSG_INFO
(
"TileRawChannelVerify initialization completed"
);
82
83
return
StatusCode::SUCCESS;
84
}
85
86
StatusCode
TileRawChannelVerify::execute
(
const
EventContext& ctx) {
87
88
// step1: read two cell containers from TES
89
SG::ReadHandle<TileRawChannelContainer>
rawChannelContainer1(
m_rawChannelContainer1Key
, ctx);
90
SG::ReadHandle<TileRawChannelContainer>
rawChannelContainer2(
m_rawChannelContainer2Key
, ctx);
91
92
SelectAllObject<TileRawChannelContainer>
selAll1(rawChannelContainer1.
cptr
());
93
SelectAllObject<TileRawChannelContainer>::const_iterator rawItr1 = selAll1.
begin
();
94
SelectAllObject<TileRawChannelContainer>::const_iterator end1 = selAll1.
end
();
95
96
SelectAllObject<TileRawChannelContainer>
selAll2(rawChannelContainer2.
cptr
());
97
SelectAllObject<TileRawChannelContainer>::const_iterator rawItr2 = selAll2.
begin
();
98
SelectAllObject<TileRawChannelContainer>::const_iterator end2 = selAll2.
end
();
99
100
// step2: first compare the number of cells in the two containers
101
int
nSize1 = 0;
102
for
(; rawItr1 != end1; ++rawItr1) ++nSize1;
103
104
int
nSize2 = 0;
105
for
(; rawItr2 != end2; ++rawItr2) ++nSize2;
106
107
ATH_MSG_INFO
(
"The number of cells in "
<<
m_rawChannelContainer1Key
.key() <<
" is "
<< nSize1 );
108
ATH_MSG_INFO
(
"The number of cells in "
<<
m_rawChannelContainer2Key
.key() <<
" is "
<< nSize2 );
109
110
if
(nSize1 != nSize2) {
111
ATH_MSG_ERROR
(
"The number of rawChannels is not equal in the two containers"
);
112
return
(StatusCode::SUCCESS);
113
}
114
115
// step3: to sort the cells in the containers by amplitude
116
vector<const TileRawChannel*> rawChannels1;
117
vector<const TileRawChannel*> rawChannels2;
118
const
TileRawChannel
* rawChannel1;
119
const
TileRawChannel
* rawChannel2;
120
if
(
m_sortFlag
) {
121
rawItr1 = selAll1.
begin
();
122
end1 = selAll1.
end
();
123
for
(; rawItr1 != end1; ++rawItr1)
124
rawChannels1.push_back((*rawItr1));
125
126
sort
(rawChannels1.begin(), rawChannels1.end(),
CompRawChannel
());
127
128
rawItr2 = selAll2.
begin
();
129
end2 = selAll2.
end
();
130
for
(; rawItr2 != end2; ++rawItr2)
131
rawChannels2.push_back((*rawItr2));
132
133
sort
(rawChannels2.begin(), rawChannels2.end(),
CompRawChannel
());
134
}
135
136
rawItr1 = selAll1.
begin
();
137
end1 = selAll1.
end
();
138
139
rawItr2 = selAll2.
begin
();
140
end2 = selAll2.
end
();
141
142
// step4: then compare every cell-pair in the containers
143
bool
bErrorFlag =
false
;
144
bool
bHeaderFlag =
true
;
145
for
(
int
i = 0; i < nSize1; ++i) {
146
if
(
m_sortFlag
) {
147
rawChannel1 = rawChannels1[i];
148
rawChannel2 = rawChannels2[i];
149
}
else
{
150
rawChannel1 = (*rawItr1);
151
++rawItr1;
152
rawChannel2 = (*rawItr2);
153
++rawItr2;
154
}
155
HWIdentifier
id1 = rawChannel1->
adc_HWID
();
156
HWIdentifier
id2 = rawChannel2->
adc_HWID
();
157
double
amp1 = rawChannel1->
amplitude
();
158
double
amp2 = rawChannel2->
amplitude
();
159
double
diff
= fabs(amp1 - amp2);
160
if
(id1 != id2 ||
diff
>
m_precision
) bErrorFlag =
true
;
161
if
(
msgLvl
(MSG::VERBOSE) && (
m_dumpRawChannels
|| bErrorFlag)) {
162
if
(bHeaderFlag) {
163
msg
(MSG::VERBOSE) <<
" ==="
<<
m_rawChannelContainer1Key
.key()
164
<<
"=== ==="
<<
m_rawChannelContainer2Key
.key() <<
"==="
<<
endmsg
;
165
msg
(MSG::VERBOSE) <<
" Index e1 id1 | e2 id2"
<<
endmsg
;
166
msg
(MSG::VERBOSE) <<
"--------------------------------------------------------------------------------"
<<
endmsg
;
167
bHeaderFlag =
false
;
168
}
169
msg
(MSG::VERBOSE) << setw(5) << i
170
<<
" "
<< setw(12) << amp1
171
<<
" ["
<<
m_tileHWID
->to_string(id1) <<
"]"
172
<<
" | "
<< setw(12) << amp2
173
<<
" ["
<<
m_tileHWID
->to_string(id2) <<
"]"
;
174
if
(
diff
>
m_precision
) {
175
msg
(MSG::VERBOSE) <<
" A* "
;
176
}
177
if
(id1 != id2) {
178
msg
(MSG::VERBOSE) <<
" I* "
;
179
}
180
msg
(MSG::VERBOSE) <<
endmsg
;
181
}
else
if
(bErrorFlag) {
182
break
;
183
}
184
}
185
if
(!bHeaderFlag) {
186
msg
(MSG::VERBOSE) <<
"--------------------------------------------------------------------------------"
<<
endmsg
;
187
}
188
if
(!bErrorFlag) {
189
ATH_MSG_INFO
(
"The two cellContainers ("
<<
m_rawChannelContainer1Key
.key()
190
<<
" and "
<<
m_rawChannelContainer2Key
.key() <<
") are the same!!!"
);
191
}
else
{
192
ATH_MSG_INFO
(
"The two cellContainers ("
<<
m_rawChannelContainer1Key
.key()
193
<<
" and "
<<
m_rawChannelContainer2Key
.key() <<
") are not the same!!!"
);
194
}
195
196
// Execution completed.
197
ATH_MSG_INFO
(
"TileRawChannelVerify execution completed successfully"
);
198
199
return
StatusCode::SUCCESS;
200
}
201
202
StatusCode
TileRawChannelVerify::finalize
() {
203
204
ATH_MSG_INFO
(
"TileRawChannelVerify finalized successfully"
);
205
206
return
StatusCode::SUCCESS;
207
}
208
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
diff
void diff(const Jet &rJet1, const Jet &rJet2, std::map< std::string, double > varDiff)
Difference between jets - Non-Class function required by trigger.
Definition
Jet.cxx:631
SelectAllObject.h
SelectAllObject
SelectAllObjectMT< DCC, OBJECT > SelectAllObject
Definition
SelectAllObject.h:11
ReadHandle.h
Handle class for reading from StoreGate.
TileHWID.h
TileRawChannelVerify.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
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:67
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:202
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_dumpRawChannels
bool m_dumpRawChannels
if true=> Differences found in the TileRawChannels are dumped on the screen
Definition
TileRawChannelVerify.h:75
TileRawChannelVerify::execute
StatusCode execute(const EventContext &ctx)
execute method
Definition
TileRawChannelVerify.cxx:86
TileRawChannelVerify::m_precision
double m_precision
maximum difference between the amplitudes of the TileRawChannels to be compared
Definition
TileRawChannelVerify.h:73
TileRawChannelVerify::~TileRawChannelVerify
virtual ~TileRawChannelVerify()
Destructor.
Definition
TileRawChannelVerify.cxx:69
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::m_sortFlag
bool m_sortFlag
if true=> TileRawChannels are sorted by amplitude
Definition
TileRawChannelVerify.h:76
TileRawChannelVerify::initialize
StatusCode initialize()
initialize method
Definition
TileRawChannelVerify.cxx:73
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