]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliRunLoader.cxx
Setting AliRICHv1 by default
[u/mrichter/AliRoot.git] / STEER / AliRunLoader.cxx
index 17f737d130c39c3c2363e6b7756b28881c5232fa..8821997daceff5c31f6ac8b1ff62653b977cb0fd 100644 (file)
@@ -1,40 +1,44 @@
 #include "AliRunLoader.h"
-//_____________________________________
-/////////////////////////////////////////////////////////////////////////////////////
-//
-// class AliRunLoader
-//
-//This class aims to be the only one interface for manging data
-//It stores Loaders for all modules which knows the filenames 
-//of the data files to be stored.
-//It aims to substitude AliRun in automatic maging of data positioning
-//thus there won't be necessity of loading gAlice from file in order to 
-//get fast ccess to the data
-//
-//logical place for putting the Loader specific to the given detector is detector itself
-// but, to load detector one need to load gAlice, and by the way all other detectors
-// with their geometries and so on. 
-// So, if one need to open TPC clusters there is no principal need to read everything
-//
-// When RunLoader is read from the file it does not connect to the folder structure
-// it must be connected (mounted) manualy in the macro or class code. 
-// Default event folder is defined by AliConfig::fgkDefaultEventFolderName
-// but can be mounted elsewhere. Usefull specially in merging, when more than session 
-// needs to be loaded
-//
-//////////////////////////////////////////////////////////////////////////////////////
-/**************************************************************************/
+//____________________________________________________________________
+//////////////////////////////////////////////////////////////////////
+//                                                                  //
+// class AliRunLoader                                               //
+//                                                                  //
+// This class aims to be the unque interface for managing data I/O. //
+// It stores Loaders for all modules which, knows names             //
+// of the files were data are to be stored.                         //
+//                                                                  //
+// It aims to substitud AliRun in automatic data managing           //
+// thus there is no necessity of loading gAlice from file in order  //
+// to get access to the data.                                       //
+//                                                                  //
+// Logical place to put the specific Loader to the given            //
+// detector is detector  itself (i.e ITSLoader in ITS).             //
+// But, to load detector object one need to load gAlice, and        //
+// by the way all other detectors with their geometrieces and       //
+// so on. So, if one need to open TPC clusters there is no          //
+// principal need to read everything.                               //
+//                                                                  //
+//                                                                  //
+// When RunLoader is read from the file it does not connect to      //
+// the folder structure automatically. It must be connected         //
+// (mounted) manualy. Default event folder is defined by            //
+// AliConfig::fgkDefaultEventFolderName                             //
+// but can be mounted elsewhere. Usefull specially in merging case, //
+// when more than pone session needs to be loaded                   //
+//                                                                  //
+//////////////////////////////////////////////////////////////////////
 
+#include <TBranch.h>
+#include <TError.h>
+#include <TFile.h>
+#include <TFolder.h>
+#include <TGeometry.h>
+#include <TObjArray.h>
 #include <TROOT.h>
 #include <TString.h>
-#include <TFolder.h>
 #include <TTask.h>
-#include <TFile.h>
 #include <TTree.h>
-#include <TBranch.h>
-#include <TGeometry.h>
-#include <TError.h>
-#include <TObjArray.h>
 
 #include "AliRun.h"
 #include "AliConfig.h"
@@ -73,6 +77,7 @@ AliRunLoader::AliRunLoader():
  fUnixDirName(".")
 {
   AliConfig::Instance();//force to build the folder structure
+  if (!fgRunLoader) fgRunLoader = this;
 }
 /**************************************************************************/
 
@@ -91,6 +96,7 @@ AliRunLoader::AliRunLoader(const char* eventfoldername):
 {
 //ctor
   SetEventFolderName(eventfoldername);
+ if (!fgRunLoader) fgRunLoader = this;
 }
 /**************************************************************************/
 
@@ -120,15 +126,26 @@ AliRunLoader::~AliRunLoader()
 }
 /**************************************************************************/
 
