]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliConfig.cxx
Corrections to obey the coding conventions
[u/mrichter/AliRoot.git] / STEER / AliConfig.cxx
index 699cd4a42a614253dd54e95fcc76171155142991..933c934ab284608d0086daad4aaecf14f5ab3d72 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/*
-$Log$
-Revision 1.2  2001/05/21 17:22:50  buncic
-Fixed problem with missing AliConfig while reading galice.root
+/* $Id$ */
 
-Revision 1.1  2001/05/16 14:57:22  alibrary
-New files for folders and Stack
+// Class for configuration of TFolder and TTasks
+// in AliRoot. Used by AliRun, AliGenerator, 
+// AliModule and AliDetector classes
+// as well as by the PHOS and EMCAL Getters
+// Author: Originally developed by the PHOS group
 
-*/
+#include <Riostream.h>
+#include <TDatabasePDG.h>
+#include <TFolder.h>
+#include <TInterpreter.h>
+#include <TROOT.h>
+#include <TSystem.h>
+#include <TVirtualMC.h>
 
 #include "AliConfig.h"
 #include "AliDetector.h"
+#include "AliGenerator.h" 
 #include "TObjString.h" 
 #include "TString.h"
 #include "TTask.h" 
-#include "AliGenerator.h" 
-#include "AliMC.h" 
 
 ClassImp(AliConfig)
 
-
-AliConfig* AliConfig::fInstance = 0;
+AliConfig* AliConfig::fgInstance = 0;
 
 //____________________________________________________________________________
 AliConfig* AliConfig::Instance ()
@@ -42,43 +46,83 @@ AliConfig* AliConfig::Instance ()
   //
   // Instance method for singleton class
   //
-        if(fInstance == 0) {
-                   fInstance = new AliConfig ("Folders","Alice data exchange");
-               }
-               return fInstance;
+  if(!fgInstance) fgInstance = new AliConfig ("Folders","Alice data exchange");
+
+  return fgInstance;
+}
+
+//____________________________________________________________________________
+AliConfig::AliConfig():
+  fTopFolder(0),
+  fTasks(0),
+  fPDGFolder(0),
+  fGeneratorFolder(0),
+  fMCFolder(0),
+  fModuleFolder(0),
+  fDetectorFolder(0),
+  fDetectorTask(0)
+{
+  //
+  // Default constructor, mainly to keep coding conventions
+  //
+  fgInstance=0;
+    
+  Fatal("ctor",
+   "Constructor should not be called for a singleton\n");
 }
 
+//____________________________________________________________________________
+AliConfig::AliConfig(const AliConfig& conf):
+  TNamed(conf),
+  fTopFolder(0),
+  fTasks(0),
+  fPDGFolder(0),
+  fGeneratorFolder(0),
+  fMCFolder(0),
+  fModuleFolder(0),
+  fDetectorFolder(0),
+  fDetectorTask(0)
+{
+  //
+  // Copy constructor, mainly to keep coding conventions
+  //
+  fgInstance=0;
+    
+  Fatal("copy ctor",
+   "Copy constructor should not be called for a singleton\n");
+}
 
