]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONPayloadTracker.cxx
Updated list of MUON libraries
[u/mrichter/AliRoot.git] / MUON / AliMUONPayloadTracker.cxx
index b07cf47e0588c55f979cba031c787e3b01238fc3..c0b17a541041db72d17608744e9ef4c9abc191be 100644 (file)
@@ -13,7 +13,6 @@
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-
 ///
 /// \class AliMUONPayloadTracker
 /// Decodes rawdata from buffer and stores in TClonesArray.
 
 #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,20 +45,22 @@ AliMUONPayloadTracker::AliMUONPayloadTracker()
     fDDLTracker(new AliMUONDDLTracker()),
     fBusStruct(new AliMUONBusStruct()),
     fBlockHeader(new AliMUONBlockHeader()),
-    fDspHeader(new AliMUONDspHeader())
+    fDspHeader(new AliMUONDspHeader()),
+    fParityErrBus(),
+    fGlitchErrors(0)
 {
-  //
-  // create an object to decode MUON payload
-  //
+  ///
+  /// create an object to decode MUON payload
+  ///
 
 }
 
 //___________________________________
 AliMUONPayloadTracker::~AliMUONPayloadTracker()
 {
-  //
-  // clean up
-  //
+  ///
+  /// clean up
+  ///
   delete fDDLTracker;
   delete fBusStruct;
   delete fBlockHeader;
@@ -75,11 +71,11 @@ AliMUONPayloadTracker::~AliMUONPayloadTracker()
 Bool_t AliMUONPayloadTracker::Decode(UInt_t* buffer, Int_t totalDDLSize)
 {
 
-  // Each DDL is made with 2 Blocks each of which consists of 5 DSP's at most 
-  // and each of DSP has at most 5 buspatches.
-  // The different structures, Block (CRT), DSP (FRT) and Buspatch,
-  // are identified by a key word 0xFC0000FC, 0xF000000F and 0xB000000B respectively.
-  // (fBusPatchManager no more needed !)
+  /// Each DDL is made with 2 Blocks each of which consists of 5 DSP's at most 
+  /// and each of DSP has at most 5 buspatches.
+  /// The different structures, Block (CRT), DSP (FRT) and Buspatch,
+  /// are identified by a key word 0xFC0000FC, 0xF000000F and 0xB000000B respectively.
+  /// (fBusPatchManager no more needed !)
 
 
   //Read Header Size of DDL,Block,DSP and BusPatch
@@ -126,15 +122,24 @@ 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())){
+         // 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 +172,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 +194,9 @@ 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", 
+           AliError(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
+
       }
 
       index = indexDsp + totalDspSize;
@@ -218,16 +221,19 @@ Bool_t AliMUONPayloadTracker::Decode(UInt_t* buffer, Int_t totalDDLSize)
 //______________________________________________________
 void AliMUONPayloadTracker::ResetDDL()
 {
-  // reseting TClonesArray
-  // after each DDL
-  //
+  /// reseting TClonesArray
+  /// after each DDL
+  ///
   fDDLTracker->GetBlkHeaderArray()->Delete();
+  fGlitchErrors = 0;
+  fParityErrBus.Reset();
+
 }
 
 //______________________________________________________
 void AliMUONPayloadTracker::SetMaxBlock(Int_t blk) 
 {
-  // set regional card number
+  /// set regional card number
   if (blk > 2) blk = 2;
   fMaxBlock = blk;
 }
@@ -235,9 +241,9 @@ void AliMUONPayloadTracker::SetMaxBlock(Int_t blk)
 //______________________________________________________
 Bool_t AliMUONPayloadTracker::CheckDataParity()
 {
-  // parity check
-  // taken from MuTrkBusPatch.cxx (sotfware test for CROCUS)
-  // A. Baldisseri
+  /// parity check
+  /// taken from MuTrkBusPatch.cxx (sotfware test for CROCUS)
+  /// A. Baldisseri
 
   Int_t  parity;
   UInt_t data;
@@ -254,13 +260,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 +270,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);
+}