]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EMCAL/AliEMCALLoader.cxx
Fixing memory leaks
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALLoader.cxx
index 2d28dbc553db8ef5d0a90301328f18cea60018e8..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,48 +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 Char_t *name, TFolder *topfolder)
   : AliLoader(name,topfolder),
     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)
-{
-  //copy ctor
 }
 
 //____________________________________________________________________________ 
@@ -165,6 +143,46 @@ 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, 
@@ -217,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)));
@@ -240,7 +259,8 @@ Int_t AliEMCALLoader::GetEvent()
        fSDigits->Clear();
      }
      branchS->SetAddress(&fSDigits);
-     treeS->GetEvent(0);
+        branchS->GetEntry(0);
+     //treeS->GetEvent(0);
    }
    
    // Digits
@@ -252,7 +272,8 @@ Int_t AliEMCALLoader::GetEvent()
        fDigits->Clear();
      }
      branchD->SetAddress(&fDigits);
-     treeD->GetEvent(0);
+        branchD->GetEntry(0);
+     //treeD->GetEvent(0);
    }
 
    // RecPoints
@@ -264,7 +285,8 @@ Int_t AliEMCALLoader::GetEvent()
        fRecPoints->Clear();
      }
      branchR->SetAddress(&fRecPoints);
-     treeR->GetEvent(0);
+     //treeR->GetEvent(0);
+        branchR->GetEntry(0);
    }
    
    return 0;