From d21e9888ae6e8f21dadff5bd27ee889c6495c271 Mon Sep 17 00:00:00 2001 From: cvetan Date: Wed, 16 Mar 2005 11:44:00 +0000 Subject: [PATCH] Method to get an approximate output file size is added. AliMDC ProcessEvent method gives an warning and returns an error when the size of the output file reaches 2Gb limit. --- RAW/AliMDC.cxx | 22 ++++++++++++++++++++++ RAW/AliMDC.h | 4 +++- RAW/AliRawDB.cxx | 39 +++++++++++++++++++++++++++++++++++++++ RAW/AliRawDB.h | 1 + RAW/mdc.cxx | 7 +++++++ RAW/mdc.h | 1 + 6 files changed, 73 insertions(+), 1 deletion(-) diff --git a/RAW/AliMDC.cxx b/RAW/AliMDC.cxx index 9da6b27cc6f..ed929a6c445 100644 --- a/RAW/AliMDC.cxx +++ b/RAW/AliMDC.cxx @@ -227,6 +227,18 @@ Int_t AliMDC::ProcessEvent(void* event, Bool_t isIovecArray) // or, if isIovecArray is kTRUE, a pointer to an array of iovecs with one // iovec per subevent (used by the event builder). // The return value is the number of written bytes or an error code + const UInt_t kFileSizeWarningLevel = 1800000000; + const UInt_t kFileSizeErrorLevel = 1900000000; + + UInt_t currentFileSize = GetTotalSize(); + if(currentFileSize > kFileSizeErrorLevel) { + Error("ProcessEvent", "file size (%u) exceeds the limit " + , currentFileSize); + return kErrFileSize; + } + if(currentFileSize > kFileSizeWarningLevel) + Warning("ProcessEvent", "file size (%u) is close to the limit " + , currentFileSize); Int_t status; char* data = (char*) event; @@ -373,6 +385,16 @@ Int_t AliMDC::ProcessEvent(void* event, Bool_t isIovecArray) return nBytes; } +//______________________________________________________________________________ +Int_t AliMDC::GetTotalSize() +{ +// return the total current raw DB file size + + if (!fRawDB) return -1; + + return fRawDB->GetTotalSize(); +} + //______________________________________________________________________________ Int_t AliMDC::Close() { diff --git a/RAW/AliMDC.h b/RAW/AliMDC.h index ee7815bced7..2e238e01070 100644 --- a/RAW/AliMDC.h +++ b/RAW/AliMDC.h @@ -47,7 +47,8 @@ public: kErrSubHeader = -4, kErrDataSize = -5, kErrEquipmentHeader = -6, - kErrEquipment = -7 }; + kErrEquipment = -7, + kErrFileSize = -8 }; AliMDC(Int_t compress, Bool_t deleteFiles, EFilterMode filterMode = kFilterTransparent, @@ -58,6 +59,7 @@ public: Int_t Open(EWriteMode mode, const char* fileName); Int_t ProcessEvent(void* event, Bool_t isIovecArray = kFALSE); + Int_t GetTotalSize(); Int_t Close(); Int_t Run(const char* inputFile, Bool_t loop, diff --git a/RAW/AliRawDB.cxx b/RAW/AliRawDB.cxx index 5259a344479..34bcbfa48e1 100644 --- a/RAW/AliRawDB.cxx +++ b/RAW/AliRawDB.cxx @@ -25,6 +25,7 @@ #include #include +#include #ifdef ALI_DATE #include "event.h" @@ -315,6 +316,44 @@ Int_t AliRawDB::Fill() return Int_t(fRawDB->GetBytesWritten() - bytes); } +//______________________________________________________________________________ +Int_t AliRawDB::GetTotalSize() +{ + // Return the total size of the trees + Int_t total = 0; + + { + Int_t skey = 0; + TDirectory *dir = fTree->GetDirectory(); + if (dir) { + TKey *key = dir->GetKey(fTree->GetName()); + if (key) skey = key->GetKeylen(); + } + total += skey; + if (fTree->GetZipBytes() > 0) total += fTree->GetTotBytes(); + TBuffer b(TBuffer::kWrite,10000); + TTree::Class()->WriteBuffer(b,fTree); + total += b.Length(); + } + + if(fESDTree) + { + Int_t skey = 0; + TDirectory *dir = fESDTree->GetDirectory(); + if (dir) { + TKey *key = dir->GetKey(fESDTree->GetName()); + if (key) skey = key->GetKeylen(); + } + total += skey; + if (fESDTree->GetZipBytes() > 0) total += fESDTree->GetTotBytes(); + TBuffer b(TBuffer::kWrite,10000); + TTree::Class()->WriteBuffer(b,fESDTree); + total += b.Length(); + } + + return total; +} + //______________________________________________________________________________ void AliRawDB::WriteStats(AliStats* stats) { diff --git a/RAW/AliRawDB.h b/RAW/AliRawDB.h index d223f848f57..bd178fe3660 100644 --- a/RAW/AliRawDB.h +++ b/RAW/AliRawDB.h @@ -49,6 +49,7 @@ public: virtual Bool_t Create(const char* fileName = NULL); virtual void Close(); Int_t Fill(); + Int_t GetTotalSize(); void WriteStats(AliStats* stats); diff --git a/RAW/mdc.cxx b/RAW/mdc.cxx index a3797e9cfec..d142c454524 100644 --- a/RAW/mdc.cxx +++ b/RAW/mdc.cxx @@ -52,6 +52,13 @@ int alimdcProcessEvent(void* alimdc, void* event, int isIovecArray) return ((AliMDC*)alimdc)->ProcessEvent(event, isIovecArray); } +int alimdcGetTotalFileSize(void* alimdc) +{ +// return the total current file size + + return ((AliMDC*)alimdc)->GetTotalSize(); +} + int alimdcClose(void* alimdc) { // close the raw DB diff --git a/RAW/mdc.h b/RAW/mdc.h index 46860d36a4f..38851f8cb3f 100644 --- a/RAW/mdc.h +++ b/RAW/mdc.h @@ -21,6 +21,7 @@ void* alimdcCreate(int compress, int filterMode, double maxSizeTagDB, const char* fileNameTagDB); int alimdcOpen(void* alimdc, int mode, const char* fileName); int alimdcProcessEvent(void* alimdc, void* event, int isIovecArray); +int alimdcGetTotalFileSize(void* alimdc); int alimdcClose(void* alimdc); void alimdcDelete(void* alimdc); void alimdcEnableDebug(); -- 2.43.0