-AliRunLoader::AliRunLoader(TFolder* topfolder):TNamed(fgkRunLoaderName,fgkRunLoaderName)
+AliRunLoader::AliRunLoader(TFolder* topfolder):
+ TNamed(fgkRunLoaderName,fgkRunLoaderName),
+ fLoaders(new TObjArray()),
+ fEventFolder(topfolder),
+ fCurrentEvent(0),
+ fGAFile(0x0),
+ fHeader(0x0),
+ fStack(0x0),
+ fKineDataLoader(new AliDataLoader(fgkDefaultKineFileName,fgkKineContainerName,"Kinematics")),
+ fTrackRefsDataLoader(new AliDataLoader(fgkDefaultTrackRefsFileName,fgkTrackRefsContainerName,"Track References")),
+ fNEventsPerFile(1),
+ fUnixDirName(".")
 {
 //ctor
+ if (!fgRunLoader) fgRunLoader = this;
  if(topfolder == 0x0)
   {
     Fatal("AliRunLoader(TFolder*)","Parameter is NULL");
     return;
   }
- fEventFolder = topfolder;
  
  TObject* obj = fEventFolder->FindObject(fgkRunLoaderName);
  if (obj)
@@ -139,7 +156,6 @@ AliRunLoader::AliRunLoader(TFolder* topfolder):TNamed(fgkRunLoaderName,fgkRunLoa
     return;//never reached
   }
    
- fLoaders = new TObjArray();
  fEventFolder->Add(this);//put myself to the folder to accessible for all
   
 }
@@ -297,7 +313,7 @@ AliRunLoader* AliRunLoader::Open
 //in case of error returns NULL
  
  static const TString webaddress("http://alisoft.cern.ch/people/skowron/codedoc/split/index.html");
