From 33314186efef24eb32b7a52722afd3c669697c42 Mon Sep 17 00:00:00 2001 From: cvetan Date: Fri, 15 May 2009 14:01:03 +0000 Subject: [PATCH] New flat raw-data event format. The details can be found at: http://indico.cern.ch/getFile.py/access?contribId=2&resId=0&materialId=slides&confId=58946. The raw-data tags are still to be revised. --- MONITOR/deroot.cxx | 4 +- MONITOR/root2date.cxx | 6 +- MONITOR/root2date.h | 7 +- PWG0/TPC/AliROCRawAnalysisSelector.cxx | 2 +- PWG0/TPC/AliROCRawAnalysisSelector.h | 4 +- RAW/AliFilter.h | 4 +- RAW/AliHoughFilter.cxx | 6 +- RAW/AliHoughFilter.h | 6 +- RAW/AliMDC.cxx | 130 +++++++-------- RAW/AliMDC.h | 9 +- RAW/AliRawCastorDB.cxx | 9 +- RAW/AliRawCastorDB.h | 2 +- RAW/AliRawDB.cxx | 119 ++++++-------- RAW/AliRawDB.h | 21 ++- RAW/AliRawData.cxx | 2 +- RAW/AliRawData.h | 20 +-- RAW/AliRawDataArrayV2.cxx | 66 ++++++++ RAW/AliRawDataArrayV2.h | 44 +++++ RAW/AliRawEquipment.cxx | 45 +++-- RAW/AliRawEquipment.h | 11 +- RAW/AliRawEquipmentHeader.h | 2 +- RAW/AliRawEquipmentV2.cxx | 117 +++++++++++++ RAW/AliRawEquipmentV2.h | 65 ++++++++ RAW/AliRawEvent.cxx | 118 ++++---------- RAW/AliRawEvent.h | 19 +-- RAW/AliRawEventHeaderBase.cxx | 57 ++++++- RAW/AliRawEventHeaderBase.h | 15 +- RAW/AliRawEventV2.cxx | 217 +++++++++++++++++++++++++ RAW/AliRawEventV2.h | 78 +++++++++ RAW/AliRawNullDB.cxx | 9 +- RAW/AliRawNullDB.h | 2 +- RAW/AliRawRFIODB.cxx | 9 +- RAW/AliRawRFIODB.h | 2 +- RAW/AliRawReader.h | 4 +- RAW/AliRawReaderChain.cxx | 13 +- RAW/AliRawReaderRoot.cxx | 67 ++++---- RAW/AliRawReaderRoot.h | 15 +- RAW/AliRawRootdDB.cxx | 9 +- RAW/AliRawRootdDB.h | 2 +- RAW/AliRawVEquipment.cxx | 42 +++++ RAW/AliRawVEquipment.h | 57 +++++++ RAW/AliRawVEvent.cxx | 43 +++++ RAW/AliRawVEvent.h | 66 ++++++++ RAW/RAWDatabaseLinkDef.h | 13 +- RAW/alirawdump_main.cxx | 14 +- RAW/libRAWDatabase.pkg | 5 +- STEER/AliReconstruction.cxx | 4 +- 47 files changed, 1185 insertions(+), 396 deletions(-) create mode 100644 RAW/AliRawDataArrayV2.cxx create mode 100644 RAW/AliRawDataArrayV2.h create mode 100644 RAW/AliRawEquipmentV2.cxx create mode 100644 RAW/AliRawEquipmentV2.h create mode 100644 RAW/AliRawEventV2.cxx create mode 100644 RAW/AliRawEventV2.h create mode 100644 RAW/AliRawVEquipment.cxx create mode 100644 RAW/AliRawVEquipment.h create mode 100644 RAW/AliRawVEvent.cxx create mode 100644 RAW/AliRawVEvent.h diff --git a/MONITOR/deroot.cxx b/MONITOR/deroot.cxx index 99a8962f04a..f0835a0ea54 100644 --- a/MONITOR/deroot.cxx +++ b/MONITOR/deroot.cxx @@ -29,7 +29,7 @@ int deroot(const char *rootFileName, const char *dateFileName, const char *ddlFi cerr << "Error getting RAW tree" << endl; return(1); } - AliRawEvent *rootEvent=NULL; + AliRawVEvent *rootEvent=NULL; t->SetBranchAddress("rawevent", &rootEvent); @@ -42,7 +42,7 @@ int deroot(const char *rootFileName, const char *dateFileName, const char *ddlFi UInt_t eventSize = 10000000; // 10MB by default unsigned char *dateEvent = new unsigned char[eventSize]; for(Long_t gdcCounter=0; gdcCounterGetEntries(); gdcCounter++) { - rootEvent=new AliRawEvent; + rootEvent=NULL; t->GetEntry(gdcCounter); if (rootEvent->GetHeader()->GetEventSize() > eventSize) { delete [] dateEvent; diff --git a/MONITOR/root2date.cxx b/MONITOR/root2date.cxx index 2136c24c041..0e2f9238f59 100644 --- a/MONITOR/root2date.cxx +++ b/MONITOR/root2date.cxx @@ -7,14 +7,14 @@ #include "root2date.h" -int Root2Date(AliRawEvent *gdcRootEvent, unsigned char *gdcDateEvent, char *ddlDir) { +int Root2Date(AliRawVEvent *gdcRootEvent, unsigned char *gdcDateEvent, char *ddlDir) { unsigned char *p=gdcDateEvent; int ldcCounter, equipmentCounter, chunkSize; - AliRawEquipment *aliEquipment=NULL; + AliRawVEquipment *aliEquipment=NULL; AliRawEquipmentHeader *aliEquipmentHeader=NULL; AliRawEventHeaderBase *aliHeader=NULL; - AliRawEvent *ldcRootEvent=NULL; + AliRawVEvent *ldcRootEvent=NULL; aliHeader=gdcRootEvent->GetHeader(); diff --git a/MONITOR/root2date.h b/MONITOR/root2date.h index 4227130f4fe..b38aea13299 100644 --- a/MONITOR/root2date.h +++ b/MONITOR/root2date.h @@ -7,16 +7,15 @@ #ifndef ROOT2DATE_H #define ROOT2DATE_H -#include "AliRawData.h" -#include "AliRawEvent.h" +#include "AliRawVEvent.h" #include "AliRawEventHeaderBase.h" -#include "AliRawEquipment.h" +#include "AliRawVEquipment.h" #include "AliRawEquipmentHeader.h" #include "AliRawData.h" #include "AliDAQ.h" #include -int Root2Date(AliRawEvent *gdcRootEvent, unsigned char *gdcDateEvent, char *ddlDir); +int Root2Date(AliRawVEvent *gdcRootEvent, unsigned char *gdcDateEvent, char *ddlDir); #endif diff --git a/PWG0/TPC/AliROCRawAnalysisSelector.cxx b/PWG0/TPC/AliROCRawAnalysisSelector.cxx index 52050418731..1154ecc7ca7 100644 --- a/PWG0/TPC/AliROCRawAnalysisSelector.cxx +++ b/PWG0/TPC/AliROCRawAnalysisSelector.cxx @@ -20,7 +20,7 @@ #include -#include +#include #include #include #include diff --git a/PWG0/TPC/AliROCRawAnalysisSelector.h b/PWG0/TPC/AliROCRawAnalysisSelector.h index 7c5e0bd8eab..d40b24ad7dd 100644 --- a/PWG0/TPC/AliROCRawAnalysisSelector.h +++ b/PWG0/TPC/AliROCRawAnalysisSelector.h @@ -9,7 +9,7 @@ // TODO explain this // -class AliRawEvent; +class AliRawVEvent; class TTree; class AliTPCParamSR; class AliTPCRawHistograms; @@ -29,7 +29,7 @@ class AliROCRawAnalysisSelector : public TSelector { virtual void Terminate(); protected: - AliRawEvent* fRawEvent; + AliRawVEvent* fRawEvent; TTree* fTree; AliTPCParamSR* fParam; // TPC hardware params diff --git a/RAW/AliFilter.h b/RAW/AliFilter.h index b205cf11289..637ee7c855a 100644 --- a/RAW/AliFilter.h +++ b/RAW/AliFilter.h @@ -13,13 +13,13 @@ #include -class AliRawEvent; +class AliRawVEvent; class AliESDEvent; class AliFilter: public TObject { public: - virtual Bool_t Filter(AliRawEvent* event, AliESDEvent* esd) = 0; + virtual Bool_t Filter(AliRawVEvent* event, AliESDEvent* esd) = 0; private: ClassDef(AliFilter, 0) // base class for high level filter algorithms diff --git a/RAW/AliHoughFilter.cxx b/RAW/AliHoughFilter.cxx index d5a650580b6..9db18e2639c 100644 --- a/RAW/AliHoughFilter.cxx +++ b/RAW/AliHoughFilter.cxx @@ -79,7 +79,7 @@ fITSgeom(NULL) } //_____________________________________________________________________________ -Bool_t AliHoughFilter::Filter(AliRawEvent* event, AliESDEvent* esd) +Bool_t AliHoughFilter::Filter(AliRawVEvent* event, AliESDEvent* esd) { // Run fast online reconstruction // based on the HLT tracking algorithms @@ -105,7 +105,7 @@ Bool_t AliHoughFilter::Filter(AliRawEvent* event, AliESDEvent* esd) } //_____________________________________________________________________________ -void AliHoughFilter::RunITSclusterer(AliRawEvent* event, TTree *treeClusters) +void AliHoughFilter::RunITSclusterer(AliRawVEvent* event, TTree *treeClusters) { // Run ITS Clusterer // The clusters are stored in a tree @@ -139,7 +139,7 @@ void AliHoughFilter::RunITSvertexer(AliESDEvent* esd, TTree *treeClusters) } //_____________________________________________________________________________ -void AliHoughFilter::RunTPCtracking(AliRawEvent* event, AliESDEvent* esd) +void AliHoughFilter::RunTPCtracking(AliRawVEvent* event, AliESDEvent* esd) { // Run hough transform tracking in TPC // The z of the vertex is taken from the ESD diff --git a/RAW/AliHoughFilter.h b/RAW/AliHoughFilter.h index 0f9e955cf7b..a8c09f82163 100644 --- a/RAW/AliHoughFilter.h +++ b/RAW/AliHoughFilter.h @@ -20,11 +20,11 @@ class AliHoughFilter: public AliFilter { public: AliHoughFilter(); - virtual Bool_t Filter(AliRawEvent* event, AliESDEvent* esd); + virtual Bool_t Filter(AliRawVEvent* event, AliESDEvent* esd); - void RunITSclusterer(AliRawEvent* event, TTree *treeClusters); + void RunITSclusterer(AliRawVEvent* event, TTree *treeClusters); void RunITSvertexer(AliESDEvent* esd, TTree *treeClusters); - void RunTPCtracking(AliRawEvent* event, AliESDEvent* esd); + void RunTPCtracking(AliRawVEvent* event, AliESDEvent* esd); void RunITStracking(AliESDEvent* esd, TTree *treeClusters); private: AliHoughFilter(const AliHoughFilter&); diff --git a/RAW/AliMDC.cxx b/RAW/AliMDC.cxx index e2bf176a000..f5a2eeb93a9 100644 --- a/RAW/AliMDC.cxx +++ b/RAW/AliMDC.cxx @@ -23,12 +23,12 @@ // // // AliMDC // // // -// Set of classes defining the ALICE RAW event format. The AliRawEvent // +// Set of classes defining the ALICE RAW event format. The AliRawEventV2// // class defines a RAW event. It consists of an AliEventHeader object // // an AliEquipmentHeader object, an AliRawData object and an array of // -// sub-events, themselves also being AliRawEvents. The number of // +// sub-events, themselves also being AliRawEventV2s. The number of // // sub-events depends on the number of DATE LDC's. // -// The AliRawEvent objects are written to a ROOT file using different // +// The AliRawEventV2 objects are written to a ROOT file using different // // technologies, i.e. to local disk via AliRawDB or via rfiod using // // AliRawRFIODB or via rootd using AliRawRootdDB or to CASTOR via // // rootd using AliRawCastorDB (and for performance testing there is // @@ -51,6 +51,7 @@ #include #include #include +#include #include #ifdef USE_EB @@ -62,12 +63,12 @@ #include #include -#include "AliRawEvent.h" +#include "AliRawEventV2.h" #include "AliRawEventHeaderBase.h" -#include "AliRawEquipment.h" +#include "AliRawEquipmentV2.h" #include "AliRawEquipmentHeader.h" +#include "AliRawDataArrayV2.h" #include "AliRawData.h" -#include "AliStats.h" #include "AliRawDB.h" #include "AliRawRFIODB.h" #include "AliRawCastorDB.h" @@ -90,9 +91,8 @@ AliMDC::AliMDC(Int_t compress, Bool_t deleteFiles, EFilterMode filterMode, Double_t maxSizeTagDB, const char* fileNameTagDB, const char *guidFileFolder, Int_t basketsize) : - fEvent(new AliRawEvent), + fEvent(new AliRawEventV2), fESD(NULL), - fStats(NULL), fRawDB(NULL), fTagDB(NULL), fEventTag(new AliRawEventTag), @@ -127,6 +127,11 @@ AliMDC::AliMDC(Int_t compress, Bool_t deleteFiles, EFilterMode filterMode, // in order to allow big raw data files TTree::SetMaxTreeSize(20000000000LL); + AliRawEquipmentHeader::Class()->IgnoreTObjectStreamer(); + AliRawEquipmentV2::Class()->IgnoreTObjectStreamer(); + AliRawEventV2::Class()->IgnoreTObjectStreamer(); + AliRawDataArrayV2::Class()->IgnoreTObjectStreamer(); + TBufferFile::SetGlobalReadParam(5); // This line is needed in case of a stand-alone application w/o @@ -179,7 +184,6 @@ AliMDC::~AliMDC() fFilters.Delete(); if(fTagDB) delete fTagDB; delete fRawDB; - delete fStats; delete fESD; delete fEvent; delete fEventTag; @@ -228,16 +232,13 @@ Int_t AliMDC::Open(EWriteMode mode, const char* fileName, Info("Open", "Filling raw DB %s\n", fRawDB->GetDBName()); - // Create AliStats object - fStats = new AliStats(fRawDB->GetDBName(), fCompress, - fFilterMode != kFilterOff); return 0; } //______________________________________________________________________________ Int_t AliMDC::ProcessEvent(void* event, Bool_t isIovecArray) { -// Convert the DATE event to an AliRawEvent object and store it in the raw DB, +// Convert the DATE event to an AliRawEventV2 object and store it in the raw DB, // optionally also run the filter. // event is either a pointer to the streamlined event // or, if isIovecArray is kTRUE, a pointer to an array of iovecs with one @@ -245,8 +246,10 @@ Int_t AliMDC::ProcessEvent(void* event, Bool_t isIovecArray) // The return value is the number of written bytes or an error code const Long64_t kFileSizeErrorLevel = 19000000000LL; + Int_t objectNumber = TProcessID::GetObjectCount(); + Long64_t currentFileSize = GetTotalSize(); - AliDebug(1,Form("current file size is %lld bytes",currentFileSize)); + // AliDebug(1,Form("current file size is %lld bytes",currentFileSize)); if(currentFileSize > kFileSizeErrorLevel) { Error("ProcessEvent", "file size (%lu) exceeds the limit " , currentFileSize); @@ -262,16 +265,19 @@ Int_t AliMDC::ProcessEvent(void* event, Bool_t isIovecArray) // Read event header if ((status = header->ReadHeader(data)) != (Int_t)header->GetHeadSize()) { + Error("ProcessEvent","Wrong event header format (%d != %d)", + status,(Int_t)header->GetHeadSize()); return kErrHeader; } - if (AliDebugLevel() > 2) ToAliDebug(3, header->Dump();); + // if (AliDebugLevel() > 2) ToAliDebug(3, header->Dump();); // Check event type and skip "Start of Run", "End of Run", // "Start of Run Files" and "End of Run Files" Int_t size = header->GetEventSize() - header->GetHeadSize(); - - AliDebug(1, Form("Processing %s (%d bytes)", header->GetTypeName(), size)); + UInt_t eventType = header->Get("Type"); + + // AliDebug(1, Form("Processing %s (%d bytes)", header->GetTypeName(), size)); // Amount of data left to read for this event Int_t toRead = size; @@ -294,9 +300,9 @@ Int_t AliMDC::ProcessEvent(void* event, Bool_t isIovecArray) while (toRead > 0) { if (isIovecArray) data = (char*) ((iovec*) event)[nsub].iov_base; - AliDebug(1, Form("reading LDC %d", nsub)); + // AliDebug(1, Form("reading LDC %d", nsub)); - AliRawEvent *subEvent = fEvent->NextSubEvent(); + AliRawEventV2 *subEvent = fEvent->NextSubEvent(); // Read sub-event header AliRawEventHeaderBase *subHeader = subEvent->GetHeader(data); @@ -304,7 +310,7 @@ Int_t AliMDC::ProcessEvent(void* event, Bool_t isIovecArray) return kErrSubHeader; } - if (AliDebugLevel() > 2) ToAliDebug(3, subHeader->Dump();); + // if (AliDebugLevel() > 2) ToAliDebug(3, subHeader->Dump();); toRead -= subHeader->GetHeadSize(); @@ -319,14 +325,14 @@ Int_t AliMDC::ProcessEvent(void* event, Bool_t isIovecArray) } // Read Equipment Headers (in case of physics or calibration event) - if (header->Get("Type") == AliRawEventHeaderBase::kPhysicsEvent || - header->Get("Type") == AliRawEventHeaderBase::kCalibrationEvent || - header->Get("Type") == AliRawEventHeaderBase::kSystemSoftwareTriggerEvent || - header->Get("Type") == AliRawEventHeaderBase::kDetectorSoftwareTriggerEvent || - header->Get("Type") == AliRawEventHeaderBase::kStartOfData || - header->Get("Type") == AliRawEventHeaderBase::kEndOfData) { + if (eventType == AliRawEventHeaderBase::kPhysicsEvent || + eventType == AliRawEventHeaderBase::kCalibrationEvent || + eventType == AliRawEventHeaderBase::kSystemSoftwareTriggerEvent || + eventType == AliRawEventHeaderBase::kDetectorSoftwareTriggerEvent || + eventType == AliRawEventHeaderBase::kStartOfData || + eventType == AliRawEventHeaderBase::kEndOfData) { while (rawSize > 0) { - AliRawEquipment &equipment = *subEvent->NextEquipment(); + AliRawEquipmentV2 &equipment = *subEvent->NextEquipment(); AliRawEquipmentHeader &equipmentHeader = *equipment.GetEquipmentHeader(); Int_t equipHeaderSize = equipmentHeader.HeaderSize(); @@ -335,13 +341,15 @@ Int_t AliMDC::ProcessEvent(void* event, Bool_t isIovecArray) return kErrEquipmentHeader; } - if (AliDebugLevel() > 2) ToAliDebug(3, equipmentHeader.Dump();); + // if (AliDebugLevel() > 2) ToAliDebug(3, equipmentHeader.Dump();); toRead -= equipHeaderSize; rawSize -= equipHeaderSize; // Read equipment raw data - AliRawData &subRaw = *equipment.GetRawData(); + AliRawDataArrayV2 *arr = fRawDB->GetRawDataArray(equipmentHeader.GetEquipmentSize(), + equipmentHeader.GetId()); + AliRawData &subRaw = *equipment.NextRawData(arr); Int_t eqSize = equipmentHeader.GetEquipmentSize() - equipHeaderSize; if ((status = ReadRawData(subRaw, eqSize, data)) != eqSize) { @@ -354,8 +362,13 @@ Int_t AliMDC::ProcessEvent(void* event, Bool_t isIovecArray) } else { // Read only raw data but no equipment header if (rawSize) { - AliRawEquipment &equipment = *subEvent->NextEquipment(); - AliRawData &subRaw = *equipment.GetRawData(); + AliRawEquipmentV2 &equipment = *subEvent->NextEquipment(); + AliRawEquipmentHeader &equipmentHeader = + *equipment.GetEquipmentHeader(); + equipmentHeader.Reset(); + AliRawDataArrayV2 *arr = fRawDB->GetRawDataArray(equipmentHeader.GetEquipmentSize(), + equipmentHeader.GetId()); + AliRawData &subRaw = *equipment.NextRawData(arr); if ((status = ReadRawData(subRaw, rawSize, data)) != rawSize) { return kErrEquipment; } @@ -369,12 +382,12 @@ Int_t AliMDC::ProcessEvent(void* event, Bool_t isIovecArray) // High Level Event Filter if (fFilterMode != kFilterOff) { - if (header->Get("Type") == AliRawEventHeaderBase::kPhysicsEvent || - header->Get("Type") == AliRawEventHeaderBase::kCalibrationEvent || - header->Get("Type") == AliRawEventHeaderBase::kSystemSoftwareTriggerEvent || - header->Get("Type") == AliRawEventHeaderBase::kDetectorSoftwareTriggerEvent || - header->Get("Type") == AliRawEventHeaderBase::kStartOfData || - header->Get("Type") == AliRawEventHeaderBase::kEndOfData) { + if (eventType == AliRawEventHeaderBase::kPhysicsEvent || + eventType == AliRawEventHeaderBase::kCalibrationEvent || + eventType == AliRawEventHeaderBase::kSystemSoftwareTriggerEvent || + eventType == AliRawEventHeaderBase::kDetectorSoftwareTriggerEvent || + eventType == AliRawEventHeaderBase::kStartOfData || + eventType == AliRawEventHeaderBase::kEndOfData) { Bool_t result = kFALSE; for (Int_t iFilter = 0; iFilter < fFilters.GetEntriesFast(); iFilter++) { AliFilter* filter = (AliFilter*) fFilters[iFilter]; @@ -385,15 +398,13 @@ Int_t AliMDC::ProcessEvent(void* event, Bool_t isIovecArray) } } - // Set stat info for first event of this file - if (fRawDB->GetEvents() == 0) - fStats->SetFirstId(header->Get("RunNb"), header->GetP("Id")[0]); - // Store raw event in tree Int_t nBytes = fRawDB->Fill(); + TProcessID::SetObjectCount(objectNumber); + // Fill the event tag object - fEventTag->SetHeader(fEvent->GetHeader()); + fEventTag->SetHeader(header); fEventTag->SetGUID(fRawDB->GetDB()->GetUUID().AsString()); fEventTag->SetEventNumber(fRawDB->GetEvents()-1); @@ -419,6 +430,8 @@ Int_t AliMDC::ProcessEvent(void* event, Bool_t isIovecArray) // Make top event object ready for next event data fEvent->Reset(); + fRawDB->Reset(); + // Clean up HLT ESD for the next event if (fESD) fESD->Reset(); @@ -445,12 +458,9 @@ Long64_t AliMDC::Close() if (!fRawDB) return -1; - fRawDB->WriteStats(fStats); Long64_t filesize = fRawDB->Close(); delete fRawDB; fRawDB = NULL; - delete fStats; - fStats = NULL; return filesize; } @@ -499,7 +509,6 @@ Int_t AliMDC::Run(const char* inputFile, Bool_t loop, // Used for statistics TStopwatch timer; timer.Start(); - Double_t told = 0, tnew = 0; Float_t chunkSize = maxFileSize/100, nextChunk = chunkSize; // Create new raw DB. @@ -516,6 +525,7 @@ Int_t AliMDC::Run(const char* inputFile, Bool_t loop, Int_t numEvents = 0; AliRawEventHeaderBase header; + AliRawEventHeaderBase *hdr = NULL; while (kTRUE) { @@ -541,8 +551,6 @@ Int_t AliMDC::Run(const char* inputFile, Bool_t loop, Error("Run", "AliMDC was compiled without event builder support"); delete fRawDB; fRawDB = NULL; - delete fStats; - fStats = NULL; return 1; #endif @@ -567,7 +575,12 @@ Int_t AliMDC::Run(const char* inputFile, Bool_t loop, } } char *data = (char *)header.HeaderBaseBegin(); - AliRawEventHeaderBase *hdr = AliRawEventHeaderBase::Create(data); + if (!hdr) { + hdr = AliRawEventHeaderBase::Create(data); + } + else { + memcpy(hdr->HeaderBaseBegin(), header.HeaderBaseBegin(), header.HeaderBaseSize()); + } Int_t nrecv; if ((nrecv = Read(fd, hdr->HeaderBegin(), hdr->HeaderSize())) != hdr->HeaderSize()) { @@ -606,7 +619,6 @@ Int_t AliMDC::Run(const char* inputFile, Bool_t loop, delete hdr; return 1; } - delete hdr; } Int_t result = ProcessEvent(event, !inputFile); @@ -615,17 +627,11 @@ Int_t AliMDC::Run(const char* inputFile, Bool_t loop, if (result >= 0) { numEvents++; - if (!(numEvents%10)) - printf("Processed event %d (%d)\n", numEvents, fRawDB->GetEvents()); } if (result > 0) { // Filling time statistics if (fRawDB->GetBytesWritten() > nextChunk) { - tnew = timer.RealTime(); - fStats->Fill(tnew-told); - told = tnew; - timer.Continue(); nextChunk += chunkSize; } @@ -636,24 +642,16 @@ Int_t AliMDC::Run(const char* inputFile, Bool_t loop, printf("Written raw DB at a rate of %.1f MB/s\n", fRawDB->GetBytesWritten() / timer.RealTime() / 1000000.); - // Write stats object to raw db, run db, MySQL and AliEn - fRawDB->WriteStats(fStats); - delete fStats; - fStats = NULL; - if (!fRawDB->NextFile()) { Error("Run", "error opening next raw data file"); Close(); if (inputFile) delete[] event; + delete hdr; return 1; } printf("Filling raw DB %s\n", fRawDB->GetDBName()); - fStats = new AliStats(fRawDB->GetDBName(), fCompress, - fFilterMode != kFilterOff); - timer.Start(); - told = 0, tnew = 0; nextChunk = chunkSize; } @@ -684,6 +682,8 @@ Int_t AliMDC::Run(const char* inputFile, Bool_t loop, } } + delete hdr; + printf("Written raw DB at a rate of %.1f MB/s\n", fRawDB->GetBytesWritten() / timer.RealTime() / 1000000.); diff --git a/RAW/AliMDC.h b/RAW/AliMDC.h index e12ddd0b9d5..d5f5fb97032 100644 --- a/RAW/AliMDC.h +++ b/RAW/AliMDC.h @@ -25,23 +25,19 @@ #endif // Forward class declarations -class AliRawEvent; class AliRawEventHeaderBase; class AliRawEquipmentHeader; class AliRawData; class AliRawDB; class AliTagDB; class AliRawEventTag; -class AliStats; class AliESDEvent; -#include "AliRawEvent.h" +#include "AliRawEventV2.h" #include "AliESDEvent.h" -#include "AliStats.h" #include "AliRawDB.h" #include "AliTagDB.h" #include "AliRawData.h" -#include "AliRawDataArray.h" #include "AliRawEventTag.h" class AliMDC : public TObject { @@ -97,9 +93,8 @@ private: AliMDCInterruptHandler& operator=(const AliMDCInterruptHandler& handler); // Not implemented }; - AliRawEvent *fEvent; // produced AliRawEvent + AliRawEventV2 *fEvent; // produced AliRawEvent AliESDEvent *fESD; // pointer to HLT ESD object - AliStats *fStats; // statistics AliRawDB *fRawDB; // raw data DB AliTagDB *fTagDB; // tag DB AliRawEventTag *fEventTag; // raw-data event tag object diff --git a/RAW/AliRawCastorDB.cxx b/RAW/AliRawCastorDB.cxx index ba03e9f3e3e..c93f7ae79ed 100644 --- a/RAW/AliRawCastorDB.cxx +++ b/RAW/AliRawCastorDB.cxx @@ -32,7 +32,7 @@ ClassImp(AliRawCastorDB) //______________________________________________________________________________ -AliRawCastorDB::AliRawCastorDB(AliRawEvent *event, +AliRawCastorDB::AliRawCastorDB(AliRawEventV2 *event, AliESDEvent *esd, Int_t compress, const char* fileName,Int_t basketsize) @@ -115,8 +115,9 @@ Long64_t AliRawCastorDB::Close() // Write the tree. Bool_t error = kFALSE; - if (fTree->Write() == 0) - error = kTRUE; + if (fTree) + if (fTree->Write() == 0) + error = kTRUE; if (fESDTree) if (fESDTree->Write() == 0) error = kTRUE; @@ -124,6 +125,8 @@ Long64_t AliRawCastorDB::Close() // Close DB, this also deletes the fTree fRawDB->Close(); + fTree = NULL; + Long64_t filesize = fRawDB->GetEND(); if (fDeleteFiles) { diff --git a/RAW/AliRawCastorDB.h b/RAW/AliRawCastorDB.h index 4b95528a508..777e515a485 100644 --- a/RAW/AliRawCastorDB.h +++ b/RAW/AliRawCastorDB.h @@ -18,7 +18,7 @@ class AliRawCastorDB : public AliRawDB { public: - AliRawCastorDB(AliRawEvent *event, + AliRawCastorDB(AliRawEventV2 *event, AliESDEvent *esd, Int_t compress, const char* fileName = NULL, diff --git a/RAW/AliRawDB.cxx b/RAW/AliRawDB.cxx index 719d97c823f..ca8c1aa3031 100644 --- a/RAW/AliRawDB.cxx +++ b/RAW/AliRawDB.cxx @@ -39,12 +39,10 @@ #include #include "AliESDEvent.h" -#include "AliRawEvent.h" -#include "AliRawDataArray.h" +#include "AliRawEventV2.h" +#include "AliRawDataArrayV2.h" #include "AliRawEventHeaderBase.h" -#include "AliRawEquipment.h" #include "AliRawEquipmentHeader.h" -#include "AliStats.h" #include "AliRawDB.h" @@ -53,12 +51,12 @@ ClassImp(AliRawDB) const char *AliRawDB::fgkAliRootTag = "$Rev$"; -// Split TPC into 9 branches in order to avoid problems with big memory +// Split TPC into 18 branches in order to avoid problems with big memory // consumption in case of TPC events w/o zero-suppression Int_t AliRawDB::fgkDetBranches[AliDAQ::kNDetectors+1] = {1,1,1,18,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,10,1}; //______________________________________________________________________________ -AliRawDB::AliRawDB(AliRawEvent *event, +AliRawDB::AliRawDB(AliRawEventV2 *event, AliESDEvent *esd, Int_t compress, const char* fileName, @@ -79,15 +77,15 @@ AliRawDB::AliRawDB(AliRawEvent *event, // Create a new raw DB for (Int_t iDet = 0; iDet < AliDAQ::kNDetectors; iDet++) { - fDetRawData[iDet] = new AliRawDataArray*[fgkDetBranches[iDet]]; + fDetRawData[iDet] = new AliRawDataArrayV2*[fgkDetBranches[iDet]]; Int_t nDDLsPerBranch = AliDAQ::NumberOfDdls(iDet)/fgkDetBranches[iDet]; for (Int_t iBranch = 0; iBranch < fgkDetBranches[iDet]; iBranch++) - fDetRawData[iDet][iBranch] = new AliRawDataArray(nDDLsPerBranch); + fDetRawData[iDet][iBranch] = new AliRawDataArrayV2(nDDLsPerBranch); } - fDetRawData[AliDAQ::kNDetectors] = new AliRawDataArray*[fgkDetBranches[AliDAQ::kNDetectors]]; + fDetRawData[AliDAQ::kNDetectors] = new AliRawDataArrayV2*[fgkDetBranches[AliDAQ::kNDetectors]]; for (Int_t iBranch = 0; iBranch < fgkDetBranches[AliDAQ::kNDetectors]; iBranch++) - fDetRawData[AliDAQ::kNDetectors][iBranch] = new AliRawDataArray(100); + fDetRawData[AliDAQ::kNDetectors][iBranch] = new AliRawDataArrayV2(100); if (fileName) { if (!Create(fileName)) @@ -259,9 +257,6 @@ again: return kFALSE; } - // Create raw data TTree - MakeTree(); - return kTRUE; } @@ -287,23 +282,21 @@ void AliRawDB::MakeTree() fTree->BranchRef(); - // splitting 29.6 MB/s, no splitting 35.3 MB/s on P4 2GHz 15k SCSI - //Int_t split = 1; - Int_t split = 0; - TBranch *b = fTree->Branch("rawevent", "AliRawEvent", &fEvent, fBasketSize, split); + Int_t split = 99; + TBranch *b = fTree->Branch("rawevent", "AliRawEventV2", &fEvent, fBasketSize, split); BranchResetBit(b); // Make brach for each sub-detector for (Int_t iDet = 0; iDet < AliDAQ::kNDetectors; iDet++) { for (Int_t iBranch = 0; iBranch < fgkDetBranches[iDet]; iBranch++) { - b = fTree->Branch(Form("%s%d",AliDAQ::DetectorName(iDet),iBranch),"AliRawDataArray", + b = fTree->Branch(Form("%s%d",AliDAQ::DetectorName(iDet),iBranch),"AliRawDataArrayV2", &fDetRawData[iDet][iBranch],fBasketSize,split); BranchResetBit(b); } } // Make special branch for unrecognized raw-data payloads for (Int_t iBranch = 0; iBranch < fgkDetBranches[AliDAQ::kNDetectors]; iBranch++) { - b = fTree->Branch(Form("Common%d",iBranch),"AliRawDataArray", + b = fTree->Branch(Form("Common%d",iBranch),"AliRawDataArrayV2", &fDetRawData[AliDAQ::kNDetectors][iBranch],fBasketSize,split); BranchResetBit(b); } @@ -331,8 +324,9 @@ Long64_t AliRawDB::Close() // Write the tree. Bool_t error = kFALSE; - if (fTree->Write() == 0) - error = kTRUE; + if (fTree) + if (fTree->Write() == 0) + error = kTRUE; if (fESDTree) if (fESDTree->Write() == 0) error = kTRUE; @@ -340,6 +334,8 @@ Long64_t AliRawDB::Close() // Close DB, this also deletes the fTree fRawDB->Close(); + fTree = NULL; + Long64_t filesize = fRawDB->GetEND(); if (fDeleteFiles) { @@ -363,31 +359,10 @@ Long64_t AliRawDB::Close() //______________________________________________________________________________ Int_t AliRawDB::Fill() { - // Fill the trees and return the number of written bytes - - for (Int_t iDet = 0; iDet < (AliDAQ::kNDetectors + 1); iDet++) - for (Int_t iBranch = 0; iBranch < fgkDetBranches[iDet]; iBranch++) - fDetRawData[iDet][iBranch]->ClearData(); + // Fill the trees and return the number of written bytes - // Move the raw-data payloads to the corresponding branches - for(Int_t iSubEvent = 0; iSubEvent < fEvent->GetNSubEvents(); iSubEvent++) { - AliRawEvent *subEvent = fEvent->GetSubEvent(iSubEvent); - for(Int_t iEquipment = 0; iEquipment < subEvent->GetNEquipments(); iEquipment++) { - AliRawEquipment *equipment = subEvent->GetEquipment(iEquipment); - Int_t iDet = AliDAQ::kNDetectors; - Int_t iBranch = 0; // can we split somehow the unrecognized data??? For the moment - no - if(equipment->GetEquipmentHeader()->GetEquipmentSize()) { - UInt_t eqId = equipment->GetEquipmentHeader()->GetId(); - Int_t ddlIndex = -1; - iDet = AliDAQ::DetectorIDFromDdlID(eqId,ddlIndex); - if (iDet < 0 || iDet >= AliDAQ::kNDetectors) - iDet = AliDAQ::kNDetectors; - else - iBranch = (ddlIndex * fgkDetBranches[iDet])/AliDAQ::NumberOfDdls(iDet); - } - equipment->SetRawDataRef(fDetRawData[iDet][iBranch]); - } - } + // Create raw data TTree if it not yet done + if (!fTree) MakeTree(); Double_t bytes = fRawDB->GetBytesWritten(); Bool_t error = kFALSE; @@ -408,7 +383,7 @@ Long64_t AliRawDB::GetTotalSize() // Return the total size of the trees Long64_t total = 0; - { + if (fTree) { Int_t skey = 0; TDirectory *dir = fTree->GetDirectory(); if (dir) { @@ -445,25 +420,6 @@ Long64_t AliRawDB::AutoSave() return nbytes; } -//______________________________________________________________________________ -void AliRawDB::WriteStats(AliStats* stats) -{ - // Write stats to raw DB, local run DB and global MySQL DB. - - AliRawEventHeaderBase &header = *GetEvent()->GetHeader(); - - // Write stats into RawDB - TDirectory *ds = gDirectory; - GetDB()->cd(); - stats->SetEvents(GetEvents()); - stats->SetLastId(header.GetP("Id")[0]); - stats->SetFileSize(GetBytesWritten()); - stats->SetCompressionFactor(GetCompressionFactor()); - stats->SetEndTime(); - stats->Write("stats"); - ds->cd(); -} - //______________________________________________________________________________ Bool_t AliRawDB::NextFile(const char* fileName) { @@ -536,3 +492,36 @@ Bool_t AliRawDB::WriteGuidFile(TString &guidFileFolder) return kTRUE; } + + +//______________________________________________________________________________ +void AliRawDB::Reset() +{ + // Clear the raw-data arrays + // Should be done before processing the raw-data event + + for (Int_t iDet = 0; iDet < (AliDAQ::kNDetectors + 1); iDet++) + for (Int_t iBranch = 0; iBranch < fgkDetBranches[iDet]; iBranch++) + fDetRawData[iDet][iBranch]->ClearData(); +} + +//______________________________________________________________________________ +AliRawDataArrayV2 *AliRawDB::GetRawDataArray(UInt_t eqSize, UInt_t eqId) const +{ + // Return the corresponding raw-datra array (branch) + // depending on the equipment ID + + Int_t iDet = AliDAQ::kNDetectors; + Int_t iBranch = 0; // can we split somehow the unrecognized data??? For the moment - no + if(eqSize) { + Int_t ddlIndex = -1; + iDet = AliDAQ::DetectorIDFromDdlID(eqId,ddlIndex); + if (iDet < 0 || iDet >= AliDAQ::kNDetectors) + iDet = AliDAQ::kNDetectors; + else + iBranch = (ddlIndex * fgkDetBranches[iDet])/AliDAQ::NumberOfDdls(iDet); + } + + return fDetRawData[iDet][iBranch]; +} + diff --git a/RAW/AliRawDB.h b/RAW/AliRawDB.h index 633b99413e4..b8a7d5b3d77 100644 --- a/RAW/AliRawDB.h +++ b/RAW/AliRawDB.h @@ -31,16 +31,15 @@ #include "AliDAQ.h" // Forward class declarations -class AliRawEvent; -class AliRawDataArray; -class AliStats; +class AliRawEventV2; +class AliRawDataArrayV2; class TFile; class AliESDEvent; class AliRawDB : public TObject { public: - AliRawDB(AliRawEvent *event, + AliRawDB(AliRawEventV2 *event, AliESDEvent *esd, Int_t compress, const char* fileName = NULL, @@ -55,8 +54,6 @@ public: Long64_t GetTotalSize(); Long64_t AutoSave(); - void WriteStats(AliStats* stats); - void SetMaxSize(Double_t maxSize) { fMaxSize = maxSize; } void SetFS(const char* fs1, const char* fs2 = NULL); void SetDeleteFiles(Bool_t deleteFiles = kTRUE) { fDeleteFiles = deleteFiles; } @@ -66,20 +63,22 @@ public: Double_t GetBytesWritten() const { return fRawDB->GetBytesWritten(); } TFile *GetDB() const { return fRawDB; } const char *GetDBName() const { return fRawDB->GetName(); } - Int_t GetEvents() const { return (Int_t) fTree->GetEntries(); } - AliRawEvent *GetEvent() const { return fEvent; } + Int_t GetEvents() const { return (fTree) ? (Int_t) fTree->GetEntries() : 0; } + AliRawEventV2 *GetEvent() const { return fEvent; } Float_t GetCompressionFactor() const; Int_t GetCompressionMode() const { return fRawDB->GetCompressionLevel(); } Int_t GetBasketSize() const { return fBasketSize; } void Stop() { fStop = kTRUE; } static const char *GetAliRootTag(); Bool_t WriteGuidFile(TString &guidFileFolder); + void Reset(); + AliRawDataArrayV2 *GetRawDataArray(UInt_t eqSize, UInt_t eqId) const; protected: TFile *fRawDB; // DB to store raw data TTree *fTree; // tree used to store raw data - AliRawEvent *fEvent; // AliRawEvent via which data is stored - AliRawDataArray **fDetRawData[AliDAQ::kNDetectors+1]; // Detectors raw-data payload + AliRawEventV2 *fEvent; // AliRawEvent via which data is stored + AliRawDataArrayV2 **fDetRawData[AliDAQ::kNDetectors+1]; // Detectors raw-data payload TTree *fESDTree; // tree for storing HLT ESD information AliESDEvent *fESD; // pointer to HLT ESD object Int_t fCompress; // compression mode (1 default) @@ -101,7 +100,7 @@ private: AliRawDB(const AliRawDB& rawDB); AliRawDB& operator = (const AliRawDB& rawDB); - ClassDef(AliRawDB,4) // Raw DB + ClassDef(AliRawDB,5) // Raw DB }; #endif diff --git a/RAW/AliRawData.cxx b/RAW/AliRawData.cxx index af4d3ec56e3..ef45aa32efc 100644 --- a/RAW/AliRawData.cxx +++ b/RAW/AliRawData.cxx @@ -28,8 +28,8 @@ ClassImp(AliRawData) AliRawData::AliRawData(): +TObject(), fSize(0), -fBufSize(0), fRawData(NULL), fOwner(kTRUE) { diff --git a/RAW/AliRawData.h b/RAW/AliRawData.h index c558604b6f9..5f37e47e9ab 100644 --- a/RAW/AliRawData.h +++ b/RAW/AliRawData.h @@ -23,39 +23,25 @@ public: AliRawData(); virtual ~AliRawData() { if (fOwner) delete [] fRawData; } - inline void SetSize(Int_t size); inline void SetBuffer(void *buf, Int_t size); Int_t GetSize() const { return fSize; } void *GetBuffer() { return fRawData; } private: Int_t fSize; // number of raw data bytes - Int_t fBufSize; //!actual size of fRawData char *fRawData; //[fSize] raw event data Bool_t fOwner; //!if true object owns fRawData buffer - AliRawData(const AliRawData &); // not implemented, usage causes - AliRawData &operator=(const AliRawData &); // link time error + AliRawData(const AliRawData &); + AliRawData &operator=(const AliRawData &); - ClassDef(AliRawData,1) // Alice raw event buffer + ClassDef(AliRawData,2) // Alice raw event buffer }; -void AliRawData::SetSize(Int_t size) -{ - if (size > fBufSize) { - if (fOwner) delete [] fRawData; - fRawData = new char [size]; - fBufSize = size; - fOwner = kTRUE; - } - fSize = size; -} - void AliRawData::SetBuffer(void *buf, Int_t size) { if (fOwner) delete [] fRawData; fRawData = (char *) buf; - fBufSize = size; fSize = size; fOwner = kFALSE; } diff --git a/RAW/AliRawDataArrayV2.cxx b/RAW/AliRawDataArrayV2.cxx new file mode 100644 index 00000000000..409b584dff5 --- /dev/null +++ b/RAW/AliRawDataArrayV2.cxx @@ -0,0 +1,66 @@ +// Author: Cvetan Cheshkov 27/03/2007 + +/************************************************************************** + * Copyright(c) 1998-2003, 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. * + **************************************************************************/ + +////////////////////////////////////////////////////////////////////////// +// // +// AliRawDataArrayV2 // +// A container object which is used in order to write the sub-detector // +// raw-data payloads into a separate branches // +// // +////////////////////////////////////////////////////////////////////////// + +#include "AliRawDataArrayV2.h" +#include "AliRawData.h" + + +ClassImp(AliRawDataArrayV2) + +AliRawDataArrayV2::AliRawDataArrayV2(): +fRawDataArray("AliRawData",100), +fNAlloc(0) +{ + // Default constructor +} + +AliRawDataArrayV2::AliRawDataArrayV2(Int_t n): +fRawDataArray("AliRawData",n), +fNAlloc(0) +{ + // Default constructor +} + +AliRawDataArrayV2::~AliRawDataArrayV2() +{ + fRawDataArray.Delete(); +} + +void AliRawDataArrayV2::ClearData() +{ + fRawDataArray.Clear(); +} + +AliRawData *AliRawDataArrayV2::Add() +{ + Int_t nEntries = fRawDataArray.GetEntriesFast(); + if (nEntries < fNAlloc) { + return (AliRawData *)fRawDataArray[nEntries]; + } + else { + fNAlloc = nEntries + 1; + return new (fRawDataArray[nEntries]) AliRawData(); + } +} diff --git a/RAW/AliRawDataArrayV2.h b/RAW/AliRawDataArrayV2.h new file mode 100644 index 00000000000..a8abea68ec1 --- /dev/null +++ b/RAW/AliRawDataArrayV2.h @@ -0,0 +1,44 @@ +#ifndef ALIRAWDATAARRAYV2_H +#define ALIRAWDATAARRAYV2_H + +// Author: Cvetan Cheshkov 27/03/2007 + +/* Copyright(c) 1998-2003, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +////////////////////////////////////////////////////////////////////////// +// // +// AliRawDataArrayV2 // +// A container object which is used in order to write the sub-detector // +// raw-data payloads into a separate branches // +// // +////////////////////////////////////////////////////////////////////////// + +#ifndef ROOT_TObject +#include +#endif +#include + +class AliRawData; + +class AliRawDataArrayV2 : public TObject { + +public: + AliRawDataArrayV2(); + AliRawDataArrayV2(Int_t n); + virtual ~AliRawDataArrayV2(); + + void ClearData(); + AliRawData *Add(); + +private: + TClonesArray fRawDataArray; // Array containing raw-data payloads + Int_t fNAlloc; //! + + AliRawDataArrayV2(const AliRawDataArrayV2 &); // not implemented, usage causes + AliRawDataArrayV2 &operator=(const AliRawDataArrayV2 &); // link time error + + ClassDef(AliRawDataArrayV2,1) // Alice raw event buffer +}; + +#endif diff --git a/RAW/AliRawEquipment.cxx b/RAW/AliRawEquipment.cxx index 22647bbc768..26747581df0 100644 --- a/RAW/AliRawEquipment.cxx +++ b/RAW/AliRawEquipment.cxx @@ -85,18 +85,6 @@ AliRawData *AliRawEquipment::GetRawData() return fRawData; } -//______________________________________________________________________________ -void AliRawEquipment::Reset() -{ - // Reset the equipment in case it needs to be re-used (avoiding costly - // new/delete cycle). We reset the size marker for the AliRawData - // object. - - if (fEqpHdr) fEqpHdr->Reset(); - GetRawData()->SetSize(0); - fRawDataRef = NULL; -} - //______________________________________________________________________________ AliRawEquipment::~AliRawEquipment() { @@ -107,19 +95,24 @@ AliRawEquipment::~AliRawEquipment() } //______________________________________________________________________________ -void AliRawEquipment::SetRawDataRef(AliRawDataArray *array) +void AliRawEquipment::Streamer(TBuffer &R__b) { - // Set the TRef to the raw-data container - // before writing it to the branch - if (fRawData) { - fRawDataRef = fRawData; - array->Add(fRawData); - fRawData = NULL; - return; - } - else { - Error("SetRawDataRef", "Raw-data payload does not exist! Can not set a reference to it!"); - fRawDataRef = NULL; - return; - } + // Stream an object of class AliRawEquipment. + + UInt_t R__s, R__c; + if (R__b.IsReading()) { + Version_t R__v = R__b.ReadVersion(&R__s, &R__c); if (R__v) { } + TObject::Streamer(R__b); + R__b >> fEqpHdr; + R__b >> fRawData; + fRawDataRef.Streamer(R__b); + R__b.CheckByteCount(R__s, R__c, AliRawEquipment::IsA()); + } else { + R__c = R__b.WriteVersion(AliRawEquipment::IsA(), kTRUE); + TObject::Streamer(R__b); + R__b << fEqpHdr; + R__b << fRawData; + fRawDataRef.Streamer(R__b); + R__b.SetByteCount(R__c, kTRUE); + } } diff --git a/RAW/AliRawEquipment.h b/RAW/AliRawEquipment.h index 0c5c6c42d1d..f429242b892 100644 --- a/RAW/AliRawEquipment.h +++ b/RAW/AliRawEquipment.h @@ -41,17 +41,16 @@ class AliRawDataArray; class AliRawEquipmentHeader; class AliRawData; +#include "AliRawVEquipment.h" -class AliRawEquipment : public TObject { +class AliRawEquipment : public AliRawVEquipment { public: AliRawEquipment(); virtual ~AliRawEquipment(); - AliRawEquipmentHeader *GetEquipmentHeader(); - AliRawData *GetRawData(); - void Reset(); - void SetRawDataRef(AliRawDataArray *array); + virtual AliRawEquipmentHeader *GetEquipmentHeader(); + virtual AliRawData *GetRawData(); private: AliRawEquipmentHeader *fEqpHdr; // equipment header @@ -61,7 +60,7 @@ private: AliRawEquipment(const AliRawEquipment& rawEvent); AliRawEquipment& operator = (const AliRawEquipment& rawEvent); - ClassDef(AliRawEquipment,2) // ALICE raw equipment object + ClassDef(AliRawEquipment,3) // ALICE raw equipment object }; #endif diff --git a/RAW/AliRawEquipmentHeader.h b/RAW/AliRawEquipmentHeader.h index dcb1170130e..136bc5b449f 100644 --- a/RAW/AliRawEquipmentHeader.h +++ b/RAW/AliRawEquipmentHeader.h @@ -49,7 +49,7 @@ private: UInt_t fTypeAttribute[kAttributeWords]; // system (0,1) and user (2) attributes UInt_t fBasicElementSizeType; // basic element size type - ClassDef(AliRawEquipmentHeader,1) //Alice equipment header + ClassDef(AliRawEquipmentHeader,2) //Alice equipment header }; #endif diff --git a/RAW/AliRawEquipmentV2.cxx b/RAW/AliRawEquipmentV2.cxx new file mode 100644 index 00000000000..10991d55bf9 --- /dev/null +++ b/RAW/AliRawEquipmentV2.cxx @@ -0,0 +1,117 @@ +// @(#) $Id: AliRawEquipment.cxx 23318 2008-01-14 12:43:28Z hristov $ +// Author: Fons Rademakers 26/11/99 + +/************************************************************************** + * Copyright(c) 1998-2003, 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. * + **************************************************************************/ + +////////////////////////////////////////////////////////////////////////// +// // +// AliRawEquipmentV2 // +// // +// Set of classes defining the ALICE RAW event format. The AliRawEventV2// +// class defines a RAW event. It consists of an AliEventHeader object // +// an AliEquipmentHeader object, an AliRawData object and an array of // +// sub-events, themselves also being AliRawEventV2s. The number of // +// sub-events depends on the number of DATE LDC's. // +// The AliRawEventV2 objects are written to a ROOT file using different // +// technologies, i.e. to local disk via AliRawDB or via rfiod using // +// AliRawRFIODB or via rootd using AliRawRootdDB or to CASTOR via // +// rootd using AliRawCastorDB (and for performance testing there is // +// also AliRawNullDB). // +// The AliStats class provides statics information that is added as // +// a single keyed object to each raw file. // +// The AliTagDB provides an interface to a TAG database. // +// The AliMDC class is usid by the "alimdc" stand-alone program // +// that reads data directly from DATE. // +// // +////////////////////////////////////////////////////////////////////////// + +#include "AliRawEquipmentV2.h" +#include "AliRawDataArrayV2.h" +#include "AliRawData.h" + +ClassImp(AliRawEquipmentV2) + +//______________________________________________________________________________ +AliRawEquipmentV2::AliRawEquipmentV2(): +AliRawVEquipment(), +fEqpHdr(), +fRawData(NULL), +fRawDataRef(NULL) +{ + // Create ALICE equipment object. + +} + +//______________________________________________________________________________ +AliRawEquipmentHeader *AliRawEquipmentV2::GetEquipmentHeader() +{ + // Get equipment header part of AliRawEquipmentV2. + + return &fEqpHdr; +} + +//______________________________________________________________________________ +AliRawData *AliRawEquipmentV2::GetRawData() +{ + // Get raw data part of AliRawEquipmentV2. + + if (!fRawData) { + if (fRawDataRef.IsValid()) { + fRawData = (AliRawData*)fRawDataRef.GetObject(); + } + } + return fRawData; +} + +//______________________________________________________________________________ +void AliRawEquipmentV2::Reset() +{ + // Reset the equipment in case it needs to be re-used (avoiding costly + // new/delete cycle). We reset the size marker for the AliRawData + // object. + + fEqpHdr.Reset(); + fRawDataRef = NULL; +} + +//______________________________________________________________________________ +AliRawEquipmentV2::~AliRawEquipmentV2() +{ + // Clean up event object. Delete also, possible, private raw data. + + if (!fRawDataRef.IsValid()) delete fRawData; +} + +//______________________________________________________________________________ +AliRawData *AliRawEquipmentV2::NextRawData(AliRawDataArrayV2 *array) +{ + // Get a pointer to the raw-data object + // stored within an array in a separate + // branch of the tree. + // Set the reference to the raw-data object + + AliRawData *raw = NULL; + if (array) { + raw = array->Add(); + fRawDataRef = raw; + } + else { + Error("NextRawData", "Raw-data array does not exist! Can not set a reference to a raw-data object!"); + fRawDataRef = NULL; + } + + return raw; +} diff --git a/RAW/AliRawEquipmentV2.h b/RAW/AliRawEquipmentV2.h new file mode 100644 index 00000000000..b250aaf41bf --- /dev/null +++ b/RAW/AliRawEquipmentV2.h @@ -0,0 +1,65 @@ +#ifndef ALIRAWEQUIPMENTV2_H +#define ALIRAWEQUIPMENTV2_H +// Author: Cvetan Cheshkov 11/05/2009 + +/* Copyright(c) 1998-2003, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +////////////////////////////////////////////////////////////////////////// +// // +// AliRawEquipmentV2 // +// // +// Set of classes defining the ALICE RAW event format. The AliRawEventV2// +// class defines a RAW event. It consists of an AliEventHeader object // +// an AliEquipmentHeader object, an AliRawData object and an array of // +// sub-events, themselves also being AliRawEventV2s. The number of // +// sub-events depends on the number of DATE LDC's. // +// The AliRawEventV2 objects are written to a ROOT file using different // +// technologies, i.e. to local disk via AliRawDB or via rfiod using // +// AliRawRFIODB or via rootd using AliRawRootdDB or to CASTOR via // +// rootd using AliRawCastorDB (and for performance testing there is // +// also AliRawNullDB). // +// The AliRunDB class provides the interface to the run and file // +// catalogues (AliEn or plain MySQL). // +// The AliStats class provides statics information that is added as // +// a single keyed object to each raw file. // +// The AliTagDB provides an interface to a TAG database. // +// The AliMDC class is usid by the "alimdc" stand-alone program // +// that reads data directly from DATE. // +// // +////////////////////////////////////////////////////////////////////////// + +#ifndef ROOT_TObject +#include +#endif +#include + +// Forward class declarations +class AliRawDataArrayV2; + +#include "AliRawVEquipment.h" +#include "AliRawEquipmentHeader.h" + +class AliRawEquipmentV2 : public AliRawVEquipment { + +public: + AliRawEquipmentV2(); + virtual ~AliRawEquipmentV2(); + + virtual AliRawEquipmentHeader *GetEquipmentHeader(); + virtual AliRawData *GetRawData(); + void Reset(); + AliRawData *NextRawData(AliRawDataArrayV2 *array); + +private: + AliRawEquipmentHeader fEqpHdr; // equipment header + AliRawData *fRawData; //! raw data container + TRef fRawDataRef; // reference to raw data container + + AliRawEquipmentV2(const AliRawEquipmentV2& eq); + AliRawEquipmentV2& operator = (const AliRawEquipmentV2& eq); + + ClassDef(AliRawEquipmentV2,1) // ALICE raw equipment object +}; + +#endif diff --git a/RAW/AliRawEvent.cxx b/RAW/AliRawEvent.cxx index 06d97fc0a75..850e6499bd9 100644 --- a/RAW/AliRawEvent.cxx +++ b/RAW/AliRawEvent.cxx @@ -64,56 +64,17 @@ fSubEvents(NULL) } -//______________________________________________________________________________ -AliRawEventHeaderBase *AliRawEvent::GetHeader(char*& data) -{ - // Get event header part of AliRawEvent. - // First the DATE version is identified and then the - // corresponding event header version object is created - - if (!fEvtHdr) { - fEvtHdr = AliRawEventHeaderBase::Create(data); - } - - return fEvtHdr; -} - //______________________________________________________________________________ AliRawEventHeaderBase *AliRawEvent::GetHeader() { if (!fEvtHdr) { - AliFatal("Header version not yet initialized!"); - return 0x0; - } + AliFatal("Event header does not exist!"); + return 0x0; + } return fEvtHdr; } -//______________________________________________________________________________ -AliRawEquipment *AliRawEvent::NextEquipment() -{ - // Returns next equipment object. - - if (!fEquipments) - fEquipments = new TObjArray(100); // arbitrary, probably enough to prevent resizing - - if (fEquipments->GetSize() <= fNEquipments) { - fEquipments->Expand(fNEquipments+10); - Warning("NextEquipment", "expanded fEquipments by 10 to %d", - fEquipments->GetSize()); - } - - AliRawEquipment *eq; - if (!(eq = (AliRawEquipment *)fEquipments->At(fNEquipments))) { - eq = new AliRawEquipment; - fEquipments->AddAt(eq, fNEquipments); - } - - fNEquipments++; - - return eq; -} - //______________________________________________________________________________ AliRawEquipment *AliRawEvent::GetEquipment(Int_t index) const { @@ -126,32 +87,7 @@ AliRawEquipment *AliRawEvent::GetEquipment(Int_t index) const } //______________________________________________________________________________ -AliRawEvent *AliRawEvent::NextSubEvent() -{ - // Returns next sub-event object. - - if (!fSubEvents) - fSubEvents = new TObjArray(100); // arbitrary, probably enough to prevent resizing - - if (fSubEvents->GetSize() <= fNSubEvents) { - fSubEvents->Expand(fNSubEvents+10); - Warning("NextSubEvent", "expanded fSubEvents by 10 to %d", - fSubEvents->GetSize()); - } - - AliRawEvent *ev; - if (!(ev = (AliRawEvent *)fSubEvents->At(fNSubEvents))) { - ev = new AliRawEvent; - fSubEvents->AddAt(ev, fNSubEvents); - } - - fNSubEvents++; - - return ev; -} - -//______________________________________________________________________________ -AliRawEvent *AliRawEvent::GetSubEvent(Int_t index) const +AliRawEvent *AliRawEvent::GetSubEvent(Int_t index) { // Get specified sub event. Returns 0 if sub event does not exist. @@ -161,25 +97,6 @@ AliRawEvent *AliRawEvent::GetSubEvent(Int_t index) const return (AliRawEvent *) fSubEvents->At(index); } -//______________________________________________________________________________ -void AliRawEvent::Reset() -{ - // Reset the event in case it needs to be re-used (avoiding costly - // new/delete cycle). We reset the size marker for the AliRawData - // objects and the sub event counter. - - for (int i = 0; i < fNEquipments; i++) { - AliRawEquipment *eq = (AliRawEquipment *)fEquipments->At(i); - eq->Reset(); - } - fNEquipments = 0; - for (int i = 0; i < fNSubEvents; i++) { - AliRawEvent *ev = (AliRawEvent *)fSubEvents->At(i); - ev->Reset(); - } - fNSubEvents = 0; -} - //______________________________________________________________________________ AliRawEvent::~AliRawEvent() { @@ -193,3 +110,30 @@ AliRawEvent::~AliRawEvent() fSubEvents->Delete(); delete fSubEvents; } + +//______________________________________________________________________________ +void AliRawEvent::Streamer(TBuffer &R__b) +{ + // Stream an object of class AliRawEvent. + + UInt_t R__s, R__c; + if (R__b.IsReading()) { + Version_t R__v = R__b.ReadVersion(&R__s, &R__c); if (R__v) { } + TObject::Streamer(R__b); + R__b >> fNEquipments; + R__b >> fNSubEvents; + R__b >> fEvtHdr; + R__b >> fEquipments; + R__b >> fSubEvents; + R__b.CheckByteCount(R__s, R__c, AliRawEvent::IsA()); + } else { + R__c = R__b.WriteVersion(AliRawEvent::IsA(), kTRUE); + TObject::Streamer(R__b); + R__b << fNEquipments; + R__b << fNSubEvents; + R__b << fEvtHdr; + R__b << fEquipments; + R__b << fSubEvents; + R__b.SetByteCount(R__c, kTRUE); + } +} diff --git a/RAW/AliRawEvent.h b/RAW/AliRawEvent.h index d0a8306a9f5..da238cef799 100644 --- a/RAW/AliRawEvent.h +++ b/RAW/AliRawEvent.h @@ -44,22 +44,19 @@ class AliRawEventHeaderBase; class AliRawEquipment; +#include "AliRawVEvent.h" -class AliRawEvent : public TObject { +class AliRawEvent : public AliRawVEvent { public: AliRawEvent(); virtual ~AliRawEvent(); - AliRawEventHeaderBase *GetHeader(char*& data); - AliRawEventHeaderBase *GetHeader(); - Int_t GetNEquipments() const { return fNEquipments; } - AliRawEquipment *NextEquipment(); - AliRawEquipment *GetEquipment(Int_t index) const; - Int_t GetNSubEvents() const { return fNSubEvents; } - AliRawEvent *NextSubEvent(); - AliRawEvent *GetSubEvent(Int_t index) const; - void Reset(); + virtual AliRawEventHeaderBase *GetHeader(); + virtual Int_t GetNEquipments() const { return fNEquipments; } + virtual AliRawEquipment *GetEquipment(Int_t index) const; + virtual Int_t GetNSubEvents() const { return fNSubEvents; } + virtual AliRawEvent *GetSubEvent(Int_t index); private: Int_t fNEquipments; // number of valid equipments @@ -71,7 +68,7 @@ private: AliRawEvent(const AliRawEvent& rawEvent); AliRawEvent& operator = (const AliRawEvent& rawEvent); - ClassDef(AliRawEvent,2) // ALICE raw event object + ClassDef(AliRawEvent,3) // ALICE raw event object }; #endif diff --git a/RAW/AliRawEventHeaderBase.cxx b/RAW/AliRawEventHeaderBase.cxx index dccd36a8099..10beea21dc3 100644 --- a/RAW/AliRawEventHeaderBase.cxx +++ b/RAW/AliRawEventHeaderBase.cxx @@ -50,17 +50,22 @@ fExtendedDataSize(0), fExtendedAllocSize(0), fExtendedData(NULL), fIsSwapped(kFALSE), -fHeaderSize(0) +fHeaderSize(0), +fHeaderBegin(NULL), +fFirstEqIndex(-1), +fLastEqIndex(-1) { // Default constructor } //______________________________________________________________________________ -void *AliRawEventHeaderBase::HeaderBegin() +void *AliRawEventHeaderBase::HeaderBegin() const { // Returns the pointer to the first data member // beyond the base class data members + if (fHeaderBegin) return fHeaderBegin; + TList *datalist = IsA()->GetListOfDataMembers(); TIter next(datalist); TDataMember *member = (TDataMember *)next(); @@ -68,7 +73,10 @@ void *AliRawEventHeaderBase::HeaderBegin() if(!strcmp(member->GetTypeName(),"TClass")) member = (TDataMember *)next(); - return (void *)((char *)this+member->GetOffset()); + void *ptr = (void *)((char *)this+member->GetOffset()); + const_cast(this)->fHeaderBegin = ptr; + + return ptr; } //______________________________________________________________________________ @@ -435,3 +443,46 @@ void AliRawEventHeaderBase::Print( const Option_t* opt ) const cout << opt << " Type attribute: " << GetP("TypeAttribute")[0] << "-" << GetP("TypeAttribute")[1] << "-" << GetP("TypeAttribute")[2] << endl; cout << opt << " GDC: " << Get("GdcId") << " LDC: " << Get("LdcId") << endl; } + +//_____________________________________________________________________________ +void AliRawEventHeaderBase::AddEqIndex(Int_t index) +{ + // Adds an equipment by changing properly + // the first and last equipment indexes + if (fFirstEqIndex < 0) fFirstEqIndex = index; + if (index > fLastEqIndex) fLastEqIndex = index; +} + +//_____________________________________________________________________________ +void AliRawEventHeaderBase::Reset() +{ + fFirstEqIndex = fLastEqIndex = -1; +} + +//______________________________________________________________________________ +void AliRawEventHeaderBase::Streamer(TBuffer &R__b) +{ + // Stream an object of class AliRawEventHeaderBase. + + if (R__b.IsReading()) { + UInt_t R__s, R__c; + Version_t R__v = R__b.ReadVersion(&R__s, &R__c); + if (R__v > 3) { + R__b.ReadClassBuffer(AliRawEventHeaderBase::Class(),this,R__v,R__s,R__c); + return; + } + TObject::Streamer(R__b); + R__b >> fSize; + R__b >> fMagic; + R__b >> fHeadSize; + R__b >> fVersion; + R__b >> fExtendedDataSize; + delete [] fExtendedData; + fExtendedData = new char[fExtendedDataSize]; + R__b.ReadFastArray(fExtendedData,fExtendedDataSize); + R__b >> fIsSwapped; + R__b.CheckByteCount(R__s, R__c, AliRawEventHeaderBase::IsA()); + } else { + R__b.WriteClassBuffer(AliRawEventHeaderBase::Class(),this); + } +} diff --git a/RAW/AliRawEventHeaderBase.h b/RAW/AliRawEventHeaderBase.h index 966a5da7892..ab24a7339b3 100644 --- a/RAW/AliRawEventHeaderBase.h +++ b/RAW/AliRawEventHeaderBase.h @@ -22,9 +22,9 @@ public: AliRawEventHeaderBase(); virtual ~AliRawEventHeaderBase() { if (fExtendedData) delete [] fExtendedData; } - void *HeaderBaseBegin() { return (void *) &fSize; } + void *HeaderBaseBegin() const { return (void *) &fSize; } Int_t HeaderBaseSize() const { return (Long_t) &fVersion - (Long_t) &fSize + sizeof(fVersion); } - void *HeaderBegin(); + void *HeaderBegin() const; Int_t HeaderSize() const; Bool_t DataIsSwapped() const { return fIsSwapped; } Bool_t IsSwapped() const { return (fMagic == fgkEventMagicNumberSwapped) ? kTRUE : kFALSE; } @@ -54,6 +54,11 @@ public: void Print( const Option_t* opt ="" ) const; + Int_t GetFirstEqIndex() const { return fFirstEqIndex; } + Int_t GetLastEqIndex() const { return fLastEqIndex; } + void AddEqIndex(Int_t index); + void Reset(); + // The following enumeration can be used once the kEventTypeMask has been // applied to the raw event type enum EAliRawEventType { @@ -87,11 +92,15 @@ private: Bool_t fIsSwapped; // is data swapped Int_t fHeaderSize; //! cache for the header size estimate + void *fHeaderBegin; //! cache for the header begin pointer + + Int_t fFirstEqIndex; // index of the first equipment + Int_t fLastEqIndex; // index of the last equipment static const UInt_t fgkEventMagicNumber = 0xDA1E5AFE; // magic word static const UInt_t fgkEventMagicNumberSwapped = 0xFE5A1EDA; // swapped magic word - ClassDef(AliRawEventHeaderBase,3) // Alice raw event header base class + ClassDef(AliRawEventHeaderBase,4) // Alice raw event header base class }; #define EVENT_HEADER_VERSION(AA,BB) AliRawEventHeaderV##AA##_##BB diff --git a/RAW/AliRawEventV2.cxx b/RAW/AliRawEventV2.cxx new file mode 100644 index 00000000000..5f4d542f476 --- /dev/null +++ b/RAW/AliRawEventV2.cxx @@ -0,0 +1,217 @@ +// Author: Cvetan Cheshkov 11/05/2009 + +/************************************************************************** + * Copyright(c) 1998-2003, 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. * + **************************************************************************/ + +////////////////////////////////////////////////////////////////////////// +// // +// AliRawEventV2 // +// // +// Set of classes defining the ALICE RAW event format. The AliRawEventV2 // +// class defines a RAW event. It consists of an AliEventHeader object // +// an AliEquipmentHeader object, an AliRawData object and an array of // +// sub-events, themselves also being AliRawEventV2s. The number of // +// sub-events depends on the number of DATE LDC's. // +// The AliRawEventV2 objects are written to a ROOT file using different // +// technologies, i.e. to local disk via AliRawDB or via rfiod using // +// AliRawRFIODB or via rootd using AliRawRootdDB or to CASTOR via // +// rootd using AliRawCastorDB (and for performance testing there is // +// also AliRawNullDB). // +// The AliStats class provides statics information that is added as // +// a single keyed object to each raw file. // +// The AliTagDB provides an interface to a TAG database. // +// The AliMDC class is usid by the "alimdc" stand-alone program // +// that reads data directly from DATE. // +// // +////////////////////////////////////////////////////////////////////////// + +#include +#include + +#include "AliLog.h" + +#include "AliRawEventHeaderBase.h" +#include "AliRawEquipmentV2.h" + +#include "AliRawEventV2.h" + + +ClassImp(AliRawEventV2) + + +//______________________________________________________________________________ +AliRawEventV2::AliRawEventV2(): +AliRawVEvent(), +fEquipments("AliRawEquipmentV2",1000), +fEvtHdrs(NULL), +fIndex(0), +fNAllocHdrs(0), +fNAllocEqs(0) +{ + // Create ALICE event object. If ownData is kFALSE we will use a static + // raw data object, otherwise a private copy will be made. + +} + +//______________________________________________________________________________ +AliRawEventHeaderBase *AliRawEventV2::GetHeader(char*& data) +{ + // Get event header part of AliRawEventV2. + // First the DATE version is identified and then the + // corresponding event header version object is created + + AliRawEventHeaderBase *hdr = NULL; + + if (!fEvtHdrs) { + hdr = AliRawEventHeaderBase::Create(data); + hdr->IsA()->IgnoreTObjectStreamer(); + fEvtHdrs = new TClonesArray(hdr->IsA()->GetName(),100); + delete hdr; + } + + if (fIndex < fNAllocHdrs) { + TClonesArray &arr = *fEvtHdrs; + return (AliRawEventHeaderBase *)arr[fIndex]; + } + else { + fNAllocHdrs = fIndex + 1; + return (AliRawEventHeaderBase *)fEvtHdrs->New(fIndex); + } +} + +//______________________________________________________________________________ +AliRawEventHeaderBase *AliRawEventV2::GetHeader() +{ + AliRawEventHeaderBase *hdr = NULL; + if (!fEvtHdrs || !(hdr = (AliRawEventHeaderBase *)fEvtHdrs->UncheckedAt(fIndex))) { + AliFatal("Event header does not exist!"); + return NULL; + } + + return hdr; +} + +//______________________________________________________________________________ +AliRawEquipmentV2 *AliRawEventV2::NextEquipment() +{ + // Returns next equipment object. + + AliRawEventHeaderBase *hdr = (AliRawEventHeaderBase *)fEvtHdrs->UncheckedAt(fIndex); + Int_t nEquipments = fEquipments.GetEntriesFast(); + hdr->AddEqIndex(nEquipments); + + if (nEquipments < fNAllocEqs) { + return (AliRawEquipmentV2 *)fEquipments[nEquipments]; + } + else { + fNAllocEqs = nEquipments + 1; + return new (fEquipments[nEquipments]) AliRawEquipmentV2(); + } +} + +//______________________________________________________________________________ +AliRawVEquipment *AliRawEventV2::GetEquipment(Int_t index) const +{ + // Get specified equipment. Returns 0 if equipment does not exist. + + // if (!fEquipments) + // return NULL; + + AliRawEventHeaderBase *hdr = NULL; + if (!fEvtHdrs || !(hdr = (AliRawEventHeaderBase *)fEvtHdrs->UncheckedAt(fIndex))) { + AliFatal("Header is not yet initialized!"); + return NULL; + } + + if ((index + hdr->GetFirstEqIndex()) > hdr->GetLastEqIndex()) { + AliFatal("Equipment index out of scope!"); + return NULL; + } + + return (AliRawVEquipment *) fEquipments.UncheckedAt(index+hdr->GetFirstEqIndex()); +} + + +//______________________________________________________________________________ +Int_t AliRawEventV2::GetNEquipments() const +{ + // if (!fEquipments) + // return 0; + + AliRawEventHeaderBase *hdr = NULL; + if (!fEvtHdrs || !(hdr = (AliRawEventHeaderBase *)fEvtHdrs->UncheckedAt(fIndex))) { + AliFatal("Header is not yet initialized!"); + return 0; + } + + return (hdr->GetFirstEqIndex() < 0) ? 0 : (hdr->GetLastEqIndex() - hdr->GetFirstEqIndex() + 1); +} + +//______________________________________________________________________________ +AliRawEventV2 *AliRawEventV2::NextSubEvent() +{ + // Returns next sub-event object. + + fIndex++; + + return this; +} + +//______________________________________________________________________________ +AliRawVEvent *AliRawEventV2::GetSubEvent(Int_t index) +{ + // Get specified sub event. Returns 0 if sub event does not exist. + + if (!fEvtHdrs) { + AliFatal("Headers are not yet initialized!"); + return NULL; + } + + fIndex = index + 1; + + return this; +} + +//______________________________________________________________________________ +void AliRawEventV2::Reset() +{ + // Reset the event in case it needs to be re-used (avoiding costly + // new/delete cycle). We reset the size marker for the AliRawData + // objects and the sub event counter. + + fEquipments.Clear(); + + if (fEvtHdrs) { + for (int i = 0; i < fEvtHdrs->GetEntriesFast(); i++) { + AliRawEventHeaderBase *hdr = (AliRawEventHeaderBase *)fEvtHdrs->UncheckedAt(i); + hdr->Reset(); + } + fEvtHdrs->Clear(); + } + fIndex = 0; +} + +//______________________________________________________________________________ +AliRawEventV2::~AliRawEventV2() +{ + // Clean up event object. Delete also, possible, private raw data. + + // if (fEquipments) + fEquipments.Delete(); + // delete fEquipments; + if (fEvtHdrs) + fEvtHdrs->Delete(); + delete fEvtHdrs; +} diff --git a/RAW/AliRawEventV2.h b/RAW/AliRawEventV2.h new file mode 100644 index 00000000000..070dd5f2a03 --- /dev/null +++ b/RAW/AliRawEventV2.h @@ -0,0 +1,78 @@ +#ifndef ALIRAWEVENTV2_H +#define ALIRAWEVENTV2_H +// Author: Cvetan Cheshkov 11/05/2009 + +/* Copyright(c) 1998-2003, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +////////////////////////////////////////////////////////////////////////// +// // +// AliRawEventV2 // +// // +// Set of classes defining the ALICE RAW event format. The AliRawEventV2 // +// class defines a RAW event. It consists of an AliEventHeader object // +// an AliEquipmentHeader object, an AliRawData object and an array of // +// sub-events, themselves also being AliRawEventV2s. The number of // +// sub-events depends on the number of DATE LDC's. // +// The AliRawEventV2 objects are written to a ROOT file using different // +// technologies, i.e. to local disk via AliRawDB or via rfiod using // +// AliRawRFIODB or via rootd using AliRawRootdDB or to CASTOR via // +// rootd using AliRawCastorDB (and for performance testing there is // +// also AliRawNullDB). // +// The AliRunDB class provides the interface to the run and file // +// catalogues (AliEn or plain MySQL). // +// The AliStats class provides statics information that is added as // +// a single keyed object to each raw file. // +// The AliTagDB provides an interface to a TAG database. // +// The AliMDC class is usid by the "alimdc" stand-alone program // +// that reads data directly from DATE. // +// // +////////////////////////////////////////////////////////////////////////// + +#ifndef ROOT_TObject +#include +#endif + +#ifndef ROOT_TClonesArray +#include +#endif + + +// Forward class declarations +class AliRawEventHeaderBase; +class AliRawVEquipment; +class AliRawEquipmentV2; + +#include "AliRawVEvent.h" + +class AliRawEventV2 : public AliRawVEvent { + +public: + AliRawEventV2(); + virtual ~AliRawEventV2(); + + AliRawEventHeaderBase *GetHeader(char*& data); + virtual AliRawEventHeaderBase *GetHeader(); + virtual Int_t GetNEquipments() const; + AliRawEquipmentV2 *NextEquipment(); + virtual AliRawVEquipment *GetEquipment(Int_t index) const; + virtual Int_t GetNSubEvents() const { return (fEvtHdrs) ? (fEvtHdrs->GetEntriesFast()-1) : 0; } + AliRawEventV2 *NextSubEvent(); + virtual AliRawVEvent *GetSubEvent(Int_t index); + void Reset(); + +private: + TClonesArray fEquipments; // AliRawEquipmentV2's + TClonesArray *fEvtHdrs; //-> event and subevent headers + + Int_t fIndex; //! + Int_t fNAllocHdrs; //! + Int_t fNAllocEqs; //! + + AliRawEventV2(const AliRawEventV2& rawEvent); + AliRawEventV2& operator = (const AliRawEventV2& rawEvent); + + ClassDef(AliRawEventV2,1) // ALICE raw event object +}; + +#endif diff --git a/RAW/AliRawNullDB.cxx b/RAW/AliRawNullDB.cxx index b8206afc2d5..a787b51a500 100644 --- a/RAW/AliRawNullDB.cxx +++ b/RAW/AliRawNullDB.cxx @@ -29,7 +29,7 @@ ClassImp(AliRawNullDB) //______________________________________________________________________________ -AliRawNullDB::AliRawNullDB(AliRawEvent *event, +AliRawNullDB::AliRawNullDB(AliRawEventV2 *event, AliESDEvent *esd, Int_t compress, const char* fileName,Int_t basketsize) @@ -60,8 +60,9 @@ Long64_t AliRawNullDB::Close() // Write the tree. Bool_t error = kFALSE; - if (fTree->Write() == 0) - error = kTRUE; + if (fTree) + if (fTree->Write() == 0) + error = kTRUE; if (fESDTree) if (fESDTree->Write() == 0) error = kTRUE; @@ -69,6 +70,8 @@ Long64_t AliRawNullDB::Close() // Close DB, this also deletes the fTree fRawDB->Close(); + fTree = NULL; + Long64_t filesize = fRawDB->GetEND(); delete fRawDB; diff --git a/RAW/AliRawNullDB.h b/RAW/AliRawNullDB.h index 812b97c44d5..b76633ae272 100644 --- a/RAW/AliRawNullDB.h +++ b/RAW/AliRawNullDB.h @@ -18,7 +18,7 @@ class AliRawNullDB : public AliRawDB { public: - AliRawNullDB(AliRawEvent *event, + AliRawNullDB(AliRawEventV2 *event, AliESDEvent *esd, Int_t compress, const char* fileName, diff --git a/RAW/AliRawRFIODB.cxx b/RAW/AliRawRFIODB.cxx index 92441bed4b7..5a1c4718c1e 100644 --- a/RAW/AliRawRFIODB.cxx +++ b/RAW/AliRawRFIODB.cxx @@ -32,7 +32,7 @@ ClassImp(AliRawRFIODB) //______________________________________________________________________________ -AliRawRFIODB::AliRawRFIODB(AliRawEvent *event, +AliRawRFIODB::AliRawRFIODB(AliRawEventV2 *event, AliESDEvent *esd, Int_t compress, const char* fileName,Int_t basketsize) @@ -115,8 +115,9 @@ Long64_t AliRawRFIODB::Close() // Write the tree. Bool_t error = kFALSE; - if (fTree->Write() == 0) - error = kTRUE; + if (fTree) + if (fTree->Write() == 0) + error = kTRUE; if (fESDTree) if (fESDTree->Write() == 0) error = kTRUE; @@ -124,6 +125,8 @@ Long64_t AliRawRFIODB::Close() // Close DB, this also deletes the fTree fRawDB->Close(); + fTree = NULL; + Long64_t filesize = fRawDB->GetEND(); if (fDeleteFiles) { diff --git a/RAW/AliRawRFIODB.h b/RAW/AliRawRFIODB.h index 4aad013eee7..74326eac935 100644 --- a/RAW/AliRawRFIODB.h +++ b/RAW/AliRawRFIODB.h @@ -18,7 +18,7 @@ class AliRawRFIODB : public AliRawDB { public: - AliRawRFIODB(AliRawEvent *event, + AliRawRFIODB(AliRawEventV2 *event, AliESDEvent *esd, Int_t compress, const char* fileName = NULL, diff --git a/RAW/AliRawReader.h b/RAW/AliRawReader.h index 5b69f9f060c..6ed347e4015 100644 --- a/RAW/AliRawReader.h +++ b/RAW/AliRawReader.h @@ -20,7 +20,7 @@ class TChain; class AliRawEventHeaderBase; -class AliRawEvent; +class AliRawVEvent; class AliRawReader: public TObject { public : @@ -44,7 +44,7 @@ class AliRawReader: public TObject { {fRequireHeader = required;}; virtual const AliRawEventHeaderBase* GetEventHeader() const {return NULL;}; - virtual const AliRawEvent* GetEvent() const {return NULL;} + virtual const AliRawVEvent* GetEvent() const {return NULL;} virtual UInt_t GetType() const = 0; virtual UInt_t GetRunNumber() const = 0; diff --git a/RAW/AliRawReaderChain.cxx b/RAW/AliRawReaderChain.cxx index 17e59f54b0e..0022a2a66e4 100644 --- a/RAW/AliRawReaderChain.cxx +++ b/RAW/AliRawReaderChain.cxx @@ -35,7 +35,7 @@ #include #include "AliRawReaderChain.h" -#include "AliRawEvent.h" +#include "AliRawVEvent.h" ClassImp(AliRawReaderChain) @@ -237,12 +237,14 @@ Bool_t AliRawReaderChain::NextEvent() do { delete fEvent; - fEvent = new AliRawEvent; + fEvent = NULL; + fEventHeader = NULL; Long64_t treeEntry = fChain->LoadTree(fEventIndex+1); if (!fBranch) return kFALSE; if (fBranch->GetEntry(treeEntry) <= 0) return kFALSE; + fEventHeader = fEvent->GetHeader(); fEventIndex++; } while (!IsEventSelected()); fEventNumber++; @@ -255,7 +257,8 @@ Bool_t AliRawReaderChain::RewindEvents() fEventIndex = -1; delete fEvent; - fEvent = new AliRawEvent; + fEvent = NULL; + fEventHeader = NULL; fEventNumber = -1; return Reset(); } @@ -269,12 +272,14 @@ Bool_t AliRawReaderChain::GotoEvent(Int_t event) if (!fChain || !fChain->GetListOfFiles()->GetEntriesFast()) return kFALSE; delete fEvent; - fEvent = new AliRawEvent; + fEvent = NULL; + fEventHeader = NULL; Long64_t treeEntry = fChain->LoadTree(event); if (!fBranch) return kFALSE; if (fBranch->GetEntry(treeEntry) <= 0) return kFALSE; + fEventHeader = fEvent->GetHeader(); fEventIndex = event; fEventNumber++; return Reset(); diff --git a/RAW/AliRawReaderRoot.cxx b/RAW/AliRawReaderRoot.cxx index 27f4d269d18..ec519f9f186 100644 --- a/RAW/AliRawReaderRoot.cxx +++ b/RAW/AliRawReaderRoot.cxx @@ -21,7 +21,7 @@ /// /// The root file is expected to contain a tree of name "RAW" with /// a branch of name "rawevent" which contains objects of type -/// AliRawEvent. +/// AliRawVEvent. /// /// The file name and the event number are arguments of the constructor /// of AliRawReaderRoot. @@ -31,9 +31,9 @@ #include #include #include "AliRawReaderRoot.h" -#include "AliRawEvent.h" +#include "AliRawVEvent.h" #include "AliRawEventHeaderBase.h" -#include "AliRawEquipment.h" +#include "AliRawVEquipment.h" #include "AliRawEquipmentHeader.h" #include "AliRawData.h" @@ -45,6 +45,7 @@ AliRawReaderRoot::AliRawReaderRoot() : fBranch(NULL), fEventIndex(-1), fEvent(NULL), + fEventHeader(NULL), fSubEventIndex(0), fSubEvent(NULL), fEquipmentIndex(0), @@ -62,6 +63,7 @@ AliRawReaderRoot::AliRawReaderRoot(const char* fileName, Int_t eventNumber) : fBranch(NULL), fEventIndex(eventNumber), fEvent(NULL), + fEventHeader(NULL), fSubEventIndex(0), fSubEvent(NULL), fEquipmentIndex(0), @@ -94,7 +96,6 @@ AliRawReaderRoot::AliRawReaderRoot(const char* fileName, Int_t eventNumber) : return; } - fEvent = new AliRawEvent; fBranch->SetAddress(&fEvent); if (fEventIndex >= 0) { if (fBranch->GetEntry(fEventIndex) <= 0) { @@ -102,14 +103,16 @@ AliRawReaderRoot::AliRawReaderRoot(const char* fileName, Int_t eventNumber) : fIsValid = kFALSE; return; } + fEventHeader = fEvent->GetHeader(); } } -AliRawReaderRoot::AliRawReaderRoot(AliRawEvent* event) : +AliRawReaderRoot::AliRawReaderRoot(AliRawVEvent* event) : fFile(NULL), fBranch(NULL), fEventIndex(-1), fEvent(event), + fEventHeader(event->GetHeader()), fSubEventIndex(0), fSubEvent(NULL), fEquipmentIndex(0), @@ -128,6 +131,7 @@ AliRawReaderRoot::AliRawReaderRoot(const AliRawReaderRoot& rawReader) : fBranch(NULL), fEventIndex(rawReader.fEventIndex), fEvent(NULL), + fEventHeader(NULL), fSubEventIndex(rawReader.fSubEventIndex), fSubEvent(NULL), fEquipmentIndex(rawReader.fEquipmentIndex), @@ -161,7 +165,6 @@ AliRawReaderRoot::AliRawReaderRoot(const AliRawReaderRoot& rawReader) : return; } - fEvent = new AliRawEvent; fBranch->SetAddress(&fEvent); if (fEventIndex >= 0) { if (fBranch->GetEntry(fEventIndex) <= 0) { @@ -170,9 +173,11 @@ AliRawReaderRoot::AliRawReaderRoot(const AliRawReaderRoot& rawReader) : fIsValid = kFALSE; return; } + fEventHeader = fEvent->GetHeader(); } } else { fEvent = rawReader.fEvent; + fEventHeader = rawReader.fEventHeader; } if (fSubEventIndex > 0) { @@ -214,56 +219,55 @@ const AliRawEventHeaderBase* AliRawReaderRoot::GetEventHeader() const { // Get the even header // Return NULL in case of failure - if (!fEvent) return NULL; - return fEvent->GetHeader(); + return fEventHeader; } UInt_t AliRawReaderRoot::GetType() const { // get the type from the event header - if (!fEvent) return 0; - return fEvent->GetHeader()->Get("Type"); + if (!fEventHeader) return 0; + return fEventHeader->Get("Type"); } UInt_t AliRawReaderRoot::GetRunNumber() const { // get the run number from the event header - if (!fEvent) return 0; - return fEvent->GetHeader()->Get("RunNb"); + if (!fEventHeader) return 0; + return fEventHeader->Get("RunNb"); } const UInt_t* AliRawReaderRoot::GetEventId() const { // get the event id from the event header - if (!fEvent) return NULL; - return fEvent->GetHeader()->GetP("Id"); + if (!fEventHeader) return NULL; + return fEventHeader->GetP("Id"); } const UInt_t* AliRawReaderRoot::GetTriggerPattern() const { // get the trigger pattern from the event header - if (!fEvent) return NULL; - return fEvent->GetHeader()->GetP("TriggerPattern"); + if (!fEventHeader) return NULL; + return fEventHeader->GetP("TriggerPattern"); } const UInt_t* AliRawReaderRoot::GetDetectorPattern() const { // get the detector pattern from the event header - if (!fEvent) return NULL; - return fEvent->GetHeader()->GetP("DetectorPattern"); + if (!fEventHeader) return NULL; + return fEventHeader->GetP("DetectorPattern"); } const UInt_t* AliRawReaderRoot::GetAttributes() const { // get the type attributes from the event header - if (!fEvent) return NULL; - return fEvent->GetHeader()->GetP("TypeAttribute"); + if (!fEventHeader) return NULL; + return fEventHeader->GetP("TypeAttribute"); } const UInt_t* AliRawReaderRoot::GetSubEventAttributes() const @@ -286,14 +290,14 @@ UInt_t AliRawReaderRoot::GetGDCId() const { // get the GDC Id from the event header - if (!fEvent) return 0; - return fEvent->GetHeader()->Get("GdcId"); + if (!fEventHeader) return 0; + return fEventHeader->Get("GdcId"); } UInt_t AliRawReaderRoot::GetTimestamp() const { - if (!fEvent) return 0; - return fEvent->GetHeader()->Get("Timestamp"); + if (!fEventHeader) return 0; + return fEventHeader->Get("Timestamp"); } Int_t AliRawReaderRoot::GetEquipmentSize() const @@ -526,10 +530,12 @@ Bool_t AliRawReaderRoot::NextEvent() do { delete fEvent; - fEvent = new AliRawEvent; + fEvent = NULL; + fEventHeader = NULL; fBranch->SetAddress(&fEvent); if (fBranch->GetEntry(fEventIndex+1) <= 0) return kFALSE; + fEventHeader = fEvent->GetHeader(); fEventIndex++; } while (!IsEventSelected()); fEventNumber++; @@ -544,7 +550,8 @@ Bool_t AliRawReaderRoot::RewindEvents() fEventIndex = -1; delete fEvent; - fEvent = new AliRawEvent; + fEvent = NULL; + fEventHeader = NULL; fBranch->SetAddress(&fEvent); fEventNumber = -1; return Reset(); @@ -559,10 +566,12 @@ Bool_t AliRawReaderRoot::GotoEvent(Int_t event) if (!fBranch) return kFALSE; delete fEvent; - fEvent = new AliRawEvent; + fEvent = NULL; + fEventHeader = NULL; fBranch->SetAddress(&fEvent); if (fBranch->GetEntry(event) <= 0) return kFALSE; + fEventHeader = fEvent->GetHeader(); fEventIndex = event; fEventNumber++; return Reset(); @@ -584,9 +593,9 @@ Int_t AliRawReaderRoot::CheckData() const if (!fEvent) return 0; - AliRawEvent* subEvent = NULL; + AliRawVEvent* subEvent = NULL; Int_t subEventIndex = 0; - AliRawEquipment* equipment = NULL; + AliRawVEquipment* equipment = NULL; Int_t equipmentIndex = 0; UChar_t* position = 0; UChar_t* end = 0; diff --git a/RAW/AliRawReaderRoot.h b/RAW/AliRawReaderRoot.h index ae890e5e542..d1b96e710c1 100644 --- a/RAW/AliRawReaderRoot.h +++ b/RAW/AliRawReaderRoot.h @@ -13,8 +13,8 @@ #include "AliRawReader.h" -class AliRawEvent; -class AliRawEquipment; +class AliRawVEvent; +class AliRawVEquipment; class AliRawData; class TFile; class TBranch; @@ -24,7 +24,7 @@ class AliRawReaderRoot: public AliRawReader { public : AliRawReaderRoot(); AliRawReaderRoot(const char* fileName, Int_t eventNumber = -1); - AliRawReaderRoot(AliRawEvent* event); + AliRawReaderRoot(AliRawVEvent* event); AliRawReaderRoot(const AliRawReaderRoot& rawReader); AliRawReaderRoot& operator = (const AliRawReaderRoot& rawReader); virtual ~AliRawReaderRoot(); @@ -63,17 +63,18 @@ class AliRawReaderRoot: public AliRawReader { virtual Int_t CheckData() const; - virtual const AliRawEvent* GetEvent() const {return fEvent;} + virtual const AliRawVEvent* GetEvent() const {return fEvent;} protected : TFile* fFile; // raw data root file TBranch* fBranch; // branch of raw events Int_t fEventIndex; // index of the event in the tree - AliRawEvent* fEvent; // (super) event + AliRawVEvent* fEvent; // (super) event + AliRawEventHeaderBase* fEventHeader; // (super) event header Int_t fSubEventIndex; // index of current sub event - AliRawEvent* fSubEvent; // current sub event + AliRawVEvent* fSubEvent; // current sub event Int_t fEquipmentIndex; // index of current equipment - AliRawEquipment* fEquipment; // current equipment + AliRawVEquipment*fEquipment; // current equipment AliRawData* fRawData; // current raw data UChar_t* fPosition; // current position in the raw data UChar_t* fEnd; // end position of the current subevent diff --git a/RAW/AliRawRootdDB.cxx b/RAW/AliRawRootdDB.cxx index b8308a874c5..74102545bd9 100644 --- a/RAW/AliRawRootdDB.cxx +++ b/RAW/AliRawRootdDB.cxx @@ -31,7 +31,7 @@ ClassImp(AliRawRootdDB) //______________________________________________________________________________ -AliRawRootdDB::AliRawRootdDB(AliRawEvent *event, +AliRawRootdDB::AliRawRootdDB(AliRawEventV2 *event, AliESDEvent *esd, Int_t compress, const char* fileName,Int_t basketsize) @@ -99,8 +99,9 @@ Long64_t AliRawRootdDB::Close() // Write the tree. Bool_t error = kFALSE; - if (fTree->Write() == 0) - error = kTRUE; + if (fTree) + if (fTree->Write() == 0) + error = kTRUE; if (fESDTree) if (fESDTree->Write() == 0) error = kTRUE; @@ -108,6 +109,8 @@ Long64_t AliRawRootdDB::Close() // Close DB, this also deletes the fTree fRawDB->Close(); + fTree = NULL; + Long64_t filesize = fRawDB->GetEND(); #if 0 diff --git a/RAW/AliRawRootdDB.h b/RAW/AliRawRootdDB.h index 21bcf63ff8b..fd46c3d60c3 100644 --- a/RAW/AliRawRootdDB.h +++ b/RAW/AliRawRootdDB.h @@ -18,7 +18,7 @@ class AliRawRootdDB : public AliRawDB { public: - AliRawRootdDB(AliRawEvent *event, + AliRawRootdDB(AliRawEventV2 *event, AliESDEvent *esd, Int_t compress, const char* fileName = NULL, diff --git a/RAW/AliRawVEquipment.cxx b/RAW/AliRawVEquipment.cxx new file mode 100644 index 00000000000..0365245d19b --- /dev/null +++ b/RAW/AliRawVEquipment.cxx @@ -0,0 +1,42 @@ +// Author: Cvetan Cheshkov 11/05/2009 + +/************************************************************************** + * Copyright(c) 1998-2003, 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. * + **************************************************************************/ + +////////////////////////////////////////////////////////////////////////// +// // +// AliRawVEquipment // +// // +// Set of classes defining the ALICE RAW event format. The AliRawVEvent // +// class defines a RAW event. It consists of an AliEventHeader object // +// an AliEquipmentHeader object, an AliRawData object and an array of // +// sub-events, themselves also being AliRawVEvents. The number of // +// sub-events depends on the number of DATE LDC's. // +// The AliRawVEvent objects are written to a ROOT file using different // +// technologies, i.e. to local disk via AliRawDB or via rfiod using // +// AliRawRFIODB or via rootd using AliRawRootdDB or to CASTOR via // +// rootd using AliRawCastorDB (and for performance testing there is // +// also AliRawNullDB). // +// The AliStats class provides statics information that is added as // +// a single keyed object to each raw file. // +// The AliTagDB provides an interface to a TAG database. // +// The AliMDC class is usid by the "alimdc" stand-alone program // +// that reads data directly from DATE. // +// // +////////////////////////////////////////////////////////////////////////// + +#include "AliRawVEquipment.h" + +ClassImp(AliRawVEquipment) diff --git a/RAW/AliRawVEquipment.h b/RAW/AliRawVEquipment.h new file mode 100644 index 00000000000..98465848871 --- /dev/null +++ b/RAW/AliRawVEquipment.h @@ -0,0 +1,57 @@ +#ifndef ALIRAWVEQUIPMENT_H +#define ALIRAWVEQUIPMENT_H +// Author: Cvetan Cheshkov 11/05/2009 + +/* Copyright(c) 1998-2003, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +////////////////////////////////////////////////////////////////////////// +// // +// AliRawVEquipment // +// // +// Set of classes defining the ALICE RAW event format. The AliRawVEvent // +// class defines a RAW event. It consists of an AliEventHeader object // +// an AliEquipmentHeader object, an AliRawData object and an array of // +// sub-events, themselves also being AliRawVEvents. The number of // +// sub-events depends on the number of DATE LDC's. // +// The AliRawVEvent objects are written to a ROOT file using different // +// technologies, i.e. to local disk via AliRawDB or via rfiod using // +// AliRawRFIODB or via rootd using AliRawRootdDB or to CASTOR via // +// rootd using AliRawCastorDB (and for performance testing there is // +// also AliRawNullDB). // +// The AliRunDB class provides the interface to the run and file // +// catalogues (AliEn or plain MySQL). // +// The AliStats class provides statics information that is added as // +// a single keyed object to each raw file. // +// The AliTagDB provides an interface to a TAG database. // +// The AliMDC class is usid by the "alimdc" stand-alone program // +// that reads data directly from DATE. // +// // +////////////////////////////////////////////////////////////////////////// + +#ifndef ROOT_TObject +#include +#endif + +// Forward class declarations +class AliRawEquipmentHeader; +class AliRawData; + +class AliRawVEquipment : public TObject { + +public: + AliRawVEquipment() { } + virtual ~AliRawVEquipment() { } + + virtual AliRawEquipmentHeader *GetEquipmentHeader() = 0; + virtual AliRawData *GetRawData() = 0; + +private: + + AliRawVEquipment(const AliRawVEquipment& eq); + AliRawVEquipment& operator = (const AliRawVEquipment& eq); + + ClassDef(AliRawVEquipment,1) // ALICE raw equipment object +}; + +#endif diff --git a/RAW/AliRawVEvent.cxx b/RAW/AliRawVEvent.cxx new file mode 100644 index 00000000000..f87b797adc8 --- /dev/null +++ b/RAW/AliRawVEvent.cxx @@ -0,0 +1,43 @@ +// Author: Cvetan Cheshkov 11/05/2009 + +/************************************************************************** + * Copyright(c) 1998-2003, 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. * + **************************************************************************/ + +////////////////////////////////////////////////////////////////////////// +// // +// AliRawVEvent // +// // +// Set of classes defining the ALICE RAW event format. The AliRawVEvent // +// class defines a RAW event. It consists of an AliEventHeader object // +// an AliEquipmentHeader object, an AliRawData object and an array of // +// sub-events, themselves also being AliRawVEvents. The number of // +// sub-events depends on the number of DATE LDC's. // +// The AliRawVEvent objects are written to a ROOT file using different // +// technologies, i.e. to local disk via AliRawDB or via rfiod using // +// AliRawRFIODB or via rootd using AliRawRootdDB or to CASTOR via // +// rootd using AliRawCastorDB (and for performance testing there is // +// also AliRawNullDB). // +// The AliStats class provides statics information that is added as // +// a single keyed object to each raw file. // +// The AliTagDB provides an interface to a TAG database. // +// The AliMDC class is usid by the "alimdc" stand-alone program // +// that reads data directly from DATE. // +// // +////////////////////////////////////////////////////////////////////////// + +#include "AliRawVEvent.h" + + +ClassImp(AliRawVEvent) diff --git a/RAW/AliRawVEvent.h b/RAW/AliRawVEvent.h new file mode 100644 index 00000000000..12cabc518dc --- /dev/null +++ b/RAW/AliRawVEvent.h @@ -0,0 +1,66 @@ +#ifndef ALIRAWVEVENT_H +#define ALIRAWVEVENT_H +// Author: Cvetan Cheshkov 11/05/2009 + +/* Copyright(c) 1998-2003, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +////////////////////////////////////////////////////////////////////////// +// // +// AliRawVEvent // +// // +// Set of classes defining the ALICE RAW event format. The AliRawVEvent // +// class defines a RAW event. It consists of an AliEventHeader object // +// an AliEquipmentHeader object, an AliRawData object and an array of // +// sub-events, themselves also being AliRawVEvents. The number of // +// sub-events depends on the number of DATE LDC's. // +// The AliRawVEvent objects are written to a ROOT file using different // +// technologies, i.e. to local disk via AliRawDB or via rfiod using // +// AliRawRFIODB or via rootd using AliRawRootdDB or to CASTOR via // +// rootd using AliRawCastorDB (and for performance testing there is // +// also AliRawNullDB). // +// The AliRunDB class provides the interface to the run and file // +// catalogues (AliEn or plain MySQL). // +// The AliStats class provides statics information that is added as // +// a single keyed object to each raw file. // +// The AliTagDB provides an interface to a TAG database. // +// The AliMDC class is usid by the "alimdc" stand-alone program // +// that reads data directly from DATE. // +// // +////////////////////////////////////////////////////////////////////////// + +#ifndef ROOT_TObject +#include +#endif + +#ifndef ROOT_TClonesArray +#include +#endif + + +// Forward class declarations +class AliRawEventHeaderBase; +class AliRawVEquipment; + + +class AliRawVEvent : public TObject { + +public: + AliRawVEvent() { } + virtual ~AliRawVEvent() { } + + virtual AliRawEventHeaderBase *GetHeader() = 0; + virtual Int_t GetNEquipments() const = 0; + virtual AliRawVEquipment *GetEquipment(Int_t index) const = 0; + virtual Int_t GetNSubEvents() const = 0; + virtual AliRawVEvent *GetSubEvent(Int_t index) = 0; + +private: + + AliRawVEvent(const AliRawVEvent& rawEvent); + AliRawVEvent& operator = (const AliRawVEvent& rawEvent); + + ClassDef(AliRawVEvent,1) // ALICE raw event object +}; + +#endif diff --git a/RAW/RAWDatabaseLinkDef.h b/RAW/RAWDatabaseLinkDef.h index 8495b7d7ab0..676b3a129de 100644 --- a/RAW/RAWDatabaseLinkDef.h +++ b/RAW/RAWDatabaseLinkDef.h @@ -4,15 +4,20 @@ #pragma link off all classes; #pragma link off all functions; -#pragma link C++ class AliRawEvent; -#pragma link C++ class AliRawEventHeaderBase; +#pragma link C++ class AliRawVEvent+; +#pragma link C++ class AliRawEvent-; +#pragma link C++ class AliRawEventV2+; +#pragma link C++ class AliRawEventHeaderBase-; #pragma link C++ defined_in RAW/AliRawEventHeaderVersions.h; #pragma link C++ class AliRawEquipmentHeader; -#pragma link C++ class AliRawEquipment; +#pragma link C++ class AliRawVEquipment+; +#pragma link C++ class AliRawEquipment-; +#pragma link C++ class AliRawEquipmentV2+; #pragma link C++ class AliRawData; +#pragma link C++ class AliRawDataArrayV2+; #pragma link C++ class AliRawDataArray; #pragma link C++ class AliStats; -#pragma link C++ class AliRawEventTag; +#pragma link C++ class AliRawEventTag+; #pragma link C++ class AliAltroMapping+; #pragma link C++ class AliCaloAltroMapping+; #pragma link C++ class AliDAQ+; diff --git a/RAW/alirawdump_main.cxx b/RAW/alirawdump_main.cxx index 59c3f3f3c70..e5fe231e8ac 100644 --- a/RAW/alirawdump_main.cxx +++ b/RAW/alirawdump_main.cxx @@ -21,9 +21,9 @@ #include #include -#include "AliRawEvent.h" +#include "AliRawVEvent.h" #include "AliRawEventHeaderBase.h" -#include "AliRawEquipment.h" +#include "AliRawVEquipment.h" #include "AliRawEquipmentHeader.h" #include "AliRawDataHeader.h" #include "AliRawData.h" @@ -104,7 +104,7 @@ static bool CheckCDH(AliRawDataHeader *cdhRef,AliRawDataHeader *cdh) } //______________________________________________________________________________ -static bool DumpEvent(const char *progname, AliRawEvent *rawEvent) +static bool DumpEvent(const char *progname, AliRawVEvent *rawEvent) { // Dumps and checks one // raw-data event @@ -121,13 +121,13 @@ static bool DumpEvent(const char *progname, AliRawEvent *rawEvent) AliRawDataHeader *cdhRef = NULL; for(Int_t iSubEvent=0; iSubEvent < rawEvent->GetNSubEvents(); iSubEvent++) { - AliRawEvent *rawSubEvent = rawEvent->GetSubEvent(iSubEvent); + AliRawVEvent *rawSubEvent = rawEvent->GetSubEvent(iSubEvent); AliRawEventHeaderBase *rawSubEventHeader = rawSubEvent->GetHeader(); cout << " *********** Sub-event header ***********" << endl; rawSubEventHeader->Print(" "); for(Int_t iEquipment=0; iEquipment < rawSubEvent->GetNEquipments(); iEquipment++) { - AliRawEquipment *rawEquip = rawSubEvent->GetEquipment(iEquipment); + AliRawVEquipment *rawEquip = rawSubEvent->GetEquipment(iEquipment); AliRawEquipmentHeader *rawEquipHeader = rawEquip->GetEquipmentHeader(); cout << " *********** Equipment event header ***********" << endl; rawEquipHeader->Print(" "); @@ -221,7 +221,7 @@ int main(int argc, char **argv) return 1; } - AliRawEvent *rawEvent=NULL; + AliRawVEvent *rawEvent=NULL; rawTree->SetBranchAddress("rawevent", &rawEvent); @@ -234,7 +234,7 @@ int main(int argc, char **argv) cout << "*******************************************" << endl; for(Int_t iEvent=0; iEvent < nEvents; iEvent++) { - rawEvent=new AliRawEvent; + rawEvent=NULL; rawTree->GetEntry(iEvent); cout << " *********** Event " << iEvent << " *******" << endl; DumpEvent(argv[0],rawEvent); diff --git a/RAW/libRAWDatabase.pkg b/RAW/libRAWDatabase.pkg index f017a0c3bcc..fbc536bb2da 100644 --- a/RAW/libRAWDatabase.pkg +++ b/RAW/libRAWDatabase.pkg @@ -1,8 +1,9 @@ #-*- Mode: Makefile -*- SRCS:= AliRawEventHeaderBase.cxx AliRawEquipmentHeader.cxx \ - AliRawData.cxx AliRawEquipment.cxx AliRawEvent.cxx \ - AliRawDataArray.cxx \ + AliRawEquipment.cxx AliRawEvent.cxx \ + AliRawData.cxx AliRawVEquipment.cxx AliRawEquipmentV2.cxx AliRawVEvent.cxx AliRawEventV2.cxx \ + AliRawDataArrayV2.cxx AliRawDataArray.cxx \ AliStats.cxx AliRawEventTag.cxx \ AliAltroMapping.cxx AliCaloAltroMapping.cxx \ AliDAQ.cxx diff --git a/STEER/AliReconstruction.cxx b/STEER/AliReconstruction.cxx index e2691bdd9d2..c484a658f5b 100644 --- a/STEER/AliReconstruction.cxx +++ b/STEER/AliReconstruction.cxx @@ -165,7 +165,7 @@ #include "AliQAv1.h" #include "AliQADataMakerRec.h" #include "AliQAManager.h" -#include "AliRawEvent.h" +#include "AliRawVEvent.h" #include "AliRawEventHeaderBase.h" #include "AliRawHLTManager.h" #include "AliRawReaderDate.h" @@ -1515,7 +1515,7 @@ Bool_t AliReconstruction::Process(Long64_t entry) AliCodeTimerAuto(""); TTree *currTree = fChain->GetTree(); - AliRawEvent *event = new AliRawEvent; + AliRawVEvent *event = NULL; currTree->SetBranchAddress("rawevent",&event); currTree->GetEntry(entry); fRawReader = new AliRawReaderRoot(event); -- 2.39.3