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"
12 ClassImp(AliITSRawStreamSPDErrorLog)
13 //________________________________________________________________________________________________
14 AliITSRawStreamSPDErrorLog::AliITSRawStreamSPDErrorLog() :
15 fText(NULL), fTextTmpGeneral(NULL)
17 // default constructor
19 fTextTmpGeneral=new TGText();
20 for (UInt_t eq=0; eq<20; eq++) {
21 fTextTmp[eq] = new TGText();
23 fPayloadSizeSet[eq] = kFALSE;
25 fSuppressEq[eq] = kFALSE;
26 for (UInt_t err=0; err<kNrErrorCodes; err++) {
27 fNErrors[err][eq] = 0;
30 for (UInt_t err=0; err<kNrErrorCodes; err++) {
31 fSuppressMess[err] = kFALSE;
35 //________________________________________________________________________________________________
36 AliITSRawStreamSPDErrorLog::AliITSRawStreamSPDErrorLog(const AliITSRawStreamSPDErrorLog& logger) :
37 TObject(logger), fText(NULL), fTextTmpGeneral(NULL)
40 for (UInt_t eq=0; eq<20; eq++) {
41 for (UInt_t err=0; err<kNrErrorCodes; err++) {
42 fNErrors[err][eq] = logger.fNErrors[err][eq];
43 fErrEventCounter[err][eq] = logger.fErrEventCounter[err][eq];
45 fNEvents[eq] = logger.fNEvents[eq];
46 fPayloadSize[eq] = logger.fPayloadSize[eq];
47 fPayloadSizeSet[eq] = logger.fPayloadSizeSet[eq];
48 fByteOffset[eq] = logger.fByteOffset[eq];
49 fSuppressEq[eq] = logger.fSuppressEq[eq];
51 for (UInt_t err=0; err<kNrErrorCodes; err++) {
52 fSuppressMess[err] = logger.fSuppressMess[err];
55 fText = new TGText(logger.fText);
56 fTextTmpGeneral = new TGText(logger.fTextTmpGeneral);
57 for (UInt_t eq=0; eq<20; eq++) {
58 fTextTmp[eq] = new TGText(logger.fTextTmp[eq]);
61 for (UInt_t eq=0; eq<20; eq++) {
62 for (UInt_t err=0; err<kNrErrorCodes; err++) {
63 fConsErrEvent[err][eq] = new TGraph(*logger.fConsErrEvent[err][eq]);
64 fConsErrPos[err][eq] = new TH1F(*logger.fConsErrPos[err][eq]);
66 fConsErrType[eq] = new TH1F(*logger.fConsErrType[eq]);
67 fConsErrFraction[eq] = new TH1F(*logger.fConsErrFraction[eq]);
71 //________________________________________________________________________________________________
72 AliITSRawStreamSPDErrorLog& AliITSRawStreamSPDErrorLog::operator=(const AliITSRawStreamSPDErrorLog& logger) {
73 // assignment operator
76 delete fTextTmpGeneral;
78 this->DeleteHistograms();
80 for (UInt_t eq=0; eq<20; eq++) {
81 for (UInt_t err=0; err<kNrErrorCodes; err++) {
82 fNErrors[err][eq] = logger.fNErrors[err][eq];
83 fErrEventCounter[err][eq] = logger.fErrEventCounter[err][eq];
85 fNEvents[eq] = logger.fNEvents[eq];
86 fPayloadSize[eq] = logger.fPayloadSize[eq];
87 fPayloadSizeSet[eq] = logger.fPayloadSizeSet[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 TH1F(*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 fErrEventCounter[err][eq] = 0;
142 histName = Form("ConsErrPos %d %d",err,eq);
143 histTitle = Form("Position in event, eq %d , error code %d",eq,err);
144 fConsErrPos[err][eq]=new TH1F(histName.Data(),histTitle.Data(),200,0,100);
145 fConsErrPos[err][eq]->SetXTitle("Position [%]");
146 fConsErrPos[err][eq]->SetYTitle("Nr Errors");
150 //________________________________________________________________________________________________
151 void AliITSRawStreamSPDErrorLog::DeleteHistograms() const {
153 for (UInt_t eq=0; eq<20; eq++) {
154 delete fConsErrType[eq];
155 delete fConsErrFraction[eq];
156 for (UInt_t err=0; err<kNrErrorCodes; err++) {
157 delete fConsErrEvent[err][eq];
158 delete fConsErrPos[err][eq];
162 //________________________________________________________________________________________________
163 void AliITSRawStreamSPDErrorLog::Reset() {
166 for (UInt_t eq=0; eq<20; eq++) {
167 fTextTmp[eq]->Clear();
168 fConsErrType[eq]->Reset();
169 fConsErrFraction[eq]->Reset();
171 fPayloadSizeSet[eq] = kFALSE;
172 for (UInt_t err=0; err<kNrErrorCodes; err++) {
173 fNErrors[err][eq] = 0;
174 delete fConsErrEvent[err][eq];
175 fErrEventCounter[err][eq] = 0;
176 fConsErrEvent[err][eq] = new TGraph();
177 fConsErrPos[err][eq]->Reset();
181 //________________________________________________________________________________________________
182 void AliITSRawStreamSPDErrorLog::ProcessError(UInt_t errorCode, UInt_t eq, Int_t bytesRead, Int_t headersRead, const Char_t *errMess) {
185 AliWarning(Form("Equipment number (%d) out of bounds",eq));
188 // check if we want to exclude the error...
189 if (!(fSuppressMess[errorCode] || fSuppressEq[eq])) {
190 fNErrors[errorCode][eq]++;
191 if (errorCode!=kTotal) fNErrors[kTotal][eq]++;
193 if (fPayloadSizeSet) {
194 fConsErrPos[errorCode][eq]->Fill(100.*bytesRead/fPayloadSize[eq]);
195 if (errorCode!=kTotal) fConsErrPos[kTotal][eq]->Fill(100.*bytesRead/fPayloadSize[eq]);
200 msg = Form("%s",errMess);
203 msg = Form("%s (%d bytes read, %d chip headers read)",errMess,bytesRead+fByteOffset[eq],headersRead);
205 fTextTmp[eq]->InsLine(fTextTmp[eq]->RowCount(),msg.Data());
208 //________________________________________________________________________________________________
209 void AliITSRawStreamSPDErrorLog::AddMessage(const Char_t *errMess) {
210 // add a general message to the buffer
211 fTextTmpGeneral->InsLine(fTextTmpGeneral->RowCount(),errMess);
213 //________________________________________________________________________________________________
214 void AliITSRawStreamSPDErrorLog::SummarizeEvent(UInt_t eventNum) {
215 // summarize the information for the current event
217 if (fText->RowCount()>5000) {
219 msg = "*** previous errors cleared ***";
220 fText->InsLine(fText->RowCount(),msg.Data());
222 if (fTextTmpGeneral->RowCount()>1) {
223 msg = Form("*** Event %d , General Errors: ***",eventNum);
224 fText->InsLine(fText->RowCount(),msg.Data());
225 fText->AddText(fTextTmpGeneral);
226 fTextTmpGeneral->Clear();
228 for (UInt_t eq=0; eq<20; eq++) {
229 for (UInt_t err=0; err<kNrErrorCodes; err++) {
230 fConsErrType[eq]->Fill(err,fNErrors[err][eq]);
231 if (fNErrors[err][eq]>0){
232 fConsErrEvent[err][eq]->SetPoint(fErrEventCounter[err][eq],eventNum,fNErrors[err][eq]);
233 fErrEventCounter[err][eq]++;
234 fConsErrFraction[eq]->Fill(err);
238 if (fNErrors[kTotal][eq]>0) {
239 msg = Form("*** Event %d , Eq %d: ***",eventNum,eq);
240 fText->InsLine(fText->RowCount(),msg.Data());
241 fText->AddText(fTextTmp[eq]);
242 fText->InsLine(fText->RowCount()," ");
244 fPayloadSizeSet[eq]=kFALSE;
246 fTextTmp[eq]->Clear();
247 for (UInt_t err=0; err<kNrErrorCodes; err++) {
252 //________________________________________________________________________________________________
253 void AliITSRawStreamSPDErrorLog::SetPayloadSize(UInt_t eq, UInt_t size) {
254 // set the payload size for this event
256 fPayloadSize[eq]=size;
257 fPayloadSizeSet[eq]=kTRUE;
260 AliWarning(Form("Equipment number (%d) out of range",eq));
263 //________________________________________________________________________________________________
264 void AliITSRawStreamSPDErrorLog::SetByteOffset(UInt_t eq, Int_t size) {
265 // set byte offset (equipment header size)
267 fByteOffset[eq]=size;
270 AliWarning(Form("Equipment number (%d) out of range",eq));
273 //________________________________________________________________________________________________
274 void AliITSRawStreamSPDErrorLog::SuppressErrorMessages(UInt_t errorCode, Bool_t suppr) {
275 // suppress error messages for specific error code
276 if (errorCode<kNrErrorCodes) {
277 fSuppressMess[errorCode] = suppr;
280 AliWarning(Form("Error code (%d) out of range",errorCode));
283 //________________________________________________________________________________________________
284 void AliITSRawStreamSPDErrorLog::SuppressErrorEq(UInt_t eq, Bool_t suppr) {
285 // suppress error messages for specific equipment
287 fSuppressEq[eq] = suppr;
290 AliWarning(Form("Eq id (%d) out of range",eq));
293 //________________________________________________________________________________________________
294 UInt_t AliITSRawStreamSPDErrorLog::GetNrErrors(UInt_t errorCode, UInt_t eq) {
295 // returns the number of errors for this event for a specific error code and equipment
296 if (errorCode<kNrErrorCodes && eq<20) return fNErrors[errorCode][eq];
298 AliWarning(Form("Error code (%d) or equipment (%d) out of range, returning 0",errorCode,eq));
302 //________________________________________________________________________________________________
303 UInt_t AliITSRawStreamSPDErrorLog::GetNrErrorsAllEq(UInt_t errorCode) {
304 // returns the number of errors for this event for a specific error code and all equipments
305 if (errorCode<kNrErrorCodes) {
307 for (UInt_t eq=0; eq<20; eq++) {
308 returnval += fNErrors[errorCode][eq];
313 AliWarning(Form("Error code (%d) out of range, returning 0",errorCode));
317 //________________________________________________________________________________________________
318 UInt_t AliITSRawStreamSPDErrorLog::GetNrErrorsTotal(UInt_t errorCode, UInt_t eq) {
319 // returns the total number of errors for a specific error code and equipment
320 if (errorCode<kNrErrorCodes && eq<20) {
321 return (UInt_t) fConsErrType[eq]->GetBinContent(errorCode+1);
324 AliWarning(Form("Error code (%d) or equipment (%d) out of range, returning 0",errorCode,eq));
328 //________________________________________________________________________________________________
329 UInt_t AliITSRawStreamSPDErrorLog::GetNrErrorsTotalAllEq(UInt_t errorCode) {
330 // returns the total number of errors for a specific error code and for all equipment
331 if (errorCode<kNrErrorCodes) {
333 for (UInt_t eq=0; eq<20; eq++) {
334 returnval += (UInt_t) fConsErrType[eq]->GetBinContent(errorCode+1);
339 AliWarning(Form("Error code (%d) out of range, returning 0",errorCode));
343 //________________________________________________________________________________________________
344 TGraph* AliITSRawStreamSPDErrorLog::GetConsErrEvent(UInt_t errorCode, UInt_t eq) {
345 // returns a pointer to the graph
346 if (errorCode<kNrErrorCodes && eq<20) return fConsErrEvent[errorCode][eq];
348 AliWarning(Form("Error code (%d) or equipment (%d) out of range, returning NULL",errorCode,eq));
352 //________________________________________________________________________________________________
353 TH1F* AliITSRawStreamSPDErrorLog::GetConsErrType(UInt_t eq) {
354 // returns a pointer to the histogram
355 if (eq<20) return fConsErrType[eq];
357 AliWarning(Form("Eq nr (%d) out of bounds",eq));
361 //________________________________________________________________________________________________
362 TH1F* AliITSRawStreamSPDErrorLog::GetConsErrFraction(UInt_t eq) {
363 // creates a new histogram and returns a pointer to it.
364 // NB!!! Take care of deleting this object later
366 TH1F* returnhisto = (TH1F*)(fConsErrFraction[eq]->Clone());
367 if (fNEvents[eq]!=0) returnhisto->Scale(1./fNEvents[eq]);
368 // returnhisto->SetMaximum(1.);
372 AliWarning(Form("Eq nr (%d) out of bounds",eq));
376 //________________________________________________________________________________________________
377 TH1F* AliITSRawStreamSPDErrorLog::GetConsErrPos(UInt_t errorCode, UInt_t eq) {
378 // returns a pointer to the histogram
379 if (errorCode<kNrErrorCodes && eq<20) return fConsErrPos[errorCode][eq];
381 AliWarning(Form("Error code (%d) or equipment (%d) out of range, returning NULL",errorCode,eq));