]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EMCAL/AliEMCALLoader.cxx
Fixing memory leaks
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALLoader.cxx
index d3f3e94ccdee9329799a6ddbb89f89c0bd572d63..f11037522e0044cd71a0d5ed2a5bd52d80cd38bd 100644 (file)
 
 ClassImp(AliEMCALLoader)
   
-const TString AliEMCALLoader::fgkECARecPointsBranchName("EMCALECARP");//Name for branch with ECA Reconstructed Points
-AliEMCALCalibData* AliEMCALLoader::fgCalibData = 0; //calibation data
+const TString         AliEMCALLoader::fgkECARecPointsBranchName("EMCALECARP");//Name for branch with ECA Reconstructed Points
+AliEMCALCalibData*    AliEMCALLoader::fgCalibData = 0; //calibration data
+AliCaloCalibPedestal* AliEMCALLoader::fgCaloPed   = 0; //dead map data
+AliEMCALSimParam*     AliEMCALLoader::fgSimParam  = 0; //simulation parameters
 
 //____________________________________________________________________________ 
 AliEMCALLoader::AliEMCALLoader()
@@ -80,30 +82,24 @@ AliEMCALLoader::AliEMCALLoader()
 AliEMCALLoader::AliEMCALLoader(const Char_t *detname,const Char_t *eventfoldername)
   : AliLoader(detname,eventfoldername),
     fDebug(0),
-    fHits(0),
-    fDigits(0),
-    fSDigits(0),
-    fRecPoints(0)
+    fHits(new TClonesArray("AliEMCALHit")),
+    fDigits(new TClonesArray("AliEMCALDigit")),
+    fSDigits(new TClonesArray("AliEMCALDigit")),
+    fRecPoints(new TObjArray())
 {
   //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),
-    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(new TClonesArray("AliEMCALHit")),
+    fDigits(new TClonesArray("AliEMCALDigit")),
+    fSDigits(new TClonesArray("AliEMCALDigit")),
+    fRecPoints(new TObjArray())
 {
-  //copy ctor
+  //Specific constructor for EMCAL Loader class
 }
 
 //____________________________________________________________________________ 
@@ -147,6 +143,47 @@ 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;
+       
+}
+
+//____________________________________________________________________________ 
+AliEMCALSimParam* AliEMCALLoader::SimulationParameters()
+{ 
+       // Check if the instance of AliEMCALSimParam exists, if not, create it if 
+       // the OCDB is available, and finally return it.
+       
+       if(!fgSimParam && (AliCDBManager::Instance()->IsDefaultStorageSet()))
+    {
+               AliCDBEntry *entry = (AliCDBEntry*) 
+               AliCDBManager::Instance()->Get("EMCAL/Calib/SimParam");
+               if (entry) fgSimParam =  (AliEMCALSimParam*) entry->GetObject();
+       
+    }
+       
+       if(!fgSimParam)
+               AliFatal("Simulations parameters not found in CDB!");
+
+       return fgSimParam;
+       
+}
+
 //____________________________________________________________________________ 
 Int_t AliEMCALLoader::CalibrateRaw(Double_t energy, Int_t module, 
                                   Int_t column, Int_t row)
@@ -198,7 +235,8 @@ Int_t AliEMCALLoader::GetEvent()
      TBranch * branchH = treeH->GetBranch(fDetectorName);
      branchH->SetAddress(&tempArr);
      for (Int_t iEnt = 0; iEnt < nEnt; iEnt++) {
-       treeH->GetEntry(iEnt);
+       //treeH->GetEntry(iEnt);
+          branchH->GetEntry(iEnt);
        Int_t nHit = tempArr->GetEntriesFast();
        for (Int_t iHit = 0; iHit < nHit; iHit++) {
         new ((*fHits)[index]) AliEMCALHit(*((AliEMCALHit*)tempArr->At(iHit)));
@@ -218,12 +256,11 @@ 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);
+        branchS->GetEntry(0);
+     //treeS->GetEvent(0);
    }
    
    // Digits
@@ -232,12 +269,11 @@ 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);
+        branchD->GetEntry(0);
+     //treeD->GetEvent(0);
    }
 
    // RecPoints
@@ -246,12 +282,11 @@ 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);
+     //treeR->GetEvent(0);
+        branchR->GetEntry(0);
    }
    
    return 0;