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 ///////////////////////////////////////////////////////////////////////
9 #include "AliITSRawStreamSPDErrorLog.h"
14 ClassImp(AliITSRawStreamSPDErrorLog)
15 //________________________________________________________________________________________________
16 AliITSRawStreamSPDErrorLog::AliITSRawStreamSPDErrorLog() :
17 fText(NULL), fTextTmpGeneral(NULL)
19 // default constructor
21 fTextTmpGeneral=new TGText();
22 for (UInt_t eq=0; eq<20; eq++) {
23 fTextTmp[eq] = new TGText();
26 fSuppressEq[eq] = kFALSE;
27 for (UInt_t err=0; err<kNrErrorCodes; err++) {
28 fNErrors[err][eq] = 0;
29 fNErrorsTotal[err][eq] = 0;
32 for (UInt_t err=0; err<kNrErrorCodes; err++) {
33 fSuppressMess[err] = kFALSE;
37 //________________________________________________________________________________________________
38 AliITSRawStreamSPDErrorLog::AliITSRawStreamSPDErrorLog(const AliITSRawStreamSPDErrorLog& logger) :
39 TObject(logger), fText(NULL), fTextTmpGeneral(NULL)
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 fNErrorsTotal[err][eq] = logger.fNErrorsTotal[err][eq];
46 fErrEventCounter[err][eq] = logger.fErrEventCounter[err][eq];
48 fNEvents[eq] = logger.fNEvents[eq];
49 fByteOffset[eq] = logger.fByteOffset[eq];
50 fSuppressEq[eq] = logger.fSuppressEq[eq];
52 for (UInt_t err=0; err<kNrErrorCodes; err++) {
53 fSuppressMess[err] = logger.fSuppressMess[err];
56 fText = new TGText(logger.fText);
57 fTextTmpGeneral = new TGText(logger.fTextTmpGeneral);
58 for (UInt_t eq=0; eq<20; eq++) {
59 fTextTmp[eq] = new TGText(logger.fTextTmp[eq]);
62 for (UInt_t eq=0; eq<20; eq++) {
63 for (UInt_t err=0; err<kNrErrorCodes; err++) {
64 fConsErrEvent[err][eq] = new TGraph(*logger.fConsErrEvent[err][eq]);
65 fConsErrPos[err][eq] = new TGraph(*logger.fConsErrPos[err][eq]);
67 fConsErrType[eq] = new TH1F(*logger.fConsErrType[eq]);
68 fConsErrType[eq]->SetDirectory(0);
69 fConsErrFraction[eq] = new TH1F(*logger.fConsErrFraction[eq]);
70 fConsErrFraction[eq]->SetDirectory(0);
74 //________________________________________________________________________________________________
75 AliITSRawStreamSPDErrorLog& AliITSRawStreamSPDErrorLog::operator=(const AliITSRawStreamSPDErrorLog& logger) {
76 // assignment operator
79 delete fTextTmpGeneral;
80 for(Int_t eq=0; eq<20;eq++){
83 this->DeleteHistograms();
85 for (UInt_t eq=0; eq<20; eq++) {
86 for (UInt_t err=0; err<kNrErrorCodes; err++) {
87 fNErrors[err][eq] = logger.fNErrors[err][eq];
88 fNErrorsTotal[err][eq] = logger.fNErrorsTotal[err][eq];
89 fErrEventCounter[err][eq] = logger.fErrEventCounter[err][eq];
91 fNEvents[eq] = logger.fNEvents[eq];
92 fByteOffset[eq] = logger.fByteOffset[eq];
93 fSuppressEq[eq] = logger.fSuppressEq[eq];
95 for (UInt_t err=0; err<kNrErrorCodes; err++) {
96 fSuppressMess[err] = logger.fSuppressMess[err];
99 fText = new TGText(logger.fText);
100 fTextTmpGeneral = new TGText(logger.fTextTmpGeneral);
101 for (UInt_t eq=0; eq<20; eq++) {
102 fTextTmp[eq] = new TGText(logger.fTextTmp[eq]);
105 for (UInt_t eq=0; eq<20; eq++) {
106 for (UInt_t err=0; err<kNrErrorCodes; err++) {
107 fConsErrEvent[err][eq] = new TGraph(*logger.fConsErrEvent[err][eq]);
108 fConsErrPos[err][eq] = new TGraph(*logger.fConsErrPos[err][eq]);
110 fConsErrType[eq] = new TH1F(*logger.fConsErrType[eq]);
111 fConsErrType[eq]->SetDirectory(0);
112 fConsErrFraction[eq] = new TH1F(*logger.fConsErrFraction[eq]);
113 fConsErrFraction[eq]->SetDirectory(0);
120 //________________________________________________________________________________________________
121 AliITSRawStreamSPDErrorLog::~AliITSRawStreamSPDErrorLog() {
125 delete fTextTmpGeneral;
126 for(Int_t eq=0; eq<20; eq++){
130 //________________________________________________________________________________________________
131 void AliITSRawStreamSPDErrorLog::InitHistograms() {
132 // initialize histograms
133 for (UInt_t eq=0; eq<20; eq++) {
134 TString histName, histTitle;
135 histName = Form("ConsErrType %d",eq);
136 histTitle = Form("Distribution of errors, eq %d",eq);
137 fConsErrType[eq]=new TH1F(histName.Data(),histTitle.Data(),kNrErrorCodes,-0.5,kNrErrorCodes-0.5);
138 fConsErrType[eq]->SetDirectory(0);
139 fConsErrType[eq]->SetXTitle("Error Code");
140 fConsErrType[eq]->SetYTitle("Nr Errors");
142 histName = Form("ConsErrFraction %d",eq);
143 histTitle = Form("Fraction of events with errors, eq %d",eq);
144 fConsErrFraction[eq]=new TH1F(histName.Data(),histTitle.Data(),kNrErrorCodes,-0.5,kNrErrorCodes-0.5);
145 fConsErrFraction[eq]->SetDirectory(0);
146 fConsErrFraction[eq]->SetXTitle("Error Code");
147 fConsErrFraction[eq]->SetYTitle("Fraction");
149 for (UInt_t err=0; err<kNrErrorCodes; err++) {
150 fConsErrEvent[err][eq]=new TGraph();
151 fConsErrPos[err][eq]=new TGraph();
152 fConsErrPosTMP[err][eq]=new TGraph();
153 fErrEventCounter[err][eq] = 0;
154 fErrPosCounter[err][eq] = 0;
155 fErrPosTMPCounter[err][eq] = 0;
159 //________________________________________________________________________________________________
160 void AliITSRawStreamSPDErrorLog::DeleteHistograms() {
162 for (UInt_t eq=0; eq<20; eq++) {
163 delete fConsErrType[eq];
164 delete fConsErrFraction[eq];
165 for (UInt_t err=0; err<kNrErrorCodes; err++) {
166 delete fConsErrEvent[err][eq];
167 delete fConsErrPos[err][eq];
168 delete fConsErrPosTMP[err][eq];
172 //________________________________________________________________________________________________
173 void AliITSRawStreamSPDErrorLog::Reset() {
176 fTextTmpGeneral->Clear();
177 for (UInt_t eq=0; eq<20; eq++) {
178 fTextTmp[eq]->Clear();
179 fConsErrType[eq]->Reset();
180 fConsErrFraction[eq]->Reset();
182 for (UInt_t err=0; err<kNrErrorCodes; err++) {
183 fNErrors[err][eq] = 0;
184 fNErrorsTotal[err][eq] = 0;
185 delete fConsErrEvent[err][eq];
186 delete fConsErrPos[err][eq];
187 delete fConsErrPosTMP[err][eq];
188 fErrEventCounter[err][eq] = 0;
189 fErrPosCounter[err][eq] = 0;
190 fErrPosTMPCounter[err][eq] = 0;
191 fConsErrEvent[err][eq] = new TGraph();
192 fConsErrPos[err][eq] = new TGraph();
193 fConsErrPosTMP[err][eq] = new TGraph();
197 //________________________________________________________________________________________________
198 void AliITSRawStreamSPDErrorLog::ProcessError(UInt_t errorCode, UInt_t eq, Int_t bytesRead, Int_t headersRead, const Char_t *errMess) {
201 AliWarning(Form("Equipment number (%d) out of bounds",eq));
204 // check if we want to exclude the error...
205 if (!(fSuppressMess[errorCode] || fSuppressEq[eq])) {
206 fNErrors[errorCode][eq]++;
207 fNErrorsTotal[errorCode][eq]++;
208 if (errorCode!=kTotal) {
209 fNErrors[kTotal][eq]++;
210 fNErrorsTotal[kTotal][eq]++;
214 fConsErrPosTMP[errorCode][eq]->SetPoint(fErrPosTMPCounter[errorCode][eq],0,bytesRead+fByteOffset[eq]);
215 fErrPosTMPCounter[errorCode][eq]++;
216 if (errorCode!=kTotal) {
217 fConsErrPosTMP[kTotal][eq]->SetPoint(fErrPosTMPCounter[kTotal][eq],0,bytesRead+fByteOffset[eq]);
218 fErrPosTMPCounter[kTotal][eq]++;
224 msg = Form("%s",errMess);
227 msg = Form("%s (%d bytes read, %d chip headers read)",errMess,bytesRead+fByteOffset[eq],headersRead);
229 fTextTmp[eq]->InsLine(fTextTmp[eq]->RowCount(),msg.Data());
232 //________________________________________________________________________________________________
233 void AliITSRawStreamSPDErrorLog::AddMessage(const Char_t *errMess) {
234 // add a general message to the buffer
235 fTextTmpGeneral->InsLine(fTextTmpGeneral->RowCount(),errMess);
237 //________________________________________________________________________________________________
238 void AliITSRawStreamSPDErrorLog::ResetEvent() {
239 // reset error counters for current event
240 for (UInt_t eq=0; eq<20; eq++) {
241 for (UInt_t err=0; err<kNrErrorCodes; err++) {
245 fTextTmpGeneral->Clear();
246 fTextTmp[eq]->Clear();
249 for (UInt_t eq=0; eq<20; eq++) {
250 for (UInt_t err=0; err<kNrErrorCodes; err++) {
251 delete fConsErrPosTMP[err][eq];
252 fErrPosTMPCounter[err][eq] = 0;
253 fConsErrPosTMP[err][eq] = new TGraph();
257 //________________________________________________________________________________________________
258 void AliITSRawStreamSPDErrorLog::AddErrorMessagesFromCurrentEvent(UInt_t eventNum) {
260 if (fText->RowCount()>5000) {
262 msg = "*** previous errors cleared ***";
263 fText->InsLine(fText->RowCount(),msg.Data());
265 if (fTextTmpGeneral->RowCount()>1) {
266 msg = Form("*** Event %d , General Errors: ***",eventNum);
267 fText->InsLine(fText->RowCount(),msg.Data());
268 fText->AddText(fTextTmpGeneral);
269 // fTextTmpGeneral->Clear();
272 for (UInt_t eq=0; eq<20; eq++) {
273 if (fNErrors[kTotal][eq]>0) {
274 msg = Form("*** Event %d , Eq %d: ***",eventNum,eq);
275 fText->InsLine(fText->RowCount(),msg.Data());
276 fText->AddText(fTextTmp[eq]);
277 fText->InsLine(fText->RowCount()," ");
279 // fTextTmp[eq]->Clear();
282 //________________________________________________________________________________________________
283 void AliITSRawStreamSPDErrorLog::ProcessEvent(UInt_t eventNum) {
284 // summarize the information for the current event
286 // if (fText->RowCount()>5000) {
288 // msg = "*** previous errors cleared ***";
289 // fText->InsLine(fText->RowCount(),msg.Data());
291 // if (fTextTmpGeneral->RowCount()>1) {
292 // msg = Form("*** Event %d , General Errors: ***",eventNum);
293 // fText->InsLine(fText->RowCount(),msg.Data());
294 // fText->AddText(fTextTmpGeneral);
295 // fTextTmpGeneral->Clear();
298 AddErrorMessagesFromCurrentEvent(eventNum);
300 for (UInt_t eq=0; eq<20; eq++) {
301 for (UInt_t err=0; err<kNrErrorCodes; err++) {
302 fConsErrType[eq]->Fill(err,fNErrors[err][eq]);
303 if (fNErrors[err][eq]>0) {
304 fConsErrEvent[err][eq]->SetPoint(fErrEventCounter[err][eq],eventNum,fNErrors[err][eq]);
305 fErrEventCounter[err][eq]++;
306 fConsErrFraction[eq]->Fill(err);
308 for (UInt_t pind=0; pind<fErrPosTMPCounter[err][eq]; pind++) {
310 fConsErrPosTMP[err][eq]->GetPoint(pind,x,y);
311 fConsErrPos[err][eq]->SetPoint(fErrPosCounter[err][eq],eventNum,y);
312 fErrPosCounter[err][eq]++;
317 // if (fNErrors[kTotal][eq]>0) {
318 // msg = Form("*** Event %d , Eq %d: ***",eventNum,eq);
319 // fText->InsLine(fText->RowCount(),msg.Data());
320 // fText->AddText(fTextTmp[eq]);
321 // fText->InsLine(fText->RowCount()," ");
323 // fByteOffset[eq]=0;
324 // fTextTmp[eq]->Clear();
328 //________________________________________________________________________________________________
329 void AliITSRawStreamSPDErrorLog::SummarizeEvent(UInt_t eventNum) {
330 // summarize the information for the current event
331 ProcessEvent(eventNum);
334 //________________________________________________________________________________________________
335 void AliITSRawStreamSPDErrorLog::SetByteOffset(UInt_t eq, Int_t size) {
336 // set byte offset (equipment header size)
338 fByteOffset[eq]=size;
341 AliWarning(Form("Equipment number (%d) out of range",eq));
344 //________________________________________________________________________________________________
345 void AliITSRawStreamSPDErrorLog::SuppressErrorMessages(UInt_t errorCode, Bool_t suppr) {
346 // suppress error messages for specific error code
347 if (errorCode<kNrErrorCodes) {
348 fSuppressMess[errorCode] = suppr;
351 AliWarning(Form("Error code (%d) out of range",errorCode));
354 //________________________________________________________________________________________________
355 void AliITSRawStreamSPDErrorLog::SuppressErrorEq(UInt_t eq, Bool_t suppr) {
356 // suppress error messages for specific equipment
358 fSuppressEq[eq] = suppr;
361 AliWarning(Form("Eq id (%d) out of range",eq));
364 //________________________________________________________________________________________________
365 UInt_t AliITSRawStreamSPDErrorLog::GetNrErrors(UInt_t errorCode, UInt_t eq) {
366 // returns the number of errors for this event for a specific error code and equipment
367 if (errorCode<kNrErrorCodes && eq<20) return fNErrors[errorCode][eq];
369 AliWarning(Form("Error code (%d) or equipment (%d) out of range, returning 0",errorCode,eq));
373 //________________________________________________________________________________________________
374 UInt_t AliITSRawStreamSPDErrorLog::GetNrErrorsAllEq(UInt_t errorCode) {
375 // returns the number of errors for this event for a specific error code and all equipments
376 if (errorCode<kNrErrorCodes) {
378 for (UInt_t eq=0; eq<20; eq++) {
379 returnval += fNErrors[errorCode][eq];
384 AliWarning(Form("Error code (%d) out of range, returning 0",errorCode));
388 //________________________________________________________________________________________________
389 UInt_t AliITSRawStreamSPDErrorLog::GetNrErrorsTotal(UInt_t errorCode, UInt_t eq) {
390 // returns the total number of errors for a specific error code and equipment
391 if (errorCode<kNrErrorCodes && eq<20) {
392 return fNErrorsTotal[errorCode][eq];
393 // return (UInt_t) fConsErrType[eq]->GetBinContent(errorCode+1);
396 AliWarning(Form("Error code (%d) or equipment (%d) out of range, returning 0",errorCode,eq));
400 //________________________________________________________________________________________________
401 UInt_t AliITSRawStreamSPDErrorLog::GetNrErrorsTotalAllEq(UInt_t errorCode) {
402 // returns the total number of errors for a specific error code and for all equipments
403 if (errorCode<kNrErrorCodes) {
405 for (UInt_t eq=0; eq<20; eq++) {
406 returnval += fNErrorsTotal[errorCode][eq];
407 // returnval += (UInt_t) fConsErrType[eq]->GetBinContent(errorCode+1);
412 AliWarning(Form("Error code (%d) out of range, returning 0",errorCode));
416 //________________________________________________________________________________________________
417 TGraph* AliITSRawStreamSPDErrorLog::GetConsErrEvent(UInt_t errorCode, UInt_t eq) {
418 // returns a pointer to the graph
419 if (errorCode<kNrErrorCodes && eq<20) return fConsErrEvent[errorCode][eq];
421 AliWarning(Form("Error code (%d) or equipment (%d) out of range, returning NULL",errorCode,eq));
425 //________________________________________________________________________________________________
426 TH1F* AliITSRawStreamSPDErrorLog::GetConsErrType(UInt_t eq) {
427 // returns a pointer to the histogram
428 if (eq<20) return fConsErrType[eq];
430 AliWarning(Form("Eq nr (%d) out of bounds",eq));
434 //________________________________________________________________________________________________
435 TH1F* AliITSRawStreamSPDErrorLog::GetConsErrFraction(UInt_t eq) {
436 // creates a new histogram and returns a pointer to it.
437 // NB!!! Take care of deleting this object later
439 TH1F* returnhisto = (TH1F*)(fConsErrFraction[eq]->Clone());
440 if (fNEvents[eq]!=0) returnhisto->Scale(1./fNEvents[eq]);
441 // returnhisto->SetMaximum(1.);
445 AliWarning(Form("Eq nr (%d) out of bounds",eq));
449 //________________________________________________________________________________________________
450 TH1F* AliITSRawStreamSPDErrorLog::GetConsErrFractionUnScaled(UInt_t eq) {
451 // returns a pointer to the histogram
452 if (eq<20) return fConsErrFraction[eq];
454 AliWarning(Form("Eq nr (%d) out of bounds",eq));
458 //________________________________________________________________________________________________
459 TGraph* AliITSRawStreamSPDErrorLog::GetConsErrPos(UInt_t errorCode, UInt_t eq) {
460 // returns a pointer to the histogram
461 if (errorCode<kNrErrorCodes && eq<20) return fConsErrPos[errorCode][eq];
463 AliWarning(Form("Error code (%d) or equipment (%d) out of range, returning NULL",errorCode,eq));
467 //________________________________________________________________________________________________
468 UInt_t AliITSRawStreamSPDErrorLog::GetEventErrPosCounter(UInt_t errorCode, UInt_t eq) {
469 // returns the number of errors with bytes information for current event
470 if (errorCode<kNrErrorCodes && eq<20) return fErrPosTMPCounter[errorCode][eq];
472 AliError(Form("Error code (%d) or equipment (%d) out of range, returning 0",errorCode,eq));
476 //________________________________________________________________________________________________
477 UInt_t AliITSRawStreamSPDErrorLog::GetEventErrPos(UInt_t index, UInt_t errorCode, UInt_t eq) {
478 // returns the bytes read for the index'th error of current event
479 if (errorCode<kNrErrorCodes && eq<20) {
480 if (index<fErrPosTMPCounter[errorCode][eq]) {
482 fConsErrPosTMP[errorCode][eq]->GetPoint(index,x,y);
486 AliError(Form("Index %d out of range, returning 0",index));
491 AliError(Form("Error code (%d) or equipment (%d) out of range, returning 0",errorCode,eq));