//
//////////////////////////////////////////////////////////////////////////////
-
// --- ROOT system ---
-
+#include "TMath.h"
#include "TTree.h"
// --- Standard library ---
#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::fCalibData = 0; //calibation data
-AliEMCALAlignData* AliEMCALLoader::fAlignData = 0; //alignment data
+AliEMCALCalibData* AliEMCALLoader::fgCalibData = 0; //calibation data
//____________________________________________________________________________
AliEMCALLoader::AliEMCALLoader()
+ : fDebug(0),
+ fHits(0),
+ fDigits(0),
+ fSDigits(0),
+ fRecPoints(0)
{
+ //Default constructor for EMCAL Loader Class
+
fDebug = 0;
fHits = new TClonesArray("AliEMCALHit");
fDigits = new TClonesArray("AliEMCALDigit");
}
//____________________________________________________________________________
-AliEMCALLoader::AliEMCALLoader(const Char_t *detname,const Char_t *eventfoldername):
- AliLoader(detname,eventfoldername)
+AliEMCALLoader::AliEMCALLoader(const Char_t *detname,const Char_t *eventfoldername)
+ : AliLoader(detname,eventfoldername),
+ 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 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");
TreeS()->SetBranchAddress(fDetectorName,0);
if (TreeR())
TreeR()->SetBranchAddress(fgkECARecPointsBranchName,0);
- delete fHits;
+ if (fHits) {
+ fHits->Delete();
+ delete fHits;
+ }
delete fDigits;
delete fSDigits;
delete fRecPoints;
}
-//____________________________________________________________________________
-AliEMCALAlignData* AliEMCALLoader::AlignData()
-{
- // Check if the instance of AliEMCALAlignData exists, and return it
-
- if( !(AliCDBManager::Instance()->IsDefaultStorageSet()) )
- fAlignData=0x0;
- return fAlignData;
-}
-
//____________________________________________________________________________
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()) )
- fCalibData=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 fCalibData;
+ return fgCalibData;
}
+
//____________________________________________________________________________
Int_t AliEMCALLoader::CalibrateRaw(Double_t energy, Int_t module,
Int_t column, Int_t row)
}
//____________________________________________________________________________
-Int_t AliEMCALLoader::LoadHits(Option_t* opt) {
-
- Int_t status = AliLoader::LoadHits(opt); // First call AliLoader to do all the groundwork
-
- TTree *treeH = TreeH();
-
- if (treeH) {
- treeH->SetBranchAddress(fDetectorName,&fHits);
- if (treeH->GetEntries() > 1)
- AliWarning("Multiple arrays in treeH no longer supported");
- treeH->GetEvent(0);
- }
-
- return status;
-}
-
-//____________________________________________________________________________
-Int_t AliEMCALLoader::LoadSDigits(Option_t* opt) {
-
- Int_t status = AliLoader::LoadSDigits(opt); // First call AliLoader to do all the groundwork
-
- TTree *treeS = TreeS();
-
- if (treeS) {
- treeS->SetBranchAddress(fDetectorName,&fSDigits);
- treeS->GetEvent(0);
- }
-
- return status;
-}
-
-//____________________________________________________________________________
-Int_t AliEMCALLoader::LoadDigits(Option_t* opt) {
-
- Int_t status = AliLoader::LoadDigits(opt); // First call AliLoader to do all the groundwork
-
- TTree *treeD = TreeD();
-
- if (treeD) {
- treeD->SetBranchAddress(fDetectorName,&fDigits);
- treeD->GetEvent(0);
- }
-
- return status;
-}
-
-//____________________________________________________________________________
-Int_t AliEMCALLoader::LoadRecPoints(Option_t* opt) {
-
- Int_t status = AliLoader::LoadRecPoints(opt); // First call AliLoader to do all the groundwork
-
- TTree *treeR = TreeR();
- if (treeR) {
- treeR->SetBranchAddress(fgkECARecPointsBranchName,&fRecPoints);
- treeR->GetEvent(0);
- }
-
- return status;
-}
+Int_t AliEMCALLoader::GetEvent()
+{
+ //Method to load all of the data
+ //members of the EMCAL for a given
+ //event from the Trees
-//____________________________________________________________________________
-Int_t AliEMCALLoader::GetEvent() {
-
AliLoader::GetEvent(); // First call AliLoader to do all the groundwork
// Now connect and fill TClonesArray
TTree *treeH = TreeH();
if (treeH) {
- treeH->SetBranchAddress(fDetectorName,&fHits);
- if (treeH->GetEntries() > 1)
- AliWarning("Multiple arrays in treeH no longer supported");
- treeH->GetEvent(0);
+ Int_t nEnt = treeH->GetEntries(); // TreeH has array of hits for every primary
+ fHits->Clear();
+ Int_t index = 0;
+ TClonesArray *tempArr = 0x0;
+ TBranch * branchH = treeH->GetBranch(fDetectorName);
+ branchH->SetAddress(&tempArr);
+ for (Int_t iEnt = 0; iEnt < nEnt; iEnt++) {
+ treeH->GetEntry(iEnt);
+ Int_t nHit = tempArr->GetEntriesFast();
+ for (Int_t iHit = 0; iHit < nHit; iHit++) {
+ new ((*fHits)[index]) AliEMCALHit(*((AliEMCALHit*)tempArr->At(iHit)));
+ index++;
+ }
+ }
+ branchH->ResetAddress();
+ if (tempArr) {
+ tempArr->Delete();
+ delete tempArr;
+ }
}
-
-
+
// SDigits
TTree *treeS = TreeS();
if (treeS) {
- treeS->SetBranchAddress(fDetectorName,&fSDigits);
+ TBranch * branchS = treeS->GetBranch(fDetectorName);
+ branchS->ResetAddress();
+ if (fSDigits) {
+ fSDigits->Clear();
+ }
+ branchS->SetAddress(&fSDigits);
treeS->GetEvent(0);
}
// Digits
TTree *treeD = TreeD();
if (treeD) {
- treeD->SetBranchAddress(fDetectorName,&fDigits);
+ TBranch * branchD = treeD->GetBranch(fDetectorName);
+ branchD->ResetAddress();
+ if (fDigits) {
+ fDigits->Clear();
+ }
+ branchD->SetAddress(&fDigits);
treeD->GetEvent(0);
}
// RecPoints
TTree *treeR = TreeR();
if (treeR) {
- treeR->SetBranchAddress(fgkECARecPointsBranchName,&fRecPoints);
+ TBranch * branchR = treeR->GetBranch(fgkECARecPointsBranchName);
+ branchR->ResetAddress();
+ if (fRecPoints) {
+ fRecPoints->Clear();
+ }
+ branchR->SetAddress(&fRecPoints);
treeR->GetEvent(0);
}