]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONPayloadTracker.cxx
DQM configure file
[u/mrichter/AliRoot.git] / MUON / AliMUONPayloadTracker.cxx
index c0b17a541041db72d17608744e9ef4c9abc191be..4733c66c994428929960cec0021bc1c22ac87828 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-///
+// $Id$
+
+//-----------------------------------------------------------------------------
 /// \class AliMUONPayloadTracker
 /// Decodes rawdata from buffer and stores in TClonesArray.
 /// First version implement for Tracker
 ///
 /// \author Christian Finck
+//-----------------------------------------------------------------------------
+
+#include <TObjString.h>
 
 #include "AliMUONPayloadTracker.h"
 
@@ -27,6 +32,7 @@
 #include "AliMUONBusStruct.h"
 #include "AliMUONDDLTracker.h"
 
+#include "AliMUONLogger.h"
 #include "AliLog.h"
 
 /// \cond CLASSIMP
@@ -46,8 +52,11 @@ AliMUONPayloadTracker::AliMUONPayloadTracker()
     fBusStruct(new AliMUONBusStruct()),
     fBlockHeader(new AliMUONBlockHeader()),
     fDspHeader(new AliMUONDspHeader()),
-    fParityErrBus(),
-    fGlitchErrors(0)
+    fLog(new AliMUONLogger(1000)),
+    fParityErrors(0),
+    fGlitchErrors(0),
+    fPaddingErrors(0),
+    fWarnings(kTRUE)
 {
   ///
   /// create an object to decode MUON payload
@@ -65,6 +74,7 @@ AliMUONPayloadTracker::~AliMUONPayloadTracker()
   delete fBusStruct;
   delete fBlockHeader;
   delete fDspHeader;
+  delete fLog;
 }
 
 //______________________________________________________
@@ -99,122 +109,142 @@ Bool_t AliMUONPayloadTracker::Decode(UInt_t* buffer, Int_t totalDDLSize)
 
   // CROCUS CRT
   while (buffer[index] == fBlockHeader->GetDefaultDataKey()) {
-
+    
     if (iBlock > fMaxBlock) break;
-     
+    
     // copy within padding words
     memcpy(fBlockHeader->GetHeader(),&buffer[index], (kBlockHeaderSize)*4);
-
+    
     totalBlockSize = fBlockHeader->GetTotalLength();
-
+    
     indexBlk = index;
     index += kBlockHeaderSize;
-
+    
     // copy in TClonesArray
     fDDLTracker->AddBlkHeader(*fBlockHeader);
-
+    
     // Crocus FRT
     Int_t iDsp = 0;
     while (buffer[index] == fDspHeader->GetDefaultDataKey()) {
-
+      
       if (iDsp > fMaxDsp) break; // if ever...
-               
+      
       memcpy(fDspHeader->GetHeader(),&buffer[index], kDspHeaderSize*4);
-
+      
       totalDspSize = fDspHeader->GetTotalLength();
-
+      
       if (fDspHeader->GetErrorWord()) {
-       fDspHeader->Print("");
-       if (fDspHeader->GetErrorWord() == (0x000000B1 |  fBlockHeader->GetDspId())){
-         // an event with a glitch in the readout  has been detected
-         // it means that somewhere a 1 byte word has been randomly inserted
-         // all the readout sequence is shifted  untill the next event 
-
-         AliWarning(Form("Glitch in data detected, skipping event ")); 
-
-         fGlitchErrors++;
-         return kFALSE ; 
-       }       
+        //     fDspHeader->Print("");
+        if ( fDspHeader->GetErrorWord() == (0x000000B1 |  fBlockHeader->GetDspId())
+            ||  fDspHeader->GetErrorWord() == (0x00000091 |  fBlockHeader->GetDspId()) ){
+          // an event with a glitch in the readout  has been detected
+          // it means that somewhere a 1 byte word has been randomly inserted
+          // all the readout sequence is shifted  untill the next event 
+          
+          Char_t* msg = Form("Glitch error detected in DSP %d, skipping event ", fBlockHeader->GetDspId());
+          
+          if (fWarnings) AliWarning(msg); 
+          AddErrorMessage(msg);
+          fGlitchErrors++;
+          return kFALSE ; 
+        }      
       }
       
       indexDsp = index;
       index += kDspHeaderSize;
-
+      
       // copy in TClonesArray
       fDDLTracker->AddDspHeader(*fDspHeader, iBlock);
-
+      
       // buspatch structure
       Int_t iBusPatch = 0;
       while (buffer[index] == fBusStruct->GetDefaultDataKey()) {
-
-       if (iBusPatch > fMaxBus) break; // if ever
-       
-       //copy buffer into header structure
-       memcpy(fBusStruct->GetHeader(), &buffer[index], kBusPatchHeaderSize*4);
-
-       totalBusPatchSize = fBusStruct->GetTotalLength();
-       indexBusPatch     = index;
-               
-       //Check Buspatch header, not empty events
-       if(totalBusPatchSize > kBusPatchHeaderSize) {    
-
-         index   += kBusPatchHeaderSize;
-         dataSize = fBusStruct->GetLength();
-         bufSize  = fBusStruct->GetBufSize();
-
-         if(dataSize > 0) { // check data present
-           if (dataSize > bufSize) // check buffer size
-             fBusStruct->SetAlloc(dataSize);
-        
-           //copy buffer into data structure
-           memcpy(fBusStruct->GetData(), &buffer[index], dataSize*4);
-           fBusStruct->SetBlockId(iBlock); // could be usefull in future applications ?
-           fBusStruct->SetDspId(iDsp);
-
-           // check parity
-           if(!CheckDataParity())
-               AddParityErrBus(fBusStruct->GetBusPatchId());
-
-           // copy in TClonesArray
-           fDDLTracker->AddBusPatch(*fBusStruct, iBlock, iDsp);
-
-         } // dataSize test
-
-       } // testing buspatch
-
-       index = indexBusPatch + totalBusPatchSize;
-       if (index >= totalDDLSize) {// check the end of DDL
-         index = totalDDLSize - 1; // point to the last element of buffer
-         break;
-       }
-       iBusPatch++;
+        
+        if (iBusPatch > fMaxBus) break; // if ever
+        
+        //copy buffer into header structure
+        memcpy(fBusStruct->GetHeader(), &buffer[index], kBusPatchHeaderSize*4);
+        
+        totalBusPatchSize = fBusStruct->GetTotalLength();
+        indexBusPatch     = index;
+        
+        //Check Buspatch header, not empty events
+        if(totalBusPatchSize > kBusPatchHeaderSize) {    
+          
+          index   += kBusPatchHeaderSize;
+          dataSize = fBusStruct->GetLength();
+          bufSize  = fBusStruct->GetBufSize();
+          
+          if(dataSize > 0) { // check data present
+            if (dataSize > bufSize) // check buffer size
+              fBusStruct->SetAlloc(dataSize);
+            
+            //copy buffer into data structure
+            memcpy(fBusStruct->GetData(), &buffer[index], dataSize*4);
+            fBusStruct->SetBlockId(iBlock); // could be usefull in future applications ?
+            fBusStruct->SetDspId(iDsp);
+            
+            // check parity
+            if(!CheckDataParity()) {
+              fParityErrors++;
+              return kFALSE;
+            }
+            
+            // copy in TClonesArray
+            fDDLTracker->AddBusPatch(*fBusStruct, iBlock, iDsp);
+            
+          } // dataSize test
+          
+        } // testing buspatch
+        
+        index = indexBusPatch + totalBusPatchSize;
+        if (index >= totalDDLSize) {// check the end of DDL
+          index = totalDDLSize - 1; // point to the last element of buffer
+          break;
+        }
+        iBusPatch++;
       }  // buspatch loop
-
+      
       // skipping additionnal word if padding
       if (fDspHeader->GetPaddingWord() == 1) {
-       if (buffer[index++] != fDspHeader->GetDefaultPaddingWord())
-
-           AliError(Form("Error in padding word for iBlock %d, iDsp %d, iBus %d\n", 
-                         iBlock, iDsp, iBusPatch));
-
+        if (buffer[index++] != fDspHeader->GetDefaultPaddingWord()) {
+          
+          Char_t *msg = Form("Padding word error for iBlock %d, iDsp %d, iBus %d\n", 
+                             iBlock, iDsp, iBusPatch);
+          
+          if (fWarnings) AliWarning(msg);
+          AddErrorMessage(msg);
+          fPaddingErrors++;
+        }
       }
-
+      
       index = indexDsp + totalDspSize;
       if (index >= totalDDLSize) {
-       index = totalDDLSize - 1;
-       break;
+        index = totalDDLSize - 1;
+        break;
       }
       iDsp++;
     }  // dsp loop
-
+    
     index = indexBlk + totalBlockSize;
     if (index >= totalDDLSize) {
       index = totalDDLSize - 1;
       break;
     }
+    
     iBlock++;
   }  // block loop
