]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EMCAL/AliEMCALLoader.cxx
Digit header added
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALLoader.cxx
index 7e29d87bccbdd067630620dd53b6fc3b0565c093..f96c9fbf4be1fcd9c0b8af44eba0d6243f070f79 100644 (file)
@@ -40,6 +40,7 @@
 //////////////////////////////////////////////////////////////////////////////
 
 // --- ROOT system ---
+#include "TMath.h"
 #include "TTree.h"
 
 // --- Standard library ---
@@ -50,6 +51,7 @@
 #include "AliCDBLocal.h"
 #include "AliCDBStorage.h"
 #include "AliCDBManager.h"
+#include "AliCDBEntry.h"
 #include "AliEMCALHit.h"
 
 ClassImp(AliEMCALLoader)
@@ -93,15 +95,21 @@ AliEMCALLoader::AliEMCALLoader(const Char_t *detname,const Char_t *eventfolderna
 }
 
 //____________________________________________________________________________
-AliEMCALLoader::AliEMCALLoader(const AliEMCALLoader & obj)
-  : AliLoader(obj),
-    fDebug(obj.fDebug),
-    fHits(obj.fHits),
-    fDigits(obj.fDigits),
-    fSDigits(obj.fSDigits),
-    fRecPoints(obj.fRecPoints)
+AliEMCALLoader::AliEMCALLoader(const Char_t *name, TFolder *topfolder)
+  : AliLoader(name,topfolder),
+    fDebug(0),
+    fHits(0),
+    fDigits(0),
+    fSDigits(0),
+    fRecPoints(0)
 {
-  //copy ctor
+  //Specific constructor for EMCAL Loader class
+
+  fDebug=0;
+  fHits = new TClonesArray("AliEMCALHit");
+  fDigits = new TClonesArray("AliEMCALDigit");
+  fSDigits = new TClonesArray("AliEMCALDigit");
+  fRecPoints = new TObjArray();
 }
 
 //____________________________________________________________________________ 
@@ -128,15 +136,24 @@ 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;
   
 }
 
+
 //____________________________________________________________________________ 
 Int_t AliEMCALLoader::CalibrateRaw(Double_t energy, Int_t module, 
                                   Int_t column, Int_t row)
@@ -208,9 +225,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);
@@ -222,9 +237,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);
@@ -236,9 +249,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);