]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/STEER/AliSimulation.cxx
Enabling creation and reading of the CDB snapshot also in simulation
[u/mrichter/AliRoot.git] / STEER / STEER / AliSimulation.cxx
index 9460d9afec83519afef529e87f93b3d875c76337..223f6a1ae75eaa972d75b7de56e8f25b234b7d76 100644 (file)
@@ -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");