]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Updated version of the altro decoder which handles more or less correctly the corrupt...
authorcvetan <cvetan@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 18 Dec 2007 17:08:31 +0000 (17:08 +0000)
committercvetan <cvetan@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 18 Dec 2007 17:08:31 +0000 (17:08 +0000)
RAW/AliAltroRawStream.cxx

index a6b008857eac4d7e9d27764a545dbfb91ddbf5b7..a91cbb7140c3cf172f2190af975055d08ec65fe7 100644 (file)
@@ -276,7 +276,13 @@ Bool_t AliAltroRawStream::ReadTrailer()
   }
   fCount |= ((temp & 0x3FF) >> 6);
   if (fCount == 0) return kFALSE;
-
+  if (fCount >= fPosition) {
+    fRawReader->AddMajorErrorLog(kAltroTrailerErr,"invalid size");
+    //    PrintDebug();
+    AliWarning(Form("Incorrect trailer found ! The altro payload size is invalid (%d >= %d) !",fCount,fPosition));
+    fCount = 0;
+    return kFALSE;
+  }
   temp = GetNextWord();
   fHWAddress |= temp;
 
@@ -310,21 +316,24 @@ void AliAltroRawStream::ReadBunch()
 {
   // Read altro payload in 
   // backward direction
-  if (fPosition <= 0) {
+  if (fCount <= 2) {
     fRawReader->AddMinorErrorLog(kBunchLengthReadErr,"");
     //    PrintDebug();
-    AliWarning("Could not read bunch length !");
+    AliWarning(Form("Could not read bunch length and time bin ! Only %d 10-bit words are left !",fCount));
+    fBunchLength = fTimeBunch = fCount = 0;
+    return;
   }
 
   fBunchLength = GetNextWord() - 2;
-  fTimeBunch = fBunchLength;
-  fCount--;
-
-  if (fPosition <= 0) {
-    fRawReader->AddMinorErrorLog(kTimeBinReadErr,"");
+  if (fBunchLength > fCount) {
+    fRawReader->AddMinorErrorLog(kBunchLengthReadErr,Form("bl=%d",fBunchLength));
     //    PrintDebug();
-    AliWarning("Could not read time bin !");
+    AliWarning(Form("Could not read bunch length ! Bunch length = %d (>%d)",fBunchLength,fCount));
+    fBunchLength = fTimeBunch = fCount = 0;
+    return;
   }
+  fTimeBunch = fBunchLength;
+  fCount--;
 
   fTime = GetNextWord();
   fCount--;
@@ -336,13 +345,16 @@ void AliAltroRawStream::ReadBunch()
 void AliAltroRawStream::ReadAmplitude()
 {
   // Read next time bin amplitude
-  if (fPosition <= 0) {
+  if (fCount <= 0) {
     fRawReader->AddMinorErrorLog(kAmplitudeReadErr,"");
     //    PrintDebug();
     AliWarning("Could not read sample amplitude !");
+    fCount = fSignal = fBunchLength = 0;
+    return;
   }
 
   fSignal = GetNextWord();
+
   fCount--;
   fBunchLength--;