From 18882b3b6521280c033377aca6bd7cc137f33d28 Mon Sep 17 00:00:00 2001 From: cvetan Date: Mon, 2 May 2005 11:37:24 +0000 Subject: [PATCH] Adding support for raw data events without subevent header --- RAW/AliRawReader.cxx | 2 ++ RAW/AliRawReader.h | 4 ++++ RAW/AliRawReaderDate.cxx | 29 +++++++++-------------- RAW/AliRawReaderDate.h | 5 ---- RAW/AliRawReaderDateV3.cxx | 3 --- RAW/AliRawReaderDateV3.h | 5 ---- RAW/AliRawReaderRoot.cxx | 47 +++++++++++++++++++++----------------- 7 files changed, 43 insertions(+), 52 deletions(-) diff --git a/RAW/AliRawReader.cxx b/RAW/AliRawReader.cxx index ced8011bc65..7d91bc13bc8 100644 --- a/RAW/AliRawReader.cxx +++ b/RAW/AliRawReader.cxx @@ -43,6 +43,7 @@ ClassImp(AliRawReader) AliRawReader::AliRawReader() : + fRequireHeader(kTRUE), fHeader(NULL), fCount(0), fSelectEquipmentType(-1), @@ -58,6 +59,7 @@ AliRawReader::AliRawReader() : AliRawReader::AliRawReader(const AliRawReader& rawReader) : TObject(rawReader), + fRequireHeader(rawReader.fRequireHeader), fHeader(rawReader.fHeader), fCount(rawReader.fCount), fSelectEquipmentType(rawReader.fSelectEquipmentType), diff --git a/RAW/AliRawReader.h b/RAW/AliRawReader.h index 7e35774cc4b..f3a6f00ac56 100644 --- a/RAW/AliRawReader.h +++ b/RAW/AliRawReader.h @@ -30,6 +30,8 @@ class AliRawReader: public TObject { void SkipInvalid(Bool_t skip = kTRUE) {fSkipInvalid = skip;}; void SelectEvents(Int_t type); + void RequireHeader(Bool_t required = kTRUE) + {fRequireHeader = required;}; virtual UInt_t GetType() const = 0; virtual UInt_t GetRunNumber() const = 0; @@ -102,6 +104,8 @@ class AliRawReader: public TObject { virtual Bool_t ReadNext(UChar_t* data, Int_t size) = 0; + Bool_t fRequireHeader; // if false, data without header is accepted + AliRawDataHeader* fHeader; // current data header Int_t fCount; // counter of bytes to be read for current DDL diff --git a/RAW/AliRawReaderDate.cxx b/RAW/AliRawReaderDate.cxx index 0a07ae290b8..64e760357cf 100644 --- a/RAW/AliRawReaderDate.cxx +++ b/RAW/AliRawReaderDate.cxx @@ -39,7 +39,6 @@ AliRawReaderDate::AliRawReaderDate( void* /* event */ #endif ) : - fRequireHeader(kTRUE), fFile(NULL), fEvent(NULL), fSubEvent(NULL), @@ -64,7 +63,6 @@ AliRawReaderDate::AliRawReaderDate( Int_t /*eventNumber*/ #endif ) : - fRequireHeader(kTRUE), fFile(NULL), fEvent(NULL), fSubEvent(NULL), @@ -103,7 +101,6 @@ AliRawReaderDate::AliRawReaderDate( AliRawReaderDate::AliRawReaderDate(const AliRawReaderDate& rawReader) : AliRawReader(rawReader), - fRequireHeader(rawReader.fRequireHeader), fFile(rawReader.fFile), fEvent(rawReader.fEvent), fSubEvent(rawReader.fSubEvent), @@ -575,25 +572,21 @@ Int_t AliRawReaderDate::CheckData() const // continue with the next sub event if no data left in the payload if (position >= end) continue; + if (fRequireHeader) { // check that there are enough bytes left for the data header - if (position + sizeof(AliRawDataHeader) > end) { - result |= kErrNoDataHeader; - position = end; - continue; - } - - // check consistency of data size in the data header and in the sub event - AliRawDataHeader* header = (AliRawDataHeader*) position; - if (header->fSize != 0xFFFFFFFF) { - if (position + header->fSize > end) { - result |= kErrSize; + if (position + sizeof(AliRawDataHeader) > end) { + result |= kErrNoDataHeader; position = end; - } else { - position += header->fSize; + continue; + } + + // check consistency of data size in the data header and in the sub event + AliRawDataHeader* header = (AliRawDataHeader*) position; + if (header->fSize != 0xFFFFFFFF) { + if (position + header->fSize > end) result |= kErrSize; } - } else { - position = end; } + position = end; }; #endif diff --git a/RAW/AliRawReaderDate.h b/RAW/AliRawReaderDate.h index 67564c54f2c..d0a43158d2d 100644 --- a/RAW/AliRawReaderDate.h +++ b/RAW/AliRawReaderDate.h @@ -23,9 +23,6 @@ class AliRawReaderDate: public AliRawReader { AliRawReaderDate(const char* fileName, Int_t eventNumber = -1); virtual ~AliRawReaderDate(); - void RequireHeader(Bool_t required = kTRUE) - {fRequireHeader = required;}; - virtual UInt_t GetType() const; virtual UInt_t GetRunNumber() const; virtual const UInt_t* GetEventId() const; @@ -55,8 +52,6 @@ class AliRawReaderDate: public AliRawReader { protected : virtual Bool_t ReadNext(UChar_t* data, Int_t size); - Bool_t fRequireHeader; // if false, data without header is accepted - FILE* fFile; // DATE file eventHeaderStruct* fEvent; // raw data super event eventHeaderStruct* fSubEvent; // raw data sub event diff --git a/RAW/AliRawReaderDateV3.cxx b/RAW/AliRawReaderDateV3.cxx index dd9e6e7bfe0..1efebe320ad 100644 --- a/RAW/AliRawReaderDateV3.cxx +++ b/RAW/AliRawReaderDateV3.cxx @@ -53,7 +53,6 @@ ClassImp(AliRawReaderDateV3) AliRawReaderDateV3::AliRawReaderDateV3(void* event) : - fRequireHeader(kTRUE), fFile(NULL), fEvent(NULL), fSubEvent(NULL), @@ -67,7 +66,6 @@ AliRawReaderDateV3::AliRawReaderDateV3(void* event) : AliRawReaderDateV3::AliRawReaderDateV3(const char* fileName, Int_t eventNumber) : - fRequireHeader(kTRUE), fFile(NULL), fEvent(NULL), fSubEvent(NULL), @@ -100,7 +98,6 @@ AliRawReaderDateV3::AliRawReaderDateV3(const char* fileName, AliRawReaderDateV3::AliRawReaderDateV3(const AliRawReaderDateV3& rawReader) : AliRawReader(rawReader), - fRequireHeader(rawReader.fRequireHeader), fFile(rawReader.fFile), fEvent(rawReader.fEvent), fSubEvent(rawReader.fSubEvent), diff --git a/RAW/AliRawReaderDateV3.h b/RAW/AliRawReaderDateV3.h index 9042fc98014..a1320762bab 100644 --- a/RAW/AliRawReaderDateV3.h +++ b/RAW/AliRawReaderDateV3.h @@ -22,9 +22,6 @@ class AliRawReaderDateV3: public AliRawReader { AliRawReaderDateV3(const char* fileName, Int_t eventNumber = -1); virtual ~AliRawReaderDateV3(); - void RequireHeader(Bool_t required = kTRUE) - {fRequireHeader = required;}; - virtual UInt_t GetType() const; virtual UInt_t GetRunNumber() const; virtual const UInt_t* GetEventId() const; @@ -54,8 +51,6 @@ class AliRawReaderDateV3: public AliRawReader { protected : virtual Bool_t ReadNext(UChar_t* data, Int_t size); - Bool_t fRequireHeader; // if false, data without header is accepted - FILE* fFile; // DATE file eventHeaderStruct* fEvent; // raw data super event eventHeaderStruct* fSubEvent; // raw data sub event diff --git a/RAW/AliRawReaderRoot.cxx b/RAW/AliRawReaderRoot.cxx index ed16d4b8191..84c10ce669b 100644 --- a/RAW/AliRawReaderRoot.cxx +++ b/RAW/AliRawReaderRoot.cxx @@ -352,20 +352,23 @@ Bool_t AliRawReaderRoot::ReadHeader() // continue with the next equipment if no data left in the payload if (fPosition >= fEnd) continue; - // 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); - fEquipment->GetEquipmentHeader()->Dump(); - fCount = 0; - fPosition = fEnd; - fErrorCode = kErrNoDataHeader; - continue; + 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!"); + Warning("ReadHeader", "skipping %d bytes", fEnd - fPosition); + fEquipment->GetEquipmentHeader()->Dump(); + fCount = 0; + fPosition = fEnd; + fErrorCode = kErrNoDataHeader; + continue; + } + + // "read" the data header + fHeader = (AliRawDataHeader*) fPosition; + fPosition += sizeof(AliRawDataHeader); } - // "read" the data header - fHeader = (AliRawDataHeader*) fPosition; - fPosition += sizeof(AliRawDataHeader); if (fHeader->fSize != 0xFFFFFFFF) { fCount = fHeader->fSize - sizeof(AliRawDataHeader); } else { @@ -512,17 +515,19 @@ Int_t AliRawReaderRoot::CheckData() const // continue with the next sub event if no data left in the payload if (position >= end) continue; + if (fRequireHeader) { // check that there are enough bytes left for the data header - if (position + sizeof(AliRawDataHeader) > end) { - result |= kErrNoDataHeader; - continue; - } + if (position + sizeof(AliRawDataHeader) > end) { + result |= kErrNoDataHeader; + continue; + } - // check consistency of data size in the header and in the equipment - AliRawDataHeader* header = (AliRawDataHeader*) position; - if (header->fSize != 0xFFFFFFFF) { - if (position + header->fSize > end) { - result |= kErrSize; + // check consistency of data size in the header and in the equipment + AliRawDataHeader* header = (AliRawDataHeader*) position; + if (header->fSize != 0xFFFFFFFF) { + if (position + header->fSize > end) { + result |= kErrSize; + } } } }; -- 2.43.0