-AliConfig::AliConfig(const char *name, const char *title)
+//____________________________________________________________________________
+AliConfig::AliConfig(const char *name, const char *title): 
+  TNamed(name,title), 
+  fTopFolder(gROOT->GetRootFolder ()->AddFolder (name,title)),
+  fTasks(0),
+  fPDGFolder("Constants/DatabasePDG"),
+  fGeneratorFolder("RunMC/Configuration/Generators"),
+  fMCFolder("RunMC/Configuration/VirtualMC"),
+  fModuleFolder("Run/Configuration/Modules"),
+  fDetectorFolder(new const char*[kFolders]),
+  fDetectorTask(new const char*[kTasks])
 {
   //
   // Constructor
   //
-  //
-  fInstance=this;
-  SetName(name) ; 
-  SetTitle(title) ; 
-  
-  fPDGFolder         =  "Constants/DatabasePDG" ;
-  fGeneratorFolder   =  "RunMC/Configuration/Generators" ;
-  fMCFolder          =  "RunMC/Configuration/VirtualMC" ;
-  fModuleFolder      =  "Run/Configuration/Modules" ;
-  fDetectorFolder    =  new char*[7] ; 
+  fgInstance=this;
+  
   fDetectorFolder[0] = "Run/Conditions/Calibration" ;
   fDetectorFolder[1] = "Run/Event/Data" ;
   fDetectorFolder[2] = "Run/Event/RecData" ;
   fDetectorFolder[3] = "RunMC/Event/Data/Hits" ;
   fDetectorFolder[4] = "RunMC/Event/Data/SDigits" ;
   fDetectorFolder[5] = "Run/Conditions/QA" ;  
-  fDetectorFolder[6] = 0 ;  
-  fDetectorTask    =  new char*[5] ; 
+  fDetectorFolder[6] = "RunMC/Event/Data/TrackReferences" ;  
+  fDetectorFolder[7] = 0 ;  
   fDetectorTask[0] = "Tasks/QA" ;  
   fDetectorTask[1] = "Tasks/SDigitizer" ;  
   fDetectorTask[2] = "Tasks/Digitizer" ;  
   fDetectorTask[3] = "Tasks/Reconstructioner" ;  
   fDetectorTask[4] = 0 ;  
 
-  fTopFolder = gROOT->GetRootFolder ()->AddFolder (name,title);
   fTopFolder->SetOwner() ; 
   gROOT->GetListOfBrowsables ()->Add (fTopFolder, name);
   
@@ -123,35 +167,38 @@ AliConfig::AliConfig(const char *name, const char *title)
   subfolder =
     event->AddFolder ("RecData", "Detectors reconstucted data");
   
-  TFolder *run_mc =
+  TFolder *runMC =
     fTopFolder->AddFolder ("RunMC", "MonteCarlo run dependent folders");
   
-  TFolder *configuration_mc =
-    run_mc->AddFolder ("Configuration","MonteCarlo run configuration");
+  TFolder *configurationMC =
+    runMC->AddFolder ("Configuration","MonteCarlo run configuration");
   
   subfolder =
-    configuration_mc->AddFolder ("Generators","list of generator objects");
+    configurationMC->AddFolder ("Generators","list of generator objects");
   
   subfolder =
-    configuration_mc->AddFolder ("VirtualMC", "the Virtual MC");
+    configurationMC->AddFolder ("VirtualMC", "the Virtual MC");
   
-  TFolder *event_mc =
-    run_mc->AddFolder ("Event", "MonteCarlo event folders");
+  TFolder *eventMC =
+    runMC->AddFolder ("Event", "MonteCarlo event folders");
   
   subfolder =
-    event_mc->AddFolder ("Header", "MonteCarlo event header");
+    eventMC->AddFolder ("Header", "MonteCarlo event header");
   
   //           subfolder =
-  //               event_mc->AddFolder ("Kinematics", "MonteCarlo generated particles");
+  //               eventMC->AddFolder ("Kinematics", "MonteCarlo generated particles");
   
-  TFolder *data_mc =
-    event_mc->AddFolder ("Data", "MonteCarlo data");
+  TFolder *dataMC =
+    eventMC->AddFolder ("Data", "MonteCarlo data");
   
   subfolder = 
-    data_mc->AddFolder ("Hits", "MonteCarlo Hits") ; 
+    dataMC->AddFolder ("Hits", "MonteCarlo Hits") ; 
  
  subfolder = 
-    data_mc->AddFolder ("SDigits", "MonteCarlo SDigits") ; 
+    dataMC->AddFolder ("SDigits", "MonteCarlo SDigits") ; 
+
+ subfolder = 
+    dataMC->AddFolder ("TrackReferences", "MonteCarlo track references") ; 
 
 
   
@@ -176,14 +223,16 @@ AliConfig::AliConfig(const char *name, const char *title)
 //____________________________________________________________________________
 AliConfig::~AliConfig()
 { 
-  delete fDetectorFolder ;  
+  // destructor
+  delete [] fDetectorFolder ;  
   delete fDetectorTask ;  
   delete fTopFolder ; 
 }
 
 //____________________________________________________________________________
-void    AliConfig::AddInFolder (char *dir, TObject *obj)
+void AliConfig::AddInFolder (const char *dir, TObject *obj)
 {
+  // Adds an object "obj" to a folder named "dir"
   TFolder *folder =
     dynamic_cast<TFolder *>(fTopFolder->FindObject(dir));
   if (folder)
@@ -191,8 +240,10 @@ void    AliConfig::AddInFolder (char *dir, TObject *obj)
 }
 
 //____________________________________________________________________________
-void    AliConfig::AddSubFolder(char * dir[], TObject *obj)
+void    AliConfig::AddSubFolder(const char * dir[], TObject *obj)
 {
+  // Adds a subfolder taken from "obj" to all the folders from dir,
+  // which are found in the top folder
   int iDir = 0;
   
   while (dir[iDir]) 
@@ -207,8 +258,10 @@ void    AliConfig::AddSubFolder(char * dir[], TObject *obj)
 }
 
 //____________________________________________________________________________
-void    AliConfig::AddSubTask(char * dir[], TObject *obj)
+void    AliConfig::AddSubTask(const char * dir[], TObject *obj)
 {
+  // Adds a subtask taken from "obj" to all the folders from dir,
+  // which are found in the top folder
   int iDir = 0;
   
   while (dir[iDir]) 
@@ -225,8 +278,10 @@ void    AliConfig::AddSubTask(char * dir[], TObject *obj)
 }
 
 //____________________________________________________________________________
-TObject* AliConfig::FindInFolder (char *dir, const char *name)
+TObject* AliConfig::FindInFolder (const char *dir, const char *name)
 {
+  // Searches for object with "name" in the top directory and in
+  // the directory "dir"
   if(!name) return(fTopFolder->FindObject(name));
   TFolder * folder = dynamic_cast<TFolder *>(fTopFolder->FindObject(dir));
   if (!folder) return (NULL);
@@ -236,30 +291,36 @@ TObject* AliConfig::FindInFolder (char *dir, const char *name)
 //____________________________________________________________________________
 void    AliConfig::Add (AliGenerator * obj)
 {
+  // Adds new AliGenerator to the generator's folder
   AddInFolder(fGeneratorFolder, obj);
 }
 
 //____________________________________________________________________________
-void    AliConfig::Add (AliMC * obj)
+void    AliConfig::Add (TVirtualMC * obj)
 {
+  // Adds new object of type TVirtualMC to the MC folder
   AddInFolder(fMCFolder, obj);
 }
 
 //____________________________________________________________________________
 void    AliConfig::Add (TDatabasePDG * obj)
 {
+  // Adds new TDatabasePDG to the PDG folder
   AddInFolder(fPDGFolder, obj);
 }
 
 //____________________________________________________________________________
 void    AliConfig::Add (AliModule* obj)
 {
+  // Adds new module to the folder of modules 
   AddInFolder(fModuleFolder, obj);
 }
 
 //____________________________________________________________________________
 void    AliConfig::Add (AliDetector * obj)
 {
+  // Adds new detector to the detctor's folder as well as to
+  // the detector's task
   AddSubFolder(fDetectorFolder, obj); 
   AddSubTask(fDetectorTask, obj);
 }
@@ -268,12 +329,14 @@ void    AliConfig::Add (AliDetector * obj)
 //____________________________________________________________________________
 void    AliConfig::Add (char *list)
 {
+  // Finds in the list of directories all macros named Configure.C 
+  // and Default.C and uses them to configure the setup
   char *path;
   
-  const char   *conf_path = gSystem->Getenv ("ALICE_CONFIG_PATH");
-  if  (conf_path) {
-    path = new char[strlen (conf_path)];
-    strcpy (path, conf_path);
+  const char   *confPath = gSystem->Getenv ("ALICE_CONFIG_PATH");
+  if  (confPath) {
+    path = new char[strlen (confPath)];
+    strcpy (path, confPath);
   } else {
     const char   *alice = gSystem->Getenv ("ALICE_ROOT");
     path = new char[strlen (alice) + 32];
@@ -308,8 +371,8 @@ void    AliConfig::Add (char *list)
       while ((obj = next ()))
        {
          TString dir(obj->GetName());
-         TString path  = dir + "/" + token;
-         TString macro = path + ".C";
+         TString tpath  = dir + "/" + token;
+         TString macro = tpath + ".C";
          if (!gSystem->AccessPathName (macro.Data()))  {
            gInterpreter->ExecuteMacro (macro.Data());                             
            found = "(" + macro + ")";
@@ -323,11 +386,11 @@ void    AliConfig::Add (char *list)
            }
            break;
          } else {
-           TString macroDefault = path + "/Default.C";
+           TString macroDefault = tpath + "/Default.C";
            if (!gSystem->AccessPathName (macroDefault.Data())) {
              gInterpreter->ExecuteMacro (macroDefault.Data());
              found = "(" + macro + ")";
-             TString macroConfigure = path + "/Configure.C";
+             TString macroConfigure = tpath + "/Configure.C";
              if (!gSystem->AccessPathName (macroConfigure.Data()))     {
                gInterpreter->ExecuteMacro (macroConfigure.Data());                                 
                found += " => Configured";