]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EMCAL/AliEMCALLoader.cxx
Added support for strip range calib objects
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALLoader.cxx
index 228af6008f87b40381228f5cf91c86278dc9d237..663f6b95dadf9922cbbf3aa3c8b51fd926973671 100644 (file)
 #include "AliCDBLocal.h"
 #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
 AliEMCALCalibData* AliEMCALLoader::fgCalibData = 0; //calibation data
+AliEMCALRecParam * AliEMCALLoader::fgRecParam  = 0; //reconstruction parameters
 
 //____________________________________________________________________________ 
 AliEMCALLoader::AliEMCALLoader()
@@ -93,6 +95,24 @@ AliEMCALLoader::AliEMCALLoader(const Char_t *detname,const Char_t *eventfolderna
   fRecPoints = new TObjArray();
 }
 
+//____________________________________________________________________________
+AliEMCALLoader::AliEMCALLoader(const Char_t *name, TFolder *topfolder)
+  : AliLoader(name,topfolder),
+    fDebug(0),
+    fHits(0),
+    fDigits(0),
+    fSDigits(0),
+    fRecPoints(0)
+{
+  //Specific constructor for EMCAL Loader class
+
+  fDebug=0;
+  fHits = new TClonesArray("AliEMCALHit");
+  fDigits = new TClonesArray("AliEMCALDigit");
+  fSDigits = new TClonesArray("AliEMCALDigit");
+  fRecPoints = new TObjArray();
+}
+
 //____________________________________________________________________________
 AliEMCALLoader::AliEMCALLoader(const AliEMCALLoader & obj)
   : AliLoader(obj),
@@ -129,15 +149,42 @@ AliEMCALLoader::~AliEMCALLoader()
 //____________________________________________________________________________ 
 AliEMCALCalibData* AliEMCALLoader::CalibData()
 { 
-  // Check if the instance of AliEMCALCalibData exists, and return it
+  // Check if the instance of AliEMCALCalibData exists, if not, create it if 
+  // the OCDB is available, and finally return it.
 
-  if( !(AliCDBManager::Instance()->IsDefaultStorageSet()) ) 
-    fgCalibData=0x0;
+  if(!fgCalibData && (AliCDBManager::Instance()->IsDefaultStorageSet()))
+    {
+      AliCDBEntry *entry = (AliCDBEntry*) 
+       AliCDBManager::Instance()->Get("EMCAL/Calib/Data");
+      if (entry) fgCalibData =  (AliEMCALCalibData*) entry->GetObject();
+    }
+  
+  if(!fgCalibData)
+    AliFatal("Calibration parameters not found in CDB!");
   
   return fgCalibData;
   
 }
 
+//____________________________________________________________________________ 
+AliEMCALRecParam* AliEMCALLoader::RecParam()
+{ 
+  // Check if the instance of AliEMCALRecParam exists, if not, create it if 
+  // the OCDB is available, and finally return it.
+
+  if(!fgRecParam && (AliCDBManager::Instance()->IsDefaultStorageSet())) {
+    AliCDBEntry *entry = (AliCDBEntry*) 
+      AliCDBManager::Instance()->Get("EMCAL/Config/RecParam/");
+    if (entry) fgRecParam =  (AliEMCALRecParam*) entry->GetObject();
+  }
+  
+  if(!fgRecParam)
+    AliWarning("Recostruction parameters not found in CDB!");
+  
+  return fgRecParam;
+  
+}
+
 //____________________________________________________________________________ 
 Int_t AliEMCALLoader::CalibrateRaw(Double_t energy, Int_t module, 
                                   Int_t column, Int_t row)
@@ -209,9 +256,7 @@ Int_t AliEMCALLoader::GetEvent()
      TBranch * branchS = treeS->GetBranch(fDetectorName);
      branchS->ResetAddress();
      if (fSDigits) {
-       fSDigits->Delete();
-       delete fSDigits;
-       fSDigits = 0x0;
+       fSDigits->Clear();
      }
      branchS->SetAddress(&fSDigits);
      treeS->GetEvent(0);
@@ -223,9 +268,7 @@ Int_t AliEMCALLoader::GetEvent()
      TBranch * branchD = treeD->GetBranch(fDetectorName);
      branchD->ResetAddress();
      if (fDigits) {
-       fDigits->Delete();
-       delete fDigits;
-       fDigits = 0x0;
+       fDigits->Clear();
      }
      branchD->SetAddress(&fDigits);
      treeD->GetEvent(0);
@@ -237,9 +280,7 @@ Int_t AliEMCALLoader::GetEvent()
      TBranch * branchR = treeR->GetBranch(fgkECARecPointsBranchName);
      branchR->ResetAddress();
      if (fRecPoints) {
-       fRecPoints->Delete();
-       delete fRecPoints;
-       fRecPoints = 0x0;
+       fRecPoints->Clear();
      }
      branchR->SetAddress(&fRecPoints);
      treeR->GetEvent(0);