]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliSimulation.cxx
log messages updated
[u/mrichter/AliRoot.git] / STEER / AliSimulation.cxx
index b930e8c6b933047a91ad3a3d22eaa6a5d150ffdb..b0f5284837dc8683036e588066e07a3f903b80f1 100644 (file)
 #include <TStopwatch.h>
 #include <TSystem.h>
 
+#include "AliLog.h"
 #include "AliDigitizer.h"
 #include "AliGenerator.h"
 #include "AliModule.h"
@@ -142,7 +143,7 @@ AliSimulation::AliSimulation(const char* configFileName,
   fEventsPerFile(),
   fBkgrdFileNames(NULL),
   fUseBkgrdVertex(kTRUE),
-  fRegionOfInterest(kTRUE)
+  fRegionOfInterest(kFALSE)
 {
 // create simulation object with default parameters
 
@@ -238,6 +239,8 @@ void AliSimulation::SetGAliceFile(const char* fileName)
     fGAliceFileName = absFileName;
     delete[] absFileName;
   }
+
+  AliDebug(2, Form("galice file name set to %s", fileName));
 }
 
 //_____________________________________________________________________________
@@ -291,10 +294,10 @@ Bool_t AliSimulation::Run(Int_t nEvents)
   // hits -> digits
   if (!fMakeDigitsFromHits.IsNull()) {
     if (fBkgrdFileNames && (fBkgrdFileNames->GetEntriesFast() > 0)) {
-      Warning("Run", "Merging and direct creation of digits from hits " 
-             "was selected for some detectors. "
-             "No merging will be done for the following detectors: %s",
-             fMakeDigitsFromHits.Data());
+      AliWarning(Form("Merging and direct creation of digits from hits " 
+                 "was selected for some detectors. "
+                 "No merging will be done for the following detectors: %s",
+                 fMakeDigitsFromHits.Data()));
     }
     if (!RunHitsDigitization(fMakeDigitsFromHits)) {
       if (fStopOnError) return kFALSE;
@@ -321,29 +324,30 @@ Bool_t AliSimulation::RunSimulation(Int_t nEvents)
   stopwatch.Start();
 
   if (!gAlice) {
-    Error("RunSimulation", "no gAlice object. Restart aliroot and try again.");
+    AliError("no gAlice object. Restart aliroot and try again.");
     return kFALSE;
   }
   if (gAlice->Modules()->GetEntries() > 0) {
-    Error("RunSimulation", 
-         "gAlice was already run. Restart aliroot and try again.");
+    AliError("gAlice was already run. Restart aliroot and try again.");
     return kFALSE;
   }
 
-  Info("RunSimulation", "initializing gAlice with config file %s",
-       fConfigFileName.Data());
-  gAlice->Init(fConfigFileName.Data());
+  AliInfo(Form("initializing gAlice with config file %s",
+          fConfigFileName.Data()));
+  StdoutToAliInfo(StderrToAliError(
+    gAlice->Init(fConfigFileName.Data());
+  ););
   AliRunLoader* runLoader = gAlice->GetRunLoader();
   if (!runLoader) {
-    Error("RunSimulation", "gAlice has no run loader object. "
-         "Check your config file: %s", fConfigFileName.Data());
+    AliError(Form("gAlice has no run loader object. "
+                  "Check your config file: %s", fConfigFileName.Data()));
     return kFALSE;
   }
   SetGAliceFile(runLoader->GetFileName());
 
   if (!gAlice->Generator()) {
-    Error("RunSimulation", "gAlice has no generator object. "
-         "Check your config file: %s", fConfigFileName.Data());
+    AliError(Form("gAlice has no generator object. "
+                  "Check your config file: %s", fConfigFileName.Data()));
     return kFALSE;
   }
   if (nEvents <= 0) nEvents = fNEvents;
@@ -354,9 +358,9 @@ Bool_t AliSimulation::RunSimulation(Int_t nEvents)
     Int_t signalPerBkgrd = GetNSignalPerBkgrd(nEvents);
     const char* fileName = ((TObjString*)
                            (fBkgrdFileNames->At(0)))->GetName();
-    Info("RunSimulation", "The vertex will be taken from the background "
-        "file %s with nSignalPerBackground = %d", 
-        fileName, signalPerBkgrd);
+    AliInfo(Form("The vertex will be taken from the background "
+                 "file %s with nSignalPerBackground = %d", 
+                 fileName, signalPerBkgrd));
     AliVertexGenFile* vtxGen = new AliVertexGenFile(fileName, signalPerBkgrd);
     gAlice->Generator()->SetVertexGenerator(vtxGen);
   }
@@ -374,31 +378,33 @@ Bool_t AliSimulation::RunSimulation(Int_t nEvents)
     loaderName += "Loader";
     AliLoader* loader = runLoader->GetLoader(loaderName);
     if (!loader) {
-      Error("RunSimulation", "no loader for %s found\n"
-           "Number of events per file not set for %s %s", 
-           detName, typeName, detName);
+      AliError(Form("RunSimulation", "no loader for %s found\n"
+                    "Number of events per file not set for %s %s", 
+                    detName, typeName, detName));
       continue;
     }
     AliDataLoader* dataLoader = 
       loader->GetDataLoader(typeName);
     if (!dataLoader) {
-      Error("RunSimulation", "no data loader for %s found\n"
-           "Number of events per file not set for %s %s", 
-           typeName, detName, typeName);
+      AliError(Form("no data loader for %s found\n"
+                    "Number of events per file not set for %s %s", 
+                    typeName, detName, typeName));
       continue;
     }
     dataLoader->SetNumberOfEventsPerFile(fEventsPerFile[i]->GetUniqueID());
-    Info("RunSimulation", "number of events per file set to %d for %s %s",
-        fEventsPerFile[i]->GetUniqueID(), detName, typeName);
+    AliDebug(1, Form("number of events per file set to %d for %s %s",
+                     fEventsPerFile[i]->GetUniqueID(), detName, typeName));
   }
 
