From 16048fcf22dfc586227653dd56176ce27bf636e1 Mon Sep 17 00:00:00 2001 From: tkuhr Date: Fri, 14 Nov 2003 12:59:12 +0000 Subject: [PATCH] new class AliRawReaderDate for reading DATE events --- RAW/AliRawReaderDate.cxx | 241 +++++++++++++++++++++++++++++++++++++++ RAW/AliRawReaderDate.h | 43 +++++++ RAW/LinkDef.h | 1 + RAW/libRAW.pkg | 1 + 4 files changed, 286 insertions(+) create mode 100644 RAW/AliRawReaderDate.cxx create mode 100644 RAW/AliRawReaderDate.h diff --git a/RAW/AliRawReaderDate.cxx b/RAW/AliRawReaderDate.cxx new file mode 100644 index 00000000000..739f05a8e7f --- /dev/null +++ b/RAW/AliRawReaderDate.cxx @@ -0,0 +1,241 @@ +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +/////////////////////////////////////////////////////////////////////////////// +// +// This is a class for reading a raw data from a date event and providing +// information about digits +// +/////////////////////////////////////////////////////////////////////////////// + +#include "AliRawReaderDate.h" +#ifdef ALI_DATE +#include "event.h" +#endif + +ClassImp(AliRawReaderDate) + + +AliRawReaderDate::AliRawReaderDate( +#ifdef ALI_DATE + void* event +#else + void* /* event */ +#endif +) +{ +// create an object to read digits from the given date event + +#ifdef ALI_DATE + fEvent = (eventHeaderStruct*) event; + fSubEvent = NULL; + fPosition = fEnd = NULL; +#else + Fatal("AliRawReaderDate", "this class was compiled without DATE"); +#endif +} + +AliRawReaderDate::AliRawReaderDate(const AliRawReaderDate& rawReader) : + AliRawReader(rawReader) +{ +// copy constructor + + fEvent = rawReader.fEvent; + fSubEvent = rawReader.fSubEvent; + fPosition = rawReader.fPosition; + fEnd = rawReader.fEnd; +} + +AliRawReaderDate& AliRawReaderDate::operator = (const AliRawReaderDate& + rawReader) +{ +// assignment operator + + this->~AliRawReaderDate(); + new(this) AliRawReaderDate(rawReader); + return *this; +} + + +UInt_t AliRawReaderDate::GetType() const +{ +// get the type from the event header + +#ifdef ALI_DATE + if (!fEvent) return 0; + return fEvent->eventType; +#else + return 0; +#endif +} + +UInt_t AliRawReaderDate::GetRunNumber() const +{ +// get the run number from the event header + +#ifdef ALI_DATE + if (!fEvent) return 0; + return fEvent->eventRunNb; +#else + return 0; +#endif +} + +const UInt_t* AliRawReaderDate::GetEventId() const +{ +// get the event id from the event header + +#ifdef ALI_DATE + if (!fEvent) return NULL; + return fEvent->eventId; +#else + return NULL; +#endif +} + +const UInt_t* AliRawReaderDate::GetTriggerPattern() const +{ +// get the trigger pattern from the event header + +#ifdef ALI_DATE + if (!fEvent) return NULL; + return fEvent->eventTriggerPattern; +#else + return NULL; +#endif +} + +const UInt_t* AliRawReaderDate::GetDetectorPattern() const +{ +// get the detector pattern from the event header + +#ifdef ALI_DATE + if (!fEvent) return NULL; + return fEvent->eventDetectorPattern; +#else + return NULL; +#endif +} + +const UInt_t* AliRawReaderDate::GetAttributes() const +{ +// get the type attributes from the event header + +#ifdef ALI_DATE + if (!fEvent) return NULL; + return fEvent->eventTypeAttribute; +#else + return NULL; +#endif +} + +UInt_t AliRawReaderDate::GetGDCId() const +{ +// get the GDC Id from the event header + +#ifdef ALI_DATE + if (!fEvent) return 0; + return fEvent->eventGdcId; +#else + return 0; +#endif +} + + +Bool_t AliRawReaderDate::ReadMiniHeader() +{ +// read a mini header at the current position +// returns kFALSE if the mini header could not be read + +#ifdef ALI_DATE + if (!fEvent) return kFALSE; + do { + if (fCount > 0) fPosition += fCount; // skip payload if event was not selected + if (!fSubEvent || (fPosition >= fEnd)) { // new sub event + if (fPosition >= ((UChar_t*)fEvent)+fEvent->eventSize) return kFALSE; // end of data + if (fSubEvent) { + fSubEvent = (eventHeaderStruct*) (((UChar_t*)fSubEvent) + + fSubEvent->eventSize); + } else { + if (fEvent->eventSize <= fEvent->eventHeadSize) return kFALSE; // no sub events + fSubEvent = (eventHeaderStruct*) (((UChar_t*)fEvent) + + fEvent->eventHeadSize); + } + fCount = 0; + fPosition = ((UChar_t*)fSubEvent) + fSubEvent->eventHeadSize + + sizeof(equipmentHeaderStruct); + fEnd = ((UChar_t*)fSubEvent) + fSubEvent->eventSize; + } + if (fPosition >= fEnd) continue; // no data left in the payload + if (fPosition + sizeof(AliMiniHeader) > fEnd) { + Error("ReadMiniHeader", "could not read data!"); + return kFALSE; + } + fMiniHeader = (AliMiniHeader*) fPosition; + fPosition += sizeof(AliMiniHeader); + CheckMiniHeader(); + fCount = fMiniHeader->fSize; + if (fPosition + fCount > fEnd) { // check data size in mini header and sub event + Error("ReadMiniHeader", "size in mini header exceeds event size!"); + fMiniHeader->fSize = fCount = fEnd - fPosition; + } + } while (!IsSelected()); + return kTRUE; +#else + return kFALSE; +#endif +} + +Bool_t AliRawReaderDate::ReadNextData(UChar_t*& data) +{ +// reads the next payload at the current position +// returns kFALSE if the data could not be read + + while (fCount == 0) { + if (!ReadMiniHeader()) return kFALSE; + } + data = fPosition; + fPosition += fCount; + fCount = 0; + return kTRUE; +} + +Bool_t AliRawReaderDate::ReadNext(UChar_t* data, Int_t size) +{ +// reads the next block of data at the current position +// returns kFALSE if the data could not be read + + if (fPosition + size > fEnd) { + Error("ReadNext", "could not read data!"); + return kFALSE; + } + memcpy(data, fPosition, size); + fPosition += size; + fCount -= size; + return kTRUE; +} + + +Bool_t AliRawReaderDate::Reset() +{ +// reset the current position to the beginning of the event + +#ifdef ALI_DATE + fSubEvent = NULL; +#endif + fCount = 0; + fPosition = fEnd = NULL; + return kTRUE; +} diff --git a/RAW/AliRawReaderDate.h b/RAW/AliRawReaderDate.h new file mode 100644 index 00000000000..57932d6f841 --- /dev/null +++ b/RAW/AliRawReaderDate.h @@ -0,0 +1,43 @@ +#ifndef ALIRAWREADERDATE_H +#define ALIRAWREADERDATE_H +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +#include "AliRawReader.h" + +struct eventHeaderStruct; + + +class AliRawReaderDate: public AliRawReader { + public : + AliRawReaderDate(void* event); + AliRawReaderDate(const AliRawReaderDate& rawReader); + AliRawReaderDate& operator = (const AliRawReaderDate& rawReader); + virtual ~AliRawReaderDate() {}; + + virtual UInt_t GetType() const; + virtual UInt_t GetRunNumber() const; + virtual const UInt_t* GetEventId() const; + virtual const UInt_t* GetTriggerPattern() const; + virtual const UInt_t* GetDetectorPattern() const; + virtual const UInt_t* GetAttributes() const; + virtual UInt_t GetGDCId() const; + + virtual Bool_t ReadMiniHeader(); + virtual Bool_t ReadNextData(UChar_t*& data); + + virtual Bool_t Reset(); + + protected : + virtual Bool_t ReadNext(UChar_t* data, Int_t size); + + eventHeaderStruct* fEvent; // raw data super event + eventHeaderStruct* fSubEvent; // raw data sub event + + UChar_t* fPosition; // current position in the raw data + UChar_t* fEnd; // end position of the current subevent + + ClassDef(AliRawReaderDate, 0) // class for reading raw digits from a root file +}; + +#endif diff --git a/RAW/LinkDef.h b/RAW/LinkDef.h index 5681a0aa46e..aa81c286606 100644 --- a/RAW/LinkDef.h +++ b/RAW/LinkDef.h @@ -22,6 +22,7 @@ #pragma link C++ class AliRawReader+; #pragma link C++ class AliRawReaderFile+; #pragma link C++ class AliRawReaderRoot+; +#pragma link C++ class AliRawReaderDate+; #pragma link C++ class AliTPCBuffer160+; #pragma link C++ class AliTPCCompression+; #pragma link C++ class AliTPCHNode+; diff --git a/RAW/libRAW.pkg b/RAW/libRAW.pkg index efbeaa62ca4..0f371259570 100644 --- a/RAW/libRAW.pkg +++ b/RAW/libRAW.pkg @@ -1,5 +1,6 @@ SRCS:= AliRawEvent.cxx \ AliRawReader.cxx AliRawReaderFile.cxx AliRawReaderRoot.cxx \ + AliRawReaderDate.cxx \ AliTPCBuffer160.cxx AliTPCHuffman.cxx AliTPCCompression.cxx \ AliTPCRawStream.cxx \ AliITSRawStream.cxx AliITSRawStreamSPD.cxx \ -- 2.43.0