- if (AliLoader::fgDebug
+ if (AliLoader::GetDebug()
   ::Info("AliRunLoader::Open",
          "\n\n\nNew I/O strcture: See more info:\n %s\n\n\n",webaddress.Data());
  
@@ -374,7 +390,7 @@ AliRunLoader* AliRunLoader::Open
  //else create new AliRunLoader
  if ( AliLoader::TestFileOption(option) )
   { 
-    if (AliLoader::fgDebug
+    if (AliLoader::GetDebug()
      ::Info("AliRunLoader::Open","Reading RL from file");
     
     result = dynamic_cast<AliRunLoader*>(gAliceFile->Get(fgkRunLoaderName));//get the run Loader from the file
@@ -395,7 +411,7 @@ AliRunLoader* AliRunLoader::Open
   }
  else
   {
-    if (AliLoader::fgDebug
+    if (AliLoader::GetDebug()
       ::Info("AliRunLoader::Open","Creating new AliRunLoader. Folder name is %s",eventfoldername);
     result = new AliRunLoader(eventfoldername);
   }
@@ -412,12 +428,12 @@ AliRunLoader* AliRunLoader::Open
   }
  else dirname = fname.Remove(nsl);//slash found
  
- if (AliLoader::fgDebug
+ if (AliLoader::GetDebug()
   ::Info("AliRunLoader::Open","Dir name is : %s",dirname.Data());
  
  result->SetDirName(dirname); 
  result->SetGAliceFile(gAliceFile);//set the pointer to gAliceFile
- fgRunLoader = result; //PH get access from any place
if (!fgRunLoader) fgRunLoader = result; //PH get access from any place
  return result;
 }
 /**************************************************************************/
@@ -1029,10 +1045,10 @@ void AliRunLoader::CleanDetectors()
 {
 //Calls CleanFolders for all detectors
   TIter next(fLoaders);
-  AliLoader *Loader;
-  while((Loader = (AliLoader*)next())) 
+  AliLoader *loader;
+  while((loader = (AliLoader*)next())) 
    {
-     Loader->CleanFolders();
+     loader->CleanFolders();
    }
 }
 /**************************************************************************/
@@ -1128,25 +1144,25 @@ Int_t AliRunLoader::LoadDigits(Option_t* detectors,Option_t* opt)
 {
 //LoadHits in selected detectors i.e. detectors="ITS TPC TRD" or "all"
 
-  TObjArray* Loaders;
+  TObjArray* loaders;
   TObjArray arr;
 
   const char* oAll = strstr(detectors,"all");
   if (oAll)
    {
-     Loaders = fLoaders;
+     loaders = fLoaders;
    }
   else
    {
      GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
-     Loaders = &arr;//get the pointer array
+     loaders = &arr;//get the pointer array
    }   
 
-  TIter next(Loaders);
-  AliLoader *Loader;
-  while((Loader = (AliLoader*)next())) 
+  TIter next(loaders);
+  AliLoader *loader;
+  while((loader = (AliLoader*)next())) 
    {
-    Loader->LoadDigits(opt);
+    loader->LoadDigits(opt);
    }
   return 0;
 } 
@@ -1156,25 +1172,25 @@ Int_t AliRunLoader::LoadRecPoints(Option_t* detectors,Option_t* opt)
 {
 //LoadHits in selected detectors i.e. detectors="ITS TPC TRD" or "all"
 
-  TObjArray* Loaders;
+  TObjArray* loaders;
   TObjArray arr;
 
   const char* oAll = strstr(detectors,"all");
   if (oAll)
    {
-     Loaders = fLoaders;
+     loaders = fLoaders;
    }
   else
    {
      GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
-     Loaders = &arr;//get the pointer array
+     loaders = &arr;//get the pointer array
    }   
 
-  TIter next(Loaders);
-  AliLoader *Loader;
-  while((Loader = (AliLoader*)next())) 
+  TIter next(loaders);
+  AliLoader *loader;
+  while((loader = (AliLoader*)next())) 
    {
-    Loader->LoadRecPoints(opt);
+    loader->LoadRecPoints(opt);
    }
   return 0;
 } 
@@ -1184,25 +1200,25 @@ Int_t AliRunLoader::LoadRecParticles(Option_t* detectors,Option_t* opt)
 {
 //LoadHits in selected detectors i.e. detectors="ITS TPC TRD" or "all"
 
-  TObjArray* Loaders;
+  TObjArray* loaders;
   TObjArray arr;
 
   const char* oAll = strstr(detectors,"all");
   if (oAll)
    {
-     Loaders = fLoaders;
+     loaders = fLoaders;
    }
   else
    {
      GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
-     Loaders = &arr;//get the pointer array
+     loaders = &arr;//get the pointer array
    }   
 
-  TIter next(Loaders);
-  AliLoader *Loader;
-  while((Loader = (AliLoader*)next())) 
+  TIter next(loaders);
+  AliLoader *loader;
+  while((loader = (AliLoader*)next())) 
    {
-    Loader->LoadRecParticles(opt);
+    loader->LoadRecParticles(opt);
    }
   return 0;
 } 
@@ -1212,25 +1228,25 @@ Int_t AliRunLoader::LoadTracks(Option_t* detectors,Option_t* opt)
 {
 //LoadHits in selected detectors i.e. detectors="ITS TPC TRD" or "all"
 
-  TObjArray* Loaders;
+  TObjArray* loaders;
   TObjArray arr;
 
   const char* oAll = strstr(detectors,"all");
   if (oAll)
    {
-     Loaders = fLoaders;
+     loaders = fLoaders;
    }
   else
    {
      GetListOfDetectors(detectors,arr);//this method looks for all Loaders corresponding to names (many) specified in detectors option
-     Loaders = &arr;//get the pointer array
+     loaders = &arr;//get the pointer array
    }   
 
-  TIter next(Loaders);
-  AliLoader *Loader;
-  while((Loader = (AliLoader*)next())) 
+  TIter next(loaders);
+  AliLoader *loader;
+  while((loader = (AliLoader*)next())) 
    {
-    Loader->LoadTracks(opt);
+    loader->LoadTracks(opt);
    }
   return 0;
 } 
@@ -1849,10 +1865,10 @@ void AliRunLoader::SetDigitsFileNameSuffix(const TString& suffix)
 //made on Jiri Chudoba demand
 
   TIter next(fLoaders);
-  AliLoader *Loader;
-  while((Loader = (AliLoader*)next())) 
+  AliLoader *loader;
+  while((loader = (AliLoader*)next())) 
    {
-     Loader->SetDigitsFileNameSuffix(suffix);
+     loader->SetDigitsFileNameSuffix(suffix);
    }
 }
 /*****************************************************************************/ 
@@ -1894,6 +1910,7 @@ void AliRunLoader::Synchronize()
   fKineDataLoader->Synchronize();
   fTrackRefsDataLoader->Synchronize();
   
+  if (fGAFile) fGAFile->Flush();
 }
 /*****************************************************************************/ 
 /*****************************************************************************/