/////////////////////////////////////////////////////////////////////// // Author: Henrik Tydesjo // // For easier handling of error messages from AliITSRawStreamSPD. // // The purpose of this class is to make possible the switch to the // // AliRoot raw data parsing routines in the onlinte monitoring // // programs, like SPD-MOOD, and still keep all the old functionality.// /////////////////////////////////////////////////////////////////////// #include "AliITSRawStreamSPDErrorLog.h" #include "AliLog.h" /* $Id$ */ ClassImp(AliITSRawStreamSPDErrorLog) //________________________________________________________________________________________________ AliITSRawStreamSPDErrorLog::AliITSRawStreamSPDErrorLog() : fText(NULL), fTextTmpGeneral(NULL) { // default constructor fText=new TGText(); fTextTmpGeneral=new TGText(); for (UInt_t eq=0; eq<20; eq++) { fTextTmp[eq] = new TGText(); fNEvents[eq] = 0; fByteOffset[eq] = 0; fSuppressEq[eq] = kFALSE; for (UInt_t err=0; errDeleteHistograms(); for (UInt_t eq=0; eq<20; eq++) { for (UInt_t err=0; errSetXTitle("Error Code"); fConsErrType[eq]->SetYTitle("Nr Errors"); histName = Form("ConsErrFraction %d",eq); histTitle = Form("Fraction of events with errors, eq %d",eq); fConsErrFraction[eq]=new TH1F(histName.Data(),histTitle.Data(),kNrErrorCodes,-0.5,kNrErrorCodes-0.5); fConsErrFraction[eq]->SetXTitle("Error Code"); fConsErrFraction[eq]->SetYTitle("Fraction"); for (UInt_t err=0; errClear(); fTextTmpGeneral->Clear(); for (UInt_t eq=0; eq<20; eq++) { fTextTmp[eq]->Clear(); fConsErrType[eq]->Reset(); fConsErrFraction[eq]->Reset(); fNEvents[eq] = 0; for (UInt_t err=0; err=20) { AliWarning(Form("Equipment number (%d) out of bounds",eq)); return; } // check if we want to exclude the error... if (!(fSuppressMess[errorCode] || fSuppressEq[eq])) { fNErrors[errorCode][eq]++; fNErrorsTotal[errorCode][eq]++; if (errorCode!=kTotal) { fNErrors[kTotal][eq]++; fNErrorsTotal[kTotal][eq]++; } if (bytesRead>=0) { fConsErrPosTMP[errorCode][eq]->SetPoint(fErrPosTMPCounter[errorCode][eq],0,bytesRead+fByteOffset[eq]); fErrPosTMPCounter[errorCode][eq]++; if (errorCode!=kTotal) { fConsErrPosTMP[kTotal][eq]->SetPoint(fErrPosTMPCounter[kTotal][eq],0,bytesRead+fByteOffset[eq]); fErrPosTMPCounter[kTotal][eq]++; } } TString msg; if (bytesRead<0) { msg = Form("%s",errMess); } else { msg = Form("%s (%d bytes read, %d chip headers read)",errMess,bytesRead+fByteOffset[eq],headersRead); } fTextTmp[eq]->InsLine(fTextTmp[eq]->RowCount(),msg.Data()); } } //________________________________________________________________________________________________ void AliITSRawStreamSPDErrorLog::AddMessage(const Char_t *errMess) { // add a general message to the buffer fTextTmpGeneral->InsLine(fTextTmpGeneral->RowCount(),errMess); } //________________________________________________________________________________________________ void AliITSRawStreamSPDErrorLog::ResetEvent() { // reset error counters for current event for (UInt_t eq=0; eq<20; eq++) { for (UInt_t err=0; errClear(); fTextTmp[eq]->Clear(); } for (UInt_t eq=0; eq<20; eq++) { for (UInt_t err=0; errRowCount()>5000) { fText->Clear(); msg = "*** previous errors cleared ***"; fText->InsLine(fText->RowCount(),msg.Data()); } if (fTextTmpGeneral->RowCount()>1) { msg = Form("*** Event %d , General Errors: ***",eventNum); fText->InsLine(fText->RowCount(),msg.Data()); fText->AddText(fTextTmpGeneral); // fTextTmpGeneral->Clear(); } for (UInt_t eq=0; eq<20; eq++) { if (fNErrors[kTotal][eq]>0) { msg = Form("*** Event %d , Eq %d: ***",eventNum,eq); fText->InsLine(fText->RowCount(),msg.Data()); fText->AddText(fTextTmp[eq]); fText->InsLine(fText->RowCount()," "); } // fTextTmp[eq]->Clear(); } } //________________________________________________________________________________________________ void AliITSRawStreamSPDErrorLog::ProcessEvent(UInt_t eventNum) { // summarize the information for the current event // TString msg; // if (fText->RowCount()>5000) { // fText->Clear(); // msg = "*** previous errors cleared ***"; // fText->InsLine(fText->RowCount(),msg.Data()); // } // if (fTextTmpGeneral->RowCount()>1) { // msg = Form("*** Event %d , General Errors: ***",eventNum); // fText->InsLine(fText->RowCount(),msg.Data()); // fText->AddText(fTextTmpGeneral); // fTextTmpGeneral->Clear(); // } AddErrorMessagesFromCurrentEvent(eventNum); for (UInt_t eq=0; eq<20; eq++) { for (UInt_t err=0; errFill(err,fNErrors[err][eq]); if (fNErrors[err][eq]>0) { fConsErrEvent[err][eq]->SetPoint(fErrEventCounter[err][eq],eventNum,fNErrors[err][eq]); fErrEventCounter[err][eq]++; fConsErrFraction[eq]->Fill(err); } for (UInt_t pind=0; pindGetPoint(pind,x,y); fConsErrPos[err][eq]->SetPoint(fErrPosCounter[err][eq],eventNum,y); fErrPosCounter[err][eq]++; } } fNEvents[eq]++; // if (fNErrors[kTotal][eq]>0) { // msg = Form("*** Event %d , Eq %d: ***",eventNum,eq); // fText->InsLine(fText->RowCount(),msg.Data()); // fText->AddText(fTextTmp[eq]); // fText->InsLine(fText->RowCount()," "); // } // fByteOffset[eq]=0; // fTextTmp[eq]->Clear(); } } //________________________________________________________________________________________________ void AliITSRawStreamSPDErrorLog::SummarizeEvent(UInt_t eventNum) { // summarize the information for the current event ProcessEvent(eventNum); ResetEvent(); } //________________________________________________________________________________________________ void AliITSRawStreamSPDErrorLog::SetByteOffset(UInt_t eq, Int_t size) { // set byte offset (equipment header size) if (eq<20) { fByteOffset[eq]=size; } else { AliWarning(Form("Equipment number (%d) out of range",eq)); } } //________________________________________________________________________________________________ void AliITSRawStreamSPDErrorLog::SuppressErrorMessages(UInt_t errorCode, Bool_t suppr) { // suppress error messages for specific error code if (errorCodeGetBinContent(errorCode+1); } else { AliWarning(Form("Error code (%d) or equipment (%d) out of range, returning 0",errorCode,eq)); return 0; } } //________________________________________________________________________________________________ UInt_t AliITSRawStreamSPDErrorLog::GetNrErrorsTotalAllEq(UInt_t errorCode) { // returns the total number of errors for a specific error code and for all equipments if (errorCodeGetBinContent(errorCode+1); } return returnval; } else { AliWarning(Form("Error code (%d) out of range, returning 0",errorCode)); return 0; } } //________________________________________________________________________________________________ TGraph* AliITSRawStreamSPDErrorLog::GetConsErrEvent(UInt_t errorCode, UInt_t eq) { // returns a pointer to the graph if (errorCodeClone()); if (fNEvents[eq]!=0) returnhisto->Scale(1./fNEvents[eq]); // returnhisto->SetMaximum(1.); return returnhisto; } else { AliWarning(Form("Eq nr (%d) out of bounds",eq)); return NULL; } } //________________________________________________________________________________________________ TH1F* AliITSRawStreamSPDErrorLog::GetConsErrFractionUnScaled(UInt_t eq) { // returns a pointer to the histogram if (eq<20) return fConsErrFraction[eq]; else { AliWarning(Form("Eq nr (%d) out of bounds",eq)); return NULL; } } //________________________________________________________________________________________________ TGraph* AliITSRawStreamSPDErrorLog::GetConsErrPos(UInt_t errorCode, UInt_t eq) { // returns a pointer to the histogram if (errorCodeGetPoint(index,x,y); return (UInt_t) y; } else { AliError(Form("Index %d out of range, returning 0",index)); return 0; } } else { AliError(Form("Error code (%d) or equipment (%d) out of range, returning 0",errorCode,eq)); return 0; } }