]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EMCAL/AliEMCALLoader.cxx
First commit of new jet reconstruction and analysis code to be used for the
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALLoader.cxx
index d24d7fa6e112020992eb906232013ee5755bea49..17be32b29c138692361af473f23cb8d9404fd540 100644 (file)
 // --- Standard library ---
 
 // --- AliRoot header files ---
-
-#include "AliEMCALLoader.h"
 #include "AliEMCAL.h"
-#include "AliEMCALHit.h"
 #include "AliEMCALGetter.h"
+#include "AliEMCALHit.h"
+#include "AliEMCALLoader.h"
+#include "AliLog.h"
+#include "AliObjectLoader.h"
 
 ClassImp(AliEMCALLoader)
   
@@ -90,10 +91,13 @@ AliEMCALLoader::~AliEMCALLoader()
   Clean(fgkECARecPointsName);
   Clean(fgkTracksName);
   Clean(fgkRecParticlesName);
-  // set to 0x0 the objgetter in AliGetter ... weird isn it !
+  CleanFolders() ; 
+ // set to 0x0 the objgetter in AliGetter ... weird isn it !
+  /* 
   AliEMCALGetter * gime = AliEMCALGetter::Instance() ; 
   if (gime) 
     gime->Reset() ;
+  */
 }
 
 //____________________________________________________________________________ 
@@ -190,7 +194,7 @@ Int_t AliEMCALLoader::LoadHits(Option_t* opt)
   
   if (res)
    {//oops, error
-     Error("LoadHits","AliLoader::LoadHits returned error");
+     AliError("returned error");
      return res;
    }
 
@@ -257,33 +261,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;
 }
 
 //____________________________________________________________________________ 
@@ -311,6 +298,7 @@ Int_t AliEMCALLoader::LoadRecParticles(Option_t* opt)
 //____________________________________________________________________________ 
 Int_t AliEMCALLoader::PostHits()
 {
+  // Post Hits
   Int_t reval = AliLoader::PostHits();
   if (reval)
     {
@@ -407,19 +395,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)
     {
@@ -439,6 +426,7 @@ Int_t AliEMCALLoader::ReadHits()
              index++ ; 
            }
        }
+      tempo->Delete() ; 
       delete tempo;
     }
   else 
@@ -712,7 +700,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;
@@ -781,10 +770,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();
 }
 
 //____________________________________________________________________________ 
@@ -898,13 +889,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);
+    }
 }
 
 //____________________________________________________________________________