]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EMCAL/AliEMCALLoader.cxx
Fixing a little overlap. Adding flags to perform material budget studies (Mario)
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALLoader.cxx
index 4ebcd6a5796be02aac40d367b7fa98f138e6ffc0..c44c07581172c61cb94056d5f78099f76f4ef37b 100644 (file)
 #include "AliCDBStorage.h"
 #include "AliCDBManager.h"
 #include "AliCDBEntry.h"
-#include "AliEMCALHit.h"
 
  ClassImp(AliEMCALLoader)
   
 const TString         AliEMCALLoader::fgkECARecPointsBranchName("EMCALECARP");//Name for branch with ECA Reconstructed Points
 const TString         AliEMCALLoader::fgkECADigitsBranchName("DIGITS");//Name for branch with ECA Digits
 const TString         AliEMCALLoader::fgkECASDigitsBranchName("SDIGITS");//Name for branch with ECA SDigits
-const TString         AliEMCALLoader::fgkECAHitsBranchName("HITS");//Name for branch with ECA Hits
 
 AliEMCALCalibData*    AliEMCALLoader::fgCalibData = 0; //calibration data
-//AliCaloCalibPedestal* AliEMCALLoader::fgCaloPed   = 0; //dead map data
+AliCaloCalibPedestal* AliEMCALLoader::fgCaloPed   = 0; //dead map data
 AliEMCALSimParam*     AliEMCALLoader::fgSimParam  = 0; //simulation parameters
+AliEMCALRecParam*     AliEMCALLoader::fgRecParam  = 0; //reconstruction parameters
 
 //____________________________________________________________________________ 
 AliEMCALLoader::AliEMCALLoader()
-  : fDebug(0)
+: fDebug(0)
 {
   //Default constructor for EMCAL Loader Class
-  
+
 }
 
 //____________________________________________________________________________ 
@@ -72,6 +71,7 @@ AliEMCALLoader::AliEMCALLoader(const Char_t *detname,const Char_t *eventfolderna
   : AliLoader(detname,eventfoldername), fDebug(0)
 {
   //Specific constructor for EMCAL Loader class
+
 }
 
 //____________________________________________________________________________
@@ -79,6 +79,7 @@ AliEMCALLoader::AliEMCALLoader(const Char_t *name, TFolder *topfolder)
   : AliLoader(name,topfolder), fDebug(0)
 {
   //Specific constructor for EMCAL Loader class
+
 }
 
 //____________________________________________________________________________ 
@@ -87,12 +88,19 @@ AliEMCALLoader::~AliEMCALLoader()
   // Disconnect trees and remove arrays
   if (TreeH())
     TreeH()->SetBranchAddress(fDetectorName,0);
-  if (TreeD())
-    TreeD()->SetBranchAddress(fDetectorName,0);
-  if (TreeS())
-    TreeS()->SetBranchAddress(fDetectorName,0);
-  if (TreeR())
-    TreeR()->SetBranchAddress(fgkECARecPointsBranchName,0);
+//  if (TreeD())
+//    TreeD()->SetBranchAddress(fDetectorName,0);
+//  if (TreeS())
+//    TreeS()->SetBranchAddress(fDetectorName,0);
+//  if (TreeR())
+//    TreeR()->SetBranchAddress(fgkECARecPointsBranchName,0);
+       
+       Clean(fgkECASDigitsBranchName);
+       Clean(fgkECADigitsBranchName);
+       Clean(fgkECARecPointsBranchName);
+       
+       AliLoader::CleanFolders();
+               
 }
 
 //____________________________________________________________________________ 
@@ -116,24 +124,24 @@ AliEMCALCalibData* AliEMCALLoader::CalibData()
 }
 
 //____________________________________________________________________________ 
-//AliCaloCalibPedestal* AliEMCALLoader::PedestalData()
-//
-//     // Check if the instance of AliCaloCalibPedestal exists, if not, create it if 
-//     // the OCDB is available, and finally return it.
-//     
-//     if(!fgCaloPed && (AliCDBManager::Instance()->IsDefaultStorageSet()))
-//    {
-//             AliCDBEntry *entry = (AliCDBEntry*) 
-//             AliCDBManager::Instance()->Get("EMCAL/Calib/Pedestals");
-//             if (entry) fgCaloPed =  (AliCaloCalibPedestal*) entry->GetObject();
-//    }
-//     
-//     if(!fgCaloPed)
-//             AliFatal("Pedestal info not found in CDB!");
-//     
-//     return fgCaloPed;
-//     
-//}
+AliCaloCalibPedestal* AliEMCALLoader::PedestalData()
+{ 
+       // Check if the instance of AliCaloCalibPedestal exists, if not, create it if 
+       // the OCDB is available, and finally return it.
+       
+       if(!fgCaloPed && (AliCDBManager::Instance()->IsDefaultStorageSet()))
+    {
+               AliCDBEntry *entry = (AliCDBEntry*) 
+               AliCDBManager::Instance()->Get("EMCAL/Calib/Pedestals");
+               if (entry) fgCaloPed =  (AliCaloCalibPedestal*) entry->GetObject();
+    }
+       
+       if(!fgCaloPed)
+               AliFatal("Pedestal info not found in CDB!");
+       
+       return fgCaloPed;
+       
+}
 
 //____________________________________________________________________________ 
 AliEMCALSimParam* AliEMCALLoader::SimulationParameters()
