]>
Commit | Line | Data |
---|---|---|
10bb1a34 | 1 | /////////////////////////////////////////////////////////////////////// |
2 | // Author: Henrik Tydesjo // | |
3 | // For easier handling of error messages from AliITSRawStreamSPD. // | |
4 | // The purpose of this class is to make possible the switch to the // | |
5 | // AliRoot raw data parsing routines in the onlinte monitoring // | |
6 | // programs, like SPD-MOOD, and still keep all the old functionality.// | |
7 | /////////////////////////////////////////////////////////////////////// | |
8 | ||
9 | #include "AliITSRawStreamSPDErrorLog.h" | |
10 | #include "AliLog.h" | |
11 | ||
12 | ClassImp(AliITSRawStreamSPDErrorLog) | |
13 | //________________________________________________________________________________________________ | |
14 | AliITSRawStreamSPDErrorLog::AliITSRawStreamSPDErrorLog() : | |
15 | fText(NULL), fTextTmpGeneral(NULL) | |
16 | { | |
17 | // default constructor | |
18 | fText=new TGText(); | |
19 | fTextTmpGeneral=new TGText(); | |
20 | for (UInt_t eq=0; eq<20; eq++) { | |
21 | fTextTmp[eq] = new TGText(); | |
22 | fNEvents[eq] = 0; | |
23 | fPayloadSizeSet[eq] = kFALSE; | |
24 | fByteOffset[eq] = 0; | |
25 | fSuppressEq[eq] = kFALSE; | |
26 | for (UInt_t err=0; err<kNrErrorCodes; err++) { | |
27 | fNErrors[err][eq] = 0; | |
28 | } | |
29 | } | |
30 | for (UInt_t err=0; err<kNrErrorCodes; err++) { | |
31 | fSuppressMess[err] = kFALSE; | |
32 | } | |
33 | InitHistograms(); | |
34 | } | |
35 | //________________________________________________________________________________________________ | |
36 | AliITSRawStreamSPDErrorLog::AliITSRawStreamSPDErrorLog(const AliITSRawStreamSPDErrorLog& logger) : | |
37 | TObject(logger), fText(NULL), fTextTmpGeneral(NULL) | |
38 | { | |
39 | // copy constructor | |
40 | for (UInt_t eq=0; eq<20; eq++) { | |
41 | for (UInt_t err=0; err<kNrErrorCodes; err++) { | |
42 | fNErrors[err][eq] = logger.fNErrors[err][eq]; | |
43 | fErrEventCounter[err][eq] = logger.fErrEventCounter[err][eq]; | |
44 | } | |
45 | fNEvents[eq] = logger.fNEvents[eq]; | |
46 | fPayloadSize[eq] = logger.fPayloadSize[eq]; | |
47 | fPayloadSizeSet[eq] = logger.fPayloadSizeSet[eq]; | |
48 | fByteOffset[eq] = logger.fByteOffset[eq]; | |
49 | fSuppressEq[eq] = logger.fSuppressEq[eq]; | |
50 | } | |
51 | for (UInt_t err=0; err<kNrErrorCodes; err++) { | |
52 | fSuppressMess[err] = logger.fSuppressMess[err]; | |
53 | } | |
54 | ||
55 | fText = new TGText(logger.fText); | |
56 | fTextTmpGeneral = new TGText(logger.fTextTmpGeneral); | |
57 | for (UInt_t eq=0; eq<20; eq++) { | |
58 | fTextTmp[eq] = new TGText(logger.fTextTmp[eq]); | |
59 | } | |
60 | ||
61 | for (UInt_t eq=0; eq<20; eq++) { | |
62 | for (UInt_t err=0; err<kNrErrorCodes; err++) { | |
63 | fConsErrEvent[err][eq] = new TGraph(*logger.fConsErrEvent[err][eq]); | |
64 | fConsErrPos[err][eq] = new TH1F(*logger.fConsErrPos[err][eq]); | |
65 | } | |
66 | fConsErrType[eq] = new TH1F(*logger.fConsErrType[eq]); | |
67 | fConsErrFraction[eq] = new TH1F(*logger.fConsErrFraction[eq]); | |
68 | } | |
69 | ||
70 | } | |
71 | //________________________________________________________________________________________________ | |
72 | AliITSRawStreamSPDErrorLog& AliITSRawStreamSPDErrorLog::operator=(const AliITSRawStreamSPDErrorLog& logger) { | |
73 | // assignment operator | |
74 | if (this!=&logger) { | |
75 | delete fText; | |
76 | delete fTextTmpGeneral; | |
77 | delete[] fTextTmp; | |
78 | this->DeleteHistograms(); | |
79 | ||
80 | for (UInt_t eq=0; eq<20; eq++) { | |
81 | for (UInt_t err=0; err<kNrErrorCodes; err++) { | |
82 | fNErrors[err][eq] = logger.fNErrors[err][eq]; | |
83 | fErrEventCounter[err][eq] = logger.fErrEventCounter[err][eq]; | |
84 | } | |
85 | fNEvents[eq] = logger.fNEvents[eq]; | |
86 | fPayloadSize[eq] = logger.fPayloadSize[eq]; | |
87 | fPayloadSizeSet[eq] = logger.fPayloadSizeSet[eq]; | |
88 | fByteOffset[eq] = logger.fByteOffset[eq]; | |
89 | fSuppressEq[eq] = logger.fSuppressEq[eq]; | |
90 | } | |
91 | for (UInt_t err=0; err<kNrErrorCodes; err++) { | |
92 | fSuppressMess[err] = logger.fSuppressMess[err]; | |
93 | } | |
94 | ||
95 | fText = new TGText(logger.fText); | |
96 | fTextTmpGeneral = new TGText(logger.fTextTmpGeneral); | |
97 | for (UInt_t eq=0; eq<20; eq++) { | |
98 | fTextTmp[eq] = new TGText(logger.fTextTmp[eq]); | |
99 | } | |
100 | ||
101 | for (UInt_t eq=0; eq<20; eq++) { | |
102 | for (UInt_t err=0; err<kNrErrorCodes; err++) { | |
103 | fConsErrEvent[err][eq] = new TGraph(*logger.fConsErrEvent[err][eq]); | |
104 | fConsErrPos[err][eq] = new TH1F(*logger.fConsErrPos[err][eq]); | |
105 | } | |
106 | fConsErrType[eq] = new TH1F(*logger.fConsErrType[eq]); | |
107 | fConsErrFraction[eq] = new TH1F(*logger.fConsErrFraction[eq]); | |
108 | } | |
109 | ||
110 | } | |
111 | return *this; | |
112 | ||
113 | } | |
114 | //________________________________________________________________________________________________ | |
115 | AliITSRawStreamSPDErrorLog::~AliITSRawStreamSPDErrorLog() { | |
116 | // destructor | |
117 | DeleteHistograms(); | |
118 | delete fText; | |
119 | delete fTextTmpGeneral; | |
120 | delete[] fTextTmp; | |
121 | } | |
122 | //________________________________________________________________________________________________ | |
123 | void AliITSRawStreamSPDErrorLog::InitHistograms() { | |
124 | // initialize histograms | |
125 | for (UInt_t eq=0; eq<20; eq++) { | |
126 | TString histName, histTitle; | |
127 | histName = Form("ConsErrType %d",eq); | |
128 | histTitle = Form("Distribution of errors, eq %d",eq); | |
129 | fConsErrType[eq]=new TH1F(histName.Data(),histTitle.Data(),kNrErrorCodes,-0.5,kNrErrorCodes-0.5); | |
130 | fConsErrType[eq]->SetXTitle("Error Code"); | |
131 | fConsErrType[eq]->SetYTitle("Nr Errors"); | |
132 | ||
133 | histName = Form("ConsErrFraction %d",eq); | |
134 | histTitle = Form("Fraction of events with errors, eq %d",eq); | |
135 | fConsErrFraction[eq]=new TH1F(histName.Data(),histTitle.Data(),kNrErrorCodes,-0.5,kNrErrorCodes-0.5); | |
136 | fConsErrFraction[eq]->SetXTitle("Error Code"); | |
137 | fConsErrFraction[eq]->SetYTitle("Fraction"); | |
138 | ||
139 | for (UInt_t err=0; err<kNrErrorCodes; err++) { | |
140 | fConsErrEvent[err][eq]=new TGraph(); | |
141 | fErrEventCounter[err][eq] = 0; | |
142 | histName = Form("ConsErrPos %d %d",err,eq); | |
143 | histTitle = Form("Position in event, eq %d , error code %d",eq,err); | |
144 | fConsErrPos[err][eq]=new TH1F(histName.Data(),histTitle.Data(),200,0,100); | |
145 | fConsErrPos[err][eq]->SetXTitle("Position [%]"); | |
146 | fConsErrPos[err][eq]->SetYTitle("Nr Errors"); | |
147 | } | |
148 | } | |
149 | } | |
150 | //________________________________________________________________________________________________ | |
151 | void AliITSRawStreamSPDErrorLog::DeleteHistograms() const { | |
152 | // delete histograms | |
153 | for (UInt_t eq=0; eq<20; eq++) { | |
154 | delete fConsErrType[eq]; | |
155 | delete fConsErrFraction[eq]; | |
156 | for (UInt_t err=0; err<kNrErrorCodes; err++) { | |
157 | delete fConsErrEvent[err][eq]; | |
158 | delete fConsErrPos[err][eq]; | |
159 | } | |
160 | } | |
161 | } | |
162 | //________________________________________________________________________________________________ | |
163 | void AliITSRawStreamSPDErrorLog::Reset() { | |
164 | // Reset | |
165 | fText->Clear(); | |
166 | for (UInt_t eq=0; eq<20; eq++) { | |
167 | fTextTmp[eq]->Clear(); | |
168 | fConsErrType[eq]->Reset(); | |
169 | fConsErrFraction[eq]->Reset(); | |
170 | fNEvents[eq] = 0; | |
171 | fPayloadSizeSet[eq] = kFALSE; | |
172 | for (UInt_t err=0; err<kNrErrorCodes; err++) { | |
173 | fNErrors[err][eq] = 0; | |
174 | delete fConsErrEvent[err][eq]; | |
175 | fErrEventCounter[err][eq] = 0; | |
176 | fConsErrEvent[err][eq] = new TGraph(); | |
177 | fConsErrPos[err][eq]->Reset(); | |
178 | } | |
179 | } | |
180 | } | |
181 | //________________________________________________________________________________________________ | |
182 | void AliITSRawStreamSPDErrorLog::ProcessError(UInt_t errorCode, UInt_t eq, Int_t bytesRead, Int_t headersRead, const Char_t *errMess) { | |
183 | // Process an error | |
184 | if (eq>=20) { | |
185 | AliWarning(Form("Equipment number (%d) out of bounds",eq)); | |
186 | return; | |
187 | } | |
188 | // check if we want to exclude the error... | |
189 | if (!(fSuppressMess[errorCode] || fSuppressEq[eq])) { | |
190 | fNErrors[errorCode][eq]++; | |
191 | if (errorCode!=kTotal) fNErrors[kTotal][eq]++; | |
192 | ||
193 | if (fPayloadSizeSet) { | |
194 | fConsErrPos[errorCode][eq]->Fill(100.*bytesRead/fPayloadSize[eq]); | |
195 | if (errorCode!=kTotal) fConsErrPos[kTotal][eq]->Fill(100.*bytesRead/fPayloadSize[eq]); | |
196 | } | |
197 | ||
198 | TString msg; | |
199 | if (bytesRead<0) { | |
200 | msg = Form("%s",errMess); | |
201 | } | |
202 | else { | |
203 | msg = Form("%s (%d bytes read, %d chip headers read)",errMess,bytesRead+fByteOffset[eq],headersRead); | |
204 | } | |
205 | fTextTmp[eq]->InsLine(fTextTmp[eq]->RowCount(),msg.Data()); | |
206 | } | |
207 | } | |
208 | //________________________________________________________________________________________________ | |
209 | void AliITSRawStreamSPDErrorLog::AddMessage(const Char_t *errMess) { | |
210 | // add a general message to the buffer | |
211 | fTextTmpGeneral->InsLine(fTextTmpGeneral->RowCount(),errMess); | |
212 | } | |
213 | //________________________________________________________________________________________________ | |
214 | void AliITSRawStreamSPDErrorLog::SummarizeEvent(UInt_t eventNum) { | |
215 | // summarize the information for the current event | |
216 | TString msg; | |
217 | if (fText->RowCount()>5000) { | |
218 | fText->Clear(); | |
219 | msg = "*** previous errors cleared ***"; | |
220 | fText->InsLine(fText->RowCount(),msg.Data()); | |
221 | } | |
222 | if (fTextTmpGeneral->RowCount()>1) { | |
223 | msg = Form("*** Event %d , General Errors: ***",eventNum); | |
224 | fText->InsLine(fText->RowCount(),msg.Data()); | |
225 | fText->AddText(fTextTmpGeneral); | |
226 | fTextTmpGeneral->Clear(); | |
227 | } | |
228 | for (UInt_t eq=0; eq<20; eq++) { | |
229 | for (UInt_t err=0; err<kNrErrorCodes; err++) { | |
230 | fConsErrType[eq]->Fill(err,fNErrors[err][eq]); | |
231 | if (fNErrors[err][eq]>0){ | |
232 | fConsErrEvent[err][eq]->SetPoint(fErrEventCounter[err][eq],eventNum,fNErrors[err][eq]); | |
233 | fErrEventCounter[err][eq]++; | |
234 | fConsErrFraction[eq]->Fill(err); | |
235 | } | |
236 | } | |
237 | fNEvents[eq]++; | |
238 | if (fNErrors[kTotal][eq]>0) { | |
239 | msg = Form("*** Event %d , Eq %d: ***",eventNum,eq); | |
240 | fText->InsLine(fText->RowCount(),msg.Data()); | |
241 | fText->AddText(fTextTmp[eq]); | |
242 | fText->InsLine(fText->RowCount()," "); | |
243 | } | |
244 | fPayloadSizeSet[eq]=kFALSE; | |
245 | fByteOffset[eq]=0; | |
246 | fTextTmp[eq]->Clear(); | |
247 | for (UInt_t err=0; err<kNrErrorCodes; err++) { | |
248 | fNErrors[err][eq]=0; | |
249 | } | |
250 | } | |
251 | } | |
252 | //________________________________________________________________________________________________ | |
253 | void AliITSRawStreamSPDErrorLog::SetPayloadSize(UInt_t eq, UInt_t size) { | |
254 | // set the payload size for this event | |
255 | if (eq<20) { | |
256 | fPayloadSize[eq]=size; | |
257 | fPayloadSizeSet[eq]=kTRUE; | |
258 | } | |
259 | else { | |
260 | AliWarning(Form("Equipment number (%d) out of range",eq)); | |
261 | } | |
262 | } | |
263 | //________________________________________________________________________________________________ | |
264 | void AliITSRawStreamSPDErrorLog::SetByteOffset(UInt_t eq, Int_t size) { | |
265 | // set byte offset (equipment header size) | |
266 | if (eq<20) { | |
267 | fByteOffset[eq]=size; | |
268 | } | |
269 | else { | |
270 | AliWarning(Form("Equipment number (%d) out of range",eq)); | |
271 | } | |
272 | } | |
273 | //________________________________________________________________________________________________ | |
274 | void AliITSRawStreamSPDErrorLog::SuppressErrorMessages(UInt_t errorCode, Bool_t suppr) { | |
275 | // suppress error messages for specific error code | |
276 | if (errorCode<kNrErrorCodes) { | |
277 | fSuppressMess[errorCode] = suppr; | |
278 | } | |
279 | else { | |
280 | AliWarning(Form("Error code (%d) out of range",errorCode)); | |
281 | } | |
282 | } | |
283 | //________________________________________________________________________________________________ | |
284 | void AliITSRawStreamSPDErrorLog::SuppressErrorEq(UInt_t eq, Bool_t suppr) { | |
285 | // suppress error messages for specific equipment | |
286 | if (eq<20) { | |
287 | fSuppressEq[eq] = suppr; | |
288 | } | |
289 | else { | |
290 | AliWarning(Form("Eq id (%d) out of range",eq)); | |
291 | } | |
292 | } | |
293 | //________________________________________________________________________________________________ | |
294 | UInt_t AliITSRawStreamSPDErrorLog::GetNrErrors(UInt_t errorCode, UInt_t eq) { | |
295 | // returns the number of errors for this event for a specific error code and equipment | |
296 | if (errorCode<kNrErrorCodes && eq<20) return fNErrors[errorCode][eq]; | |
297 | else { | |
298 | AliWarning(Form("Error code (%d) or equipment (%d) out of range, returning 0",errorCode,eq)); | |
299 | return 0; | |
300 | } | |
301 | } | |
302 | //________________________________________________________________________________________________ | |
303 | UInt_t AliITSRawStreamSPDErrorLog::GetNrErrorsAllEq(UInt_t errorCode) { | |
304 | // returns the number of errors for this event for a specific error code and all equipments | |
305 | if (errorCode<kNrErrorCodes) { | |
306 | UInt_t returnval=0; | |
307 | for (UInt_t eq=0; eq<20; eq++) { | |
308 | returnval += fNErrors[errorCode][eq]; | |
309 | } | |
310 | return returnval; | |
311 | } | |
312 | else { | |
313 | AliWarning(Form("Error code (%d) out of range, returning 0",errorCode)); | |
314 | return 0; | |
315 | } | |
316 | } | |
317 | //________________________________________________________________________________________________ | |
318 | UInt_t AliITSRawStreamSPDErrorLog::GetNrErrorsTotal(UInt_t errorCode, UInt_t eq) { | |
319 | // returns the total number of errors for a specific error code and equipment | |
320 | if (errorCode<kNrErrorCodes && eq<20) { | |
321 | return (UInt_t) fConsErrType[eq]->GetBinContent(errorCode+1); | |
322 | } | |
323 | else { | |
324 | AliWarning(Form("Error code (%d) or equipment (%d) out of range, returning 0",errorCode,eq)); | |
325 | return 0; | |
326 | } | |
327 | } | |
328 | //________________________________________________________________________________________________ | |
329 | UInt_t AliITSRawStreamSPDErrorLog::GetNrErrorsTotalAllEq(UInt_t errorCode) { | |
330 | // returns the total number of errors for a specific error code and for all equipment | |
331 | if (errorCode<kNrErrorCodes) { | |
332 | UInt_t returnval=0; | |
333 | for (UInt_t eq=0; eq<20; eq++) { | |
334 | returnval += (UInt_t) fConsErrType[eq]->GetBinContent(errorCode+1); | |
335 | } | |
336 | return returnval; | |
337 | } | |
338 | else { | |
339 | AliWarning(Form("Error code (%d) out of range, returning 0",errorCode)); | |
340 | return 0; | |
341 | } | |
342 | } | |
343 | //________________________________________________________________________________________________ | |
344 | TGraph* AliITSRawStreamSPDErrorLog::GetConsErrEvent(UInt_t errorCode, UInt_t eq) { | |
345 | // returns a pointer to the graph | |
346 | if (errorCode<kNrErrorCodes && eq<20) return fConsErrEvent[errorCode][eq]; | |
347 | else { | |
348 | AliWarning(Form("Error code (%d) or equipment (%d) out of range, returning NULL",errorCode,eq)); | |
349 | return NULL; | |
350 | } | |
351 | } | |
352 | //________________________________________________________________________________________________ | |
353 | TH1F* AliITSRawStreamSPDErrorLog::GetConsErrType(UInt_t eq) { | |
354 | // returns a pointer to the histogram | |
355 | if (eq<20) return fConsErrType[eq]; | |
356 | else { | |
357 | AliWarning(Form("Eq nr (%d) out of bounds",eq)); | |
358 | return NULL; | |
359 | } | |
360 | } | |
361 | //________________________________________________________________________________________________ | |
362 | TH1F* AliITSRawStreamSPDErrorLog::GetConsErrFraction(UInt_t eq) { | |
363 | // creates a new histogram and returns a pointer to it. | |
364 | // NB!!! Take care of deleting this object later | |
365 | if (eq<20) { | |
366 | TH1F* returnhisto = (TH1F*)(fConsErrFraction[eq]->Clone()); | |
367 | if (fNEvents[eq]!=0) returnhisto->Scale(1./fNEvents[eq]); | |
368 | // returnhisto->SetMaximum(1.); | |
369 | return returnhisto; | |
370 | } | |
371 | else { | |
372 | AliWarning(Form("Eq nr (%d) out of bounds",eq)); | |
373 | return NULL; | |
374 | } | |
375 | } | |
376 | //________________________________________________________________________________________________ | |
377 | TH1F* AliITSRawStreamSPDErrorLog::GetConsErrPos(UInt_t errorCode, UInt_t eq) { | |
378 | // returns a pointer to the histogram | |
379 | if (errorCode<kNrErrorCodes && eq<20) return fConsErrPos[errorCode][eq]; | |
380 | else { | |
381 | AliWarning(Form("Error code (%d) or equipment (%d) out of range, returning NULL",errorCode,eq)); | |
382 | return NULL; | |
383 | } | |
384 | } |