-  Info("RunSimulation", "running gAlice");
-  gAlice->Run(nEvents);
+  AliInfo("running gAlice");
+  StdoutToAliInfo(StderrToAliError(
+    gAlice->Run(nEvents);
+  ););
 
   delete runLoader;
 
-  Info("RunSimulation", "execution time:");
-  stopwatch.Print();
+  AliInfo("execution time:");
+  StdoutToAliInfo(stopwatch.Print(););
 
   return kTRUE;
 }
@@ -420,26 +426,25 @@ Bool_t AliSimulation::RunSDigitization(const char* detectors)
     AliModule* det = (AliModule*) detArray->At(iDet);
     if (!det || !det->IsActive()) continue;
     if (IsSelected(det->GetName(), detStr)) {
-      Info("RunSDigitization", "creating summable digits for %s", 
-          det->GetName());
+      AliInfo(Form("creating summable digits for %s", det->GetName()));
       TStopwatch stopwatchDet;
       stopwatchDet.Start();
       det->Hits2SDigits();
-      Info("RunSDigitization", "execution time for %s:", det->GetName());
-      stopwatchDet.Print();
+      AliInfo(Form("execution time for %s:", det->GetName()));
+      StdoutToAliInfo(stopwatchDet.Print(););
     }
   }
 
   if ((detStr.CompareTo("ALL") != 0) && !detStr.IsNull()) {
-    Error("RunSDigitization", "the following detectors were not found: %s", 
-         detStr.Data());
+    AliError(Form("the following detectors were not found: %s",
+                  detStr.Data()));
     if (fStopOnError) return kFALSE;
   }
 
   delete runLoader;
 
-  Info("RunSDigitization", "execution time:");
-  stopwatch.Print();
+  AliInfo("execution time:");
+  StdoutToAliInfo(stopwatch.Print(););
 
   return kTRUE;
 }
