ATLAS Offline Software
Loading...
Searching...
No Matches
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
6
13
14LArBadEventCatcher::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;
34 m_nEvent=0;
36 m_stopJob=false;
37 m_thisSize=0;
38}
39
40
43
44
46
48 ATH_MSG_WARNING ("All checks switched off ?!");
49
50 ATH_MSG_INFO ("LArBadEventChacher initialized");
51
52
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
66
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) {
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
98 for (size_t i=0;i<m_keyList.size();++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
123 for (size_t i=0;i<m_keyList.size();++i) {
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
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
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
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
213std::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
#define endmsg
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
Algorithm to catch corrupt events and stop the job.
static Double_t sc
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
const ServiceHandle< StoreGateSvc > & detStore() const
MsgStream & msg() const
size_type size() const noexcept
Returns the number of elements in the collection.
Container class for LArAccumulatedCalibDigit.
LArBadEventCatcher(const std::string &name, ISvcLocator *pSvcLocator)
std::vector< std::string > m_keyList
std::string decipherFebError(const uint32_t errword) const
std::size_t m_nAccCalibDigits
std::string eventDetails() const
const LArOnlineID * m_onlineID
Container class for LArDigit.
Holds information from the FEB Error Summary.
const std::map< unsigned int, uint16_t > & get_all_febs() const
get all febs with error
Container class for LArFebHeader.
uint32_t runNumber() const
The current event's run number.
uint64_t eventNumber() const
The current event's event number.
bool contains(const std::string &s, const std::string &regx)
does a string contain the substring
Definition hcg.cxx:114
EventInfo_v1 EventInfo
Definition of the latest event info version.