Introducing the fixes needed in order to read the old RCU firmware format (v<3) with...
authorcvetan <cvetan@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 19 May 2009 16:35:27 +0000 (16:35 +0000)
committercvetan <cvetan@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 19 May 2009 16:35:27 +0000 (16:35 +0000)
FMD/AliFMDRawReader.cxx
FMD/AliFMDRawStream.cxx
RAW/AliAltroRawStream.cxx
RAW/AliAltroRawStream.h
RAW/AliAltroRawStreamV3.cxx
RAW/AliAltroRawStreamV3.h
RAW/AliCaloRawStream.cxx
TPC/AliTPCRawStream.cxx

index 74c44e1..e456975 100644 (file)
@@ -148,7 +148,6 @@ AliFMDRawReader::NextSample(UShort_t& det, Char_t&   rng, UShort_t& sec,
     AliFMDDebug(5, ("Setting %d word headers", 
                    pars->HasCompleteHeader() ? 8 : 7));
     stream.SetShortDataHeader(!pars->HasCompleteHeader());
-    stream.SetNoAltroMapping(kFALSE);
 
     // Reset variables
     ddl    = -1;  
index 3234b1f..34337e6 100644 (file)
@@ -47,7 +47,6 @@ AliFMDRawStream::AliFMDRawStream(AliRawReader* reader)
 {
   // CTOR 
   reader->Reset();
-  fNoAltroMapping = kFALSE;
   // Select FMD DDL's 
   SelectRawData("FMD");
 }
index 4159dc3..2e9bef8 100644 (file)
@@ -35,7 +35,6 @@ ClassImp(AliAltroRawStream)
 
 //_____________________________________________________________________________
 AliAltroRawStream::AliAltroRawStream(AliRawReader* rawReader) :
-  fNoAltroMapping(kTRUE),
   fIsShortDataHeader(kFALSE),
   fDDLNumber(-1),
   fPrevDDLNumber(-1),
@@ -65,13 +64,11 @@ AliAltroRawStream::AliAltroRawStream(AliRawReader* rawReader) :
   fAltroCFG2(0)
 {
 // create an object to read Altro raw digits
-  fSegmentation[0] = fSegmentation[1] = fSegmentation[2] = -1;
 }
 
 //_____________________________________________________________________________
 AliAltroRawStream::AliAltroRawStream(const AliAltroRawStream& stream) :
   TObject(stream),
-  fNoAltroMapping(stream.fNoAltroMapping),
   fIsShortDataHeader(stream.fIsShortDataHeader),
   fDDLNumber(stream.fDDLNumber),
   fPrevDDLNumber(stream.fPrevDDLNumber),
@@ -100,9 +97,6 @@ AliAltroRawStream::AliAltroRawStream(const AliAltroRawStream& stream) :
   fAltroCFG1(stream.fAltroCFG1),
   fAltroCFG2(stream.fAltroCFG2)
 {
-  fSegmentation[0]   = stream.fSegmentation[0];
-  fSegmentation[1]   = stream.fSegmentation[1];
-  fSegmentation[2]   = stream.fSegmentation[2];
 }
 
 //_____________________________________________________________________________
@@ -110,7 +104,6 @@ AliAltroRawStream& AliAltroRawStream::operator = (const AliAltroRawStream& strea
 {
   if(&stream == this) return *this;
 
-  fNoAltroMapping    = stream.fNoAltroMapping;
   fIsShortDataHeader = stream.fIsShortDataHeader;
   fDDLNumber         = stream.fDDLNumber;
   fPrevDDLNumber     = stream.fPrevDDLNumber;
@@ -139,10 +132,6 @@ AliAltroRawStream& AliAltroRawStream::operator = (const AliAltroRawStream& strea
   fAltroCFG1         = stream.fAltroCFG1;
   fAltroCFG2         = stream.fAltroCFG2;
 
-  fSegmentation[0]   = stream.fSegmentation[0];
-  fSegmentation[1]   = stream.fSegmentation[1];
-  fSegmentation[2]   = stream.fSegmentation[2];
-
   return *this;
 }
 
@@ -168,8 +157,6 @@ void AliAltroRawStream::Reset()
   fDDLNumber = fPrevDDLNumber = fRCUId = fPrevRCUId = fHWAddress = fPrevHWAddress = fTime = fPrevTime = fSignal = fTimeBunch = -1;
 
   if (fRawReader) fRawReader->Reset();
-
-  fSegmentation[0] = fSegmentation[1] = fSegmentation[2] = -1;
 }
 
 //_____________________________________________________________________________
@@ -208,6 +195,53 @@ Bool_t AliAltroRawStream::Next()
 }
 
 //_____________________________________________________________________________
+Bool_t AliAltroRawStream::NextDDL(UChar_t *data)
+{
+  if (!data) {
+    do {
+      if (!fRawReader->ReadNextData(fData)) return kFALSE;
+    } while (fRawReader->GetDataSize() == 0);
+  }
+  else {
+    fData = data;
+  }
+
+  fDDLNumber = fRawReader->GetDDLID();
+  fPosition = GetPosition();
+
+  return kTRUE;
+}
+
+//_____________________________________________________________________________
+Bool_t AliAltroRawStream::NextChannel()
+{
+  if (fPosition <= 0) return kFALSE;
+
+  ReadTrailer();
+
+  return kTRUE;
+}
+
+//_____________________________________________________________________________
+Bool_t AliAltroRawStream::NextBunch(UShort_t *bunchData,
+                                   Int_t &bunchLength,
+                                   Int_t &startTimeBin)
+{
+  if (fCount == 0) return kFALSE;
+
+  ReadBunch();
+  bunchLength = fTimeBunch;
+  startTimeBin = fTime;
+
+  while (fBunchLength > 0) {
+    ReadAmplitude();
+    bunchData[bunchLength-fBunchLength-1] = fSignal;
+  }
+
+  return kTRUE;
+}
+
+//_____________________________________________________________________________
 void AliAltroRawStream::SelectRawData(Int_t detId)
 {
   // Select the raw data for specific
@@ -249,12 +283,6 @@ UShort_t AliAltroRawStream::GetNextWord()
 Bool_t AliAltroRawStream::ReadTrailer()
 {
   //Read a trailer of 40 bits in the backward reading mode
-  //In case of no mapping is provided, read a dummy trailer
-  if (fNoAltroMapping) {
-    AliError("No ALTRO mapping information is loaded! Reading a dummy trailer!");
-    return ReadDummyTrailer();
-  }
-
   //First reading filling words
   UShort_t temp;
   Int_t nFillWords = 0;
@@ -319,26 +347,6 @@ Bool_t AliAltroRawStream::ReadTrailer()
 }
 
 //_____________________________________________________________________________
-Bool_t AliAltroRawStream::ReadDummyTrailer()
-{
-  //Read a trailer of 40 bits in the backward reading mode
-  //In case of no mapping is provided, read a dummy trailer
-  UShort_t temp;
-  while ((temp = GetNextWord()) == 0x2AA) { };
-
-  fSegmentation[0] = temp;
-  fSegmentation[1] = GetNextWord();
-  fSegmentation[2] = GetNextWord();
-  fCount = GetNextWord();
-  if (fCount == 0) return kFALSE;
-  fHWAddress = -1;
-
-  fPosition -= (4 - (fCount % 4)) % 4;  // skip fill words
-
-  return kTRUE;
-}
-
-//_____________________________________________________________________________
 void AliAltroRawStream::ReadBunch()
 {
   // Read altro payload in 
index f06df1b..817d1ac 100644 (file)
@@ -27,6 +27,12 @@ class AliAltroRawStream: public TObject {
     virtual void             Reset();
     virtual Bool_t           Next();
 
+    virtual Bool_t NextDDL(UChar_t* data = NULL);              // Iterate over DDLs/RCUs
+    virtual Bool_t NextChannel();                              // Iterate over altro channels
+    virtual Bool_t NextBunch(UShort_t *bunchData,
+                            Int_t &bunchLength,
+                            Int_t &startTimeBin);             // Iterate over altro bunches
+
     Int_t GetDDLNumber()  const { return fDDLNumber; }  // Provide current DDL number
     Int_t GetPrevDDLNumber() const { return fPrevDDLNumber; }// Provide previous DDL number
     Bool_t  IsNewDDLNumber() const {return (fDDLNumber != fPrevDDLNumber);};
@@ -83,7 +89,6 @@ class AliAltroRawStream: public TObject {
     void SelectRawData(Int_t detId);                           // Select raw data for specific detector id
     void SelectRawData(const char *detName);                   // Select raw data for specific detector name
 
-    void  SetNoAltroMapping(Bool_t flag) { fNoAltroMapping = flag; }  // Specify whenever to use or not the altro mapping
     void  SetShortDataHeader(Bool_t flag) { fIsShortDataHeader = flag; } // Specify whenever to assume or not a short CDH format
 
     void PrintDebug() const; // Print debug information in case of decoding errors
@@ -105,16 +110,12 @@ class AliAltroRawStream: public TObject {
 
   protected:
 
-    Bool_t           fNoAltroMapping;  // temporary flag in case of no altro mapping is provided
-    Short_t          fSegmentation[3]; // temporary container for the dummy trailer, to be removed
-
     Bool_t           fIsShortDataHeader; // flag used to select between normal and short CDH format
 
   private :
 
     UShort_t         GetNextWord();
     Bool_t           ReadTrailer();
-    Bool_t           ReadDummyTrailer();
     void             ReadBunch();
     void             ReadAmplitude();
     Int_t            GetPosition();
index 71f125a..2a0c501 100644 (file)
@@ -29,6 +29,7 @@
 #include "AliAltroRawStreamV3.h"
 #include "AliRawReader.h"
 #include "AliLog.h"
+#include "AliAltroRawStream.h"
 
 ClassImp(AliAltroRawStreamV3)
 
@@ -58,7 +59,8 @@ AliAltroRawStreamV3::AliAltroRawStreamV3(AliRawReader* rawReader) :
   fActiveFECsA(0),
   fActiveFECsB(0),
   fAltroCFG1(0),
-  fAltroCFG2(0)
+  fAltroCFG2(0),
+  fOldStream(NULL)
 {
   // Constructor
   // Create an object to read Altro raw digits in
@@ -70,7 +72,8 @@ AliAltroRawStreamV3::AliAltroRawStreamV3(AliRawReader* rawReader) :
 AliAltroRawStreamV3::~AliAltroRawStreamV3()
 {
 // destructor
-// nothing to do
+// delete old stream object if one exists
+  if (fOldStream) delete fOldStream;
 }
 
 //_____________________________________________________________________________
@@ -99,11 +102,15 @@ AliAltroRawStreamV3::AliAltroRawStreamV3(const AliAltroRawStreamV3& stream) :
   fActiveFECsA(stream.fActiveFECsA),
   fActiveFECsB(stream.fActiveFECsB),
   fAltroCFG1(stream.fAltroCFG1),
-  fAltroCFG2(stream.fAltroCFG2)
+  fAltroCFG2(stream.fAltroCFG2),
+  fOldStream(NULL)
 {
   // Copy constructor
   // Copy the bunch data array
   for(Int_t i = 0; i < kMaxNTimeBins; i++) fBunchData[i] = stream.fBunchData[i];
+
+  if (stream.fOldStream)
+    fOldStream = new AliAltroRawStream(*stream.fOldStream);
 }
 
 //_____________________________________________________________________________
@@ -140,6 +147,12 @@ AliAltroRawStreamV3& AliAltroRawStreamV3::operator = (const AliAltroRawStreamV3&
 
   for(Int_t i = 0; i < kMaxNTimeBins; i++) fBunchData[i] = stream.fBunchData[i];
 
+  if (stream.fOldStream) {
+    if (fOldStream) delete fOldStream;
+    fOldStream = new AliAltroRawStream(stream.fRawReader);
+    *fOldStream = *stream.fOldStream;
+  }
+
   return *this;
 }
 
@@ -164,6 +177,7 @@ void AliAltroRawStreamV3::Reset()
 
   if (fRawReader) fRawReader->Reset();
 
+  if (fOldStream) fOldStream->Reset();
 }
 
 //_____________________________________________________________________________
@@ -185,9 +199,32 @@ Bool_t AliAltroRawStreamV3::NextDDL()
 
   UChar_t rcuVer = fRawReader->GetBlockAttributes();
 
-  if (!ReadRCUTrailer(rcuVer)) return kFALSE;
+  if (rcuVer < 2) {
+    // old altro format data
+    if (!fOldStream) {
+      fOldStream = new AliAltroRawStream(fRawReader);
+      AliInfo(Form("RCU firmware verion %d detected. Using AliAltroRawStream to decode the data.",
+                  rcuVer));
+    }
+    Bool_t status = fOldStream->NextDDL(fData);
+    if (status) {
+      fRCUId = fOldStream->GetRCUId();
+      fRCUTrailerSize = fOldStream->GetRCUTrailerSize();
+      fOldStream->GetRCUTrailerData(fRCUTrailerData);
+      fFECERRA = fOldStream->GetFECERRA();
+      fFECERRB = fOldStream->GetFECERRB();
+      fERRREG2 = fOldStream->GetERRREG2();
+      fERRREG3 = ((UInt_t)fOldStream->GetNChAddrMismatch()) |
+       (((UInt_t)fOldStream->GetNChLengthMismatch()) << 12);
+      fActiveFECsA = fOldStream->GetActiveFECsA();
+      fActiveFECsB = fOldStream->GetActiveFECsB();
+      fAltroCFG1 = fOldStream->GetAltroCFG1();
+      fAltroCFG2 = fOldStream->GetAltroCFG2();
+    }
+    return status;
+  }
 
-  return kTRUE;
+  return ReadRCUTrailer(rcuVer);
 }
 
 //_____________________________________________________________________________
@@ -198,6 +235,12 @@ Bool_t AliAltroRawStreamV3::NextChannel()
   // Updates the channel hardware address member and
   // channel data size. Sets the error flag in case
   // RCU signals readout error in this channel
+  if (fOldStream) {
+    Bool_t status = fOldStream->NextChannel();
+    if (status) fHWAddress = fOldStream->GetHWAddress();
+    return status;
+  }
+
   fCount = -1;
   fBadChannel = kFALSE;
   fBunchDataIndex = 0;
@@ -249,6 +292,13 @@ Bool_t AliAltroRawStreamV3::NextBunch()
   // raw-data stream.
   // Updates the start/end time-bins
   // and the array with altro samples
+  if (fOldStream) {
+    Bool_t status = fOldStream->NextBunch(fBunchData,fBunchLength,fStartTimeBin);
+    if (status) fBunchDataPointer = &fBunchData[0];
+    else fBunchDataPointer = NULL;
+    return status;
+  }
+
   fBunchLength = fStartTimeBin = -1;
   fBunchDataPointer = NULL;
 
index f7790a1..bc3b287 100644 (file)
@@ -19,6 +19,7 @@
 #include <TObject.h>
 
 class AliRawReader;
+class AliAltroRawStream;
 
 class AliAltroRawStreamV3: public TObject {
   public :
@@ -144,6 +145,8 @@ class AliAltroRawStreamV3: public TObject {
     UInt_t           fAltroCFG1;    // ALTROCFG1 register
     UInt_t           fAltroCFG2;    // ALTROCFG2 and ALTROIF registers
 
+    AliAltroRawStream* fOldStream;  // streamer for old altro format
+
     ClassDef(AliAltroRawStreamV3, 0)  // base class for reading Altro raw digits
 };
 
index 043f3c0..a150aa4 100644 (file)
@@ -94,8 +94,6 @@ AliCaloRawStream::AliCaloRawStream(AliRawReader* rawReader, TString calo, AliAlt
       fMapping[i] = mapping[i];
     
   }
-  
-  SetNoAltroMapping(kFALSE);
 }
 
 //_____________________________________________________________________________
index e036a10..57701c8 100644 (file)
@@ -67,7 +67,6 @@ AliTPCRawStream::AliTPCRawStream(AliRawReader* rawReader, AliAltroMapping **mapp
       fMapping[i] = mapping[i];
   }
     
-  fNoAltroMapping = kFALSE;
 }
 
 //_____________________________________________________________________________