Correct procedure for padding word (Christian)
authormartinez <martinez@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 16 Jun 2006 14:12:40 +0000 (14:12 +0000)
committermartinez <martinez@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 16 Jun 2006 14:12:40 +0000 (14:12 +0000)
MUON/AliMUONPayloadTracker.cxx
MUON/AliMUONRawWriter.cxx

index caae37d..8b3a40f 100644 (file)
@@ -145,11 +145,11 @@ Bool_t AliMUONPayloadTracker::Decode(UInt_t* buffer, Int_t totalDDLSize)
       indexDsp = index;
       index += kDspHeaderSize;
 
-      if (fDspHeader->GetPaddingWord() != fDspHeader->GetDefaultPaddingWord()) {
-       // copy the field of Padding word into ErrorWord field
-       fDspHeader->SetErrorWord(fDspHeader->GetPaddingWord());
-       index--;
-      }
+//       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);
@@ -196,7 +196,14 @@ Bool_t AliMUONPayloadTracker::Decode(UInt_t* buffer, Int_t totalDDLSize)
        }
        iBusPatch++;
       }  // buspatch loop
-               
+
+      // skipping additionnal word if padding
+      if (fDspHeader->GetPaddingWord() == 1) {
+       if (buffer[index++] != fDspHeader->GetDefaultPaddingWord())
+         AliWarning(Form("Error in padding word for iBlock %d, iDsp %d, iBus %d\n", 
+                         iBlock, iDsp, iBusPatch));
+      }
+
       index = indexDsp + totalDspSize;
       if (index >= totalDDLSize) {
        index = totalDDLSize - 1;
index d0d7413..858b1c7 100644 (file)
@@ -101,9 +101,6 @@ AliMUONRawWriter::AliMUONRawWriter(AliMUONData* data)
   fDspHeader->SetDataKey(fDspHeader->GetDefaultDataKey());
   fBusStruct->SetDataKey(fBusStruct->GetDefaultDataKey());
 
-  // set default paddind word (only for writting)
-  fDspHeader->SetPaddingWord(fDspHeader->GetDefaultPaddingWord());
-
   // ddl trigger pointers
   fDarcHeader      = new AliMUONDarcHeader();
   fRegHeader       = new AliMUONRegHeader();
@@ -520,22 +517,20 @@ Int_t AliMUONRawWriter::WriteTrackerDDL(Int_t iCh)
          }
        } // bus patch
 
-       totalDspLength     = index - indexDsp;
+       // check if totalLength even
+       // set padding word in case
+       // Add one word 0xBEEFFACE at the end of DSP structure
+       totalDspLength  = index - indexDsp;
+       if ((totalDspLength % 2) == 1) { 
+         buffer[indexDsp + fDspHeader->GetHeaderLength() - 2] = 1;
+         buffer[index++] = fDspHeader->GetDefaultPaddingWord();
+         totalDspLength++;
+       }
+
        dspLength          = totalDspLength - fDspHeader->GetHeaderLength();
 
        buffer[indexDsp+1] = totalDspLength; // dsp total length
        buffer[indexDsp+2] = dspLength; // data length  
-
-       // remove padding word if necessary cos already in Dsp header length
-       // if total length is even, remove already placed padding word, else let it as it is.
-       if ((totalDspLength % 2) == 1) { 
-         buffer[indexDsp+1] -= 1;
-         buffer[indexDsp+2] -= 1;
-         index--;
-         Int_t indexCopy = indexDsp + fDspHeader->GetHeaderLength() - 2;
-         memcpy(&buffer[indexCopy], &buffer[indexCopy+1], 
-                (totalDspLength - fDspHeader->GetHeaderLength() + 2)*4);
-       }
           
       } // dsp