From 19359f9c05640c59158d827331686610fcf656f2 Mon Sep 17 00:00:00 2001 From: cvetan Date: Tue, 5 Jun 2007 11:45:14 +0000 Subject: [PATCH] Changes to the AliMDC API requested by DAQ. 1. The writing of the guid file is moved as close as possible to the place where we open the output raw-data file. 2. AliMDC::Open method return error code = -2 in case the guid file can not be opened in the specified folder. 3. AliMDC::ProcessEvent method return error code = -11 in case the tag file can not be created in the specified folder --- RAW/AliMDC.cxx | 35 ++++++++++++++++------------------- RAW/AliMDC.h | 3 ++- RAW/AliRawDB.cxx | 23 +++++++++++++---------- RAW/AliRawDB.h | 6 +----- 4 files changed, 32 insertions(+), 35 deletions(-) diff --git a/RAW/AliMDC.cxx b/RAW/AliMDC.cxx index dac7f34b3f1..2be7729e083 100644 --- a/RAW/AliMDC.cxx +++ b/RAW/AliMDC.cxx @@ -130,19 +130,6 @@ AliMDC::AliMDC(Int_t compress, Bool_t deleteFiles, EFilterMode filterMode, fESD = new AliESD; } -// Tag DB is now created at the point where the header version is -// already known -// if (fileNameTagDB) { -// if (maxSizeTagDB > 0) { -// fTagDB = new AliTagDB(fEvent->GetHeader(), NULL); -// fTagDB->SetMaxSize(maxSizeTagDB); -// fTagDB->SetFS(fileNameTagDB); -// fTagDB->Create(); -// } else { -// fTagDB = new AliTagDB(fEvent->GetHeader(), fileNameTagDB); -// } -// } - // Create the guid files folder if it does not exist if (fGuidFileFolder) { gSystem->ResetErrno(); @@ -206,19 +193,28 @@ Int_t AliMDC::Open(EWriteMode mode, const char* fileName, fRawDB = new AliRawDB(fEvent, fESD, fCompress, fileName); fRawDB->SetDeleteFiles(fDeleteFiles); + if (fRawDB->IsZombie()) { + delete fRawDB; + fRawDB = NULL; + return -1; + } + if (fileName == NULL) { fRawDB->SetMaxSize(maxFileSize); fRawDB->SetFS(fs1, fs2); - fRawDB->Create(); + if (!fRawDB->Create()) { + delete fRawDB; + fRawDB = NULL; + return -1; + } } - if (fGuidFileFolder) fRawDB->SetGuidFileFolder(fGuidFileFolder); - - if (fRawDB->IsZombie()) { + if (!fRawDB->WriteGuidFile(fGuidFileFolder)) { delete fRawDB; fRawDB = NULL; - return -1; + return -2; } + Info("Open", "Filling raw DB %s\n", fRawDB->GetDBName()); // Create AliStats object @@ -393,9 +389,10 @@ Int_t AliMDC::ProcessEvent(void* event, Bool_t isIovecArray) fTagDB = new AliTagDB(fEventTag, NULL); fTagDB->SetMaxSize(fMaxSizeTagDB); fTagDB->SetFS(fFileNameTagDB); - fTagDB->Create(); + if (!fTagDB->Create()) return kErrTagFile; } else { fTagDB = new AliTagDB(fEventTag, fFileNameTagDB); + if (fTagDB->IsZombie()) return kErrTagFile; } } fIsTagDBCreated = kTRUE; diff --git a/RAW/AliMDC.h b/RAW/AliMDC.h index 1c8e76d170c..d488848ee9a 100644 --- a/RAW/AliMDC.h +++ b/RAW/AliMDC.h @@ -49,7 +49,8 @@ public: kErrEquipment = -7, kErrFileSize = -8, kFilterReject = -9, - kErrWriting = -10 }; + kErrWriting = -10, + kErrTagFile = -11}; AliMDC(Int_t compress, Bool_t deleteFiles, EFilterMode filterMode = kFilterTransparent, diff --git a/RAW/AliRawDB.cxx b/RAW/AliRawDB.cxx index f9436e5cd3a..2be89658da4 100644 --- a/RAW/AliRawDB.cxx +++ b/RAW/AliRawDB.cxx @@ -66,8 +66,7 @@ AliRawDB::AliRawDB(AliRawEvent *event, fFS1(""), fFS2(""), fDeleteFiles(kFALSE), - fStop(kFALSE), - fGuidFileFolder(NULL) + fStop(kFALSE) { // Create a new raw DB @@ -318,10 +317,6 @@ Int_t AliRawDB::Close() return -1; } - // Write a text file with file GUID - // in the specified folder - WriteGuidFile(); - delete fRawDB; fRawDB = 0; if(!error) @@ -452,14 +447,16 @@ const char *AliRawDB::GetAliRootTag() } //______________________________________________________________________________ -void AliRawDB::WriteGuidFile() +Bool_t AliRawDB::WriteGuidFile(const char *guidFileFolder) { // Write the guid file - // in the specified folder + // in the specified folder or + // in the folder where the raw data + // file is. TString guidFileName; - if (fGuidFileFolder) { - guidFileName = fGuidFileFolder; + if (guidFileFolder) { + guidFileName = guidFileFolder; TString pathStr = fRawDB->GetName(); TObjArray *pathArr = pathStr.Tokenize('/'); @@ -474,7 +471,13 @@ void AliRawDB::WriteGuidFile() guidFileName += ".guid"; ofstream fguid(guidFileName.Data()); + if (!fguid.is_open()) { + Error("WriteGuidFile", "failure to open guid file %s", guidFileName.Data()); + return kFALSE; + } TString guid = fRawDB->GetUUID().AsString(); fguid << "guid: \t" << guid.Data(); fguid.close(); + + return kTRUE; } diff --git a/RAW/AliRawDB.h b/RAW/AliRawDB.h index 28ca3600623..04b1499dd78 100644 --- a/RAW/AliRawDB.h +++ b/RAW/AliRawDB.h @@ -58,8 +58,6 @@ public: void SetMaxSize(Double_t maxSize) { fMaxSize = maxSize; } void SetFS(const char* fs1, const char* fs2 = NULL); void SetDeleteFiles(Bool_t deleteFiles = kTRUE) { fDeleteFiles = deleteFiles; } - void SetGuidFileFolder(const char* guidFileFolder) - { fGuidFileFolder = guidFileFolder; } Bool_t NextFile(const char* fileName = NULL); @@ -72,6 +70,7 @@ public: Int_t GetCompressionMode() const { return fRawDB->GetCompressionLevel(); } void Stop() { fStop = kTRUE; } static const char *GetAliRootTag(); + Bool_t WriteGuidFile(const char *guidFileFolder); protected: TFile *fRawDB; // DB to store raw data @@ -86,15 +85,12 @@ protected: TString fFS2; // second raw DB file system location Bool_t fDeleteFiles; // flag for deletion of files Bool_t fStop; // stop execution (triggered by SIGUSR1) - const char *fGuidFileFolder; // folder which contains guid files static const char *fgkAliRootTag; // string with the aliroot tag id virtual const char *GetFileName() const; virtual Bool_t FSHasSpace(const char *fs) const; virtual void MakeTree(); - void WriteGuidFile(); - private: AliRawDB(const AliRawDB& rawDB); AliRawDB& operator = (const AliRawDB& rawDB); -- 2.39.3