Consistent treatment of Post/Clean
authorhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 27 Jan 2004 18:09:17 +0000 (18:09 +0000)
committerhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 27 Jan 2004 18:09:17 +0000 (18:09 +0000)
STEER/AliDataLoader.cxx
STEER/AliDataLoader.h
STEER/AliLoader.cxx

index 139edb9..37128dc 100644 (file)
@@ -835,6 +835,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)
   {
@@ -1197,6 +1204,21 @@ AliTaskLoader& AliTaskLoader::operator=(const AliTaskLoader& /*source*/) {
   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)
 {
index 25e9401..68d189b 100644 (file)
@@ -252,6 +252,7 @@ class AliTaskLoader: public AliBaseLoader
     
     TObject*           Get() const; 
     virtual TTask*     Task() const {return dynamic_cast<TTask*>(Get());}
+    virtual void       Clean();
 
   protected:
     Int_t              AddToBoard(TObject* obj);
index 480c112..8c718fc 100644 (file)
@@ -665,81 +665,61 @@ void AliLoader::CleanFolders()
 void AliLoader::CleanSDigitizer()
 {
 //removes and deletes detector task from Run Task
-  TTask* task = AliRunLoader::GetRunSDigitizer();
-  if (task == 0x0)
-   {
-     Error("CleanSDigitizer","Can not get RunSDigitizer from folder. Can not clean");
-     return;
-   }
-
-  if (GetDebug()) Info("CleanSDigitizer","Attempting to delete S Digitizer");
-  delete task->GetListOfTasks()->Remove(SDigitizer()); //TTList::Remove does not delete object
+ if ( GetSDigitsDataLoader()->GetBaseTaskLoader() == 0x0 )
+  {
+    Warning("CleanSDigitizer","Task Loader for SDigits does not exist");
+    return;
+  }
+ GetSDigitsDataLoader()->GetBaseTaskLoader()->Clean();
 }
 /*****************************************************************************/ 
 
 void AliLoader::CleanDigitizer()
 {
 //removes and deletes detector task from Run Task
-  TTask* task = AliRunLoader::GetRunDigitizer();
-  if (task == 0x0)
-   {
-     Error("CleanDigitizer","Can not get RunDigitizer from folder. Can not clean");
-     return;
-   }
-
-  if (GetDebug()) 
-   Info("CleanDigitizer","Attempting to delete Digitizer %X",
-         task->GetListOfTasks()->Remove(Digitizer()));
-  delete task->GetListOfTasks()->Remove(Digitizer()); //TTList::Remove does not delete object
+ if ( GetDigitsDataLoader()->GetBaseTaskLoader() == 0x0 )
+  {
+    Warning("CleanDigitizer","Task Loader for Digits does not exist");
+    return;
+  }
+ GetDigitsDataLoader()->GetBaseTaskLoader()->Clean();
 }
 /*****************************************************************************/ 
 
 void AliLoader::CleanReconstructioner()
 {
 //removes and deletes detector Reconstructioner from Run Reconstructioner
-  TTask* task = AliRunLoader::GetRunReconstructioner();
-  if (task == 0x0)
-   {
-     Error("CleanReconstructioner","Can not get RunReconstructioner from folder. Can not clean");
-     return;
-   }
-
-  if (GetDebug()) 
-   Info("CleanReconstructioner","Attempting to delete Reconstructioner");
-  delete task->GetListOfTasks()->Remove(Reconstructioner()); //TTList::Remove does not delete object
+ if ( GetRecPointsDataLoader()->GetBaseTaskLoader() == 0x0 )
+  {
+    Warning("CleanSDigitizer","Task Loader for SDigits does not exist");
+    return;
+  }
+ GetRecPointsDataLoader()->GetBaseTaskLoader()->Clean();
 }
 /*****************************************************************************/ 
 
 void AliLoader::CleanTracker()
 {
-//removes and deletes detector tracker from Run Tracker
-  TTask* task = AliRunLoader::GetRunTracker();
-  if (task == 0x0)
-   {
-     Error("CleanTracker","Can not get RunTracker from folder. Can not clean");
-     return;
-   }
-
-  if (GetDebug()) 
-   Info("CleanTracker","Attempting to delete Tracker %X",
-         task->GetListOfTasks()->Remove(Tracker()));
-  delete task->GetListOfTasks()->Remove(Tracker()); //TTList::Remove does not delete object
+//removes and deletes detector task from Run Task
+ if ( GetTracksDataLoader()->GetBaseTaskLoader() == 0x0 )
+  {
+    Warning("CleanTracker","Task Loader for Tracks does not exist");
+    return;
+  }
+ GetTracksDataLoader()->GetBaseTaskLoader()->Clean();
 }
 /*****************************************************************************/ 
 
 void AliLoader::CleanPIDTask()
 {
 //removes and deletes detector Reconstructioner from Run Reconstructioner
-  TTask* task = AliRunLoader::GetRunPIDTask();
-  if (task == 0x0)
-   {
-     Error("CleanPIDTask","Can not get Run PID Task from folder. Can not clean");
-     return;
-   }
 
-  if (GetDebug()) 
-   Info("CleanPIDTask","Attempting to delete PID Task");
-  delete task->GetListOfTasks()->Remove(PIDTask()); //TTList::Remove does not delete object
+ if (  GetRecParticlesDataLoader()->GetBaseTaskLoader() == 0x0 )
+  {
+    Warning("CleanPIDTask","Task Loader for Reconstructed Particles does not exist");
+    return;
+  }
+  GetRecParticlesDataLoader()->GetBaseTaskLoader()->Clean();
 }
 /*****************************************************************************/