]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliSimulation.cxx
New code to record the timing information of various methods in simulation and recons...
[u/mrichter/AliRoot.git] / STEER / AliSimulation.cxx
index fc1c285ea9e6fe645abae30a494fbd118947b649..57ff80506e8c93637d2bfa4e61e4bd1d17301480 100644 (file)
 #include <TVirtualMCApplication.h>
 #include <TGeoManager.h>
 #include <TObjString.h>
-#include <TStopwatch.h>
 #include <TSystem.h>
 #include <TFile.h>
 
+#include "AliCodeTimer.h"
 #include "AliCDBStorage.h"
 #include "AliCDBEntry.h"
 #include "AliCDBManager.h"
@@ -249,6 +249,8 @@ AliSimulation::~AliSimulation()
 
   fSpecCDBUri.Delete();
   if (fgInstance==this) fgInstance = 0;
+
+  AliCodeTimer::Instance()->Print();
 }
 
 
@@ -369,8 +371,8 @@ Bool_t AliSimulation::MisalignGeometry(AliRunLoader *runLoader)
   // then applied to the TGeo geometry.
   // Finally an overlaps check is performed.
 
-  if (!gGeoManager || !gGeoManager->IsClosed()) {
-    AliError("Can't apply the misalignment! gGeoManager doesn't exist or it is still opened!");
+  if (!AliGeomManager::GetGeometry() || !AliGeomManager::GetGeometry()->IsClosed()) {
+    AliError("Can't apply the misalignment! Geometry is not loaded or it is still opened!");
     return kFALSE;
   }  
   Bool_t delRunLoader = kFALSE;
@@ -381,7 +383,7 @@ Bool_t AliSimulation::MisalignGeometry(AliRunLoader *runLoader)
   }
 
   // Export ideal geometry 
-  gGeoManager->Export("geometry.root");
+  AliGeomManager::GetGeometry()->Export("geometry.root");
 
   // Load alignment data from CDB and apply to geometry through AliGeomManager
   if(fLoadAlignFromCDB){
@@ -399,13 +401,13 @@ Bool_t AliSimulation::MisalignGeometry(AliRunLoader *runLoader)
         loadAlObjsListOfDets += " ";
       }
     } // end loop over detectors
