]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EMCAL/AliEMCALLoader.cxx
Changes needed to run simulation and reconstrruction in the same AliRoot session
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALLoader.cxx
index 83854a853b745d0a972e22f4c49e28d9b8f23d0d..d23adb2397b414b216827b711b2070448ed96b54 100644 (file)
 // --- Standard library ---
 
 // --- AliRoot header files ---
-
-#include "AliEMCALLoader.h"
 #include "AliEMCAL.h"
+#include "AliEMCALGetter.h"
 #include "AliEMCALHit.h"
+#include "AliEMCALLoader.h"
+#include "AliLog.h"
+#include "AliObjectLoader.h"
 
 ClassImp(AliEMCALLoader)
   
@@ -89,6 +91,11 @@ AliEMCALLoader::~AliEMCALLoader()
   Clean(fgkECARecPointsName);
   Clean(fgkTracksName);
   Clean(fgkRecParticlesName);
+  CleanFolders() ; 
+ // set to 0x0 the objgetter in AliGetter ... weird isn it !
+  AliEMCALGetter * gime = AliEMCALGetter::Instance() ; 
+  if (gime) 
+    gime->Reset() ;
 }
 
 //____________________________________________________________________________ 
@@ -185,7 +192,7 @@ Int_t AliEMCALLoader::LoadHits(Option_t* opt)
   
   if (res)
    {//oops, error
-     Error("LoadHits","AliLoader::LoadHits returned error");
+     AliError("returned error");
      return res;
    }
 
@@ -252,33 +259,16 @@ Int_t AliEMCALLoader::LoadRecPoints(Option_t* opt)
 Int_t  AliEMCALLoader::LoadTracks(Option_t* opt)
 {
   //Loads Tracks: Open File, Reads Tree and posts, Read Data and Posts
-  if (GetDebug()) 
-    printf("LoadTracks: opt = %s",opt);
-  if (fTracksLoaded)
-    {
-      Warning("LoadTracks","Tracks are already loaded");
-      return 0;
-    }
+  AliDebug(1, Form("opt = %s",opt));
   Int_t res;
-  //First call the AliLoader's method to send the TreeS to folder
-  if (GetTracksDataLoader()->GetBaseLoader(0)->IsLoaded() == kFALSE) 
-    {//tracks can be loaded by LoadRecPoints
-      res = AliLoader::LoadTracks(opt);
-      if (res)
-       {//oops, error
-         Error("LoadTracks","AliLoader::LoadTracks returned error");
-         return res;
-       }
-    }
-  res = ReadTracks();
+  res = AliLoader::LoadTracks(opt);
   if (res)
-    {
-      Error("LoadTracks","Error occured while reading Tracks");
+    {//oops, error
+      AliError("returned error");
       return res;
-    }
+    }  
+  return ReadTracks();
   
-  fTracksLoaded = kTRUE;
-  return 0;
 }
 
 //____________________________________________________________________________ 
@@ -293,26 +283,20 @@ Int_t AliEMCALLoader::LoadRecParticles(Option_t* opt)
       Error("LoadRecParticles","AliLoader::LoadRecParticles returned error");
       return res;
     }
-  
-  TFolder * emcalFolder = GetDetectorDataFolder();
-  if ( emcalFolder  == 0x0 ) 
-    {
-      Error("PostDigits","Can not get detector data folder");
-      return 1;
-    }
   return ReadRecParticles();
 }
 
 //____________________________________________________________________________ 
 Int_t AliEMCALLoader::PostHits()
 {
+  // Post Hits
   Int_t reval = AliLoader::PostHits();
   if (reval)
     {
      Error("PostHits","AliLoader::  returned error");
      return reval;
     }
-  return ReadHits();
+  return const_cast<AliEMCALLoader *>(this)->ReadHits();
 }
 
 //____________________________________________________________________________ 
@@ -325,7 +309,7 @@ Int_t AliEMCALLoader::PostSDigits()
      Error("PostSDigits","AliLoader::PostSDigits  returned error");
      return reval;
    }
-  return ReadSDigits();
+  return const_cast<AliEMCALLoader *>(this)->ReadSDigits();
 }
 
 //____________________________________________________________________________ 
