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 fConsErrFraction[eq] = new TH1F(*logger.fConsErrFraction[eq]);
72 //________________________________________________________________________________________________
73 AliITSRawStreamSPDErrorLog& AliITSRawStreamSPDErrorLog::operator=(const AliITSRawStreamSPDErrorLog& logger) {
74 // assignment operator
77 delete fTextTmpGeneral;
79 this->DeleteHistograms();
81 for (UInt_t eq=0; eq<20; eq++) {
82 for (UInt_t err=0; err<kNrErrorCodes; err++) {
83 fNErrors[err][eq] = logger.fNErrors[err][eq];
84 fNErrorsTotal[err][eq] = logger.fNErrorsTotal[err][eq];
85 fErrEventCounter[err][eq] = logger.fErrEventCounter[err][eq];
87 fNEvents[eq] = logger.fNEvents[eq];
88 fByteOffset[eq] = logger.fByteOffset[eq];
89 fSuppressEq[eq] = logger.fSuppressEq[eq];
91 for (UInt_t err=0; err<kNrErrorCodes; err++) {
92 fSuppressMess[err] = logger.fSuppressMess[err];
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]);
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 TGraph(*logger.fConsErrPos[err][eq]);
106 fConsErrType[eq] = new TH1F(*logger.fConsErrType[eq]);
107 fConsErrFraction[eq] = new TH1F(*logger.fConsErrFraction[eq]);
114 //________________________________________________________________________________________________
115 AliITSRawStreamSPDErrorLog::~AliITSRawStreamSPDErrorLog() {
119 delete fTextTmpGeneral;
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");
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");
139 for (UInt_t err=0; err<kNrErrorCodes; err++) {
140 fConsErrEvent[err][eq]=new TGraph();
141 fConsErrPos[err][eq]=new TGraph();
142 fConsErrPosTMP[err][eq]=new TGraph();
143 fErrEventCounter[err][eq] = 0;
144 fErrPosCounter[err][eq] = 0;
145 fErrPosTMPCounter[err][eq] = 0;
149 //________________________________________________________________________________________________
150 void AliITSRawStreamSPDErrorLog::DeleteHistograms() const {
152 for (UInt_t eq=0; eq<20; eq++) {
153 delete fConsErrType[eq];
154 delete fConsErrFraction[eq];
155 for (UInt_t err=0; err<kNrErrorCodes; err++) {
156 delete fConsErrEvent[err][eq];
157 delete fConsErrPos[err][eq];
158 delete fConsErrPosTMP[err][eq];
162 //________________________________________________________________________________________________
163 void AliITSRawStreamSPDErrorLog::Reset() {
166 fTextTmpGeneral->Clear();
167 for (UInt_t eq=0; eq<20; eq++) {
168 fTextTmp[eq]->Clear();
169 fConsErrType[eq]->Reset();
170 fConsErrFraction[eq]->Reset();
172 for (UInt_t err=0; err<kNrErrorCodes; err++) {
173 fNErrors[err][eq] = 0;
174 fNErrorsTotal[err][eq] = 0;
175 delete fConsErrEvent[err][eq];
176 delete fConsErrPos[err][eq];
177 delete fConsErrPosTMP[err][eq];
178 fErrEventCounter[err][eq] = 0;
179 fErrPosCounter[err][eq] = 0;
180 fErrPosTMPCounter[err][eq] = 0;
181 fConsErrEvent[err][eq] = new TGraph();
182 fConsErrPos[err][eq] = new TGraph();
183 fConsErrPosTMP[err][eq] = new TGraph();
187 //________________________________________________________________________________________________
188 void AliITSRawStreamSPDErrorLog::ProcessError(UInt_t errorCode, UInt_t eq, Int_t bytesRead, Int_t headersRead, const Char_t *errMess) {
191 AliWarning(Form("Equipment number (%d) out of bounds",eq));
194 // check if we want to exclude the error...
195 if (!(fSuppressMess[errorCode] || fSuppressEq[eq])) {
196 fNErrors[errorCode][eq]++;
197 fNErrorsTotal[errorCode][eq]++;
198 if (errorCode!=kTotal) {
199 fNErrors[kTotal][eq]++;
200 fNErrorsTotal[kTotal][eq]++;
204 fConsErrPosTMP[errorCode][eq]->SetPoint(fErrPosTMPCounter[errorCode][eq],0,bytesRead+fByteOffset[eq]);
205 fErrPosTMPCounter[errorCode][eq]++;
206 if (errorCode!=kTotal) {
207 fConsErrPosTMP[kTotal][eq]->SetPoint(fErrPosTMPCounter[kTotal][eq],0,bytesRead+fByteOffset[eq]);
208 fErrPosTMPCounter[kTotal][eq]++;
214 msg = Form("%s",errMess);
217 msg = Form("%s (%d bytes read, %d chip headers read)",errMess,bytesRead+fByteOffset[eq],headersRead);
219 fTextTmp[eq]->InsLine(fTextTmp[eq]->RowCount(),msg.Data());
222 //________________________________________________________________________________________________
223 void AliITSRawStreamSPDErrorLog::AddMessage(const Char_t *errMess) {
224 // add a general message to the buffer
225 fTextTmpGeneral->InsLine(fTextTmpGeneral->RowCount(),errMess);
227 //________________________________________________________________________________________________
228 void AliITSRawStreamSPDErrorLog::ResetEvent() {
229 // reset error counters for current event
230 for (UInt_t eq=0; eq<20; eq++) {
231 for (UInt_t err=0; err<kNrErrorCodes; err++) {
235 fTextTmpGeneral->Clear();
236 fTextTmp[eq]->Clear();
239 for (UInt_t eq=0; eq<20; eq++) {
240 for (UInt_t err=0; err<kNrErrorCodes; err++) {
241 delete fConsErrPosTMP[err][eq];
242 fErrPosTMPCounter[err][eq] = 0;
243 fConsErrPosTMP[err][eq] = new TGraph();
247 //________________________________________________________________________________________________
248 void AliITSRawStreamSPDErrorLog::AddErrorMessagesFromCurrentEvent(UInt_t eventNum) {
250 if (fText->RowCount()>5000) {
252 msg = "*** previous errors cleared ***";
253 fText->InsLine(fText->RowCount(),msg.Data());
255 if (fTextTmpGeneral->RowCount()>1) {
256 msg = Form("*** Event %d , General Errors: ***",eventNum);
257 fText->InsLine(fText->RowCount(),msg.Data());
258 fText->AddText(fTextTmpGeneral);
259 // fTextTmpGeneral->Clear();
262 for (UInt_t eq=0; eq<20; eq++) {
263 if (fNErrors[kTotal][eq]>0) {
264 msg = Form("*** Event %d , Eq %d: ***",eventNum,eq);
265 fText->InsLine(fText->RowCount(),msg.Data());
266 fText->AddText(fTextTmp[eq]);
267 fText->InsLine(fText->RowCount()," ");
269 // fTextTmp[eq]->Clear();
272 //________________________________________________________________________________________________
273 void AliITSRawStreamSPDErrorLog::ProcessEvent(UInt_t eventNum) {
274 // summarize the information for the current event
276 // if (fText->RowCount()>5000) {
278 // msg = "*** previous errors cleared ***";
279 // fText->InsLine(fText->RowCount(),msg.Data());
281 // if (fTextTmpGeneral->RowCount()>1) {
282 // msg = Form("*** Event %d , General Errors: ***",eventNum);
283 // fText->InsLine(fText->RowCount(),msg.Data());
284 // fText->AddText(fTextTmpGeneral);
285 // fTextTmpGeneral->Clear();
288 AddErrorMessagesFromCurrentEvent(eventNum);
290 for (UInt_t eq=0; eq<20; eq++) {
291 for (UInt_t err=0; err<kNrErrorCodes; err++) {
292 fConsErrType[eq]->Fill(err,fNErrors[err][eq]);
293 if (fNErrors[err][eq]>0) {
294 fConsErrEvent[err][eq]->SetPoint(fErrEventCounter[err][eq],eventNum,fNErrors[err][eq]);
295 fErrEventCounter[err][eq]++;
296 fConsErrFraction[eq]->Fill(err);
298 for (UInt_t pind=0; pind<fErrPosTMPCounter[err][eq]; pind++) {
300 fConsErrPosTMP[err][eq]->GetPoint(pind,x,y);
301 fConsErrPos[err][eq]->SetPoint(fErrPosCounter[err][eq],eventNum,y);
302 fErrPosCounter[err][eq]++;
307 // if (fNErrors[kTotal][eq]>0) {
308 // msg = Form("*** Event %d , Eq %d: ***",eventNum,eq);
309 // fText->InsLine(fText->RowCount(),msg.Data());
310 // fText->AddText(fTextTmp[eq]);
311 // fText->InsLine(fText->RowCount()," ");
313 // fByteOffset[eq]=0;
314 // fTextTmp[eq]->Clear();
318 //________________________________________________________________________________________________
319 void AliITSRawStreamSPDErrorLog::SummarizeEvent(UInt_t eventNum) {
320 // summarize the information for the current event
321 ProcessEvent(eventNum);
324 //________________________________________________________________________________________________
325 void AliITSRawStreamSPDErrorLog::SetByteOffset(UInt_t eq, Int_t size) {
326 // set byte offset (equipment header size)
328 fByteOffset[eq]=size;
331 AliWarning(Form("Equipment number (%d) out of range",eq));
334 //________________________________________________________________________________________________
335 void AliITSRawStreamSPDErrorLog::SuppressErrorMessages(UInt_t errorCode, Bool_t suppr) {
336 // suppress error messages for specific error code
337 if (errorCode<kNrErrorCodes) {
338 fSuppressMess[errorCode] = suppr;
341 AliWarning(Form("Error code (%d) out of range",errorCode));
344 //________________________________________________________________________________________________
345 void AliITSRawStreamSPDErrorLog::SuppressErrorEq(UInt_t eq, Bool_t suppr) {
346 // suppress error messages for specific equipment
348 fSuppressEq[eq] = suppr;
351 AliWarning(Form("Eq id (%d) out of range",eq));
354 //________________________________________________________________________________________________
355 UInt_t AliITSRawStreamSPDErrorLog::GetNrErrors(UInt_t errorCode, UInt_t eq) {
356 // returns the number of errors for this event for a specific error code and equipment
357 if (errorCode<kNrErrorCodes && eq<20) return fNErrors[errorCode][eq];
359 AliWarning(Form("Error code (%d) or equipment (%d) out of range, returning 0",errorCode,eq));
363 //________________________________________________________________________________________________
364 UInt_t AliITSRawStreamSPDErrorLog::GetNrErrorsAllEq(UInt_t errorCode) {
365 // returns the number of errors for this event for a specific error code and all equipments
366 if (errorCode<kNrErrorCodes) {
368 for (UInt_t eq=0; eq<20; eq++) {
369 returnval += fNErrors[errorCode][eq];
374 AliWarning(Form("Error code (%d) out of range, returning 0",errorCode));
378 //________________________________________________________________________________________________
379 UInt_t AliITSRawStreamSPDErrorLog::GetNrErrorsTotal(UInt_t errorCode, UInt_t eq) {
380 // returns the total number of errors for a specific error code and equipment
381 if (errorCode<kNrErrorCodes && eq<20) {
382 return fNErrorsTotal[errorCode][eq];
383 // return (UInt_t) fConsErrType[eq]->GetBinContent(errorCode+1);
386 AliWarning(Form("Error code (%d) or equipment (%d) out of range, returning 0",errorCode,eq));
390 //________________________________________________________________________________________________
391 UInt_t AliITSRawStreamSPDErrorLog::GetNrErrorsTotalAllEq(UInt_t errorCode) {
392 // returns the total number of errors for a specific error code and for all equipments
393 if (errorCode<kNrErrorCodes) {
395 for (UInt_t eq=0; eq<20; eq++) {
396 returnval += fNErrorsTotal[errorCode][eq];
397 // returnval += (UInt_t) fConsErrType[eq]->GetBinContent(errorCode+1);
402 AliWarning(Form("Error code (%d) out of range, returning 0",errorCode));
406 //________________________________________________________________________________________________
407 TGraph* AliITSRawStreamSPDErrorLog::GetConsErrEvent(UInt_t errorCode, UInt_t eq) {
408 // returns a pointer to the graph
409 if (errorCode<kNrErrorCodes && eq<20) return fConsErrEvent[errorCode][eq];
411 AliWarning(Form("Error code (%d) or equipment (%d) out of range, returning NULL",errorCode,eq));
415 //________________________________________________________________________________________________
416 TH1F* AliITSRawStreamSPDErrorLog::GetConsErrType(UInt_t eq) {
417 // returns a pointer to the histogram
418 if (eq<20) return fConsErrType[eq];
420 AliWarning(Form("Eq nr (%d) out of bounds",eq));
424 //________________________________________________________________________________________________
425 TH1F* AliITSRawStreamSPDErrorLog::GetConsErrFraction(UInt_t eq) {
426 // creates a new histogram and returns a pointer to it.
427 // NB!!! Take care of deleting this object later
429 TH1F* returnhisto = (TH1F*)(fConsErrFraction[eq]->Clone());
430 if (fNEvents[eq]!=0) returnhisto->Scale(1./fNEvents[eq]);
431 // returnhisto->SetMaximum(1.);
435 AliWarning(Form("Eq nr (%d) out of bounds",eq));
439 //________________________________________________________________________________________________
440 TH1F* AliITSRawStreamSPDErrorLog::GetConsErrFractionUnScaled(UInt_t eq) {
441 // returns a pointer to the histogram
442 if (eq<20) return fConsErrFraction[eq];
444 AliWarning(Form("Eq nr (%d) out of bounds",eq));
448 //________________________________________________________________________________________________
449 TGraph* AliITSRawStreamSPDErrorLog::GetConsErrPos(UInt_t errorCode, UInt_t eq) {
450 // returns a pointer to the histogram
451 if (errorCode<kNrErrorCodes && eq<20) return fConsErrPos[errorCode][eq];
453 AliWarning(Form("Error code (%d) or equipment (%d) out of range, returning NULL",errorCode,eq));
457 //________________________________________________________________________________________________
458 UInt_t AliITSRawStreamSPDErrorLog::GetEventErrPosCounter(UInt_t errorCode, UInt_t eq) {
459 // returns the number of errors with bytes information for current event
460 if (errorCode<kNrErrorCodes && eq<20) return fErrPosTMPCounter[errorCode][eq];
462 AliError(Form("Error code (%d) or equipment (%d) out of range, returning 0",errorCode,eq));
466 //________________________________________________________________________________________________
467 UInt_t AliITSRawStreamSPDErrorLog::GetEventErrPos(UInt_t index, UInt_t errorCode, UInt_t eq) {
468 // returns the bytes read for the index'th error of current event
469 if (errorCode<kNrErrorCodes && eq<20) {
470 if (index<fErrPosTMPCounter[errorCode][eq]) {
472 fConsErrPosTMP[errorCode][eq]->GetPoint(index,x,y);
476 AliError(Form("Index %d out of range, returning 0",index));
481 AliError(Form("Error code (%d) or equipment (%d) out of range, returning 0",errorCode,eq));