X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=EMCAL%2FAliEMCALLoader.cxx;h=c44c07581172c61cb94056d5f78099f76f4ef37b;hb=3880d135d53c3edf56cee9d06fbdc7be81917067;hp=21fa357c1ba50c60f10c745f84a6ca28af667f7d;hpb=40164976e6eea42a0e01a8207e005746885743cb;p=u%2Fmrichter%2FAliRoot.git diff --git a/EMCAL/AliEMCALLoader.cxx b/EMCAL/AliEMCALLoader.cxx index 21fa357c1ba..c44c0758117 100644 --- a/EMCAL/AliEMCALLoader.cxx +++ b/EMCAL/AliEMCALLoader.cxx @@ -16,17 +16,10 @@ /* $Id$ */ //_________________________________________________________________________ -// A singleton. This class should be used in the analysis stage to get -// reconstructed objects: Digits, RecPoints, TrackSegments and RecParticles, -// instead of directly reading them from galice.root file. -// -// MvL Feb 2006: -// The AliEMCALLoader now holds the TClonesArray and TObjArray for reading +// The AliEMCALLoader gets the TClonesArray and TObjArray for reading // Hits, Dgits, SDigits and RecPoints. Filling is managed in the GetEvent() // method. -// -// Creation/writing of files is managed by the relevant parts of the -// reconstruction software (AliEMCALDigitiser etx) +// It also provides acces methods to the calibration and simulation OCDB parameters // //*-- Author: Yves Schutz (SUBATECH) & Dmitri Peressounko (RRC KI & SUBATECH) //*-- Completely redesigned by Dmitri Peressounko March 2001 @@ -36,13 +29,14 @@ // //*-- Marco van Leeuwen, Jan 2006: complete revision to simplify reading //*-- and fit better in general ALICE scheme +//*-- GCB: Remove TClonesArrays and TObjArrays data members, they are created elsewhere. +//*-- Provide access to OCDB calibration and simulation parameters. // ////////////////////////////////////////////////////////////////////////////// // --- ROOT system --- #include "TMath.h" #include "TTree.h" - // --- Standard library --- // --- AliRoot header files --- @@ -52,53 +46,40 @@ #include "AliCDBStorage.h" #include "AliCDBManager.h" #include "AliCDBEntry.h" -#include "AliEMCALHit.h" -ClassImp(AliEMCALLoader) + 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 +const TString AliEMCALLoader::fgkECADigitsBranchName("DIGITS");//Name for branch with ECA Digits +const TString AliEMCALLoader::fgkECASDigitsBranchName("SDIGITS");//Name for branch with ECA SDigits + +AliEMCALCalibData* AliEMCALLoader::fgCalibData = 0; //calibration data AliCaloCalibPedestal* AliEMCALLoader::fgCaloPed = 0; //dead map data +AliEMCALSimParam* AliEMCALLoader::fgSimParam = 0; //simulation parameters +AliEMCALRecParam* AliEMCALLoader::fgRecParam = 0; //reconstruction parameters //____________________________________________________________________________ AliEMCALLoader::AliEMCALLoader() - : fDebug(0), - fHits(0), - fDigits(0), - fSDigits(0), - fRecPoints(0) +: fDebug(0) { //Default 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 *detname,const Char_t *eventfoldername) - : AliLoader(detname,eventfoldername), - fDebug(0), - fHits(new TClonesArray("AliEMCALHit")), - fDigits(new TClonesArray("AliEMCALDigit")), - fSDigits(new TClonesArray("AliEMCALDigit")), - fRecPoints(new TObjArray()) + : AliLoader(detname,eventfoldername), fDebug(0) { //Specific constructor for EMCAL Loader class + } //____________________________________________________________________________ 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()) + : AliLoader(name,topfolder), fDebug(0) { //Specific constructor for EMCAL Loader class + } //____________________________________________________________________________ @@ -107,19 +88,19 @@ AliEMCALLoader::~AliEMCALLoader() // Disconnect trees and remove arrays if (TreeH()) TreeH()->SetBranchAddress(fDetectorName,0); - if (TreeD()) - TreeD()->SetBranchAddress(fDetectorName,0); - if (TreeS()) - TreeS()->SetBranchAddress(fDetectorName,0); - if (TreeR()) - TreeR()->SetBranchAddress(fgkECARecPointsBranchName,0); - if (fHits) { - fHits->Delete(); - delete fHits; - } - delete fDigits; - delete fSDigits; - delete fRecPoints; +// if (TreeD()) +// TreeD()->SetBranchAddress(fDetectorName,0); +// if (TreeS()) +// TreeS()->SetBranchAddress(fDetectorName,0); +// if (TreeR()) +// TreeR()->SetBranchAddress(fgkECARecPointsBranchName,0); + + Clean(fgkECASDigitsBranchName); + Clean(fgkECADigitsBranchName); + Clean(fgkECARecPointsBranchName); + + AliLoader::CleanFolders(); + } //____________________________________________________________________________ @@ -127,7 +108,7 @@ 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*) @@ -162,36 +143,51 @@ AliCaloCalibPedestal* AliEMCALLoader::PedestalData() } - //____________________________________________________________________________ -Int_t AliEMCALLoader::CalibrateRaw(Double_t energy, Int_t module, - Int_t column, Int_t row) -{ - // Convert energy into digitized amplitude for a cell relId - // It is a user responsilibity to open CDB and set - // AliEMCALCalibData object by the following operators: - // - // AliCDBLocal *loc = new AliCDBLocal("deCalibDB"); - // AliEMCALCalibData* clb = (AliEMCALCalibData*)AliCDBStorage::Instance() - // ->Get(path_to_calibdata,run_number); - // AliEMCALGetter* gime = AliEMCALGetter::Instance("galice.root"); - // gime->SetCalibData(clb); - - if (CalibData() == 0) - Warning("CalibrateRaw","Calibration DB is not initiated!"); +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; + +} - Float_t gainFactor = 0.00305;//0.0015; // width of one ADC channel in GeV - Float_t pedestal = 0.009;//0.005; // pedestals - if(CalibData()) { - gainFactor = CalibData()->GetADCchannel (module,column,row); - pedestal = CalibData()->GetADCpedestal(module,column,row); +//____________________________________________________________________________ +AliEMCALRecParam* AliEMCALLoader::ReconstructionParameters(Int_t eventType = 0) +{ + // Check if the instance of AliEMCALRecParam exists, if not, create it if + // the OCDB is available, and finally return it. + // The event type must be provided. + + if(!fgRecParam && (AliCDBManager::Instance()->IsDefaultStorageSet())) + { + AliCDBEntry *entry = (AliCDBEntry*) + AliCDBManager::Instance()->Get("EMCAL/Calib/RecoParam"); + if (entry) fgRecParam = (AliEMCALRecParam*)((TObjArray *) entry->GetObject())->At(eventType); + } - Int_t amp = static_cast( (energy - pedestal) / gainFactor + 0.5 ) ; - return amp; + if(!fgRecParam) + AliFatal("Reconstruction parameters not found in CDB!"); + + return fgRecParam; + } + //____________________________________________________________________________ Int_t AliEMCALLoader::GetEvent() { @@ -201,68 +197,87 @@ Int_t AliEMCALLoader::GetEvent() AliLoader::GetEvent(); // First call AliLoader to do all the groundwork - // Now connect and fill TClonesArray - - // Hits - 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; - } - } + // *** Hits *** + // Hits are now handled directly on the AliEMCALSDigitizer, the only place it is requested. + // together with AliEveEMCALData + + // *** SDigits *** + // Initialize the SDigits TClonesArray, only if it did not existed before + MakeSDigitsArray(); + + TTree *treeS = TreeS(); + if (treeS) { + TBranch * branchS = treeS->GetBranch(fDetectorName); + + // Reset SDigits array and branch + branchS->ResetAddress(); + TClonesArray* sdigits = const_cast(this)->SDigits(); + if (sdigits) sdigits->Clear("C"); + + branchS->SetAddress(&sdigits); + branchS->GetEntry(0); + } + + // *** Digits *** + // Initialize the Digits TClonesArray, only if it did not existed before + MakeDigitsArray(); + + TTree *treeD = TreeD(); + if (treeD) { + TBranch * branchD = treeD->GetBranch(fDetectorName); + + // Reset Digits array and branch + branchD->ResetAddress(); + TClonesArray* digits = const_cast(this)->Digits(); + if (digits) digits->Clear("C"); + + branchD->SetAddress(&digits); + branchD->GetEntry(0); + } - // SDigits - TTree *treeS = TreeS(); - if (treeS) { - TBranch * branchS = treeS->GetBranch(fDetectorName); - branchS->ResetAddress(); - if (fSDigits) { - fSDigits->Clear(); - } - branchS->SetAddress(&fSDigits); - treeS->GetEvent(0); - } - - // Digits - TTree *treeD = TreeD(); - if (treeD) { - TBranch * branchD = treeD->GetBranch(fDetectorName); - branchD->ResetAddress(); - if (fDigits) { - fDigits->Clear(); - } - branchD->SetAddress(&fDigits); - treeD->GetEvent(0); - } + // *** RecPoints *** + // Initialize the RecPoints TObjArray, only if it did not existed before + MakeRecPointsArray(); + + TTree *treeR = TreeR(); + if (treeR) { + TBranch * branchR = treeR->GetBranch(fgkECARecPointsBranchName); + + // Reset RecPoints array and branch + branchR->ResetAddress(); + TObjArray* rp = const_cast(this)->RecPoints(); + if (rp) rp->Clear(); + + branchR->SetAddress(&rp); + branchR->GetEntry(0); + } + + return 0; +} - // RecPoints - TTree *treeR = TreeR(); - if (treeR) { - TBranch * branchR = treeR->GetBranch(fgkECARecPointsBranchName); - branchR->ResetAddress(); - if (fRecPoints) { - fRecPoints->Clear(); - } - branchR->SetAddress(&fRecPoints); - treeR->GetEvent(0); - } - - return 0; +//____________________________________________________________________________ +void AliEMCALLoader::MakeSDigitsArray(){ + // Add SDigits array to the data folder + if (SDigits()) return; + TClonesArray* sdigits = new TClonesArray("AliEMCALDigit",0); + sdigits->SetName(fgkECASDigitsBranchName); + GetDetectorDataFolder()->Add(sdigits); +} + +//____________________________________________________________________________ +void AliEMCALLoader::MakeDigitsArray(){ + // Add Digits array to the data folder + if (Digits()) return; + TClonesArray* digits = new TClonesArray("AliEMCALDigit",0); + digits->SetName(fgkECADigitsBranchName); + GetDetectorDataFolder()->Add(digits); +} + +//____________________________________________________________________________ +void AliEMCALLoader::MakeRecPointsArray(){ + // Add RecPoints array to the data folder + if (RecPoints()) return; + TObjArray* rp = new TObjArray(0); + rp->SetName(fgkECARecPointsBranchName); + GetDetectorDataFolder()->Add(rp); }