From f07ec91134d579190702795f9e48455f81a25b59 Mon Sep 17 00:00:00 2001 From: cvetan Date: Mon, 13 Jun 2005 08:04:22 +0000 Subject: [PATCH] Updates to RAW package. Used during the Computing DC. --- RAW/AliMDC.cxx | 15 ++++++++++----- RAW/AliMDC.h | 7 ++++--- RAW/AliRawCastorDB.cxx | 21 +++++++++++++++++---- RAW/AliRawCastorDB.h | 2 +- RAW/AliRawDB.cxx | 43 +++++++++++++++++++++++++++++++----------- RAW/AliRawDB.h | 4 ++-- RAW/AliRawNullDB.cxx | 20 ++++++++++++++++---- RAW/AliRawNullDB.h | 2 +- RAW/AliRawRFIODB.cxx | 21 +++++++++++++++++---- RAW/AliRawRFIODB.h | 2 +- RAW/AliRawRootdDB.cxx | 20 ++++++++++++++++---- RAW/AliRawRootdDB.h | 2 +- RAW/AliRunDB.cxx | 12 ++++++++++++ RAW/AliTagDB.cxx | 6 ++++++ RAW/alimdc_main.cxx | 3 ++- RAW/mdc.cxx | 1 + 16 files changed, 139 insertions(+), 42 deletions(-) diff --git a/RAW/AliMDC.cxx b/RAW/AliMDC.cxx index d1c94afabbc..19a6d5e8e22 100644 --- a/RAW/AliMDC.cxx +++ b/RAW/AliMDC.cxx @@ -77,7 +77,6 @@ #include "AliMDC.h" - ClassImp(AliMDC) @@ -208,7 +207,7 @@ Int_t AliMDC::Open(EWriteMode mode, const char* fileName) if (fRawDB->IsZombie()) { delete fRawDB; fRawDB = NULL; - return 1; + return -1; } Info("Open", "Filling raw DB %s\n", fRawDB->GetDBName()); @@ -378,7 +377,10 @@ Int_t AliMDC::ProcessEvent(void* event, Bool_t isIovecArray) // Clean up HLT ESD for the next event if (fESD) fESD->Reset(); - return nBytes; + if(nBytes >= 0) + return nBytes; + else + return kErrWriting; } //______________________________________________________________________________ @@ -396,15 +398,16 @@ Int_t AliMDC::Close() { // close the current raw DB file - if (!fRawDB) return 1; + if (!fRawDB) return -1; fRawDB->WriteStats(fStats); fRunDB->Update(fStats); + Int_t filesize = fRawDB->Close(); delete fRawDB; fRawDB = NULL; delete fStats; fStats = NULL; - return 0; + return filesize; } //______________________________________________________________________________ @@ -545,6 +548,8 @@ Int_t AliMDC::Run(const char* inputFile, Bool_t loop, } Int_t result = ProcessEvent(event, !inputFile); + if(result < -1) + Error("Run", "error writing data. Error code: %d",result); if (result >= 0) { numEvents++; diff --git a/RAW/AliMDC.h b/RAW/AliMDC.h index 2e238e01070..eecf2417b33 100644 --- a/RAW/AliMDC.h +++ b/RAW/AliMDC.h @@ -40,15 +40,16 @@ class AliMDC : public TObject { public: enum EWriteMode { kLOCAL, kRFIO, kROOTD, kCASTOR, kDEVNULL }; enum EFilterMode { kFilterOff, kFilterTransparent, kFilterOn }; - enum EErrorCode { kFilterReject = 0, - kErrStartEndRun = -1, + enum EErrorCode { kErrStartEndRun = -1, kErrHeader = -2, kErrHeaderSize = -3, kErrSubHeader = -4, kErrDataSize = -5, kErrEquipmentHeader = -6, kErrEquipment = -7, - kErrFileSize = -8 }; + kErrFileSize = -8, + kFilterReject = -9, + kErrWriting = -10 }; AliMDC(Int_t compress, Bool_t deleteFiles, EFilterMode filterMode = kFilterTransparent, diff --git a/RAW/AliRawCastorDB.cxx b/RAW/AliRawCastorDB.cxx index f57921b0f85..9f81676af90 100644 --- a/RAW/AliRawCastorDB.cxx +++ b/RAW/AliRawCastorDB.cxx @@ -103,21 +103,29 @@ const char *AliRawCastorDB::GetFileName() const } //______________________________________________________________________________ -void AliRawCastorDB::Close() +Int_t AliRawCastorDB::Close() { // Close raw CASTOR/rootd DB. - if (!fRawDB) return; + if (!fRawDB) return 0; + + if (!fRawDB->IsOpen()) return 0; fRawDB->cd(); // Write the tree. - fTree->Write(); - if (fESDTree) fESDTree->Write(); + Bool_t error = kFALSE; + if (fTree->Write() == 0) + error = kTRUE; + if (fESDTree) + if (fESDTree->Write() == 0) + error = kTRUE; // Close DB, this also deletes the fTree fRawDB->Close(); + Int_t filesize = fRawDB->GetEND(); + if (fDeleteFiles) { TUrl u(fRawDB->GetName()); gSystem->Exec(Form("rfrm %s", u.GetFile())); @@ -125,4 +133,9 @@ void AliRawCastorDB::Close() delete fRawDB; fRawDB = 0; + + if(!error) + return filesize; + else + return -1; } diff --git a/RAW/AliRawCastorDB.h b/RAW/AliRawCastorDB.h index 88766bf6d19..e744bab35b5 100644 --- a/RAW/AliRawCastorDB.h +++ b/RAW/AliRawCastorDB.h @@ -26,7 +26,7 @@ public: const char *GetOpenOption() const { return "-RECREATE"; } Int_t GetNetopt() const { return 0; } - void Close(); + Int_t Close(); private: const char *GetFileName() const; diff --git a/RAW/AliRawDB.cxx b/RAW/AliRawDB.cxx index 1810a69b595..1bf1e618d59 100644 --- a/RAW/AliRawDB.cxx +++ b/RAW/AliRawDB.cxx @@ -185,7 +185,7 @@ Bool_t AliRawDB::Create(const char* fileName) { // Create a new raw DB. - const Int_t kMaxRetry = 200; + const Int_t kMaxRetry = 1; const Int_t kMaxSleep = 1; // seconds const Int_t kMaxSleepLong = 10; // seconds Int_t retry = 0; @@ -203,8 +203,8 @@ again: retry++; fRawDB = TFile::Open(fname, GetOpenOption(), - Form("ALICE MDC%d raw DB", kMDC), fCompress, - GetNetopt()); + Form("ALICE MDC%d raw DB", kMDC), fCompress, + GetNetopt()); if (!fRawDB) { if (retry < kMaxRetry) { Warning("Create", "failure to open file, sleeping %d %s before retrying...", @@ -275,26 +275,36 @@ void AliRawDB::MakeTree() } //______________________________________________________________________________ -void AliRawDB::Close() +Int_t AliRawDB::Close() { // Close raw DB. + if (!fRawDB) return 0; - if (!fRawDB) return; + if (!fRawDB->IsOpen()) return 0; fRawDB->cd(); // Write the tree. - fTree->Write(); - if (fESDTree) fESDTree->Write(); + Bool_t error = kFALSE; + if (fTree->Write() == 0) + error = kTRUE; + if (fESDTree) + if (fESDTree->Write() == 0) + error = kTRUE; // Close DB, this also deletes the fTree fRawDB->Close(); + Int_t filesize = fRawDB->GetEND(); + if (fDeleteFiles) { gSystem->Unlink(fRawDB->GetName()); delete fRawDB; fRawDB = 0; - return; + if(!error) + return filesize; + else + return -1; } // Create semaphore to say this file is finished @@ -303,6 +313,10 @@ void AliRawDB::Close() delete fRawDB; fRawDB = 0; + if(!error) + return filesize; + else + return -1; } //______________________________________________________________________________ @@ -311,9 +325,16 @@ Int_t AliRawDB::Fill() // Fill the trees and return the number of written bytes Double_t bytes = fRawDB->GetBytesWritten(); - fTree->Fill(); - if (fESDTree) fESDTree->Fill(); - return Int_t(fRawDB->GetBytesWritten() - bytes); + Bool_t error = kFALSE; + if (fTree->Fill() == -1) + error = kTRUE; + if (fESDTree) + if (fESDTree->Fill() == -1) + error = kTRUE; + if(!error) + return Int_t(fRawDB->GetBytesWritten() - bytes); + else + return -1; } //______________________________________________________________________________ diff --git a/RAW/AliRawDB.h b/RAW/AliRawDB.h index bd178fe3660..e5098964a38 100644 --- a/RAW/AliRawDB.h +++ b/RAW/AliRawDB.h @@ -42,12 +42,12 @@ public: AliESD *esd, Int_t compress, const char* fileName = NULL); - virtual ~AliRawDB() { Close(); } + virtual ~AliRawDB() { if(Close()==-1) Error("~AliRawDB", "cannot close output file!"); } virtual const char *GetOpenOption() const { return "RECREATE"; } virtual Int_t GetNetopt() const { return 0; } virtual Bool_t Create(const char* fileName = NULL); - virtual void Close(); + virtual Int_t Close(); Int_t Fill(); Int_t GetTotalSize(); diff --git a/RAW/AliRawNullDB.cxx b/RAW/AliRawNullDB.cxx index 7455f9d8421..eefde1cf9c4 100644 --- a/RAW/AliRawNullDB.cxx +++ b/RAW/AliRawNullDB.cxx @@ -48,21 +48,33 @@ const char *AliRawNullDB::GetFileName() const } //______________________________________________________________________________ -void AliRawNullDB::Close() +Int_t AliRawNullDB::Close() { // Close raw RFIO DB. - if (!fRawDB) return; + if (!fRawDB) return 0; + + if (!fRawDB->IsOpen()) return 0; fRawDB->cd(); // Write the tree. - fTree->Write(); - if (fESDTree) fESDTree->Write(); + Bool_t error = kFALSE; + if (fTree->Write() == 0) + error = kTRUE; + if (fESDTree) + if (fESDTree->Write() == 0) + error = kTRUE; // Close DB, this also deletes the fTree fRawDB->Close(); + Int_t filesize = fRawDB->GetEND(); + delete fRawDB; fRawDB = 0; + if(!error) + return filesize; + else + return -1; } diff --git a/RAW/AliRawNullDB.h b/RAW/AliRawNullDB.h index 4f462adafd1..0d0ffb5a623 100644 --- a/RAW/AliRawNullDB.h +++ b/RAW/AliRawNullDB.h @@ -24,7 +24,7 @@ public: const char* fileName); ~AliRawNullDB() { Close(); } - void Close(); + Int_t Close(); private: const char *GetFileName() const; diff --git a/RAW/AliRawRFIODB.cxx b/RAW/AliRawRFIODB.cxx index 899eb3346f6..8b8dac2785c 100644 --- a/RAW/AliRawRFIODB.cxx +++ b/RAW/AliRawRFIODB.cxx @@ -103,21 +103,29 @@ const char *AliRawRFIODB::GetFileName() const } //______________________________________________________________________________ -void AliRawRFIODB::Close() +Int_t AliRawRFIODB::Close() { // Close raw RFIO DB. - if (!fRawDB) return; + if (!fRawDB) return 0; + + if (!fRawDB->IsOpen()) return 0; fRawDB->cd(); // Write the tree. - fTree->Write(); - if (fESDTree) fESDTree->Write(); + Bool_t error = kFALSE; + if (fTree->Write() == 0) + error = kTRUE; + if (fESDTree) + if (fESDTree->Write() == 0) + error = kTRUE; // Close DB, this also deletes the fTree fRawDB->Close(); + Int_t filesize = fRawDB->GetEND(); + if (fDeleteFiles) { TUrl u(fRawDB->GetName()); gSystem->Exec(Form("rfrm %s", u.GetFile())); @@ -125,4 +133,9 @@ void AliRawRFIODB::Close() delete fRawDB; fRawDB = 0; + + if(!error) + return filesize; + else + return -1; } diff --git a/RAW/AliRawRFIODB.h b/RAW/AliRawRFIODB.h index 529cfe177c8..436d56ddb26 100644 --- a/RAW/AliRawRFIODB.h +++ b/RAW/AliRawRFIODB.h @@ -24,7 +24,7 @@ public: const char* fileName = NULL); ~AliRawRFIODB() { Close(); } - void Close(); + Int_t Close(); private: const char *GetFileName() const; diff --git a/RAW/AliRawRootdDB.cxx b/RAW/AliRawRootdDB.cxx index 1de0c9a30bd..542e3de5d00 100644 --- a/RAW/AliRawRootdDB.cxx +++ b/RAW/AliRawRootdDB.cxx @@ -87,21 +87,29 @@ const char *AliRawRootdDB::GetFileName() const } //______________________________________________________________________________ -void AliRawRootdDB::Close() +Int_t AliRawRootdDB::Close() { // Close raw rootd DB. - if (!fRawDB) return; + if (!fRawDB) return 0; + + if (!fRawDB->IsOpen()) return 0; fRawDB->cd(); // Write the tree. - fTree->Write(); - if (fESDTree) fESDTree->Write(); + Bool_t error = kFALSE; + if (fTree->Write() == 0) + error = kTRUE; + if (fESDTree) + if (fESDTree->Write() == 0) + error = kTRUE; // Close DB, this also deletes the fTree fRawDB->Close(); + Int_t filesize = fRawDB->GetEND(); + #if 0 // can use services of TFTP if (fDeleteFiles) @@ -110,4 +118,8 @@ void AliRawRootdDB::Close() delete fRawDB; fRawDB = 0; + if(!error) + return filesize; + else + return -1; } diff --git a/RAW/AliRawRootdDB.h b/RAW/AliRawRootdDB.h index d226c4bb890..43532f3b961 100644 --- a/RAW/AliRawRootdDB.h +++ b/RAW/AliRawRootdDB.h @@ -24,7 +24,7 @@ public: const char* fileName = NULL); ~AliRawRootdDB() { Close(); } - void Close(); + Int_t Close(); private: const char *GetFileName() const; diff --git a/RAW/AliRunDB.cxx b/RAW/AliRunDB.cxx index e89333f6857..90fc4be54d3 100644 --- a/RAW/AliRunDB.cxx +++ b/RAW/AliRunDB.cxx @@ -57,6 +57,12 @@ AliRunDB::AliRunDB(const char* localFS, Bool_t rdbms, // check that fs exists (crude check fails if fs is a file) gSystem->MakeDirectory(localFS); + // Put wide read-write permissions + if(gSystem->Chmod(localFS,1023)) { + Error("AliRunDB","can't set permissions for run DB directory"); + return; + } + strcpy(hostname, gSystem->HostName()); char *s; @@ -69,6 +75,12 @@ AliRunDB::AliRunDB(const char* localFS, Bool_t rdbms, fRunDB = new TFile(filename, "UPDATE"); else fRunDB = new TFile(filename, "CREATE", Form("ALICE MDC%d Run DB", AliRawDB::kMDC)); + + // Put wide read-write permissions + if(gSystem->Chmod(filename,438)) { + Error("AliRunDB","can't set permissions for run DB file"); + return; + } } //______________________________________________________________________________ diff --git a/RAW/AliTagDB.cxx b/RAW/AliTagDB.cxx index b77044d7ba1..1fa42188731 100644 --- a/RAW/AliTagDB.cxx +++ b/RAW/AliTagDB.cxx @@ -84,6 +84,12 @@ Bool_t AliTagDB::Create(const char* fileName) fTagDB = 0; return kFALSE; } + // Put wide read-write permissions + if(gSystem->Chmod(name,438)) { + Error("Create", "can't set permissions for tag DB file"); + fTagDB = 0; + return kFALSE; + } // Create ROOT Tree object container fTree = new TTree("TAG", Form("ALICE MDC%d header data tree", AliRawDB::kMDC)); diff --git a/RAW/alimdc_main.cxx b/RAW/alimdc_main.cxx index 44f41e810eb..61b19dd7b60 100644 --- a/RAW/alimdc_main.cxx +++ b/RAW/alimdc_main.cxx @@ -160,7 +160,8 @@ int main(int argc, char **argv) const char* castorFS = castorStr.Data(); #endif const char* rootdFS = "root://localhost//tmp/mdc1"; - const char* alienHost = "alien://aliens7.cern.ch:15000/?direct"; + // const char* alienHost = "alien://aliens7.cern.ch:15000/?direct"; + const char* alienHost = NULL; const char* alienDir = "/alice_mdc/DC"; // User defined file system locations diff --git a/RAW/mdc.cxx b/RAW/mdc.cxx index d142c454524..67a32b81d2c 100644 --- a/RAW/mdc.cxx +++ b/RAW/mdc.cxx @@ -81,4 +81,5 @@ void alimdcEnableDebug() AliLog::SetGlobalLogLevel(AliLog::kMaxType); AliLog::SetGlobalDebugLevel(AliLog::kMaxType); AliLog::SetPrintRepetitions(kFALSE); + AliLog::SetHandleRootMessages(kTRUE); } -- 2.43.0