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