-
+  
+  if (buffer[index++] != fBlockHeader->GetDdlDataKey() || 
+      buffer[index++] != fBlockHeader->GetDdlDataKey()) {
+    
+    Char_t *msg = Form("Bad end of DDL data key\n");
+    
+    if (fWarnings) AliWarning(msg);
+    AddErrorMessage(msg);
+  }
+  
+  
   return kTRUE;
 }
 
@@ -225,8 +255,9 @@ void AliMUONPayloadTracker::ResetDDL()
   /// after each DDL
   ///
   fDDLTracker->GetBlkHeaderArray()->Delete();
-  fGlitchErrors = 0;
-  fParityErrBus.Reset();
+  fGlitchErrors  = 0;
+  fPaddingErrors = 0;
+  fParityErrors  = 0;
 
 }
 
@@ -261,9 +292,14 @@ Bool_t AliMUONPayloadTracker::CheckDataParity()
     // Check
     if (parity != fBusStruct->GetParity(idata)) {
 
-      AliWarning(Form("Parity error in word %d for manuId %d and channel %d\n", 
-                     idata, fBusStruct->GetManuId(idata), fBusStruct->GetChannelId(idata)));
-
+      Char_t* msg = Form("Parity error in word %d for manuId %d and channel %d in buspatch %d\n", 
+                          idata, fBusStruct->GetManuId(idata), fBusStruct->GetChannelId(idata),
+                          fBusStruct->GetBusPatchId());
+      
+      if (fWarnings) AliWarning(msg);
+      AddErrorMessage(msg);
+      fParityErrors++;
+      
       return kFALSE;
                     
     }
@@ -272,9 +308,16 @@ Bool_t AliMUONPayloadTracker::CheckDataParity()
 }
 
 //______________________________________________________
-void AliMUONPayloadTracker::AddParityErrBus(Int_t buspatch)
+void AliMUONPayloadTracker::AddErrorMessage(const Char_t* msg)
 {
-/// adding bus with at least on parity error
-    fParityErrBus.Set(fParityErrBus.GetSize() + 1);
-    fParityErrBus.AddAt(buspatch, fParityErrBus.GetSize() - 1);
+/// adding message to logger
+    TString tmp(msg);
+  
+    Int_t pos = tmp.First("\n");
+    tmp[pos] = 0;
+    
+    fLog->Log(tmp.Data());
 }
+
+