]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliDataLoader.cxx
pyquen added.
[u/mrichter/AliRoot.git] / STEER / AliDataLoader.cxx
index 76b0e91846cb0b19a8ee71796014d5497ce29fd3..ad55ed51d10a6b75456dbde11cdd65802a0079d3 100644 (file)
@@ -32,7 +32,6 @@
 #include <TFile.h>
 #include <TString.h>
 #include <TBits.h>
-#include <TList.h>
 
 #include "AliRunLoader.h"
 
@@ -44,6 +43,7 @@ AliDataLoader::AliDataLoader():
  fDirectory(0x0),
  fFileOption(),
  fCompressionLevel(2),
+ fNEventsPerFile(0),
  fBaseLoaders(0x0),
  fHasTask(kFALSE),
  fTaskName(),
@@ -62,6 +62,7 @@ AliDataLoader::AliDataLoader(const char* filename, const char* contname, const c
  fDirectory(0x0),
  fFileOption(0),
  fCompressionLevel(2),
+ fNEventsPerFile(0),
  fBaseLoaders(new TObjArray(4)),
  fHasTask(kFALSE),
  fTaskName(),
@@ -86,6 +87,17 @@ AliDataLoader::AliDataLoader(const char* filename, const char* contname, const c
   
 }
 /*****************************************************************************/ 
+AliDataLoader::AliDataLoader(const AliDataLoader& source):TNamed(source) {
+  // copy constructor
+  Fatal("AliDataLoader","Copy constructor not implemented");
+}
+/*****************************************************************************/ 
+AliDataLoader& AliDataLoader::operator=(const AliDataLoader& /*source*/) {
+  // Assignment operator
+  Fatal("AliDataLoader","Assignment operator not implemented");
+  return *this;
+}
+/*****************************************************************************/ 
 
 AliDataLoader::~AliDataLoader()
 {
@@ -245,6 +257,8 @@ void AliDataLoader::Unload()
 void AliDataLoader::UnloadAll()
 {
 //Unloads all data and tasks
+ if ( fFile == 0x0 ) return; //nothing loaded
  TIter next(fBaseLoaders);
  AliBaseLoader* bl;
  while ((bl = (AliBaseLoader*)next()))
@@ -329,7 +343,7 @@ Int_t  AliDataLoader::SetEventFolder(TFolder* eventfolder)
 
 Int_t  AliDataLoader::SetFolder(TFolder* folder)
 {
-
+  // Sets the folder and the data loaders
  if (folder == 0x0)
   {
     Error("SetFolder","Stupid joke. Argument is NULL");
@@ -369,7 +383,7 @@ AliRunLoader* AliDataLoader::GetRunLoader()
      Error("GetRunLoader","Can not get event folder.");
      return 0;
    }
-  rg = dynamic_cast<AliRunLoader*>(ef->FindObject(AliRunLoader::fgkRunLoaderName));
+  rg = dynamic_cast<AliRunLoader*>(ef->FindObject(AliRunLoader::GetRunLoaderName()));
   return rg;
 }
 
@@ -447,6 +461,9 @@ const TString AliDataLoader::SetFileOffset(const TString& fname)
 
 //return fname;
   Long_t offset = (Long_t)GetRunLoader()->GetFileOffset();
+  if (fNEventsPerFile > 0) {
+    offset = GetRunLoader()->GetEventNumber()/fNEventsPerFile;
+  }
   if (offset < 1) return fname;
 
   TString soffset;
@@ -488,6 +505,7 @@ Int_t AliDataLoader::GetDebug() const
 
 void AliDataLoader::MakeTree()
 {
+  // Makes tree for the current data loader
   AliTreeLoader* tl = dynamic_cast<AliTreeLoader*>(fBaseLoaders->At(0));
   if (tl == 0x0)
    {
@@ -564,6 +582,7 @@ AliBaseLoader* AliDataLoader::GetBaseLoader(const TString& name) const
 
 AliBaseLoader* AliDataLoader::GetBaseLoader(Int_t n) const
 {
+  // Gets the n-th base loader (what is n?)
  return dynamic_cast<AliBaseLoader*>(fBaseLoaders->At(n));
 }
 /*****************************************************************************/ 
@@ -582,6 +601,7 @@ TTree* AliDataLoader::Tree() const
 
 void  AliDataLoader::SetDirName(TString& dirname)
 {
+  // Sets the directory name where the files will be stored
   if (GetDebug()>9) Info("SetDirName","FileName before %s",fFileName.Data());
 
   Int_t n = fFileName.Last('/');
@@ -599,16 +619,19 @@ void  AliDataLoader::SetDirName(TString& dirname)
 /*****************************************************************************/ 
 AliObjectLoader* AliDataLoader::GetBaseDataLoader()
 {
+  // Gets the base data loader
  return dynamic_cast<AliObjectLoader*>(GetBaseLoader(kData));
 }
 /*****************************************************************************/ 
 AliTaskLoader* AliDataLoader::GetBaseTaskLoader()
 {
+  // Gets the base task loader
  return dynamic_cast<AliTaskLoader*>(GetBaseLoader(kTask));
 }
 /*****************************************************************************/ 
 AliBaseLoader* AliDataLoader::GetBaseQALoader()
 {
+  // Gets the base QA loader
   return GetBaseLoader(kQA);
 }
 /*****************************************************************************/ 
@@ -668,9 +691,7 @@ void AliDataLoader::SetBaseQATaskLoader(AliTaskLoader* bl)
 void AliDataLoader::Synchronize()
 {
   //synchrinizes all writtable files 
-  if ( fFile == 0x0 ) return;
-  if ( fFile->IsWritable() == kFALSE ) return;
-  fFile->Write(0,TObject::kOverwrite);
+  if ( fFile ) fFile->Flush();
 }
 
 /*****************************************************************************/ 
@@ -691,6 +712,7 @@ AliBaseLoader::AliBaseLoader():
  fDoNotReload(kFALSE),
  fDataLoader(0x0)
 {
+  //default constructor
 }
 /*****************************************************************************/ 
 
@@ -701,19 +723,33 @@ AliBaseLoader::AliBaseLoader(const TString& name,  AliDataLoader* dl, Bool_t sto
  fDoNotReload(storeontop),//if stored on top of file - this object is loaded ones pe
  fDataLoader(dl)
 {
+  //constructor
 }
 
+/*****************************************************************************/ 
+AliBaseLoader::AliBaseLoader(const AliBaseLoader& source):TNamed(source) {
+  // copy constructor
+  Fatal("AliBaseLoader","Copy constructor not implemented");
+}
+/*****************************************************************************/ 
+AliBaseLoader& AliBaseLoader::operator=(const AliBaseLoader& /*source*/) {
+  // Assignment operator
+  Fatal("AliBaseLoader","Assignment operator not implemented");
+  return *this;
+}
 /*****************************************************************************/ 
 
 Int_t AliBaseLoader::Load(Option_t* opt)
 {
+  // Loads and posts the data
   if (GetDebug())
     Info("Load","data type = %s, option = %s",GetName(),opt);
 
   if (Get())
    {
-      Warning("Load","Data <<%s>> are already loaded. Use ReloadData to force reload. Nothing done",GetName());
-      return 0;
+     if (GetDebug())
+       Warning("Load","Data <<%s>> are already loaded. Use ReloadData to force reload. Nothing done",GetName());
+     return 0;
    }
   
   Int_t retval;
@@ -789,7 +825,8 @@ Int_t AliBaseLoader::Post()
      }
     else
      {
-        Warning("Post","Can not find %s in file %s", GetName(),GetDataLoader()->GetFile()->GetName());
+        Error("Post","Can not find %s in file %s", GetName(),GetDataLoader()->GetFile()->GetName());
+        return 5;
      }
    }
   return 0;
@@ -804,6 +841,13 @@ Int_t AliBaseLoader::Post(TObject* data)
     Error("Post","Pointer to object is NULL");
     return 1;
   }
+
+ if ( fName.CompareTo(data->GetName()) != 0)
+   {
+     Fatal("Post(TObject*)","Object name is <<%s>> while <<%s>> expected",data->GetName(),GetName());
+     return -1;//pro forma
+   }
+   
  TObject* obj = Get();
  if (data == obj)
   {
@@ -912,6 +956,7 @@ void AliBaseLoader::Clean()
 
 void AliBaseLoader::Unload()
 {
+  // Unloads data and closes the files
   Clean();
   fIsLoaded = kFALSE;
   GetDataLoader()->CloseFile();
@@ -919,6 +964,7 @@ void AliBaseLoader::Unload()
 /*****************************************************************************/ 
 AliDataLoader* AliBaseLoader::GetDataLoader() const
 {
+  // Returns pointer to the data loader
  if (fDataLoader == 0x0) 
   {
     Fatal("GetDataLoader","Pointer to Data Loader is NULL");
@@ -929,10 +975,11 @@ AliDataLoader* AliBaseLoader::GetDataLoader() const
 
 Int_t AliBaseLoader::GetDebug() const 
 { 
- return (Int_t)AliLoader::fgDebug;
+  // Returns debug level
+ return (Int_t)AliLoader::GetDebug();
 }
 
-TDirectory* AliBaseLoader::GetDirectory()
+TDirectory* AliBaseLoader::GetDirectory() const
 {
  // returnd TDirectory where data are to be saved
  //if fStoreInTopOfFile flag is true - returns pointer to file
@@ -960,6 +1007,7 @@ AliObjectLoader::AliObjectLoader(const TString& name, AliDataLoader* dl, Bool_t
 
 TFolder* AliObjectLoader::GetFolder() const
 {
+  // Returns pointer to the object folder
   TFolder* df = GetDataLoader()->GetFolder();
   if (df == 0x0)
    {
@@ -968,14 +1016,28 @@ TFolder* AliObjectLoader::GetFolder() const
   return df;
 }
 /*****************************************************************************/ 
+AliObjectLoader::AliObjectLoader(const AliObjectLoader& source):
+  AliBaseLoader(source) {
+  // copy constructor
+  Fatal("AliObjectLoader","Copy constructor not implemented");
+}
+/*****************************************************************************/ 
+AliObjectLoader& AliObjectLoader::operator=(const AliObjectLoader& /*source*/) {
+  // Assignment operator
+  Fatal("AliObjectLoader","Assignment operator not implemented");
+  return *this;
+}
+/*****************************************************************************/ 
 
 void AliObjectLoader::RemoveFromBoard(TObject* obj)
 {
+  // Removes "obj" from the board
   GetFolder()->Remove(obj);
 }
 /*****************************************************************************/ 
 Int_t AliObjectLoader::AddToBoard(TObject* obj)
 {
+  // Adds "obj" to the board
   GetFolder()->Add(obj);
   return 0;
 }
@@ -983,6 +1045,7 @@ Int_t AliObjectLoader::AddToBoard(TObject* obj)
 
 TObject* AliObjectLoader::Get() const
 {
+  // Returns pointer to the object loader
   return (GetFolder()) ? GetFolder()->FindObject(GetName()) : 0x0;
 }
 
@@ -1004,6 +1067,18 @@ AliTreeLoader::AliTreeLoader(const TString& name, AliDataLoader* dl,Bool_t store
 {
 //constructor
 }
+/*****************************************************************************/ 
+AliTreeLoader::AliTreeLoader(const AliTreeLoader& source):
+  AliObjectLoader(source) {
+  // copy constructor
+  Fatal("AliTreeLoader","Copy constructor not implemented");
+}
+/*****************************************************************************/ 
+AliTreeLoader& AliTreeLoader::operator=(const AliTreeLoader& /*source*/) {
+  // Assignment operator
+  Fatal("AliTreeLoader","Assignment operator not implemented");
+  return *this;
+}
 
 /*****************************************************************************/ 
 
@@ -1122,16 +1197,45 @@ AliTaskLoader::AliTaskLoader(const TString& name, AliDataLoader* dl, TTask* pare
 //constructor
 }
 
+/*****************************************************************************/ 
+AliTaskLoader::AliTaskLoader(const AliTaskLoader& source):
+  AliBaseLoader(source) {
+  // copy constructor
+  Fatal("AliTaskLoader","Copy constructor not implemented");
+}
+/*****************************************************************************/ 
+AliTaskLoader& AliTaskLoader::operator=(const AliTaskLoader& /*source*/) {
+  // Assignment operator
+  Fatal("AliTaskLoader","Assignment operator not implemented");
+  return *this;
+}
+/*****************************************************************************/ 
+void AliTaskLoader::Clean()
+{
+//removes tasl from parental task
+// DO NOT DELETE OBJECT contrary to BaseLoader
+//
+  if (GetDebug()) Info("Clean","%s %s",GetName(),GetDataLoader()->GetName());
+  TObject* obj = Get();
+  if(obj)
+   { 
+     if (GetDebug()) 
+       Info("Clean","cleaning %s.",GetName());
+     RemoveFromBoard(obj);
+   }
+}
 /*****************************************************************************/ 
 
 void AliTaskLoader::RemoveFromBoard(TObject* obj)
 {
+  // Removes the task "obj" from the board
   GetParentalTask()->GetListOfTasks()->Remove(obj);
 }
 /*****************************************************************************/ 
 
 Int_t AliTaskLoader::AddToBoard(TObject* obj)
 {
+  // Adds task "obj" to the board
   TTask* task = dynamic_cast<TTask*>(obj);
   if (task == 0x0)
    {
@@ -1145,6 +1249,7 @@ Int_t AliTaskLoader::AddToBoard(TObject* obj)
 
 TObject* AliTaskLoader::Get() const
 {
+  // Returns pointer to the current task
   return (GetParentalTask()) ? GetParentalTask()->GetListOfTasks()->FindObject(GetName()) : 0x0;
 }
 /*****************************************************************************/