-    (AliGeomManager::Instance())->ApplyAlignObjsFromCDB(loadAlObjsListOfDets.Data());
+    AliGeomManager::ApplyAlignObjsFromCDB(loadAlObjsListOfDets.Data());
   }else{
     // Check if the array with alignment objects was
     // provided by the user. If yes, apply the objects
     // to the present TGeo geometry
     if (fAlignObjArray) {
-      if ((AliGeomManager::Instance())->ApplyAlignObjsToGeom(fAlignObjArray) == kFALSE) {
+      if (AliGeomManager::ApplyAlignObjsToGeom(*fAlignObjArray) == kFALSE) {
         AliError("The misalignment of one or more volumes failed!"
                  "Compare the list of simulated detectors and the list of detector alignment data!");
         if (delRunLoader) delete runLoader;
@@ -429,9 +431,6 @@ Bool_t AliSimulation::MisalignGeometry(AliRunLoader *runLoader)
 
   if (delRunLoader) delete runLoader;
 
-  // Update the TGeoPhysicalNodes
-  gGeoManager->RefreshPhysicalNodes();
-
   return kTRUE;
 }
 
@@ -477,6 +476,8 @@ Bool_t AliSimulation::Run(Int_t nEvents)
 {
 // run the generation, simulation and digitization
 
+  AliCodeTimerAuto("")
+  
   InitCDBStorage();
 
   if (nEvents > 0) fNEvents = nEvents;
@@ -490,10 +491,11 @@ Bool_t AliSimulation::Run(Int_t nEvents)
   if (!SetRunNumber()) if (fStopOnError) return kFALSE;
 
   // If RunSimulation was not called, load the geometry and misalign it
-  if (!gGeoManager) {
-    TGeoManager::Import("geometry.root");
-    if (!gGeoManager) if (fStopOnError) return kFALSE;
-    // Initialize the geometry manager (if not already done)
+  if (!AliGeomManager::GetGeometry()) {
+    // Initialize the geometry manager
+    AliGeomManager::LoadGeometry("geometry.root");
+    if (!AliGeomManager::GetGeometry()) if (fStopOnError) return kFALSE;
+    // Misalign geometry
     if(!MisalignGeometry()) if (fStopOnError) return kFALSE;
   }
 
@@ -543,8 +545,7 @@ Bool_t AliSimulation::RunTrigger(const char* descriptors)
 {
   // run the trigger
 
-   TStopwatch stopwatch;
-   stopwatch.Start();
+  AliCodeTimerAuto("")
 
    AliRunLoader* runLoader = LoadRun("READ");
    if (!runLoader) return kFALSE;
@@ -573,9 +574,6 @@ Bool_t AliSimulation::RunTrigger(const char* descriptors)
       }
    }
 
-   AliInfo(Form("Execution time: R:%.2fs C:%.2fs",
-           stopwatch.RealTime(),stopwatch.CpuTime()));
-
    delete runLoader;
 
    return kTRUE;
@@ -598,8 +596,7 @@ Bool_t AliSimulation::RunSimulation(Int_t nEvents)
 {
 // run the generation and simulation
 
-  TStopwatch stopwatch;
-  stopwatch.Start();
+  AliCodeTimerAuto("")
 
   if (!gAlice) {
     AliError("no gAlice object. Restart aliroot and try again.");
@@ -627,7 +624,6 @@ Bool_t AliSimulation::RunSimulation(Int_t nEvents)
     gAlice->SetTriggerDescriptor(fMakeTrigger.Data());
 
   // Set run number in CDBManager
-  AliCDBManager::Instance()->SetRun(gAlice->GetRunNumber());
   AliInfo(Form("Run number: %d",AliCDBManager::Instance()->GetRun()));
 
   AliRunLoader* runLoader = gAlice->GetRunLoader();
@@ -640,6 +636,7 @@ Bool_t AliSimulation::RunSimulation(Int_t nEvents)
  
   // Misalign geometry
 #if ROOT_VERSION_CODE < 331527
+  AliGeomManager::SetGeometry(gGeoManager);
   MisalignGeometry(runLoader);
 #endif
 
@@ -709,8 +706,6 @@ Bool_t AliSimulation::RunSimulation(Int_t nEvents)
 
   delete runLoader;
 
-  AliInfo(Form("Execution time: R:%.2fs C:%.2fs",
-              stopwatch.RealTime(),stopwatch.CpuTime()));
 
   return kTRUE;
 }
@@ -720,8 +715,7 @@ Bool_t AliSimulation::RunSDigitization(const char* detectors)
 {
 // run the digitization and produce summable digits
 
-  TStopwatch stopwatch;
-  stopwatch.Start();
+  AliCodeTimerAuto("")
 
   AliRunLoader* runLoader = LoadRun();
   if (!runLoader) return kFALSE;
@@ -733,11 +727,8 @@ Bool_t AliSimulation::RunSDigitization(const char* detectors)
     if (!det || !det->IsActive()) continue;
     if (IsSelected(det->GetName(), detStr)) {
       AliInfo(Form("creating summable digits for %s", det->GetName()));
-      TStopwatch stopwatchDet;
-      stopwatchDet.Start();
+      AliCodeTimerAuto(Form("creating summable digits for %s", det->GetName()));
       det->Hits2SDigits();
-      AliInfo(Form("Execution time for %s: R:%.2fs C:%.2fs",
-          det->GetName(),stopwatchDet.RealTime(),stopwatchDet.CpuTime()));
     }
   }
 
@@ -749,9 +740,6 @@ Bool_t AliSimulation::RunSDigitization(const char* detectors)
 
   delete runLoader;
 
-  AliInfo(Form("Execution time: R:%.2fs C:%.2fs",
-          stopwatch.RealTime(),stopwatch.CpuTime()));
-
   return kTRUE;
 }
 
@@ -762,8 +750,7 @@ Bool_t AliSimulation::RunDigitization(const char* detectors,
 {
 // run the digitization and produce digits from sdigits
 
-  TStopwatch stopwatch;
-  stopwatch.Start();
+  AliCodeTimerAuto("")
 
   while (AliRunLoader::GetRunLoader()) delete AliRunLoader::GetRunLoader();
   if (gAlice) delete gAlice;
@@ -816,9 +803,6 @@ Bool_t AliSimulation::RunDigitization(const char* detectors,
 
   delete manager;
 
-  AliInfo(Form("Execution time: R:%.2fs C:%.2fs",
-              stopwatch.RealTime(),stopwatch.CpuTime()));
-  
   return kTRUE;
 }
 
@@ -827,8 +811,7 @@ Bool_t AliSimulation::RunHitsDigitization(const char* detectors)
 {
 // run the digitization and produce digits from hits
 
-  TStopwatch stopwatch;
-  stopwatch.Start();
+  AliCodeTimerAuto("")
 
   AliRunLoader* runLoader = LoadRun("READ");
   if (!runLoader) return kFALSE;
@@ -854,9 +837,6 @@ Bool_t AliSimulation::RunHitsDigitization(const char* detectors)
   //PH Temporary fix to avoid interference with the PHOS loder/getter
   //PH The problem has to be solved in more general way 09/06/05
 
-  AliInfo(Form("Execution time: R:%.2fs C:%.2fs",
-              stopwatch.RealTime(),stopwatch.CpuTime()));
-
   return kTRUE;
 }
 
@@ -874,8 +854,7 @@ Bool_t AliSimulation::WriteRawData(const char* detectors,
 // to a root file.
 // If deleteIntermediateFiles is true, the DATE file is deleted afterwards.
 
-  TStopwatch stopwatch;
-  stopwatch.Start();
+  AliCodeTimerAuto("")
 
   if (!WriteRawFiles(detectors)) {
     if (fStopOnError) return kFALSE;
@@ -908,9 +887,6 @@ Bool_t AliSimulation::WriteRawData(const char* detectors,
     }
   }
 
-  AliInfo(Form("Execution time: R:%.2fs C:%.2fs",
-              stopwatch.RealTime(),stopwatch.CpuTime()));
-
   return kTRUE;
 }
 
@@ -919,6 +895,8 @@ Bool_t AliSimulation::WriteRawFiles(const char* detectors)
 {
 // convert the digits to raw data DDL files
 
+  AliCodeTimerAuto("")
+  
   AliRunLoader* runLoader = LoadRun("READ");
   if (!runLoader) return kFALSE;
 
@@ -958,6 +936,7 @@ Bool_t AliSimulation::WriteRawFiles(const char* detectors)
   }
 
   delete runLoader;
+  
   return kTRUE;
 }
 
@@ -966,6 +945,8 @@ Bool_t AliSimulation::ConvertRawFilesToDate(const char* dateFileName)
 {
 // convert raw data DDL files to a DATE file with the program "dateStream"
 
+  AliCodeTimerAuto("")
+  
   char* path = gSystem->Which(gSystem->Getenv("PATH"), "dateStream");
   if (!path) {
     AliError("the program dateStream was not found");