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();
25 fPayloadSizeSet[eq] = kFALSE;
27 fSuppressEq[eq] = kFALSE;
28 for (UInt_t err=0; err<kNrErrorCodes; err++) {
29 fNErrors[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 fErrEventCounter[err][eq] = logger.fErrEventCounter[err][eq];
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];
53 for (UInt_t err=0; err<kNrErrorCodes; err++) {
54 fSuppressMess[err] = logger.fSuppressMess[err];
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]);
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]);
68 fConsErrType[eq] = new TH1F(*logger.fConsErrType[eq]);
69 fConsErrFraction[eq] = new TH1F(*logger.fConsErrFraction[eq]);
73 //________________________________________________________________________________________________
74 AliITSRawStreamSPDErrorLog& AliITSRawStreamSPDErrorLog::operator=(const AliITSRawStreamSPDErrorLog& logger) {
75 // assignment operator
78 delete fTextTmpGeneral;
80 this->DeleteHistograms();
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];
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];
93 for (UInt_t err=0; err<kNrErrorCodes; err++) {
94 fSuppressMess[err] = logger.fSuppressMess[err];
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]);
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]);
108 fConsErrType[eq] = new TH1F(*logger.fConsErrType[eq]);
109 fConsErrFraction[eq] = new TH1F(*logger.fConsErrFraction[eq]);
116 //________________________________________________________________________________________________
117 AliITSRawStreamSPDErrorLog::~AliITSRawStreamSPDErrorLog() {
121 delete fTextTmpGeneral;
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");
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");
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");
152 //________________________________________________________________________________________________
153 void AliITSRawStreamSPDErrorLog::DeleteHistograms() const {
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];
164 //________________________________________________________________________________________________
165 void AliITSRawStreamSPDErrorLog::Reset() {
168 for (UInt_t eq=0; eq<20; eq++) {
169 fTextTmp[eq]->Clear();
170 fConsErrType[eq]->Reset();
171 fConsErrFraction[eq]->Reset();
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();
183 //________________________________________________________________________________________________
184 void AliITSRawStreamSPDErrorLog::ProcessError(UInt_t errorCode, UInt_t eq, Int_t bytesRead, Int_t headersRead, const Char_t *errMess) {
187 AliWarning(Form("Equipment number (%d) out of bounds",eq));
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]++;
195 if (fPayloadSizeSet[eq]) {
196 fConsErrPos[errorCode][eq]->Fill(100.*bytesRead/fPayloadSize[eq]);
197 if (errorCode!=kTotal) fConsErrPos[kTotal][eq]->Fill(100.*bytesRead/fPayloadSize[eq]);
202 msg = Form("%s",errMess);
205 msg = Form("%s (%d bytes read, %d chip headers read)",errMess,bytesRead+fByteOffset[eq],headersRead);
207 fTextTmp[eq]->InsLine(fTextTmp[eq]->RowCount(),msg.Data());
210 //________________________________________________________________________________________________
211 void AliITSRawStreamSPDErrorLog::AddMessage(const Char_t *errMess) {
212 // add a general message to the buffer
213 fTextTmpGeneral->InsLine(fTextTmpGeneral->RowCount(),errMess);
215 //________________________________________________________________________________________________
216 void AliITSRawStreamSPDErrorLog::SummarizeEvent(UInt_t eventNum) {
217 // summarize the information for the current event
219 if (fText->RowCount()>5000) {
221 msg = "*** previous errors cleared ***";
222 fText->InsLine(fText->RowCount(),msg.Data());
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();
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);
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()," ");
246 fPayloadSizeSet[eq]=kFALSE;
248 fTextTmp[eq]->Clear();
249 for (UInt_t err=0; err<kNrErrorCodes; err++) {
254 //________________________________________________________________________________________________
255 void AliITSRawStreamSPDErrorLog::SetPayloadSize(UInt_t eq, UInt_t size) {
256 // set the payload size for this event
258 fPayloadSize[eq]=size;
259 fPayloadSizeSet[eq]=kTRUE;
262 AliWarning(Form("Equipment number (%d) out of range",eq));
265 //________________________________________________________________________________________________
266 void AliITSRawStreamSPDErrorLog::SetByteOffset(UInt_t eq, Int_t size) {
267 // set byte offset (equipment header size)
269 fByteOffset[eq]=size;
272 AliWarning(Form("Equipment number (%d) out of range",eq));
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;
282 AliWarning(Form("Error code (%d) out of range",errorCode));
285 //________________________________________________________________________________________________
286 void AliITSRawStreamSPDErrorLog::SuppressErrorEq(UInt_t eq, Bool_t suppr) {
287 // suppress error messages for specific equipment
289 fSuppressEq[eq] = suppr;
292 AliWarning(Form("Eq id (%d) out of range",eq));
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];
300 AliWarning(Form("Error code (%d) or equipment (%d) out of range, returning 0",errorCode,eq));
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) {
309 for (UInt_t eq=0; eq<20; eq++) {
310 returnval += fNErrors[errorCode][eq];
315 AliWarning(Form("Error code (%d) out of range, returning 0",errorCode));
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);
326 AliWarning(Form("Error code (%d) or equipment (%d) out of range, returning 0",errorCode,eq));
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) {
335 for (UInt_t eq=0; eq<20; eq++) {
336 returnval += (UInt_t) fConsErrType[eq]->GetBinContent(errorCode+1);
341 AliWarning(Form("Error code (%d) out of range, returning 0",errorCode));
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];
350 AliWarning(Form("Error code (%d) or equipment (%d) out of range, returning NULL",errorCode,eq));
354 //________________________________________________________________________________________________
355 TH1F* AliITSRawStreamSPDErrorLog::GetConsErrType(UInt_t eq) {
356 // returns a pointer to the histogram
357 if (eq<20) return fConsErrType[eq];
359 AliWarning(Form("Eq nr (%d) out of bounds",eq));
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
368 TH1F* returnhisto = (TH1F*)(fConsErrFraction[eq]->Clone());
369 if (fNEvents[eq]!=0) returnhisto->Scale(1./fNEvents[eq]);
370 // returnhisto->SetMaximum(1.);
374 AliWarning(Form("Eq nr (%d) out of bounds",eq));
378 //________________________________________________________________________________________________
379 TH1F* AliITSRawStreamSPDErrorLog::GetConsErrFractionUnScaled(UInt_t eq) {
380 // returns a pointer to the histogram
381 if (eq<20) return fConsErrFraction[eq];
383 AliWarning(Form("Eq nr (%d) out of bounds",eq));
387 //________________________________________________________________________________________________
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];
392 AliWarning(Form("Error code (%d) or equipment (%d) out of range, returning NULL",errorCode,eq));