]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONPayloadTracker.cxx
Protection if the compiler is not gcc
[u/mrichter/AliRoot.git] / MUON / AliMUONPayloadTracker.cxx
index 1868c6ed27e54052c8c3f48c1d8846d7559cf06a..6fdf9285e42ce9cac91e15ae6af4137d51401f88 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 "AliMUONPayloadTracker.h"
 
-#include "AliRawReader.h"
-#include "AliRawDataHeader.h"
-
-#ifndef DATE_SYS
-#include "AliLog.h"
-#endif
-
 #include "AliMUONDspHeader.h"
 #include "AliMUONBlockHeader.h"
 #include "AliMUONBusStruct.h"
 #include "AliMUONDDLTracker.h"
 
+#include "AliLog.h"
+
 /// \cond CLASSIMP
 ClassImp(AliMUONPayloadTracker)
 /// \endcond
@@ -51,7 +48,10 @@ AliMUONPayloadTracker::AliMUONPayloadTracker()
     fDDLTracker(new AliMUONDDLTracker()),
     fBusStruct(new AliMUONBusStruct()),
     fBlockHeader(new AliMUONBlockHeader()),
-    fDspHeader(new AliMUONDspHeader())
+    fDspHeader(new AliMUONDspHeader()),
+    fParityErrBus(),
+    fGlitchErrors(0),
+    fPaddingErrors(0)
 {
   ///
   /// create an object to decode MUON payload
@@ -126,15 +126,25 @@ Bool_t AliMUONPayloadTracker::Decode(UInt_t* buffer, Int_t totalDDLSize)
       memcpy(fDspHeader->GetHeader(),&buffer[index], kDspHeaderSize*4);
 
       totalDspSize = fDspHeader->GetTotalLength();
+
+      if (fDspHeader->GetErrorWord()) {
+       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 
+
+         AliWarning(Form("Glitch in data detected, skipping event ")); 
+
+         fGlitchErrors++;
+         return kFALSE ; 
+       }       
+      }
+      
       indexDsp = index;
       index += kDspHeaderSize;
 
-//       if (fDspHeader->GetPaddingWord() != fDspHeader->GetDefaultPaddingWord()) {
-//     // copy the field of Padding word into ErrorWord field
-//     fDspHeader->SetErrorWord(fDspHeader->GetPaddingWord());
-//     index--;
-//       }
-
       // copy in TClonesArray
       fDDLTracker->AddDspHeader(*fDspHeader, iBlock);
 
@@ -167,7 +177,8 @@ Bool_t AliMUONPayloadTracker::Decode(UInt_t* buffer, Int_t totalDDLSize)
            fBusStruct->SetDspId(iDsp);
 
            // check parity
-           CheckDataParity();
+           if(!CheckDataParity())
+               AddParityErrBus(fBusStruct->GetBusPatchId());
 
            // copy in TClonesArray
            fDDLTracker->AddBusPatch(*fBusStruct, iBlock, iDsp);
@@ -188,12 +199,10 @@ Bool_t AliMUONPayloadTracker::Decode(UInt_t* buffer, Int_t totalDDLSize)
       if (fDspHeader->GetPaddingWord() == 1) {
        if (buffer[index++] != fDspHeader->GetDefaultPaddingWord())
 
-#ifndef DATE_SYS
-         AliWarning(Form("Error in padding word for iBlock %d, iDsp %d, iBus %d\n", 
+           AliWarning(Form("Error in padding word for iBlock %d, iDsp %d, iBus %d\n", 
                          iBlock, iDsp, iBusPatch));
-#else
-       printf("Error in padding word for iBlock %d, iDsp %d, iBus %d\n", iBlock, iDsp, iBusPatch);
-#endif
+
+       fPaddingErrors++;
       }
 
       index = indexDsp + totalDspSize;
@@ -222,6 +231,10 @@ void AliMUONPayloadTracker::ResetDDL()
   /// after each DDL
   ///
   fDDLTracker->GetBlkHeaderArray()->Delete();
+  fGlitchErrors = 0;
+  fPaddingErrors = 0;
+  fParityErrBus.Reset();
+
 }
 
 //______________________________________________________
@@ -254,13 +267,9 @@ Bool_t AliMUONPayloadTracker::CheckDataParity()
 
     // Check
     if (parity != fBusStruct->GetParity(idata)) {
-#ifndef DATE_SYS
+
       AliWarning(Form("Parity error in word %d for manuId %d and channel %d\n", 
                      idata, fBusStruct->GetManuId(idata), fBusStruct->GetChannelId(idata)));
-#else
-      printf("Parity error in word %d for manuId %d and channel %d\n", 
-            idata, fBusStruct->GetManuId(idata), fBusStruct->GetChannelId(idata));
-#endif
 
       return kFALSE;
                     
@@ -268,3 +277,11 @@ Bool_t AliMUONPayloadTracker::CheckDataParity()
   }
   return kTRUE;
 }
+
+//______________________________________________________
+void AliMUONPayloadTracker::AddParityErrBus(Int_t buspatch)
+{
+/// adding bus with at least on parity error
+    fParityErrBus.Set(fParityErrBus.GetSize() + 1);
+    fParityErrBus.AddAt(buspatch, fParityErrBus.GetSize() - 1);
+}