]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITSRawStreamSPDErrorLog.cxx
Correct formula for phi, in case of current local X <0, in GetLocalXat and GetPhiZat
[u/mrichter/AliRoot.git] / ITS / AliITSRawStreamSPDErrorLog.cxx
index af3bd7dc8e98fa375079659e522ae748adc7d5dc..437e48e02e1ac0799f297ad94c6d76365a93aeb5 100644 (file)
@@ -9,6 +9,8 @@
 #include "AliITSRawStreamSPDErrorLog.h"
 #include "AliLog.h"
 
+/* $Id$ */
+
 ClassImp(AliITSRawStreamSPDErrorLog)
 //________________________________________________________________________________________________
 AliITSRawStreamSPDErrorLog::AliITSRawStreamSPDErrorLog() :
@@ -20,11 +22,11 @@ AliITSRawStreamSPDErrorLog::AliITSRawStreamSPDErrorLog() :
   for (UInt_t eq=0; eq<20; eq++) {
     fTextTmp[eq] = new TGText();
     fNEvents[eq] = 0;
-    fPayloadSizeSet[eq] = kFALSE;
     fByteOffset[eq] = 0;
     fSuppressEq[eq] = kFALSE;
     for (UInt_t err=0; err<kNrErrorCodes; err++) {
       fNErrors[err][eq] = 0;
+      fNErrorsTotal[err][eq] = 0;
     }
   }
   for (UInt_t err=0; err<kNrErrorCodes; err++) {
@@ -40,11 +42,10 @@ AliITSRawStreamSPDErrorLog::AliITSRawStreamSPDErrorLog(const AliITSRawStreamSPDE
   for (UInt_t eq=0; eq<20; eq++) {
     for (UInt_t err=0; err<kNrErrorCodes; err++) {
       fNErrors[err][eq] = logger.fNErrors[err][eq];
+      fNErrorsTotal[err][eq] = logger.fNErrorsTotal[err][eq];
       fErrEventCounter[err][eq] = logger.fErrEventCounter[err][eq];
     }
     fNEvents[eq] = logger.fNEvents[eq];
-    fPayloadSize[eq] = logger.fPayloadSize[eq];
-    fPayloadSizeSet[eq] = logger.fPayloadSizeSet[eq];
     fByteOffset[eq] = logger.fByteOffset[eq];
     fSuppressEq[eq] = logger.fSuppressEq[eq];
   }
@@ -61,7 +62,7 @@ AliITSRawStreamSPDErrorLog::AliITSRawStreamSPDErrorLog(const AliITSRawStreamSPDE
   for (UInt_t eq=0; eq<20; eq++) {
     for (UInt_t err=0; err<kNrErrorCodes; err++) {
       fConsErrEvent[err][eq] = new TGraph(*logger.fConsErrEvent[err][eq]);
-      fConsErrPos[err][eq] = new TH1F(*logger.fConsErrPos[err][eq]);
+      fConsErrPos[err][eq] = new TGraph(*logger.fConsErrPos[err][eq]);
     }
     fConsErrType[eq] = new TH1F(*logger.fConsErrType[eq]);
     fConsErrFraction[eq] = new TH1F(*logger.fConsErrFraction[eq]);
@@ -80,11 +81,10 @@ AliITSRawStreamSPDErrorLog& AliITSRawStreamSPDErrorLog::operator=(const AliITSRa
     for (UInt_t eq=0; eq<20; eq++) {
       for (UInt_t err=0; err<kNrErrorCodes; err++) {
        fNErrors[err][eq] = logger.fNErrors[err][eq];
+       fNErrorsTotal[err][eq] = logger.fNErrorsTotal[err][eq];
        fErrEventCounter[err][eq] = logger.fErrEventCounter[err][eq];
       }
       fNEvents[eq] = logger.fNEvents[eq];
-      fPayloadSize[eq] = logger.fPayloadSize[eq];
-      fPayloadSizeSet[eq] = logger.fPayloadSizeSet[eq];
       fByteOffset[eq] = logger.fByteOffset[eq];
       fSuppressEq[eq] = logger.fSuppressEq[eq];
     }
@@ -101,7 +101,7 @@ AliITSRawStreamSPDErrorLog& AliITSRawStreamSPDErrorLog::operator=(const AliITSRa
     for (UInt_t eq=0; eq<20; eq++) {
       for (UInt_t err=0; err<kNrErrorCodes; err++) {
        fConsErrEvent[err][eq] = new TGraph(*logger.fConsErrEvent[err][eq]);
-       fConsErrPos[err][eq] = new TH1F(*logger.fConsErrPos[err][eq]);
+       fConsErrPos[err][eq] = new TGraph(*logger.fConsErrPos[err][eq]);
       }
       fConsErrType[eq] = new TH1F(*logger.fConsErrType[eq]);
       fConsErrFraction[eq] = new TH1F(*logger.fConsErrFraction[eq]);
@@ -138,12 +138,11 @@ void AliITSRawStreamSPDErrorLog::InitHistograms() {
     
     for (UInt_t err=0; err<kNrErrorCodes; err++) {
       fConsErrEvent[err][eq]=new TGraph();
+      fConsErrPos[err][eq]=new TGraph();
+      fConsErrPosTMP[err][eq]=new TGraph();
       fErrEventCounter[err][eq] = 0;
-      histName = Form("ConsErrPos %d %d",err,eq);
-      histTitle = Form("Position in event, eq %d , error code %d",eq,err);
-      fConsErrPos[err][eq]=new TH1F(histName.Data(),histTitle.Data(),200,0,100);
-      fConsErrPos[err][eq]->SetXTitle("Position [%]");
-      fConsErrPos[err][eq]->SetYTitle("Nr Errors");
+      fErrPosCounter[err][eq] = 0;
+      fErrPosTMPCounter[err][eq] = 0;
     }
   }
 }
@@ -156,6 +155,7 @@ void AliITSRawStreamSPDErrorLog::DeleteHistograms() const {
     for (UInt_t err=0; err<kNrErrorCodes; err++) {
       delete fConsErrEvent[err][eq];
       delete fConsErrPos[err][eq];
+      delete fConsErrPosTMP[err][eq];
     }
   }
 }
@@ -163,18 +163,24 @@ void AliITSRawStreamSPDErrorLog::DeleteHistograms() const {
 void AliITSRawStreamSPDErrorLog::Reset() {
   // Reset
   fText->Clear();
+  fTextTmpGeneral->Clear();
   for (UInt_t eq=0; eq<20; eq++) {
     fTextTmp[eq]->Clear();
     fConsErrType[eq]->Reset();
     fConsErrFraction[eq]->Reset();
     fNEvents[eq] = 0;
-    fPayloadSizeSet[eq] = kFALSE;
     for (UInt_t err=0; err<kNrErrorCodes; err++) {
       fNErrors[err][eq] = 0;
+      fNErrorsTotal[err][eq] = 0;
       delete fConsErrEvent[err][eq];
+      delete fConsErrPos[err][eq];
+      delete fConsErrPosTMP[err][eq];
       fErrEventCounter[err][eq] = 0;
+      fErrPosCounter[err][eq] = 0;
+      fErrPosTMPCounter[err][eq] = 0;
       fConsErrEvent[err][eq] = new TGraph();
-      fConsErrPos[err][eq]->Reset();
+      fConsErrPos[err][eq] = new TGraph();
+      fConsErrPosTMP[err][eq] = new TGraph();
     }
   }
 }
@@ -188,11 +194,19 @@ void AliITSRawStreamSPDErrorLog::ProcessError(UInt_t errorCode, UInt_t eq, Int_t
   // check if we want to exclude the error...
   if (!(fSuppressMess[errorCode] || fSuppressEq[eq])) {
     fNErrors[errorCode][eq]++;
-    if (errorCode!=kTotal) fNErrors[kTotal][eq]++;
+    fNErrorsTotal[errorCode][eq]++;
+    if (errorCode!=kTotal) {
+      fNErrors[kTotal][eq]++;
+      fNErrorsTotal[kTotal][eq]++;
+    }
 
-    if (fPayloadSizeSet) {
-      fConsErrPos[errorCode][eq]->Fill(100.*bytesRead/fPayloadSize[eq]);
-      if (errorCode!=kTotal) fConsErrPos[kTotal][eq]->Fill(100.*bytesRead/fPayloadSize[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;
@@ -211,8 +225,27 @@ void AliITSRawStreamSPDErrorLog::AddMessage(const Char_t *errMess) {
   fTextTmpGeneral->InsLine(fTextTmpGeneral->RowCount(),errMess);
 }
 //________________________________________________________________________________________________
-void AliITSRawStreamSPDErrorLog::SummarizeEvent(UInt_t eventNum) {
-  // summarize the information for the current event
+void AliITSRawStreamSPDErrorLog::ResetEvent() {
+  // reset error counters for current event
+  for (UInt_t eq=0; eq<20; eq++) {
+    for (UInt_t err=0; err<kNrErrorCodes; err++) {
+      fNErrors[err][eq]=0;
+    }
+    fByteOffset[eq]=0;
+    fTextTmpGeneral->Clear();
+    fTextTmp[eq]->Clear();
+  }
+
+  for (UInt_t eq=0; eq<20; eq++) {
+    for (UInt_t err=0; err<kNrErrorCodes; err++) {
+      delete fConsErrPosTMP[err][eq];
+      fErrPosTMPCounter[err][eq] = 0;
+      fConsErrPosTMP[err][eq] = new TGraph();
+    }
+  }
+}
+//________________________________________________________________________________________________
+void AliITSRawStreamSPDErrorLog::AddErrorMessagesFromCurrentEvent(UInt_t eventNum) {
   TString msg;
   if (fText->RowCount()>5000) {
     fText->Clear();
@@ -223,42 +256,70 @@ void AliITSRawStreamSPDErrorLog::SummarizeEvent(UInt_t eventNum) {
     msg = Form("*** Event %d , General Errors: ***",eventNum);
     fText->InsLine(fText->RowCount(),msg.Data());
     fText->AddText(fTextTmpGeneral);
-    fTextTmpGeneral->Clear();
+    //    fTextTmpGeneral->Clear();
   }
+
   for (UInt_t eq=0; eq<20; eq++) {
-    for (UInt_t err=0; err<kNrErrorCodes; err++) {
-      fConsErrType[eq]->Fill(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);
-      }
-    }
-    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()," ");
     }
-    fPayloadSizeSet[eq]=kFALSE;
-    fByteOffset[eq]=0;
-    fTextTmp[eq]->Clear();
+    //    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; err<kNrErrorCodes; err++) {
-      fNErrors[err][eq]=0;
+      fConsErrType[eq]->Fill(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; pind<fErrPosTMPCounter[err][eq]; pind++) {
+       Double_t x,y;
+       fConsErrPosTMP[err][eq]->GetPoint(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::SetPayloadSize(UInt_t eq, UInt_t size) {
-  // set the payload size for this event
-  if (eq<20) {
-    fPayloadSize[eq]=size;
-    fPayloadSizeSet[eq]=kTRUE;
-  }
-  else {
-    AliWarning(Form("Equipment number (%d) out of range",eq));
-  }
+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) {
@@ -318,7 +379,8 @@ UInt_t AliITSRawStreamSPDErrorLog::GetNrErrorsAllEq(UInt_t errorCode) {
 UInt_t AliITSRawStreamSPDErrorLog::GetNrErrorsTotal(UInt_t errorCode, UInt_t eq) {
   // returns the total number of errors for a specific error code and equipment
   if (errorCode<kNrErrorCodes && eq<20) {
-    return (UInt_t) fConsErrType[eq]->GetBinContent(errorCode+1);
+    return fNErrorsTotal[errorCode][eq];
+    //    return (UInt_t) fConsErrType[eq]->GetBinContent(errorCode+1);
   }
   else {
     AliWarning(Form("Error code (%d) or equipment (%d) out of range, returning 0",errorCode,eq));
@@ -327,11 +389,12 @@ UInt_t AliITSRawStreamSPDErrorLog::GetNrErrorsTotal(UInt_t errorCode, UInt_t eq)
 }
 //________________________________________________________________________________________________
 UInt_t AliITSRawStreamSPDErrorLog::GetNrErrorsTotalAllEq(UInt_t errorCode) {
-  // returns the total number of errors for a specific error code and for all equipment
+  // returns the total number of errors for a specific error code and for all equipments
   if (errorCode<kNrErrorCodes) {
     UInt_t returnval=0;
     for (UInt_t eq=0; eq<20; eq++) {
-      returnval += (UInt_t) fConsErrType[eq]->GetBinContent(errorCode+1);
+      returnval += fNErrorsTotal[errorCode][eq];
+      //      returnval += (UInt_t) fConsErrType[eq]->GetBinContent(errorCode+1);
     }
     return returnval;
   }
@@ -374,7 +437,16 @@ TH1F* AliITSRawStreamSPDErrorLog::GetConsErrFraction(UInt_t eq) {
   }
 }
 //________________________________________________________________________________________________
-TH1F* AliITSRawStreamSPDErrorLog::GetConsErrPos(UInt_t errorCode, UInt_t eq) {
+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 (errorCode<kNrErrorCodes && eq<20) return fConsErrPos[errorCode][eq];
   else {
@@ -382,3 +454,33 @@ TH1F* AliITSRawStreamSPDErrorLog::GetConsErrPos(UInt_t errorCode, UInt_t eq) {
     return NULL;
   }
 }
+//________________________________________________________________________________________________
+UInt_t AliITSRawStreamSPDErrorLog::GetEventErrPosCounter(UInt_t errorCode, UInt_t eq) {
+  // returns the number of errors with bytes information for current event
+  if (errorCode<kNrErrorCodes && eq<20) return fErrPosTMPCounter[errorCode][eq];
+  else {
+    AliError(Form("Error code (%d) or equipment (%d) out of range, returning 0",errorCode,eq));
+    return 0;
+  }
+}
+//________________________________________________________________________________________________
+UInt_t AliITSRawStreamSPDErrorLog::GetEventErrPos(UInt_t index, UInt_t errorCode, UInt_t eq) {
+  // returns the bytes read for the index'th error of current event
+  if (errorCode<kNrErrorCodes && eq<20) {
+    if (index<fErrPosTMPCounter[errorCode][eq]) {
+      Double_t x,y;
+      fConsErrPosTMP[errorCode][eq]->GetPoint(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;
+  }
+
+}
+