@@ -482,7 +487,7 @@ Bool_t AliSimulation::RunDigitization(const char* detectors,
        !IsSelected(det->GetName(), detExcl)) {
       AliDigitizer* digitizer = det->CreateDigitizer(manager);
       if (!digitizer) {
-       Error("RunDigitization", "no digitizer for %s", det->GetName());
+       AliError(Form("no digitizer for %s", det->GetName()));
        if (fStopOnError) return kFALSE;
       } else {
        digitizer->SetRegionOfInterest(fRegionOfInterest);
@@ -491,20 +496,20 @@ Bool_t AliSimulation::RunDigitization(const char* detectors,
   }
 
   if ((detStr.CompareTo("ALL") != 0) && !detStr.IsNull()) {
-    Error("RunDigitization", "the following detectors were not found: %s", 
-         detStr.Data());
+    AliError(Form("the following detectors were not found: %s", 
+                  detStr.Data()));
     if (fStopOnError) return kFALSE;
   }
 
   if (!manager->GetListOfTasks()->IsEmpty()) {
-    Info("RunDigitization", "executing digitization");
+    AliInfo("executing digitization");
     manager->Exec("");
   }
 
   delete manager;
 
-  Info("RunDigitization", "execution time:");
-  stopwatch.Print();
+  AliInfo("execution time:");
+  StdoutToAliInfo(stopwatch.Print(););
 
   return kTRUE;
 }
@@ -526,22 +531,21 @@ Bool_t AliSimulation::RunHitsDigitization(const char* detectors)
     AliModule* det = (AliModule*) detArray->At(iDet);
     if (!det || !det->IsActive()) continue;
     if (IsSelected(det->GetName(), detStr)) {
-      Info("RunHitsDigitization", "creating digits from hits for %s", 
-          det->GetName());
+      AliInfo(Form("creating digits from hits for %s", det->GetName()));
       det->Hits2Digits();
     }
   }
 
   if ((detStr.CompareTo("ALL") != 0) && !detStr.IsNull()) {
-    Error("RunHitsDigitization", "the following detectors were not found: %s", 
-         detStr.Data());
+    AliError(Form("the following detectors were not found: %s", 
+                  detStr.Data()));
     if (fStopOnError) return kFALSE;
   }
 
   delete runLoader;
 
-  Info("RunHitsDigitization", "execution time:");
-  stopwatch.Print();
+  AliInfo("execution time:");
+  StdoutToAliInfo(stopwatch.Print(););
 
   return kTRUE;
 }
@@ -594,8 +598,8 @@ Bool_t AliSimulation::WriteRawData(const char* detectors,
     }
   }
 
-  Info("WriteRawData", "execution time:");
-  stopwatch.Print();
+  AliInfo("execution time:");
+  StdoutToAliInfo(stopwatch.Print(););
 
   return kTRUE;
 }
@@ -610,14 +614,14 @@ Bool_t AliSimulation::WriteRawFiles(const char* detectors)
 
   // write raw data to DDL files
   for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) {
-    Info("WriteRawFiles", "processing event %d", iEvent);
+    AliInfo(Form("processing event %d", iEvent));
     runLoader->GetEvent(iEvent);
     TString baseDir = gSystem->WorkingDirectory();
     char dirName[256];
     sprintf(dirName, "raw%d", iEvent);
     gSystem->MakeDirectory(dirName);
     if (!gSystem->ChangeDirectory(dirName)) {
-      Error("WriteRawData", "couldn't change to directory %s", dirName);
+      AliError(Form("couldn't change to directory %s", dirName));
       if (fStopOnError) return kFALSE; else continue;
     }
 
@@ -627,16 +631,15 @@ Bool_t AliSimulation::WriteRawFiles(const char* detectors)
       AliModule* det = (AliModule*) detArray->At(iDet);
       if (!det || !det->IsActive()) continue;
       if (IsSelected(det->GetName(), detStr)) {
-       Info("WriteRawData", "creating raw data from digits for %s", 
-            det->GetName());
+       AliInfo(Form("creating raw data from digits for %s", det->GetName()));
        det->Digits2Raw();
       }
     }
 
     gSystem->ChangeDirectory(baseDir);
     if ((detStr.CompareTo("ALL") != 0) && !detStr.IsNull()) {
-      Error("WriteRawData", "the following detectors were not found: %s", 
-           detStr.Data());
+      AliError(Form("the following detectors were not found: %s", 
+                    detStr.Data()));
       if (fStopOnError) return kFALSE;
     }
   }
