From f5cb4aecdc46e8874d3e8c21d0c1bed70e18a4a6 Mon Sep 17 00:00:00 2001 From: rgrosso Date: Mon, 23 Jan 2012 11:20:05 +0000 Subject: [PATCH] Enabling creation and reading of the CDB snapshot also in simulation --- STEER/STEER/AliSimulation.cxx | 31 +++++++++++++++++++++++++------ STEER/STEER/AliSimulation.h | 4 ++++ 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/STEER/STEER/AliSimulation.cxx b/STEER/STEER/AliSimulation.cxx index 9460d9afec8..223f6a1ae75 100644 --- a/STEER/STEER/AliSimulation.cxx +++ b/STEER/STEER/AliSimulation.cxx @@ -194,6 +194,8 @@ AliSimulation::AliSimulation(const char* configFileName, fRun(-1), fSeed(0), fInitCDBCalled(kFALSE), + fFromCDBSnapshot(kFALSE), + fSnapshotFileName(""), fInitRunNumberCalled(kFALSE), fSetRunNumberFromDataCalled(kFALSE), fEmbeddingFlag(kFALSE), @@ -749,15 +751,27 @@ Bool_t AliSimulation::Run(Int_t nEvents) AliSysInfo::AddStamp("RunHLT"); //QA - if (fRunQA) { - Bool_t rv = RunQA() ; - if (!rv) - if (fStopOnError) - return kFALSE ; - } + if (fRunQA) { + Bool_t rv = RunQA() ; + if (!rv) + if (fStopOnError) + return kFALSE ; + } AliSysInfo::AddStamp("RunQA"); + TString snapshotFileOut(""); // we could use fSnapshotFileName if we are not interested + // in reading from and writing to a snapshot file at the same time + if(TString(gSystem->Getenv("OCDB_SNAPSHOT_CREATE")) == TString("kTRUE")){ + AliInfo(" ******** Creating the snapshot! *********"); + TString snapshotFile(gSystem->Getenv("OCDB_SNAPSHOT_FILENAME")); + if(!(snapshotFile.IsNull() || snapshotFile.IsWhitespace())) + snapshotFileOut = snapshotFile; + else + snapshotFileOut="OCDB.root"; + AliCDBManager::Instance()->DumpToSnapshotFile(snapshotFileOut.Data()); + } + // Cleanup of CDB manager: cache and active storages! AliCDBManager::Instance()->ClearCache(); @@ -978,6 +992,11 @@ Bool_t AliSimulation::RunSimulation(Int_t nEvents) InitCDB(); AliSysInfo::AddStamp("RunSimulation_InitCDB"); InitRunNumber(); + if(fFromCDBSnapshot){ + AliDebug(2,Form("Initializing from the CDB snapshot \"%s\"",fSnapshotFileName.Data())); + AliCDBManager::Instance()->InitFromSnapshot(fSnapshotFileName.Data()); + } + SetCDBLock(); AliSysInfo::AddStamp("RunSimulation_SetCDBLock"); diff --git a/STEER/STEER/AliSimulation.h b/STEER/STEER/AliSimulation.h index e3d67681dd8..1aacd356481 100644 --- a/STEER/STEER/AliSimulation.h +++ b/STEER/STEER/AliSimulation.h @@ -80,6 +80,8 @@ public: // CDB storage activation void SetDefaultStorage(const char* uri); void SetSpecificStorage(const char* calibType, const char* uri); + void SetFromCDBSnapshot(const char* snapshotFileName) {fFromCDBSnapshot = kTRUE; fSnapshotFileName=snapshotFileName;} + void UnSetFromCDBSnapshot() {fFromCDBSnapshot = kFALSE;} virtual Bool_t Run(Int_t nEvents = 0); virtual Bool_t RunLego(const char *setup="Config.C",Int_t nc1=60,Float_t c1min=2,Float_t c1max=178, @@ -183,6 +185,8 @@ private: Int_t fRun; //! Run number, will be passed to CDB and gAlice!! Int_t fSeed; //! Seed for random number generator Bool_t fInitCDBCalled; //! flag to check if CDB storages are already initialized + Bool_t fFromCDBSnapshot; //! flag to check if we are loading the CDB from a snapshot + TString fSnapshotFileName; //! string for the file containing the CDB snapshot Bool_t fInitRunNumberCalled; //! flag to check if run number is already initialized Bool_t fSetRunNumberFromDataCalled; //! flag to check if run number is already loaded from run loader -- 2.43.0