X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=EMCAL%2FAliEMCALLoader.cxx;h=154740f91b7eb2a02499d81cf51259bf049469d4;hb=2e90ca058835357d26c09ed6ef5fa194d4025eb0;hp=d2b55a4ca2dd8ce9713c243632b8be32bd011368;hpb=78cbbabb10b975736f78ee0b5dd2b15c19891b8a;p=u%2Fmrichter%2FAliRoot.git diff --git a/EMCAL/AliEMCALLoader.cxx b/EMCAL/AliEMCALLoader.cxx index d2b55a4ca2d..154740f91b7 100644 --- a/EMCAL/AliEMCALLoader.cxx +++ b/EMCAL/AliEMCALLoader.cxx @@ -39,9 +39,8 @@ // ////////////////////////////////////////////////////////////////////////////// - // --- ROOT system --- - +#include "TMath.h" #include "TTree.h" // --- Standard library --- @@ -52,16 +51,25 @@ #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 +AliEMCALRecParam * AliEMCALLoader::fgRecParam = 0; //reconstruction parameters //____________________________________________________________________________ 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"); @@ -70,9 +78,34 @@ AliEMCALLoader::AliEMCALLoader() } //____________________________________________________________________________ -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"); @@ -80,6 +113,18 @@ AliEMCALLoader::AliEMCALLoader(const Char_t *detname,const Char_t *eventfolderna 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 +} + //____________________________________________________________________________ AliEMCALLoader::~AliEMCALLoader() { @@ -92,31 +137,51 @@ AliEMCALLoader::~AliEMCALLoader() 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 +//____________________________________________________________________________ +AliEMCALCalibData* AliEMCALLoader::CalibData() +{ + // Check if the instance of AliEMCALCalibData exists, if not, create it if + // the OCDB is available, and finally return it. + + 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; - if( !(AliCDBManager::Instance()->IsDefaultStorageSet()) ) - fAlignData=0x0; - return fAlignData; } //____________________________________________________________________________ -AliEMCALCalibData* AliEMCALLoader::CalibData() +AliEMCALRecParam* AliEMCALLoader::RecParam() { - // Check if the instance of AliEMCALCalibData exists, and return it + // Check if the instance of AliEMCALRecParam exists, if not, create it if + // the OCDB is available, and finally return it. - if( !(AliCDBManager::Instance()->IsDefaultStorageSet()) ) - fCalibData=0x0; + if(!fgRecParam && (AliCDBManager::Instance()->IsDefaultStorageSet())) { + AliCDBEntry *entry = (AliCDBEntry*) + AliCDBManager::Instance()->Get("EMCAL/RecParam/Data"); + if (entry) fgRecParam = (AliEMCALRecParam*) entry->GetObject(); + } + + if(!fgRecParam) + AliWarning("Recostruction parameters not found in CDB!"); - return fCalibData; + return fgRecParam; } @@ -149,42 +214,83 @@ Int_t AliEMCALLoader::CalibrateRaw(Double_t energy, Int_t module, return amp; } - //____________________________________________________________________________ -Int_t AliEMCALLoader::GetEvent() { - AliLoader::GetEvent(); // First call AliLoader to do all the groundwork +Int_t AliEMCALLoader::GetEvent() +{ + //Method to load all of the data + //members of the EMCAL for a given + //event from the Trees + AliLoader::GetEvent(); // First call AliLoader to do all the groundwork + // Now connect and fill TClonesArray // Hits - TTree *treeH = TreeH(); - if (treeH) { - treeH->SetBranchAddress(fDetectorName,&fHits); - if (treeH->GetEntries() > 1) - AliWarning("Multiple arrays in treeH no longer supported"); - treeH->GetEvent(0); - } - - // SDigits - TTree *treeS = TreeS(); - if (treeS) { - treeS->SetBranchAddress(fDetectorName,&fSDigits); - treeS->GetEvent(0); - } - - // Digits - TTree *treeD = TreeD(); - if (treeD) { - treeD->SetBranchAddress(fDetectorName,&fDigits); - treeD->GetEvent(0); - } - - // RecPoints - TTree *treeR = TreeR(); - if (treeR) { - treeR->SetBranchAddress(fgkECARecPointsBranchName,&fRecPoints); - treeR->GetEvent(0); - } + TTree *treeH = TreeH(); + + if (treeH) { + 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) { + TBranch * branchS = treeS->GetBranch(fDetectorName); + branchS->ResetAddress(); + if (fSDigits) { + fSDigits->Delete(); + delete fSDigits; + fSDigits = 0x0; + } + branchS->SetAddress(&fSDigits); + treeS->GetEvent(0); + } + + // Digits + TTree *treeD = TreeD(); + if (treeD) { + TBranch * branchD = treeD->GetBranch(fDetectorName); + branchD->ResetAddress(); + if (fDigits) { + fDigits->Delete(); + delete fDigits; + fDigits = 0x0; + } + branchD->SetAddress(&fDigits); + treeD->GetEvent(0); + } - return 0; + // RecPoints + TTree *treeR = TreeR(); + if (treeR) { + TBranch * branchR = treeR->GetBranch(fgkECARecPointsBranchName); + branchR->ResetAddress(); + if (fRecPoints) { + fRecPoints->Delete(); + delete fRecPoints; + fRecPoints = 0x0; + } + branchR->SetAddress(&fRecPoints); + treeR->GetEvent(0); + } + + return 0; }