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;
31 for (UInt_t err=0; err<kNrErrorCodes; err++) {
32 fSuppressMess[err] = kFALSE;
36 //________________________________________________________________________________________________
37 AliITSRawStreamSPDErrorLog::AliITSRawStreamSPDErrorLog(const AliITSRawStreamSPDErrorLog& logger) :
38 TObject(logger), fText(NULL), fTextTmpGeneral(NULL)
41 for (UInt_t eq=0; eq<20; eq++) {
42 for (UInt_t err=0; err<kNrErrorCodes; err++) {
43 fNErrors[err][eq] = logger.fNErrors[err][eq];
44 fErrEventCounter[err][eq] = logger.fErrEventCounter[err][eq];
46 fNEvents[eq] = logger.fNEvents[eq];
47 fByteOffset[eq] = logger.fByteOffset[eq];
48 fSuppressEq[eq] = logger.fSuppressEq[eq];
50 for (UInt_t err=0; err<kNrErrorCodes; err++) {
51 fSuppressMess[err] = logger.fSuppressMess[err];
54 fText = new TGText(logger.fText);
55 fTextTmpGeneral = new TGText(logger.fTextTmpGeneral);
56 for (UInt_t eq=0; eq<20; eq++) {
57 fTextTmp[eq] = new TGText(logger.fTextTmp[eq]);
60 for (UInt_t eq=0; eq<20; eq++) {
61 for (UInt_t err=0; err<kNrErrorCodes; err++) {
62 fConsErrEvent[err][eq] = new TGraph(*logger.fConsErrEvent[err][eq]);
63 fConsErrPos[err][eq] = new TGraph(*logger.fConsErrPos[err][eq]);
65 fConsErrType[eq] = new TH1F(*logger.fConsErrType[eq]);
66 fConsErrFraction[eq] = new TH1F(*logger.fConsErrFraction[eq]);
70 //________________________________________________________________________________________________
71 AliITSRawStreamSPDErrorLog& AliITSRawStreamSPDErrorLog::operator=(const AliITSRawStreamSPDErrorLog& logger) {
72 // assignment operator
75 delete fTextTmpGeneral;
77 this->DeleteHistograms();
79 for (UInt_t eq=0; eq<20; eq++) {
80 for (UInt_t err=0; err<kNrErrorCodes; err++) {
81 fNErrors[err][eq] = logger.fNErrors[err][eq];
82 fErrEventCounter[err][eq] = logger.fErrEventCounter[err][eq];
84 fNEvents[eq] = logger.fNEvents[eq];
85 fByteOffset[eq] = logger.fByteOffset[eq];
86 fSuppressEq[eq] = logger.fSuppressEq[eq];
88 for (UInt_t err=0; err<kNrErrorCodes; err++) {
89 fSuppressMess[err] = logger.fSuppressMess[err];
92 fText = new TGText(logger.fText);
93 fTextTmpGeneral = new TGText(logger.fTextTmpGeneral);
94 for (UInt_t eq=0; eq<20; eq++) {
95 fTextTmp[eq] = new TGText(logger.fTextTmp[eq]);
98 for (UInt_t eq=0; eq<20; eq++) {
99 for (UInt_t err=0; err<kNrErrorCodes; err++) {
100 fConsErrEvent[err][eq] = new TGraph(*logger.fConsErrEvent[err][eq]);
101 fConsErrPos[err][eq] = new TGraph(*logger.fConsErrPos[err][eq]);
103 fConsErrType[eq] = new TH1F(*logger.fConsErrType[eq]);
104 fConsErrFraction[eq] = new TH1F(*logger.fConsErrFraction[eq]);
111 //________________________________________________________________________________________________
112 AliITSRawStreamSPDErrorLog::~AliITSRawStreamSPDErrorLog() {
116 delete fTextTmpGeneral;
119 //________________________________________________________________________________________________
120 void AliITSRawStreamSPDErrorLog::InitHistograms() {
121 // initialize histograms
122 for (UInt_t eq=0; eq<20; eq++) {
123 TString histName, histTitle;
124 histName = Form("ConsErrType %d",eq);
125 histTitle = Form("Distribution of errors, eq %d",eq);
126 fConsErrType[eq]=new TH1F(histName.Data(),histTitle.Data(),kNrErrorCodes,-0.5,kNrErrorCodes-0.5);
127 fConsErrType[eq]->SetXTitle("Error Code");
128 fConsErrType[eq]->SetYTitle("Nr Errors");
130 histName = Form("ConsErrFraction %d",eq);
131 histTitle = Form("Fraction of events with errors, eq %d",eq);
132 fConsErrFraction[eq]=new TH1F(histName.Data(),histTitle.Data(),kNrErrorCodes,-0.5,kNrErrorCodes-0.5);
133 fConsErrFraction[eq]->SetXTitle("Error Code");
134 fConsErrFraction[eq]->SetYTitle("Fraction");
136 for (UInt_t err=0; err<kNrErrorCodes; err++) {
137 fConsErrEvent[err][eq]=new TGraph();
138 fConsErrPos[err][eq]=new TGraph();
139 fConsErrPosTMP[err][eq]=new TGraph();
140 fErrEventCounter[err][eq] = 0;
141 fErrPosCounter[err][eq] = 0;
142 fErrPosTMPCounter[err][eq] = 0;
146 //________________________________________________________________________________________________
147 void AliITSRawStreamSPDErrorLog::DeleteHistograms() const {
149 for (UInt_t eq=0; eq<20; eq++) {
150 delete fConsErrType[eq];
151 delete fConsErrFraction[eq];
152 for (UInt_t err=0; err<kNrErrorCodes; err++) {
153 delete fConsErrEvent[err][eq];
154 delete fConsErrPos[err][eq];
155 delete fConsErrPosTMP[err][eq];
159 //________________________________________________________________________________________________
160 void AliITSRawStreamSPDErrorLog::Reset() {
163 for (UInt_t eq=0; eq<20; eq++) {
164 fTextTmp[eq]->Clear();
165 fConsErrType[eq]->Reset();
166 fConsErrFraction[eq]->Reset();
168 for (UInt_t err=0; err<kNrErrorCodes; err++) {
169 fNErrors[err][eq] = 0;
170 delete fConsErrEvent[err][eq];
171 delete fConsErrPos[err][eq];
172 delete fConsErrPosTMP[err][eq];
173 fErrEventCounter[err][eq] = 0;
174 fErrPosCounter[err][eq] = 0;
175 fErrPosTMPCounter[err][eq] = 0;
176 fConsErrEvent[err][eq] = new TGraph();
177 fConsErrPos[err][eq] = new TGraph();
178 fConsErrPosTMP[err][eq] = new TGraph();
182 //________________________________________________________________________________________________
183 void AliITSRawStreamSPDErrorLog::ProcessError(UInt_t errorCode, UInt_t eq, Int_t bytesRead, Int_t headersRead, const Char_t *errMess) {
186 AliWarning(Form("Equipment number (%d) out of bounds",eq));
189 // check if we want to exclude the error...
190 if (!(fSuppressMess[errorCode] || fSuppressEq[eq])) {
191 fNErrors[errorCode][eq]++;
192 if (errorCode!=kTotal) fNErrors[kTotal][eq]++;
195 fConsErrPosTMP[errorCode][eq]->SetPoint(fErrPosTMPCounter[errorCode][eq],0,bytesRead+fByteOffset[eq]);
196 fErrPosTMPCounter[errorCode][eq]++;
197 if (errorCode!=kTotal) {
198 fConsErrPosTMP[kTotal][eq]->SetPoint(fErrPosTMPCounter[kTotal][eq],0,bytesRead+fByteOffset[eq]);
199 fErrPosTMPCounter[kTotal][eq]++;
205 msg = Form("%s",errMess);
208 msg = Form("%s (%d bytes read, %d chip headers read)",errMess,bytesRead+fByteOffset[eq],headersRead);
210 fTextTmp[eq]->InsLine(fTextTmp[eq]->RowCount(),msg.Data());
213 //________________________________________________________________________________________________
214 void AliITSRawStreamSPDErrorLog::AddMessage(const Char_t *errMess) {
215 // add a general message to the buffer
216 fTextTmpGeneral->InsLine(fTextTmpGeneral->RowCount(),errMess);
218 //________________________________________________________________________________________________
219 void AliITSRawStreamSPDErrorLog::SummarizeEvent(UInt_t eventNum) {
220 // summarize the information for the current event
222 if (fText->RowCount()>5000) {
224 msg = "*** previous errors cleared ***";
225 fText->InsLine(fText->RowCount(),msg.Data());
227 if (fTextTmpGeneral->RowCount()>1) {
228 msg = Form("*** Event %d , General Errors: ***",eventNum);
229 fText->InsLine(fText->RowCount(),msg.Data());
230 fText->AddText(fTextTmpGeneral);
231 fTextTmpGeneral->Clear();
233 for (UInt_t eq=0; eq<20; eq++) {
234 for (UInt_t err=0; err<kNrErrorCodes; err++) {
235 fConsErrType[eq]->Fill(err,fNErrors[err][eq]);
236 if (fNErrors[err][eq]>0){
237 fConsErrEvent[err][eq]->SetPoint(fErrEventCounter[err][eq],eventNum,fNErrors[err][eq]);
238 fErrEventCounter[err][eq]++;
239 fConsErrFraction[eq]->Fill(err);
241 for (UInt_t pind=0; pind<fErrPosTMPCounter[err][eq]; pind++) {
243 fConsErrPosTMP[err][eq]->GetPoint(pind,x,y);
244 fConsErrPos[err][eq]->SetPoint(fErrPosCounter[err][eq],eventNum,y);
245 fErrPosCounter[err][eq]++;
250 if (fNErrors[kTotal][eq]>0) {
251 msg = Form("*** Event %d , Eq %d: ***",eventNum,eq);
252 fText->InsLine(fText->RowCount(),msg.Data());
253 fText->AddText(fTextTmp[eq]);
254 fText->InsLine(fText->RowCount()," ");
257 fTextTmp[eq]->Clear();
258 for (UInt_t err=0; err<kNrErrorCodes; err++) {
263 for (UInt_t eq=0; eq<20; eq++) {
264 for (UInt_t err=0; err<kNrErrorCodes; err++) {
265 delete fConsErrPosTMP[err][eq];
266 fErrPosTMPCounter[err][eq] = 0;
267 fConsErrPosTMP[err][eq] = new TGraph();
271 //________________________________________________________________________________________________
272 void AliITSRawStreamSPDErrorLog::SetByteOffset(UInt_t eq, Int_t size) {
273 // set byte offset (equipment header size)
275 fByteOffset[eq]=size;
278 AliWarning(Form("Equipment number (%d) out of range",eq));
281 //________________________________________________________________________________________________
282 void AliITSRawStreamSPDErrorLog::SuppressErrorMessages(UInt_t errorCode, Bool_t suppr) {
283 // suppress error messages for specific error code
284 if (errorCode<kNrErrorCodes) {
285 fSuppressMess[errorCode] = suppr;
288 AliWarning(Form("Error code (%d) out of range",errorCode));
291 //________________________________________________________________________________________________
292 void AliITSRawStreamSPDErrorLog::SuppressErrorEq(UInt_t eq, Bool_t suppr) {
293 // suppress error messages for specific equipment
295 fSuppressEq[eq] = suppr;
298 AliWarning(Form("Eq id (%d) out of range",eq));
301 //________________________________________________________________________________________________
302 UInt_t AliITSRawStreamSPDErrorLog::GetNrErrors(UInt_t errorCode, UInt_t eq) {
303 // returns the number of errors for this event for a specific error code and equipment
304 if (errorCode<kNrErrorCodes && eq<20) return fNErrors[errorCode][eq];
306 AliWarning(Form("Error code (%d) or equipment (%d) out of range, returning 0",errorCode,eq));
310 //________________________________________________________________________________________________
311 UInt_t AliITSRawStreamSPDErrorLog::GetNrErrorsAllEq(UInt_t errorCode) {
312 // returns the number of errors for this event for a specific error code and all equipments
313 if (errorCode<kNrErrorCodes) {
315 for (UInt_t eq=0; eq<20; eq++) {
316 returnval += fNErrors[errorCode][eq];
321 AliWarning(Form("Error code (%d) out of range, returning 0",errorCode));
325 //________________________________________________________________________________________________
326 UInt_t AliITSRawStreamSPDErrorLog::GetNrErrorsTotal(UInt_t errorCode, UInt_t eq) {
327 // returns the total number of errors for a specific error code and equipment
328 if (errorCode<kNrErrorCodes && eq<20) {
329 return (UInt_t) fConsErrType[eq]->GetBinContent(errorCode+1);
332 AliWarning(Form("Error code (%d) or equipment (%d) out of range, returning 0",errorCode,eq));
336 //________________________________________________________________________________________________
337 UInt_t AliITSRawStreamSPDErrorLog::GetNrErrorsTotalAllEq(UInt_t errorCode) {
338 // returns the total number of errors for a specific error code and for all equipment
339 if (errorCode<kNrErrorCodes) {
341 for (UInt_t eq=0; eq<20; eq++) {
342 returnval += (UInt_t) fConsErrType[eq]->GetBinContent(errorCode+1);
347 AliWarning(Form("Error code (%d) out of range, returning 0",errorCode));
351 //________________________________________________________________________________________________
352 TGraph* AliITSRawStreamSPDErrorLog::GetConsErrEvent(UInt_t errorCode, UInt_t eq) {
353 // returns a pointer to the graph
354 if (errorCode<kNrErrorCodes && eq<20) return fConsErrEvent[errorCode][eq];
356 AliWarning(Form("Error code (%d) or equipment (%d) out of range, returning NULL",errorCode,eq));
360 //________________________________________________________________________________________________
361 TH1F* AliITSRawStreamSPDErrorLog::GetConsErrType(UInt_t eq) {
362 // returns a pointer to the histogram
363 if (eq<20) return fConsErrType[eq];
365 AliWarning(Form("Eq nr (%d) out of bounds",eq));
369 //________________________________________________________________________________________________
370 TH1F* AliITSRawStreamSPDErrorLog::GetConsErrFraction(UInt_t eq) {
371 // creates a new histogram and returns a pointer to it.
372 // NB!!! Take care of deleting this object later
374 TH1F* returnhisto = (TH1F*)(fConsErrFraction[eq]->Clone());
375 if (fNEvents[eq]!=0) returnhisto->Scale(1./fNEvents[eq]);
376 // returnhisto->SetMaximum(1.);
380 AliWarning(Form("Eq nr (%d) out of bounds",eq));
384 //________________________________________________________________________________________________
385 TH1F* AliITSRawStreamSPDErrorLog::GetConsErrFractionUnScaled(UInt_t eq) {
386 // returns a pointer to the histogram
387 if (eq<20) return fConsErrFraction[eq];
389 AliWarning(Form("Eq nr (%d) out of bounds",eq));
393 //________________________________________________________________________________________________
394 TGraph* AliITSRawStreamSPDErrorLog::GetConsErrPos(UInt_t errorCode, UInt_t eq) {
395 // returns a pointer to the histogram
396 if (errorCode<kNrErrorCodes && eq<20) return fConsErrPos[errorCode][eq];
398 AliWarning(Form("Error code (%d) or equipment (%d) out of range, returning NULL",errorCode,eq));