From 39f9963faf67a511516c176c9a9112a156cd8ceb Mon Sep 17 00:00:00 2001 From: tkuhr Date: Thu, 22 Apr 2004 12:02:02 +0000 Subject: [PATCH] readers updated (mini header -> data header) --- RAW/AliRawReader.cxx | 62 +++++++------------- RAW/AliRawReader.h | 33 ++++++----- RAW/AliRawReaderDate.cxx | 82 ++++++++++----------------- RAW/AliRawReaderDate.h | 6 +- RAW/AliRawReaderFile.cxx | 119 ++++++++++++++++++++++++--------------- RAW/AliRawReaderFile.h | 16 ++++-- RAW/AliRawReaderRoot.cxx | 69 +++++++++++------------ 7 files changed, 188 insertions(+), 199 deletions(-) diff --git a/RAW/AliRawReader.cxx b/RAW/AliRawReader.cxx index 57fc236081f..ab714cbb15d 100644 --- a/RAW/AliRawReader.cxx +++ b/RAW/AliRawReader.cxx @@ -20,7 +20,7 @@ // // The derived classes, which operate on concrete raw data formats, // should implement -// - ReadHeader to read the next (mini or equipment) header +// - ReadHeader to read the next (data/equipment) header // - ReadNextData to read the next raw data block (=1 DDL) // - ReadNext to read a given number of bytes // - several getters like GetType @@ -42,14 +42,12 @@ ClassImp(AliRawReader) AliRawReader::AliRawReader() : - fMiniHeader(NULL), + fHeader(NULL), fCount(0), - fSelectDetectorID(-1), - fSelectMinDDLID(-1), - fSelectMaxDDLID(-1), fSelectEquipmentType(-1), fSelectMinEquipmentId(-1), fSelectMaxEquipmentId(-1), + fSkipInvalid(kFALSE), fErrorCode(0) { // default constructor: initialize data members @@ -58,14 +56,12 @@ AliRawReader::AliRawReader() : AliRawReader::AliRawReader(const AliRawReader& rawReader) : TObject(rawReader), - fMiniHeader(rawReader.fMiniHeader), + fHeader(rawReader.fHeader), fCount(rawReader.fCount), - fSelectDetectorID(rawReader.fSelectDetectorID), - fSelectMinDDLID(rawReader.fSelectMinDDLID), - fSelectMaxDDLID(rawReader.fSelectMaxDDLID), fSelectEquipmentType(rawReader.fSelectEquipmentType), fSelectMinEquipmentId(rawReader.fSelectMinEquipmentId), fSelectMaxEquipmentId(rawReader.fSelectMaxEquipmentId), + fSkipInvalid(rawReader.fSkipInvalid), fErrorCode(0) { // copy constructor @@ -76,12 +72,13 @@ AliRawReader& AliRawReader::operator = (const AliRawReader& rawReader) { // assignment operator - fMiniHeader = rawReader.fMiniHeader; + fHeader = rawReader.fHeader; fCount = rawReader.fCount; - fSelectDetectorID = rawReader.fSelectDetectorID; - fSelectMinDDLID = rawReader.fSelectMinDDLID; - fSelectMaxDDLID = rawReader.fSelectMaxDDLID; + fSelectEquipmentType = rawReader.fSelectEquipmentType; + fSelectMinEquipmentId = rawReader.fSelectMinEquipmentId; + fSelectMaxEquipmentId = rawReader.fSelectMaxEquipmentId; + fSkipInvalid = rawReader.fSkipInvalid; fErrorCode = rawReader.fErrorCode; @@ -95,9 +92,11 @@ void AliRawReader::Select(Int_t detectorID, Int_t minDDLID, Int_t maxDDLID) // range of DDLs (minDDLID <= DDLID <= maxDDLID). // no selection is applied if a value < 0 is used. - fSelectDetectorID = detectorID; - fSelectMinDDLID = minDDLID; - fSelectMaxDDLID = maxDDLID; + fSelectEquipmentType = 0; + if (minDDLID < 0) minDDLID = 0; + fSelectMinEquipmentId = (detectorID << 8) + minDDLID; + if (maxDDLID < 0) maxDDLID = 0xFF; + fSelectMaxEquipmentId = (detectorID << 8) + maxDDLID; } void AliRawReader::SelectEquipment(Int_t equipmentType, @@ -116,14 +115,7 @@ Bool_t AliRawReader::IsSelected() const { // apply the selection (if any) - if (fSelectDetectorID >= 0) { - if (!fMiniHeader) return kFALSE; - if (fMiniHeader->fDetectorID != fSelectDetectorID) return kFALSE; - if ((fSelectMinDDLID >= 0) && (fMiniHeader->fDDLID < fSelectMinDDLID)) - return kFALSE; - if ((fSelectMaxDDLID >= 0) && (fMiniHeader->fDDLID > fSelectMaxDDLID)) - return kFALSE; - } + if (fSkipInvalid && !IsValid()) return kFALSE; if (fSelectEquipmentType >= 0) { if (GetEquipmentType() != fSelectEquipmentType) return kFALSE; @@ -139,20 +131,6 @@ Bool_t AliRawReader::IsSelected() const } -Bool_t AliRawReader::CheckMiniHeader(AliMiniHeader* miniHeader) const -{ -// check the magic number of the mini header - - if (!miniHeader) miniHeader = fMiniHeader; - if (!miniHeader) return kFALSE; - UInt_t magicWord = miniHeader->fMagicWord[2]*65536 + - miniHeader->fMagicWord[1]*256 + miniHeader->fMagicWord[0]; - if (magicWord != AliMiniHeader::kMagicWord) { - return kFALSE; - } - return kTRUE; -} - Bool_t AliRawReader::ReadNextInt(UInt_t& data) { // reads the next 4 bytes at the current position @@ -271,11 +249,9 @@ void AliRawReader::DumpData(Int_t limit) } printf("element size = %d\n", GetEquipmentElementSize()); - printf("mini header:\n" - " size = %d detector = %d DDL = %d\n" - " version = %d compression = %d\n", - GetDataSize(), GetDetectorID(), GetDDLID(), - GetVersion(), IsCompressed()); + printf("data header:\n" + " size = %d version = %d valid = %d compression = %d\n", + GetDataSize(), GetVersion(), IsValid(), IsCompressed()); printf("\n"); if (limit == 0) continue; diff --git a/RAW/AliRawReader.h b/RAW/AliRawReader.h index 68e88bc52de..c3316a889c2 100644 --- a/RAW/AliRawReader.h +++ b/RAW/AliRawReader.h @@ -4,7 +4,7 @@ * See cxx source for full Copyright notice */ #include -#include "AliMiniHeader.h" +#include "AliRawDataHeader.h" class AliRawReader: public TObject { @@ -19,6 +19,8 @@ class AliRawReader: public TObject { void SelectEquipment(Int_t equipmentType, Int_t minEquipmentId = -1, Int_t maxEquipmentId = -1); + void SkipInvalid(Bool_t skip = kTRUE) + {fSkipInvalid = skip;}; virtual UInt_t GetType() const = 0; virtual UInt_t GetRunNumber() const = 0; @@ -35,18 +37,22 @@ class AliRawReader: public TObject { virtual const UInt_t* GetEquipmentAttributes() const = 0; virtual Int_t GetEquipmentElementSize() const = 0; + Int_t GetDetectorID() const + {if (GetEquipmentId() >= 0) return (GetEquipmentId() >> 8); else return -1;}; + Int_t GetDDLID() const + {if (GetEquipmentId() >= 0) return (GetEquipmentId() & 0xFF); else return -1;}; + Int_t GetDataSize() const - {if (fMiniHeader) return fMiniHeader->fSize; + {if (fHeader) return fHeader->fSize - sizeof(AliRawDataHeader); else return GetEquipmentSize();}; - Int_t GetDetectorID() const - {if (fMiniHeader) return fMiniHeader->fDetectorID; else return -1;}; - Int_t GetDDLID() const - {if (fMiniHeader) return fMiniHeader->fDDLID; else return -1;}; Int_t GetVersion() const - {if (fMiniHeader) return fMiniHeader->fVersion; else return -1;}; + {if (fHeader) return fHeader->fVersion; else return -1;}; + Bool_t IsValid() const + {if (fHeader) return fHeader->TestAttribute(0); + else return kFALSE;}; Bool_t IsCompressed() const - {if (fMiniHeader) return fMiniHeader->fCompressionFlag != 0; + {if (fHeader) return fHeader->TestAttribute(1); else return kFALSE;}; virtual Bool_t ReadHeader() = 0; @@ -57,8 +63,8 @@ class AliRawReader: public TObject { virtual Bool_t Reset() = 0; - enum {kErrMagic=1, kErrNoMiniHeader=2, kErrMiniMagic=4, - kErrSize=8, kErrOutOfBounds=16}; + enum {kErrMagic=1, kErrNoDataHeader=2, + kErrSize=4, kErrOutOfBounds=8}; virtual Int_t CheckData() const; Int_t GetErrorCode() {return fErrorCode;}; @@ -67,18 +73,15 @@ class AliRawReader: public TObject { protected : Bool_t IsSelected() const; - Bool_t CheckMiniHeader(AliMiniHeader* miniHeader = NULL) const; virtual Bool_t ReadNext(UChar_t* data, Int_t size) = 0; - AliMiniHeader* fMiniHeader; // current mini header + AliRawDataHeader* fHeader; // current data header Int_t fCount; // counter of bytes to be read for current DDL - Int_t fSelectDetectorID; // id of selected detector (<0 = no selection) - Int_t fSelectMinDDLID; // minimal index of selected DDLs (<0 = no selection) - Int_t fSelectMaxDDLID; // maximal index of selected DDLs (<0 = no selection) Int_t fSelectEquipmentType; // type of selected equipment (<0 = no selection) Int_t fSelectMinEquipmentId; // minimal index of selected equipment (<0 = no selection) Int_t fSelectMaxEquipmentId; // maximal index of selected equipment (<0 = no selection) + Bool_t fSkipInvalid; // skip invalid data Int_t fErrorCode; // code of last error diff --git a/RAW/AliRawReaderDate.cxx b/RAW/AliRawReaderDate.cxx index 608222e855e..30a749d3e23 100644 --- a/RAW/AliRawReaderDate.cxx +++ b/RAW/AliRawReaderDate.cxx @@ -35,7 +35,7 @@ AliRawReaderDate::AliRawReaderDate( void* /* event */ #endif ) : - fRequireMiniHeader(kTRUE), + fRequireHeader(kTRUE), fEvent(NULL), fSubEvent(NULL), fEquipment(NULL), @@ -60,7 +60,7 @@ AliRawReaderDate::AliRawReaderDate( Int_t /*eventNumber*/ #endif ) : - fRequireMiniHeader(kTRUE), + fRequireHeader(kTRUE), fEvent(NULL), fSubEvent(NULL), fEquipment(NULL), @@ -99,7 +99,7 @@ AliRawReaderDate::AliRawReaderDate( AliRawReaderDate::AliRawReaderDate(const AliRawReaderDate& rawReader) : AliRawReader(rawReader), - fRequireMiniHeader(rawReader.fRequireMiniHeader), + fRequireHeader(rawReader.fRequireHeader), fEvent(rawReader.fEvent), fSubEvent(rawReader.fSubEvent), fEquipment(rawReader.fEquipment), @@ -292,8 +292,8 @@ Int_t AliRawReaderDate::GetEquipmentElementSize() const Bool_t AliRawReaderDate::ReadHeader() { -// read a mini header at the current position -// returns kFALSE if the mini header could not be read +// read a data header at the current position +// returns kFALSE if the data header could not be read fErrorCode = 0; @@ -349,11 +349,11 @@ Bool_t AliRawReaderDate::ReadHeader() // continue with the next sub event if no data left in the payload if (fPosition >= fEnd) continue; - fMiniHeader = NULL; - if (fRequireMiniHeader) { - // check that there are enough bytes left for the mini header - if (fPosition + sizeof(AliMiniHeader) > fEnd) { - Error("ReadHeader", "could not read mini header data!"); + fHeader = NULL; + if (fRequireHeader) { + // check that there are enough bytes left for the data header + if (fPosition + sizeof(AliRawDataHeader) > fEnd) { + Error("ReadHeader", "could not read data header data!"); Warning("ReadHeader", "skipping %d bytes\n" " run: %d event: %d %d LDC: %d GDC: %d\n", fEnd - fPosition, fSubEvent->eventRunNb, @@ -361,41 +361,21 @@ Bool_t AliRawReaderDate::ReadHeader() fSubEvent->eventLdcId, fSubEvent->eventGdcId); fCount = 0; fPosition = fEnd; - fErrorCode = kErrNoMiniHeader; + fErrorCode = kErrNoDataHeader; continue; } - // "read" and check the mini header - fMiniHeader = (AliMiniHeader*) fPosition; - fPosition += sizeof(AliMiniHeader); - if (!CheckMiniHeader()) { - Error("ReadHeader", "wrong magic word in mini header!"); - Warning("ReadHeader", "skipping %d bytes\n" - " run: %d event: %d %d LDC: %d GDC: %d\n", - fEnd - fPosition, fSubEvent->eventRunNb, - fSubEvent->eventId[0], fSubEvent->eventId[1], - fSubEvent->eventLdcId, fSubEvent->eventGdcId); - fCount = 0; - fPosition = fEnd; - fErrorCode = kErrMiniMagic; - continue; - } - - } else { // if mini header not required - // assume there is a mini header if the magic word is correct - if ((fPosition + sizeof(AliMiniHeader) <= fEnd) && - CheckMiniHeader((AliMiniHeader*) fPosition)) { - fMiniHeader = (AliMiniHeader*) fPosition; - fPosition += sizeof(AliMiniHeader); - } + // "read" the data header + fHeader = (AliRawDataHeader*) fPosition; + fPosition += sizeof(AliRawDataHeader); } - if (fMiniHeader) { - fCount = fMiniHeader->fSize; + if (fHeader && (fHeader->fSize != 0xFFFFFFFF)) { + fCount = fHeader->fSize - sizeof(AliRawDataHeader); - // check consistency of data size in the mini header and in the sub event + // check consistency of data size in the header and in the sub event if (fPosition + fCount > fEnd) { - Error("ReadHeader", "size in mini header exceeds event size!"); + Error("ReadHeader", "size in data header exceeds event size!"); Warning("ReadHeader", "skipping %d bytes\n" " run: %d event: %d %d LDC: %d GDC: %d\n", fEnd - fPosition, fSubEvent->eventRunNb, @@ -507,25 +487,25 @@ Int_t AliRawReaderDate::CheckData() const // continue with the next sub event if no data left in the payload if (position >= end) continue; - // check that there are enough bytes left for the mini header - if (position + sizeof(AliMiniHeader) > end) { - result |= kErrNoMiniHeader; + // check that there are enough bytes left for the data header + if (position + sizeof(AliRawDataHeader) > end) { + result |= kErrNoDataHeader; position = end; continue; } - // "read" and check the mini header - AliMiniHeader* miniHeader = (AliMiniHeader*) position; - position += sizeof(AliMiniHeader); - if (!CheckMiniHeader(miniHeader)){ - result |= kErrMiniMagic; + // check consistency of data size in the data header and in the sub event + AliRawDataHeader* header = (AliRawDataHeader*) position; + if (fHeader->fSize != 0xFFFFFFFF) { + if (position + header->fSize > end) { + result |= kErrSize; + position = end; + } else { + position += header->fSize; + } + } else { position = end; - continue; } - - // check consistency of data size in the mini header and in the sub event - if (position + miniHeader->fSize > end) result |= kErrSize; - position += miniHeader->fSize; }; #endif diff --git a/RAW/AliRawReaderDate.h b/RAW/AliRawReaderDate.h index 0f856fd47d0..b7c9e868f28 100644 --- a/RAW/AliRawReaderDate.h +++ b/RAW/AliRawReaderDate.h @@ -17,8 +17,8 @@ class AliRawReaderDate: public AliRawReader { AliRawReaderDate& operator = (const AliRawReaderDate& rawReader); virtual ~AliRawReaderDate(); - void RequireMiniHeader(Bool_t required = kTRUE) - {fRequireMiniHeader = required;}; + void RequireHeader(Bool_t required = kTRUE) + {fRequireHeader = required;}; virtual UInt_t GetType() const; virtual UInt_t GetRunNumber() const; @@ -45,7 +45,7 @@ class AliRawReaderDate: public AliRawReader { protected : virtual Bool_t ReadNext(UChar_t* data, Int_t size); - Bool_t fRequireMiniHeader; // if false, data without mini header is accepted + Bool_t fRequireHeader; // if false, data without header is accepted eventHeaderStruct* fEvent; // raw data super event eventHeaderStruct* fSubEvent; // raw data sub event diff --git a/RAW/AliRawReaderFile.cxx b/RAW/AliRawReaderFile.cxx index f3b447e4e50..1b5edc3840c 100644 --- a/RAW/AliRawReaderFile.cxx +++ b/RAW/AliRawReaderFile.cxx @@ -21,32 +21,47 @@ /////////////////////////////////////////////////////////////////////////////// #include "AliRawReaderFile.h" +#include ClassImp(AliRawReaderFile) -AliRawReaderFile::AliRawReaderFile(const char* fileName, Bool_t addNumber) +AliRawReaderFile::AliRawReaderFile(Int_t eventNumber) : + fDirName("raw"), + fDirectory(NULL), + fStream(NULL), + fEquipmentId(-1), + fBuffer(NULL), + fBufferSize(0) { -// create an object to read digits from the given input file(s) -// if addNumber is true, a number starting at 1 is appended to the file name +// create an object to read digits from the given event - fFileName = fileName; - if (!addNumber) { - fFileNumber = -1; -#ifndef __DECCXX - fStream = new fstream(fileName, ios::binary|ios::in); -#else - fStream = new fstream(fileName, ios::in); -#endif - } else { - fFileNumber = 0; - fStream = NULL; - OpenNextFile(); + fDirName += eventNumber; + fDirectory = gSystem->OpenDirectory(fDirName); + if (!fDirectory) { + Error("AliRawReaderFile", "could not open directory %s", fDirName.Data()); + } + OpenNextFile(); + fHeader = new AliRawDataHeader; +} + +AliRawReaderFile::AliRawReaderFile(const char* dirName) : + fDirName(dirName), + fDirectory(NULL), + fStream(NULL), + fEquipmentId(-1), + fBuffer(NULL), + fBufferSize(0) +{ +// create an object to read digits from the given directory + + fDirectory = gSystem->OpenDirectory(fDirName); + if (!fDirectory) { + Error("AliRawReaderFile", "could not open directory %s", fDirName.Data()); } - fMiniHeader = new AliMiniHeader; - fBuffer = NULL; - fBufferSize = 0; + OpenNextFile(); + fHeader = new AliRawDataHeader; } AliRawReaderFile::AliRawReaderFile(const AliRawReaderFile& rawReader) : @@ -66,6 +81,7 @@ AliRawReaderFile::~AliRawReaderFile() { // close the input file + if (fDirectory) gSystem->FreeDirectory(fDirectory); if (fStream) { #if defined(__HP_aCC) || defined(__DECCXX) if (fStream->rdbuf()->is_open()) fStream->close(); @@ -74,7 +90,7 @@ AliRawReaderFile::~AliRawReaderFile() #endif delete fStream; } - delete fMiniHeader; + delete fHeader; if (fBuffer) delete[] fBuffer; } @@ -92,17 +108,27 @@ Bool_t AliRawReaderFile::OpenNextFile() #endif delete fStream; fStream = NULL; + fEquipmentId = -1; } - if (fFileNumber < 0) return kFALSE; - fFileNumber++; - char fileName[256]; - sprintf(fileName, "%s%d", fFileName.Data(), fFileNumber); + if (!fDirectory) return kFALSE; + TString entry; + while (entry = gSystem->GetDirEntry(fDirectory)) { + if (entry.IsNull()) return kFALSE; + if (!entry.EndsWith(".ddl")) continue; + char* fileName = gSystem->ConcatFileName(fDirName, entry); #ifndef __DECCXX - fStream = new fstream(fileName, ios::binary|ios::in); + fStream = new fstream(fileName, ios::binary|ios::in); #else - fStream = new fstream(fileName, ios::in); + fStream = new fstream(fileName, ios::in); #endif + break; + } + + if (!fStream) return kFALSE; + entry.Remove(0, entry.Last('_')+1); + entry.Remove(entry.Length()-4); + fEquipmentId = atoi(entry.Data()); #if defined(__HP_aCC) || defined(__DECCXX) return (fStream->rdbuf()->is_open()); #else @@ -111,19 +137,25 @@ Bool_t AliRawReaderFile::OpenNextFile() } -Bool_t AliRawReaderFile::ReadMiniHeader() +Bool_t AliRawReaderFile::ReadHeader() { -// read a mini header at the current stream position +// read a data header at the current stream position // returns kFALSE if the mini header could not be read if (!fStream) return kFALSE; do { if (fCount > 0) fStream->seekg(Int_t(fStream->tellg()) + fCount); - while (!fStream->read((char*) fMiniHeader, sizeof(AliMiniHeader))) { + while (!fStream->read((char*) fHeader, sizeof(AliRawDataHeader))) { if (!OpenNextFile()) return kFALSE; } - CheckMiniHeader(); - fCount = fMiniHeader->fSize; + if (fHeader->fSize != 0xFFFFFFFF) { + fCount = fHeader->fSize - sizeof(AliRawDataHeader); + } else { + UInt_t currentPos = fStream->tellg(); + fStream->seekg(0, ios::end); + fCount = UInt_t(fStream->tellg()) - currentPos; + fStream->seekg(currentPos); + } } while (!IsSelected()); return kTRUE; } @@ -134,7 +166,7 @@ Bool_t AliRawReaderFile::ReadNextData(UChar_t*& data) // returns kFALSE if the data could not be read while (fCount == 0) { - if (!ReadMiniHeader()) return kFALSE; + if (!ReadHeader()) return kFALSE; } if (fBufferSize < fCount) { if (fBuffer) delete[] fBuffer; @@ -169,7 +201,13 @@ Bool_t AliRawReaderFile::Reset() { // reset the current stream position to the beginning of the file - if ((fFileNumber > 0) && fStream) { + void* directory = gSystem->OpenDirectory(fDirName); + if (!directory) { + Error("Reset", "could not open directory %s", fDirName.Data()); + return kFALSE; + } + + if (fStream) { #if defined(__HP_aCC) || defined(__DECCXX) if (fStream->rdbuf()->is_open()) fStream->close(); #else @@ -177,23 +215,12 @@ Bool_t AliRawReaderFile::Reset() #endif delete fStream; fStream = NULL; - fFileNumber = 0; } - if (!fStream) { - if (fFileNumber < 0) { -#ifndef __DECCXX - fStream = new fstream(fFileName, ios::binary|ios::in); -#else - fStream = new fstream(fFileName, ios::in); -#endif - } else { - if (!OpenNextFile()) return kFALSE; - } - } + if (fDirectory) gSystem->FreeDirectory(fDirectory); + fDirectory = directory; - if (!fStream || !fStream->rdbuf()->is_open()) return kFALSE; - fStream->seekg(0); + OpenNextFile(); fCount = 0; return kTRUE; } diff --git a/RAW/AliRawReaderFile.h b/RAW/AliRawReaderFile.h index c4f29d119a9..16fec380cd6 100644 --- a/RAW/AliRawReaderFile.h +++ b/RAW/AliRawReaderFile.h @@ -14,7 +14,8 @@ class fstream; class AliRawReaderFile: public AliRawReader { public : - AliRawReaderFile(const char* fileName, Bool_t addNumber = kTRUE); + AliRawReaderFile(Int_t eventNumber); + AliRawReaderFile(const char* dirName); AliRawReaderFile(const AliRawReaderFile& rawReader); AliRawReaderFile& operator = (const AliRawReaderFile& rawReader); virtual ~AliRawReaderFile(); @@ -25,10 +26,16 @@ class AliRawReaderFile: public AliRawReader { virtual const UInt_t* GetTriggerPattern() const {return 0;}; virtual const UInt_t* GetDetectorPattern() const {return 0;}; virtual const UInt_t* GetAttributes() const {return 0;}; + virtual UInt_t GetLDCId() const {return 0;}; virtual UInt_t GetGDCId() const {return 0;}; + virtual Int_t GetEquipmentSize() const {return 0;}; + virtual Int_t GetEquipmentType() const {return 0;}; + virtual Int_t GetEquipmentId() const {return fEquipmentId;}; + virtual const UInt_t* GetEquipmentAttributes() const {return NULL;}; + virtual Int_t GetEquipmentElementSize() const {return 0;}; - virtual Bool_t ReadMiniHeader(); + virtual Bool_t ReadHeader(); virtual Bool_t ReadNextData(UChar_t*& data); virtual Bool_t Reset(); @@ -38,9 +45,10 @@ class AliRawReaderFile: public AliRawReader { virtual Bool_t ReadNext(UChar_t* data, Int_t size); - TString fFileName; // name of input files - Int_t fFileNumber; // number of current input file + TString fDirName; // name of the input directory + void* fDirectory; // pointer to the input directory fstream* fStream; // stream of raw digits + Int_t fEquipmentId; // equipment ID from file name UChar_t* fBuffer; // buffer for payload Int_t fBufferSize; // size of fBuffer in bytes diff --git a/RAW/AliRawReaderRoot.cxx b/RAW/AliRawReaderRoot.cxx index fe0ead832b7..cb52604f8a2 100644 --- a/RAW/AliRawReaderRoot.cxx +++ b/RAW/AliRawReaderRoot.cxx @@ -61,7 +61,7 @@ AliRawReaderRoot::AliRawReaderRoot(const char* fileName, Int_t eventNumber) fSubEventIndex = 0; fSubEvent = NULL; fRawData = NULL; - fMiniHeader = NULL; + fHeader = NULL; fCount = 0; fPosition = fEnd = NULL; @@ -77,7 +77,7 @@ AliRawReaderRoot::AliRawReaderRoot(AliRawEvent* event) fSubEventIndex = 0; fSubEvent = NULL; fRawData = NULL; - fMiniHeader = NULL; + fHeader = NULL; fCount = 0; fPosition = fEnd = NULL; @@ -94,7 +94,7 @@ AliRawReaderRoot::AliRawReaderRoot(const AliRawReaderRoot& rawReader) : fSubEventIndex = rawReader.fSubEventIndex; fSubEvent = rawReader.fSubEvent; fRawData = rawReader.fRawData; - fMiniHeader = rawReader.fMiniHeader; + fHeader = rawReader.fHeader; fCount = rawReader.fCount; fPosition = rawReader.fPosition; @@ -231,8 +231,8 @@ Int_t AliRawReaderRoot::GetEquipmentElementSize() const Bool_t AliRawReaderRoot::ReadHeader() { -// read a mini header at the current position -// returns kFALSE if the mini header could not be read +// read a data header at the current position +// returns kFALSE if the data header could not be read fErrorCode = 0; if (!fEvent) return kFALSE; @@ -265,34 +265,29 @@ Bool_t AliRawReaderRoot::ReadHeader() // continue with the next sub event if no data left in the payload if (fPosition >= fEnd) continue; - // check that there are enough bytes left for the mini header - if (fPosition + sizeof(AliMiniHeader) > fEnd) { - Error("ReadHeader", "could not read mini header data!"); + // check that there are enough bytes left for the data header + if (fPosition + sizeof(AliRawDataHeader) > fEnd) { + Error("ReadHeader", "could not read data header!"); Warning("ReadHeader", "skipping %d bytes", fEnd - fPosition); fSubEvent->GetHeader()->Dump(); fCount = 0; fPosition = fEnd; - fErrorCode = kErrNoMiniHeader; + fErrorCode = kErrNoDataHeader; continue; } - // "read" and check the mini header - fMiniHeader = (AliMiniHeader*) fPosition; - fPosition += sizeof(AliMiniHeader); - if (!CheckMiniHeader()) { - Error("ReadHeader", "wrong magic word in mini header!"); - Warning("ReadHeader", "skipping %d bytes", fEnd - fPosition); - fSubEvent->GetHeader()->Dump(); - fCount = 0; - fPosition = fEnd; - fErrorCode = kErrMiniMagic; - continue; + // "read" the data header + fHeader = (AliRawDataHeader*) fPosition; + fPosition += sizeof(AliRawDataHeader); + if (fHeader->fSize != 0xFFFFFFFF) { + fCount = fHeader->fSize - sizeof(AliRawDataHeader); + } else { + fCount = fEnd - fPosition; } - fCount = fMiniHeader->fSize; - // check consistency of data size in the mini header and in the sub event + // check consistency of data size in the header and in the sub event if (fPosition + fCount > fEnd) { - Error("ReadHeader", "size in mini header exceeds event size!"); + Error("ReadHeader", "size in data header exceeds event size!"); Warning("ReadHeader", "skipping %d bytes", fEnd - fPosition); fSubEvent->GetHeader()->Dump(); fCount = 0; @@ -346,7 +341,7 @@ Bool_t AliRawReaderRoot::Reset() fSubEventIndex = 0; fSubEvent = NULL; fRawData = NULL; - fMiniHeader = NULL; + fHeader = NULL; fCount = 0; fPosition = fEnd = NULL; @@ -388,25 +383,25 @@ Int_t AliRawReaderRoot::CheckData() const // continue with the next sub event if no data left in the payload if (position >= end) continue; - // check that there are enough bytes left for the mini header - if (position + sizeof(AliMiniHeader) > end) { - result |= kErrNoMiniHeader; + // check that there are enough bytes left for the data header + if (position + sizeof(AliRawDataHeader) > end) { + result |= kErrNoDataHeader; position = end; continue; } - // "read" and check the mini header - AliMiniHeader* miniHeader = (AliMiniHeader*) position; - position += sizeof(AliMiniHeader); - if (!CheckMiniHeader(miniHeader)) { - result |= kErrMiniMagic; + // check consistency of data size in the header and in the sub event + AliRawDataHeader* header = (AliRawDataHeader*) position; + if (fHeader->fSize != 0xFFFFFFFF) { + if (position + header->fSize > end) { + result |= kErrSize; + position = end; + } else { + position += header->fSize; + } + } else { position = end; - continue; } - - // check consistency of data size in the mini header and in the sub event - if (position + miniHeader->fSize > end) result |= kErrSize; - position += miniHeader->fSize; }; return result; -- 2.31.1