ALIROOT-5769: Better handling of the error (R. Preghenella)
authorzampolli <Chiara.Zampolli@cern.ch>
Sat, 24 Jan 2015 16:53:05 +0000 (17:53 +0100)
committerzampolli <Chiara.Zampolli@cern.ch>
Sat, 24 Jan 2015 16:53:05 +0000 (17:53 +0100)
TOF/TOFbase/AliTOFDecoderV2.cxx
TOF/TOFbase/AliTOFDecoderV2.h

index b6e1ee6..9a93671 100644 (file)
@@ -558,26 +558,26 @@ AliTOFDecoderV2::Decode(UInt_t *rawData, UInt_t nWords)
       
     case GLOBAL_TRAILER:
    
-   //switch slot ID
-   switch (*rawData & SLOT_ID_MASK){
+      //switch slot ID
+      switch (*rawData & SLOT_ID_MASK){
      
-     //DRM global trailer (slotID=1)
-   case 1:
-     //recover error
-     if (fDecoderSummaryData->GetRecoveringError()){
-       //change decode status
-       decoderStatus = DRM_TRAILER_STATUS;
-       fDecoderSummaryData->SetDecoderStatus(decoderStatus);
-       fDecoderSummaryData->SetRecoveringError(kFALSE);
-       if (fVerbose)
-        AliInfo("DRM global trailer found: error probably recovered");
-     }
-     //check decode status
-     if ( decoderStatus != DRM_TRAILER_STATUS ){
-       if (fLogErrors)
-        AliError(Form("  %02x - 0x%08x [ERROR] Unexpected DRM global trailer (curslot=%d)",decoderStatus,*rawData,fDecoderSummaryData->GetCurrentSlotID()));
-       fDecoderSummaryData->SetErrorDetected(kTRUE);
-       fDecoderSummaryData->SetErrorSlotID(fDecoderSummaryData->GetCurrentSlotID());
+       //DRM global trailer (slotID=1)
+      case 1:
+       //recover error
+       if (fDecoderSummaryData->GetRecoveringError()){
+         //change decode status
+         decoderStatus = DRM_TRAILER_STATUS;
+         fDecoderSummaryData->SetDecoderStatus(decoderStatus);
+         fDecoderSummaryData->SetRecoveringError(kFALSE);
+         if (fVerbose)
+           AliInfo("DRM global trailer found: error probably recovered");
+       }
+       //check decode status
+       if ( decoderStatus != DRM_TRAILER_STATUS ){
+         if (fLogErrors)
+           AliError(Form("  %02x - 0x%08x [ERROR] Unexpected DRM global trailer (curslot=%d)",decoderStatus,*rawData,fDecoderSummaryData->GetCurrentSlotID()));
+         fDecoderSummaryData->SetErrorDetected(kTRUE);
+         fDecoderSummaryData->SetErrorSlotID(fDecoderSummaryData->GetCurrentSlotID());
          errorWarning++;
          //try to recover error
          if (fRecoverError){
@@ -938,6 +938,32 @@ AliTOFDecoderV2::Decode(UInt_t *rawData, UInt_t nWords)
       //try to recover error
       if (fDecoderSummaryData->GetRecoveringError())
        continue;
+      //check decode status
+      if ( decoderStatus != TRM_ERROR_STATUS  && !fDecoderSummaryData->GetRecoveringError()){
+       if (fLogErrors)
+         AliError(Form("  %02x - 0x%08x [ERROR] Unexpected ERROR word (curslot=%d)",decoderStatus,*rawData,fDecoderSummaryData->GetCurrentSlotID()));
+       fDecoderSummaryData->SetErrorDetected(kTRUE);
+       fDecoderSummaryData->SetErrorSlotID(fDecoderSummaryData->GetCurrentSlotID());
+       errorWarning++;
+       //try to recover error
+       if (fRecoverError){
+         if (errorWarning > fRecoverErrorThr) {
+           if (fVerbose)
+             AliInfo("Trying to recover the error: searching for the next header");
+           fDecoderSummaryData->SetRecoveringError(kTRUE);
+           continue;
+         }
+         else {
+           if (fVerbose)
+             AliInfo("Do not try to recover error yet, go on with decoding process");
+           continue;
+         }
+       }
+       return(fDecoderSummaryData->GetErrorDetected());
+      }
+      //decode status ok
+      errorWarning = 0;
+
       //decode TRM TDC error
       fTRMTDCError = (AliTOFTRMTDCError *)rawData;
       //check diagnostic word
@@ -946,13 +972,43 @@ AliTOFDecoderV2::Decode(UInt_t *rawData, UInt_t nWords)
          AliInfo(Form("  %02x - 0x%08x \t  Diagnostic error word",decoderStatus,*rawData));
        break;
       }
+
+      //try to recover error
+      if (fDecoderSummaryData->GetRecoveringError())
+       continue;
+      //check decode status
+      if ( decoderStatus != CHAIN_A_TDCERROR_STATUS && decoderStatus != CHAIN_B_TDCERROR_STATUS  && !fDecoderSummaryData->GetRecoveringError()){
+       if (fLogErrors)
+         AliError(Form("  %02x - 0x%08x [ERROR] Unexpected TDC error (curslot=%d)",decoderStatus,*rawData,fDecoderSummaryData->GetCurrentSlotID()));
+       fDecoderSummaryData->SetErrorDetected(kTRUE);
+       fDecoderSummaryData->SetErrorSlotID(fDecoderSummaryData->GetCurrentSlotID());
+       errorWarning++;
+       //try to recover error
+       if (fRecoverError){
+         if (errorWarning > fRecoverErrorThr) {
+           if (fVerbose)
+             AliInfo("Trying to recover the error: searching for the next header");
+           fDecoderSummaryData->SetRecoveringError(kTRUE);
+           continue;
+         }
+         else {
+           if (fVerbose)
+             AliInfo("Do not try to recover error yet, go on with decoding process");
+           continue;
+         }
+       }
+       return(fDecoderSummaryData->GetErrorDetected());
+      }
+      //decode status ok
+      errorWarning = 0;
+      
       //set error data
       error.SetErrorFlags(fTRMTDCError->GetErrorFlags());
       error.SetTDCID(fTRMTDCError->GetTDCID());
       //fill TDC error buffer
       if (fTDCErrorBuffer) fTDCErrorBuffer->Add(error);
       else {
-       AliError("fTDCErrorBuffer is 0: no chain header was detected"); 
+       AliError("fTDCErrorBuffer is 0: no chain header was detected"); 
       }
       if (fVerbose)
        AliInfo(Form("  %02x - 0x%08x \t  TDC error",decoderStatus,*rawData));
index 55e3bd0..94d92c8 100644 (file)
                             ((a & 0xff000000) >> 24) )
 
 
+#define TRM_ERROR_STATUS      (DRM_BIT|TRM_BIT)
+#define CHAIN_A_TDCERROR_STATUS  (DRM_BIT|TRM_BIT|CHAIN_A_BIT)
+#define CHAIN_B_TDCERROR_STATUS  (DRM_BIT|TRM_BIT|CHAIN_B_BIT)
+
 #include "TObject.h"
 #include "AliRawReader.h"
 #include "AliTOFTDCHit.h"