@@ -144,7 +152,7 @@ AliEMCALSimParam* AliEMCALLoader::SimulationParameters()
   if(!fgSimParam && (AliCDBManager::Instance()->IsDefaultStorageSet()))
     {
       AliCDBEntry *entry = (AliCDBEntry*) 
-       AliCDBManager::Instance()->Get("EMCAL/Calib/SimParam");
+      AliCDBManager::Instance()->Get("EMCAL/Calib/SimParam");
       if (entry) fgSimParam =  (AliEMCALSimParam*) entry->GetObject();
       
     }
@@ -156,43 +164,43 @@ AliEMCALSimParam* AliEMCALLoader::SimulationParameters()
   
 }
 
+
+//____________________________________________________________________________ 
+AliEMCALRecParam* AliEMCALLoader::ReconstructionParameters(Int_t eventType = 0)
+{ 
+  // Check if the instance of AliEMCALRecParam exists, if not, create it if 
+  // the OCDB is available, and finally return it. 
+  // The event type must be provided.
+  
+  if(!fgRecParam && (AliCDBManager::Instance()->IsDefaultStorageSet()))
+  {
+    AliCDBEntry *entry = (AliCDBEntry*) 
+    AliCDBManager::Instance()->Get("EMCAL/Calib/RecoParam");
+    if (entry) fgRecParam =  (AliEMCALRecParam*)((TObjArray *) entry->GetObject())->At(eventType);
+    
+  }
+  
+  if(!fgRecParam)
+    AliFatal("Reconstruction parameters not found in CDB!");
+  
+  return fgRecParam;
+  
+}
+
+
 //____________________________________________________________________________ 
 Int_t AliEMCALLoader::GetEvent() 
 {
   //Method to load all of the data
   //members of the EMCAL for a given
   //event from the Trees
-  
+
   AliLoader::GetEvent();  // First call AliLoader to do all the groundwork
   
   // *** Hits ***
-  // Initialize the Hits TClonesArray, only if it did not existed before
-  MakeHitsArray();
-  
-  TTree *treeH = TreeH();      
-  if (treeH) {
-    Int_t nEnt = treeH->GetEntries();  // TreeH has array of hits for every primary
-    Int_t index = 0;
-    TClonesArray *tempArr = 0x0;
-    TBranch * branchH = treeH->GetBranch(fDetectorName);
-    branchH->SetAddress(&tempArr);
-    TClonesArray* hits = const_cast<AliEMCALLoader *>(this)->Hits();
-    if (hits) hits->Clear();
-    for (Int_t iEnt = 0; iEnt < nEnt; iEnt++) {
-      branchH->GetEntry(iEnt);
-      Int_t nHit = tempArr->GetEntriesFast();
-      for (Int_t iHit = 0; iHit < nHit; iHit++) {
-       new ((*hits)[index]) AliEMCALHit(*((AliEMCALHit*)tempArr->At(iHit)));
-       index++;
-      }
-    }
-    branchH->ResetAddress();
-    if (tempArr) {
-      tempArr->Delete();
-      delete tempArr;
-    }
-  }
-  
+  // Hits are now handled directly on the AliEMCALSDigitizer, the only place it is requested.
+  // together with AliEveEMCALData
+       
   // *** SDigits ***
   // Initialize the SDigits TClonesArray, only if it did not existed before
   MakeSDigitsArray();
@@ -204,7 +212,7 @@ Int_t AliEMCALLoader::GetEvent()
     // Reset SDigits array and branch
     branchS->ResetAddress();
     TClonesArray* sdigits = const_cast<AliEMCALLoader *>(this)->SDigits();
-    if (sdigits) sdigits->Clear();
+    if (sdigits) sdigits->Clear("C");
     
     branchS->SetAddress(&sdigits);
     branchS->GetEntry(0);
@@ -221,7 +229,7 @@ Int_t AliEMCALLoader::GetEvent()
     // Reset Digits array and branch
     branchD->ResetAddress();
     TClonesArray* digits = const_cast<AliEMCALLoader *>(this)->Digits();
-    if (digits) digits->Clear();
+    if (digits) digits->Clear("C");
     
     branchD->SetAddress(&digits);
     branchD->GetEntry(0);
@@ -247,15 +255,6 @@ Int_t AliEMCALLoader::GetEvent()
   return 0;
 }
 
-//____________________________________________________________________________
-void AliEMCALLoader::MakeHitsArray(){
-  // Add Hits array to the data folder
-  if (Hits()) return;
-  TClonesArray* hits = new TClonesArray("AliEMCALHit",0);
-  hits->SetName(fgkECAHitsBranchName);
-  GetDetectorDataFolder()->Add(hits);
-}
-
 //____________________________________________________________________________
 void AliEMCALLoader::MakeSDigitsArray(){
   // Add SDigits array to the data folder