]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - RAW/AliAltroBuffer.cxx
Removing RAW/alimdc.spec, not used
[u/mrichter/AliRoot.git] / RAW / AliAltroBuffer.cxx
index a06927f834ff1ac5a0aec5488633290fe48f6166..924477cddc26f126458880d849bab8c6160cd394 100644 (file)
@@ -31,7 +31,7 @@
 ClassImp(AliAltroBuffer)
 
 //_____________________________________________________________________________
-AliAltroBuffer::AliAltroBuffer(const char* fileName, const AliAltroMapping *mapping):
+AliAltroBuffer::AliAltroBuffer(const char* fileName, AliAltroMapping *mapping):
   fShift(0),
   fCurrentCell(0),
   fFreeCellBuffer(16),
@@ -129,23 +129,6 @@ void AliAltroBuffer::FillBuffer(Int_t val)
   }
 }
 
-
-//_____________________________________________________________________________
-void AliAltroBuffer::WriteDummyTrailer(Int_t wordsNumber, Int_t padNumber,
-                                      Int_t rowNumber, Int_t secNumber)
-{
-//Writes a trailer of 40 bits
-
-   Int_t num = fFreeCellBuffer % 4;
-   for(Int_t i = 0; i < num; i++) {
-     FillBuffer(0x2AA);
-   }//end for
-   FillBuffer(wordsNumber);
-   FillBuffer(padNumber);
-   FillBuffer(rowNumber);
-   FillBuffer(secNumber);
-}
-
 //_____________________________________________________________________________
 void AliAltroBuffer::WriteTrailer(Int_t wordsNumber, Int_t padNumber,
                                  Int_t rowNumber, Int_t secNumber)
@@ -153,9 +136,7 @@ void AliAltroBuffer::WriteTrailer(Int_t wordsNumber, Int_t padNumber,
 //Writes a trailer of 40 bits
 
   if (!fMapping) {
-    AliError("No ALTRO mapping information is loaded! Filling a dummy trailer!");
-    return WriteDummyTrailer(wordsNumber,padNumber,
-                            rowNumber,secNumber);
+    AliFatal("No ALTRO mapping information is loaded!");
   }
 
   Short_t hwAddress = fMapping->GetHWAddress(rowNumber,padNumber,secNumber);
@@ -199,7 +180,7 @@ void AliAltroBuffer::WriteChannel(Int_t padNumber, Int_t rowNumber,
   //Write all ADC values and the trailer of a channel
   Int_t nWords = WriteBunch(nTimeBins,adcValues,threshold);
   // write the trailer
-  WriteTrailer(nWords, padNumber, rowNumber, secNumber);
+  if (nWords) WriteTrailer(nWords, padNumber, rowNumber, secNumber);
 }
 
 //_____________________________________________________________________________
@@ -210,7 +191,7 @@ void AliAltroBuffer::WriteChannel(Short_t hwAddress,
   //Write all ADC values and the trailer of a channel
   Int_t nWords = WriteBunch(nTimeBins,adcValues,threshold);
   // write the trailer
-  WriteTrailer(nWords, hwAddress);
+  if (nWords) WriteTrailer(nWords, hwAddress);
 }
 
 //_____________________________________________________________________________
@@ -251,10 +232,10 @@ Int_t AliAltroBuffer::WriteBunch(Int_t nTimeBins, const Int_t* adcValues,
 }
 
 //_____________________________________________________________________________
-void AliAltroBuffer::WriteDataHeader(Bool_t dummy, Bool_t compressed)
+void AliAltroBuffer::WriteDataHeader(Bool_t dummy, Bool_t /*compressed*/)
 {
 //Write a (dummy or real) DDL data header, 
-//set the compression bit if compressed
+//set the attributes according to the RCU version
 
   AliRawDataHeaderSim header;
   if (dummy) {
@@ -262,19 +243,18 @@ void AliAltroBuffer::WriteDataHeader(Bool_t dummy, Bool_t compressed)
     fDataHeaderPos = fFile->Tellp();
     fFile->WriteBuffer((char*)(&header), sizeof(header));
   } else {
-    WriteRCUTrailer(0);
+    UChar_t rcuVer = WriteRCUTrailer(0);
     UInt_t currentFilePos = fFile->Tellp();
     fFile->Seekp(fDataHeaderPos);
-    header.fSize = currentFilePos-fDataHeaderPos;
-    header.SetAttribute(0);  // valid data
-    if (compressed) header.SetAttribute(1); 
+    header.fSize = 0xFFFFFFFF; // RCU can't write raw-data size so we always get an 'invalid' size field
+    header.fAttributesSubDetectors |= (rcuVer << 24);
     fFile->WriteBuffer((char*)(&header), sizeof(header));
     fFile->Seekp(currentFilePos);
   }
 }
 
 //_____________________________________________________________________________
-void AliAltroBuffer::WriteRCUTrailer(Int_t rcuId)
+UChar_t AliAltroBuffer::WriteRCUTrailer(Int_t rcuId)
 {
   // Writes the RCU trailer
   // rcuId the is serial number of the corresponding
@@ -289,7 +269,7 @@ void AliAltroBuffer::WriteRCUTrailer(Int_t rcuId)
   
   if ((size % 5) != 0) {
     AliFatal(Form("The current raw data payload is not a mutiple of 5 (%d) ! Can not write the RCU trailer !",size));
-    return;
+    return 0;
   }
 
   // Now put the size in unit of number of 40bit words
@@ -305,8 +285,10 @@ void AliAltroBuffer::WriteRCUTrailer(Int_t rcuId)
   
   //  Now the RCU identifier and size of the trailer
   //  FOr the moment the triler size is 2 32-bit words
-  UInt_t buffer = 2;
-  buffer |= ((rcuId & 0x3FF) << 22);
+  UInt_t buffer = (2 & 0x7F);
+  buffer |= ((rcuId & 0x1FF) << 7);
+  buffer |= 0xAAAAU << 16;
   fFile->WriteBuffer((char *)(&buffer),sizeof(UInt_t));
 
+  return 0;
 }