@@ -338,7 +322,7 @@ Int_t AliEMCALLoader::PostDigits()
       Error("PostDigits","AliLoader::PostDigits  returned error");
       return reval;
     }
-  return ReadDigits();
+  return const_cast<AliEMCALLoader *>(this)->ReadDigits();
 }
 
 //____________________________________________________________________________ 
@@ -351,7 +335,7 @@ Int_t AliEMCALLoader::PostRecPoints()
      Error("PostRecPoints","AliLoader::PostRecPoints  returned error");
      return reval;
    }
-  return ReadRecPoints();
+  return const_cast<AliEMCALLoader *>(this)->ReadRecPoints();
 }
 
 //____________________________________________________________________________ 
@@ -365,7 +349,7 @@ Int_t AliEMCALLoader::PostRecParticles()
       Error("PostRecParticles","AliLoader::PostRecParticles  returned error");
       return reval;
     }
-  return ReadRecParticles();
+  return const_cast<AliEMCALLoader *>(this)->ReadRecParticles();
 }
 
 //____________________________________________________________________________ 
@@ -378,7 +362,7 @@ Int_t AliEMCALLoader::PostTracks()
       Error("PostTracks","AliLoader::PostTracks  returned error");
       return reval;
     }
-  return ReadTracks();
+  return const_cast<AliEMCALLoader *>(this)->ReadTracks();
 }
 
 //____________________________________________________________________________ 
@@ -402,19 +386,18 @@ Int_t AliEMCALLoader::ReadHits()
   
   if(treeh == 0)
     {
-      Error("ReadHits"," Cannot read TreeH from folder");
+      AliError("Cannot read TreeH from folder");
       return 1;
     }
   
   TBranch * hitsbranch = treeh->GetBranch(fDetectorName);
   if (hitsbranch == 0) 
     {
-      Error("ReadHits"," Cannot find branch EMCAL"); 
+      AliError("Cannot find branch EMCAL"); 
       return 1;
     }
   
-  if (GetDebug()) 
-    printf("ReadHits: Reading Hits");
+  AliDebug(1, "Reading Hits");
   
   if (hitsbranch->GetEntries() > 1)
     {
@@ -434,6 +417,7 @@ Int_t AliEMCALLoader::ReadHits()
              index++ ; 
            }
        }
+      tempo->Delete() ; 
       delete tempo;
     }
   else 
@@ -707,7 +691,8 @@ AliEMCALLoader* AliEMCALLoader::GetEMCALLoader(const  char* eventfoldername)
 
 //____________________________________________________________________________ 
 Bool_t AliEMCALLoader::BranchExists(const TString& recName)
-{
+{ 
+  // Check is branch exists
   if (fBranchTitle.IsNull()) return kFALSE;
   TString dataname, zername ;
   TTree* tree;
@@ -776,10 +761,12 @@ void AliEMCALLoader::SetBranchTitle(const TString& btitle)
 //____________________________________________________________________________ 
 void AliEMCALLoader::CleanHits()
 {
+  // Clean hits        
   AliLoader::CleanHits();
   //Clear an array 
   TClonesArray* hits = Hits();
-  if (hits) hits->Clear();
+  if (hits) 
+    hits->Clear();
 }
 
 //____________________________________________________________________________ 
@@ -893,13 +880,14 @@ void AliEMCALLoader::MakeDigitsArray()
 //____________________________________________________________________________ 
 void AliEMCALLoader::MakeRecPointsArray()
 {
-  if ( ECARecPoints() == 0x0) {
-    if (GetDebug()>9) 
-      printf("MakeRecPointsArray: Making array for ECA");
-    TObjArray* eca = new TObjArray(100) ;
-    eca->SetName(fgkECARecPointsName) ;
-    GetDetectorDataFolder()->Add(eca);
-   }
+  // Make recpoints array
+  if ( ECARecPoints() == 0x0) 
+    {
+      AliDebug(9, "Making array for ECA");
+      TObjArray* eca = new TObjArray(100) ;
+      eca->SetName(fgkECARecPointsName) ;
+      GetDetectorDataFolder()->Add(eca);
+    }
 }
 
 //____________________________________________________________________________