@@ -670,7 +673,7 @@ Bool_t AliSimulation::ConvertRawFilesToDate(const char* dateFileName)
 
   char* path = gSystem->Which(gSystem->Getenv("PATH"), "dateStream");
   if (!path) {
-    Error("ConvertRawFilesToDate", "the program dateStream was not found");
+    AliError("the program dateStream was not found");
     if (fStopOnError) return kFALSE;
   } else {
     delete[] path;
@@ -679,8 +682,7 @@ Bool_t AliSimulation::ConvertRawFilesToDate(const char* dateFileName)
   AliRunLoader* runLoader = LoadRun("READ");
   if (!runLoader) return kFALSE;
 
-  Info("ConvertRawFilesToDate", 
-       "converting raw data DDL files to DATE file %s", dateFileName);
+  AliInfo(Form("converting raw data DDL files to DATE file %s", dateFileName));
   char command[256];
   sprintf(command, "dateStream -o %s -# %d -C", 
          dateFileName, runLoader->GetNumberOfEvents());
@@ -742,14 +744,14 @@ Bool_t AliSimulation::ConvertDateToRoot(const char* dateFileName,
 
   char* path = gSystem->Which(gSystem->Getenv("PATH"), "alimdc");
   if (!path) {
-    Error("ConvertDateToRoot", "the program alimdc was not found");
+    AliError("the program alimdc was not found");
     if (fStopOnError) return kFALSE;
   } else {
     delete[] path;
   }
 
-  Info("ConvertDateToRoot", "converting DATE file %s to root file %s", 
-       dateFileName, rootFileName);
+  AliInfo(Form("converting DATE file %s to root file %s", 
+               dateFileName, rootFileName));
 
   gSystem->Exec("rm -rf /tmp/mdc1");
   gSystem->Exec("rm -rf /tmp/mdc2");
@@ -776,15 +778,14 @@ AliRunLoader* AliSimulation::LoadRun(const char* mode) const
     AliRunLoader::Open(fGAliceFileName.Data(), 
                       AliConfig::GetDefaultEventFolderName(), mode);
   if (!runLoader) {
-    Error("LoadRun", "no run loader found in file %s", 
-         fGAliceFileName.Data());
+    AliError(Form("no run loader found in file %s", fGAliceFileName.Data()));
     return NULL;
   }
   runLoader->LoadgAlice();
   gAlice = runLoader->GetAliRun();
   if (!gAlice) {
-    Error("LoadRun", "no gAlice object found in file %s", 
-         fGAliceFileName.Data());
+    AliError(Form("no gAlice object found in file %s", 
+                  fGAliceFileName.Data()));
     return NULL;
   }
   return runLoader;
@@ -824,18 +825,17 @@ Int_t AliSimulation::GetNSignalPerBkgrd(Int_t nEvents) const
     if (nSignalPerBkgrd <= 0) {
       nSignalPerBkgrd = (nEvents-1) / nBkgrdEvents + 1;
     } else if (result && (result != nSignalPerBkgrd)) {
-      Info("GetNSignalPerBkgrd", "the number of signal events per "
-          "background event will be changed from %d to %d for stream %d", 
-          nSignalPerBkgrd, result, iBkgrdFile+1);
+      AliInfo(Form("the number of signal events per background event "
+                   "will be changed from %d to %d for stream %d", 
+                   nSignalPerBkgrd, result, iBkgrdFile+1));
       nSignalPerBkgrd = result;
     }
 
     if (!result) result = nSignalPerBkgrd;
     if (nSignalPerBkgrd * nBkgrdEvents < nEvents) {
-      Warning("GetNSignalPerBkgrd", "not enough background events (%d) for "
-             "%d signal events using %d signal per background events for "
-             "stream %d", 
-             nBkgrdEvents, nEvents, nSignalPerBkgrd, iBkgrdFile+1);
+      AliWarning(Form("not enough background events (%d) for %d signal events "
+                      "using %d signal per background events for stream %d",
+                      nBkgrdEvents, nEvents, nSignalPerBkgrd, iBkgrdFile+1));
     }
   }