ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
LArCalorimeter
LArCalibDataQuality
src
LArBadEventCatcher.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
LArCalibDataQuality/LArBadEventCatcher.h
"
6
7
#include "
LArRawEvent/LArDigitContainer.h
"
8
#include "
LArRawEvent/LArAccumulatedCalibDigitContainer.h
"
9
#include "
LArRawEvent/LArFebHeaderContainer.h
"
10
#include "
LArRawEvent/LArFebErrorSummary.h
"
11
#include "
xAODEventInfo/EventInfo.h
"
12
#include "
LArIdentifier/LArOnlineID.h
"
13
14
LArBadEventCatcher::LArBadEventCatcher
(
const
std::string & name, ISvcLocator * pSvcLocator) :
15
AthAlgorithm
(name,pSvcLocator),
16
m_onlineID
(0),
17
m_thisSize
(0)
18
{
19
m_keyList
.push_back(
"HIGH"
);
20
m_keyList
.push_back(
"MEDIUM"
);
21
m_keyList
.push_back(
"LOW"
);
22
23
declareProperty
(
"CheckDigitCont"
,
m_checkDigits
=
false
);
24
declareProperty
(
"CheckAccCalibDigitCont"
,
m_checkAccCalibDigits
=
false
);
25
declareProperty
(
"CheckFebHeader"
,
m_checkFebHeaders
=
false
);
26
declareProperty
(
"CheckBSErrors"
,
m_checkBSErrors
=
false
);
27
declareProperty
(
"KeyList"
,
m_keyList
);
28
declareProperty
(
"StopOnError"
,
m_stopOnError
=
true
);
29
30
31
m_nDigits
=0;
32
m_nAccCalibDigits
=0;
33
m_nFebheaders
=0;
34
m_nEvent
=0;
35
m_BSErrFailMask
=0;
36
m_stopJob
=
false
;
37
m_thisSize
=0;
38
}
39
40
41
LArBadEventCatcher::~LArBadEventCatcher
() {
42
}
43
44
45
StatusCode
LArBadEventCatcher::initialize
() {
46
47
if
(!
m_checkDigits
&& !
m_checkAccCalibDigits
&& !
m_checkFebHeaders
&& !
m_checkBSErrors
)
48
ATH_MSG_WARNING
(
"All checks switched off ?!"
);
49
50
ATH_MSG_INFO
(
"LArBadEventChacher initialized"
);
51
52
53
m_BSErrFailMask
=(1<<
LArFebErrorSummary::CheckSum
);
54
56
StatusCode
sc
=
detStore
()->retrieve(
m_onlineID
,
"LArOnlineID"
);
57
if
(
sc
.isFailure()) {
58
ATH_MSG_ERROR
(
"Could not get LArOnlineID helper !"
);
59
return
StatusCode::FAILURE;
60
}
61
62
return
StatusCode::SUCCESS;
63
}
64
65
StatusCode
LArBadEventCatcher::execute
(
const
EventContext&
/*ctx*/
) {
66
67
if
(
m_checkDigits
||
m_checkAccCalibDigits
||
m_checkFebHeaders
)
68
m_thisSize
=0;
69
else
70
m_thisSize
=1;
//Assume non-empty event if no event-container is checked
71
72
if
(
m_checkDigits
) {
73
for
(
size_t
i=0;i<
m_keyList
.size();++i) {
74
if
(
evtStore
()->
contains<LArDigitContainer>
(
m_keyList
[i])) {
75
const
LArDigitContainer
* cont;
76
StatusCode
sc
=
evtStore
()->retrieve(cont,
m_keyList
[i]);
77
if
(
sc
.isFailure()) {
78
ATH_MSG_ERROR
(
"Can't retrieve LArDigitContainer with key "
<<
m_keyList
[i]);
79
return
StatusCode::FAILURE;
80
}
81
const
size_t
currSize=cont->
size
();
82
m_thisSize
=currSize;
83
if
(currSize>0) {
//We ignore emtpy containers
84
if
(
m_nDigits
==0)
m_nDigits
=currSize;
//Apparently the first event with an non-empty container
85
if
(
m_nDigits
!=currSize) {
86
ATH_MSG_FATAL
(
eventDetails
() <<
"Mismatch in size of LArDigitContainer: Have "
<< currSize <<
" elements, expected "
<<
m_nDigits
);
87
m_stopJob
=
true
;
88
if
(
m_stopOnError
)
89
return
StatusCode::FAILURE;
90
}
//end if have mismatch
91
}
//end if currSize>0
92
}
//end if storeGate->contains
93
}
//end loop over keys
94
}
//end if m_checkDigits
95
96
97
if
(
m_checkFebHeaders
) {
98
for
(
size_t
i=0;i<
m_keyList
.size();++i) {
99
if
(
evtStore
()->
contains<LArFebHeaderContainer>
(
m_keyList
[i])) {
100
const
LArFebHeaderContainer
* cont;
101
StatusCode
sc
=
evtStore
()->retrieve(cont,
m_keyList
[i]);
102
if
(
sc
.isFailure()) {
103
ATH_MSG_ERROR
(
"Can't retrieve LArFebHeaderContainer with key "
<<
m_keyList
[i]);
104
return
StatusCode::FAILURE;
105
}
106
const
size_t
currSize=cont->
size
();
107
if
(currSize>0) {
//We ignore emtpy containers
108
if
(
m_nFebheaders
==0)
m_nFebheaders
=currSize;
//Apparently the first event with an non-empty container
109
if
(
m_nFebheaders
!=currSize) {
110
ATH_MSG_FATAL
(
eventDetails
() <<
"Mismatch in size of LArFebHeaderContainer: Have "
<< currSize <<
" elements, expected "
<<
m_nFebheaders
);
111
m_stopJob
=
true
;
112
if
(
m_stopOnError
)
113
return
StatusCode::FAILURE;
114
}
//end if have mismatch
115
}
//end if currSize>0
116
}
//end if storeGate->contains
117
}
//end loop over keys
118
}
//end if m_checkFebHeaders
119
120
121
122
if
(
m_checkAccCalibDigits
) {
123
for
(
size_t
i=0;i<
m_keyList
.size();++i) {
124
if
(
evtStore
()->
contains<LArAccumulatedCalibDigitContainer>
(
m_keyList
[i])) {
125
const
LArAccumulatedCalibDigitContainer
* cont;
126
StatusCode
sc
=
evtStore
()->retrieve(cont,
m_keyList
[i]);
127
if
(
sc
.isFailure()) {
128
ATH_MSG_ERROR
(
"Can't retrieve LArAccumulatedCalibDigitContainer with key "
<<
m_keyList
[i]);
129
return
StatusCode::FAILURE;
130
}
131
const
size_t
currSize=cont->
size
();
132
m_thisSize
=currSize;
133
if
(currSize>0) {
//We ignore emtpy containers
134
if
(
m_nAccCalibDigits
==0)
m_nAccCalibDigits
=currSize;
//Apparently the first event with an non-empty container
135
if
(
m_nAccCalibDigits
!=currSize) {
136
ATH_MSG_FATAL
(
eventDetails
() <<
"Mismatch in size of LArAccCalibDigitContainer: Have "
<< currSize <<
" elements, expected "
<<
m_nAccCalibDigits
);
137
m_stopJob
=
true
;
138
if
(
m_stopOnError
)
139
return
StatusCode::FAILURE;
140
}
//end if have mismatch
141
}
//end if currSize>0
142
}
//end if storeGate->contains
143
}
//end loop over keys
144
}
//end if m_checkAccCalibDigits
145
146
147
if
(
m_checkBSErrors
) {
148
const
LArFebErrorSummary
* febErrSum =
nullptr
;
149
StatusCode
sc
=
evtStore
()->retrieve(febErrSum);
150
if
(
sc
.isFailure()) {
151
ATH_MSG_ERROR
(
"Can't retrieve LArFEBErrorSummary"
);
152
return
sc
;
153
}
154
155
const
std::map<unsigned int,uint16_t>& allFebErrs=febErrSum->
get_all_febs
();
156
std::map<unsigned int,uint16_t>::const_iterator it=allFebErrs.begin();
157
std::map<unsigned int,uint16_t>::const_iterator it_e=allFebErrs.end();
158
for
(;it!=it_e;++it) {
159
if
(it->second & 0xEFFF) {
//FIXME all events have missing header ???
160
//std::cout << std::hex << "Feb: 0x" << it->first << " Err 0x"
161
// << it->second << std::endl;
162
MSG::Level msglvl=MSG::WARNING;
163
if
((it->second &
m_BSErrFailMask
) && (
m_thisSize
>0)) {
164
m_stopJob
=
true
;
165
if
(
m_stopOnError
) msglvl=MSG::FATAL;
else
msglvl=MSG::ERROR;
166
}
167
const
HWIdentifier
fId(it->first);
168
msg
() << msglvl <<
eventDetails
() <<
"FEB 0x"
<< std::hex << it->first <<
" reports the following error(s): "
169
<<
decipherFebError
(it->second) <<
endmsg
;
170
msg
() << msglvl <<
"Feb location: "
<<
m_onlineID
->channel_name(fId) <<
endmsg
;
171
172
if
(
m_thisSize
>0)
msg
() << msglvl <<
"This event carries data"
<<
endmsg
;
173
174
if
(
m_stopJob
&&
m_stopOnError
)
175
return
StatusCode::FAILURE;
176
}
//end if error
177
}
//end loop over FEBs
178
}
//end if check BS Errs
179
180
181
m_nEvent
++;
182
return
StatusCode::SUCCESS;
183
}
184
185
186
std::string
LArBadEventCatcher::eventDetails
()
const
{
187
std::stringstream result;
188
189
const
xAOD::EventInfo
* eventInfo;
190
StatusCode
sc
=
evtStore
()->retrieve(eventInfo);
191
if
(
sc
.isFailure())
192
result <<
"[No EventInfo]"
;
193
else
{
194
unsigned
int
evtNum = eventInfo->
eventNumber
();
195
unsigned
int
runNum = eventInfo->
runNumber
();
196
result <<
"Run "
<< runNum <<
", Evt "
<< evtNum;
197
}
198
result <<
", Idx "
<<
m_nEvent
<<
": "
;
199
return
result.str();
200
}
201
202
203
StatusCode
LArBadEventCatcher::stop
() {
204
if
(
m_stopJob
&&
m_stopOnError
) {
205
ATH_MSG_FATAL
(
"Fatal error found during execute"
);
206
return
StatusCode::FAILURE;
207
}
208
else
209
return
StatusCode::SUCCESS;
210
}
211
212
213
std::string
LArBadEventCatcher::decipherFebError
(
const
uint32_t errword)
const
{
214
215
std::string result;
216
217
if
(errword & (0x1U <<
LArFebErrorSummary::Parity
))
218
result+=
"Parity Error, "
;
219
if
(errword & (0x1U <<
LArFebErrorSummary::BCID
))
220
result+=
"BCID Mismatch, "
;
221
if
(errword & (0x1U <<
LArFebErrorSummary::SampleHeader
))
222
result+=
"Sample Header Error, "
;
223
if
(errword & (0x1U <<
LArFebErrorSummary::EVTID
))
224
result+=
"EVTID Error, "
;
225
if
(errword & (0x1U <<
LArFebErrorSummary::ScacStatus
))
226
result+=
"SCAC Status, "
;
227
if
(errword & (0x1U <<
LArFebErrorSummary::ScaOutOfRange
))
228
result+=
"SCA out of range, "
;
229
if
(errword & (0x1U <<
LArFebErrorSummary::GainMismatch
))
230
result+=
"Gain Mismatch, "
;
231
if
(errword & (0x1U <<
LArFebErrorSummary::TypeMismatch
))
232
result+=
"Type Mismatch "
;
233
if
(errword & (0x1U <<
LArFebErrorSummary::NumOfSamples
))
234
result+=
"Number of Samples Mismatch, "
;
235
if
(errword & (0x1U <<
LArFebErrorSummary::EmptyDataBlock
))
236
result+=
"Empty Data Block, "
;
237
if
(errword & (0x1U <<
LArFebErrorSummary::DspBlockSize
))
238
result+=
"DSP Block Size, "
;
239
if
(errword & (0x1U <<
LArFebErrorSummary::CheckSum
))
240
result+=
"Checksum error, "
;
241
if
(errword & (0x1U <<
LArFebErrorSummary::MissingHeader
))
242
result+=
"Missing Header, "
;
243
244
if
(result.size()<2)
245
result=
"Unknown error"
;
246
else
247
result.erase(result.end()-2,result.end());
248
249
return
result;
250
}
251
252
253
endmsg
#define endmsg
Definition
AnalysisConfig_Ntuple.cxx:54
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition
AthMsgStreamMacros.h:34
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition
AthMsgStreamMacros.h:32
LArAccumulatedCalibDigitContainer.h
LArBadEventCatcher.h
Algorithm to catch corrupt events and stop the job.
LArDigitContainer.h
LArFebErrorSummary.h
LArFebHeaderContainer.h
LArOnlineID.h
sc
static Double_t sc
Definition
LArPhysWaveHECTool.cxx:37
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 >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
Definition
AthCommonDataStore.h:85
AthCommonAlgorithm< Gaudi::Algorithm >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
Definition
AthCommonDataStore.h:95
AthCommonAlgorithm< Gaudi::Algorithm >::msg
MsgStream & msg() const
Definition
AthCommonMsg.h:24
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
HWIdentifier
Definition
HWIdentifier.h:13
LArAccumulatedCalibDigitContainer
Container class for LArAccumulatedCalibDigit.
Definition
LArAccumulatedCalibDigitContainer.h:25
LArBadEventCatcher::LArBadEventCatcher
LArBadEventCatcher(const std::string &name, ISvcLocator *pSvcLocator)
Definition
LArBadEventCatcher.cxx:14
LArBadEventCatcher::initialize
StatusCode initialize()
Definition
LArBadEventCatcher.cxx:45
LArBadEventCatcher::~LArBadEventCatcher
~LArBadEventCatcher()
Definition
LArBadEventCatcher.cxx:41
LArBadEventCatcher::stop
StatusCode stop()
Definition
LArBadEventCatcher.cxx:203
LArBadEventCatcher::m_keyList
std::vector< std::string > m_keyList
Definition
LArBadEventCatcher.h:78
LArBadEventCatcher::decipherFebError
std::string decipherFebError(const uint32_t errword) const
Definition
LArBadEventCatcher.cxx:213
LArBadEventCatcher::m_nFebheaders
std::size_t m_nFebheaders
Definition
LArBadEventCatcher.h:76
LArBadEventCatcher::m_nAccCalibDigits
std::size_t m_nAccCalibDigits
Definition
LArBadEventCatcher.h:76
LArBadEventCatcher::eventDetails
std::string eventDetails() const
Definition
LArBadEventCatcher.cxx:186
LArBadEventCatcher::m_checkDigits
bool m_checkDigits
Definition
LArBadEventCatcher.h:67
LArBadEventCatcher::m_nEvent
unsigned m_nEvent
Definition
LArBadEventCatcher.h:74
LArBadEventCatcher::m_nDigits
std::size_t m_nDigits
Definition
LArBadEventCatcher.h:76
LArBadEventCatcher::execute
StatusCode execute(const EventContext &ctx)
Execute method.
Definition
LArBadEventCatcher.cxx:65
LArBadEventCatcher::m_checkFebHeaders
bool m_checkFebHeaders
Definition
LArBadEventCatcher.h:69
LArBadEventCatcher::m_BSErrFailMask
uint16_t m_BSErrFailMask
Definition
LArBadEventCatcher.h:73
LArBadEventCatcher::m_stopJob
bool m_stopJob
Definition
LArBadEventCatcher.h:80
LArBadEventCatcher::m_checkBSErrors
bool m_checkBSErrors
Definition
LArBadEventCatcher.h:70
LArBadEventCatcher::m_onlineID
const LArOnlineID * m_onlineID
Definition
LArBadEventCatcher.h:63
LArBadEventCatcher::m_thisSize
std::size_t m_thisSize
Definition
LArBadEventCatcher.h:77
LArBadEventCatcher::m_checkAccCalibDigits
bool m_checkAccCalibDigits
Definition
LArBadEventCatcher.h:68
LArBadEventCatcher::m_stopOnError
bool m_stopOnError
Definition
LArBadEventCatcher.h:81
LArDigitContainer
Container class for LArDigit.
Definition
LArDigitContainer.h:24
LArFebErrorSummary
Holds information from the FEB Error Summary.
Definition
LArFebErrorSummary.h:23
LArFebErrorSummary::get_all_febs
const std::map< unsigned int, uint16_t > & get_all_febs() const
get all febs with error
Definition
LArFebErrorSummary.cxx:47
LArFebErrorSummary::SampleHeader
@ SampleHeader
Definition
LArFebErrorSummary.h:27
LArFebErrorSummary::EVTID
@ EVTID
Definition
LArFebErrorSummary.h:27
LArFebErrorSummary::DspBlockSize
@ DspBlockSize
Definition
LArFebErrorSummary.h:28
LArFebErrorSummary::CheckSum
@ CheckSum
Definition
LArFebErrorSummary.h:28
LArFebErrorSummary::GainMismatch
@ GainMismatch
Definition
LArFebErrorSummary.h:28
LArFebErrorSummary::EmptyDataBlock
@ EmptyDataBlock
Definition
LArFebErrorSummary.h:28
LArFebErrorSummary::NumOfSamples
@ NumOfSamples
Definition
LArFebErrorSummary.h:28
LArFebErrorSummary::ScacStatus
@ ScacStatus
Definition
LArFebErrorSummary.h:27
LArFebErrorSummary::ScaOutOfRange
@ ScaOutOfRange
Definition
LArFebErrorSummary.h:27
LArFebErrorSummary::MissingHeader
@ MissingHeader
Definition
LArFebErrorSummary.h:28
LArFebErrorSummary::Parity
@ Parity
Definition
LArFebErrorSummary.h:27
LArFebErrorSummary::BCID
@ BCID
Definition
LArFebErrorSummary.h:27
LArFebErrorSummary::TypeMismatch
@ TypeMismatch
Definition
LArFebErrorSummary.h:28
LArFebHeaderContainer
Container class for LArFebHeader.
Definition
LArFebHeaderContainer.h:20
xAOD::EventInfo_v1::runNumber
uint32_t runNumber() const
The current event's run number.
xAOD::EventInfo_v1::eventNumber
uint64_t eventNumber() const
The current event's event number.
contains
bool contains(const std::string &s, const std::string ®x)
does a string contain the substring
Definition
hcg.cxx:116
xAOD::EventInfo
EventInfo_v1 EventInfo
Definition of the latest event info version.
Definition
IEventInfoCnvTool.h:16
EventInfo.h
Generated on
for ATLAS Offline Software by
1.17.0