X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=EMCAL%2FAliEMCALLoader.cxx;h=c44c07581172c61cb94056d5f78099f76f4ef37b;hb=4a5374bd6892a76d4ca2de6c5218d4e9e09916df;hp=16681949f4a6beafc8db179145ff8f6ed7269747;hpb=a2a0f9c26499f7377e04d000f52947d3fda5abb1;p=u%2Fmrichter%2FAliRoot.git diff --git a/EMCAL/AliEMCALLoader.cxx b/EMCAL/AliEMCALLoader.cxx index 16681949f4a..c44c0758117 100644 --- a/EMCAL/AliEMCALLoader.cxx +++ b/EMCAL/AliEMCALLoader.cxx @@ -16,905 +16,268 @@ /* $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. This container -// ensures, that one reads Digits, made of these particular digits, RecPoints, -// made of these particular RecPoints, TrackSegments and RecParticles. -// This becomes non trivial if there are several identical branches, produced with -// different set of parameters. +// The AliEMCALLoader gets the TClonesArray and TObjArray for reading +// Hits, Dgits, SDigits and RecPoints. Filling is managed in the GetEvent() +// method. +// It also provides acces methods to the calibration and simulation OCDB parameters // -// An example of how to use (see also class AliEMCALAnalyser): -// for(Int_t irecp = 0; irecp < gime->NRecParticles() ; irecp++) -// AliEMCALRecParticle * part = gime->RecParticle(1) ; -// ................ -// please->GetEvent(event) ; // reads new event from galice.root -// //*-- Author: Yves Schutz (SUBATECH) & Dmitri Peressounko (RRC KI & SUBATECH) //*-- Completely redesigned by Dmitri Peressounko March 2001 // //*-- YS June 2001 : renamed the original AliEMCALIndexToObject and make -//*-- systematic usage of TFolders without changing the interface +//*-- systematic usage of TFolders without changing the interface +// +//*-- 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 --- -#include "AliLog.h" #include "AliEMCALLoader.h" -#include "AliEMCAL.h" -#include "AliEMCALHit.h" -#include "AliEMCALGetter.h" +#include "AliLog.h" +#include "AliCDBLocal.h" +#include "AliCDBStorage.h" +#include "AliCDBManager.h" +#include "AliCDBEntry.h" -ClassImp(AliEMCALLoader) - + ClassImp(AliEMCALLoader) -const TString AliEMCALLoader::fgkHitsName("HITS");//Name for TClonesArray with hits from one event -const TString AliEMCALLoader::fgkSDigitsName("SDIGITS");//Name for TClonesArray -const TString AliEMCALLoader::fgkDigitsName("DIGITS");//Name for TClonesArray -const TString AliEMCALLoader::fgkECARecPointsName("ECARECPOINTS");//Name for TClonesArray -const TString AliEMCALLoader::fgkTracksName("TRACKS");//Name for TClonesArray -const TString AliEMCALLoader::fgkRecParticlesName("RECPARTICLES");//Name for TClonesArray +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 -const TString AliEMCALLoader::fgkECARecPointsBranchName("EMCALECARP");//Name for branch with ECA Reconstructed Points -const TString AliEMCALLoader::fgkTrackSegmentsBranchName("EMCALTS");//Name for branch with TrackSegments -const TString AliEMCALLoader::fgkRecParticlesBranchName("EMCALRP");//Name for branch with Reconstructed Particles +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) { - fDebug = 0; - fRecParticlesLoaded = kFALSE; -} + //Default constructor for EMCAL Loader Class -//____________________________________________________________________________ -AliEMCALLoader::AliEMCALLoader(const Char_t *detname,const Char_t *eventfoldername): - AliLoader(detname,eventfoldername) -{ - fDebug=0; - fRecParticlesLoaded = kFALSE; } //____________________________________________________________________________ -AliEMCALLoader::~AliEMCALLoader() +AliEMCALLoader::AliEMCALLoader(const Char_t *detname,const Char_t *eventfoldername) + : AliLoader(detname,eventfoldername), fDebug(0) { - //remove and delete arrays - Clean(fgkHitsName); - Clean(fgkSDigitsName); - Clean(fgkDigitsName); - Clean(fgkECARecPointsName); - Clean(fgkTracksName); - Clean(fgkRecParticlesName); - CleanFolders() ; - // set to 0x0 the objgetter in AliGetter ... weird isn it ! - /* - AliEMCALGetter * gime = AliEMCALGetter::Instance() ; - if (gime) - gime->Reset() ; - */ -} + //Specific constructor for EMCAL Loader class -//____________________________________________________________________________ -void AliEMCALLoader::CleanFolders() -{ - CleanRecParticles(); - AliLoader::CleanFolders(); } -//____________________________________________________________________________ -Int_t AliEMCALLoader::SetEvent() +//____________________________________________________________________________ +AliEMCALLoader::AliEMCALLoader(const Char_t *name, TFolder *topfolder) + : AliLoader(name,topfolder), fDebug(0) { - //Cleans loaded stuff and and sets Files and Directories - // do not post any data to folder/tasks - - - Int_t retval = AliLoader::SetEvent(); - if (retval) - { - Error("SetEvent","AliLoader::SetEvent returned error"); - return retval; - } + //Specific constructor for EMCAL Loader class - - if (Hits()) Hits()->Clear(); - if (SDigits()) SDigits()->Clear(); - if (Digits()) Digits()->Clear(); - if (ECARecPoints()) ECARecPoints()->Clear(); - if (TrackSegments()) TrackSegments()->Clear(); - if (RecParticles()) RecParticles()->Clear(); - - return 0; } //____________________________________________________________________________ -Int_t AliEMCALLoader::GetEvent() +AliEMCALLoader::~AliEMCALLoader() { - //Overloads GetEvent method called by AliRunLoader::GetEvent(Int_t) method - //to add Rec Particles specific for EMCAL - - //First call the original method to get whatever from std. setup is needed - Int_t retval; + // 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); + + Clean(fgkECASDigitsBranchName); + Clean(fgkECADigitsBranchName); + Clean(fgkECARecPointsBranchName); + + AliLoader::CleanFolders(); + +} + +//____________________________________________________________________________ +AliEMCALCalibData* AliEMCALLoader::CalibData() +{ + // Check if the instance of AliEMCALCalibData exists, if not, create it if + // the OCDB is available, and finally return it. - retval = AliLoader::GetEvent(); - if (retval) + if(!fgCalibData && (AliCDBManager::Instance()->IsDefaultStorageSet())) { - Error("GetEvent","AliLoader::GetEvent returned error"); - return retval; + AliCDBEntry *entry = (AliCDBEntry*) + AliCDBManager::Instance()->Get("EMCAL/Calib/Data"); + if (entry) fgCalibData = (AliEMCALCalibData*) entry->GetObject(); } - if (GetHitsDataLoader()->GetBaseDataLoader()->IsLoaded()) ReadHits(); - if (GetSDigitsDataLoader()->GetBaseDataLoader()->IsLoaded()) ReadSDigits(); - if (GetDigitsDataLoader()->GetBaseDataLoader()->IsLoaded()) ReadDigits(); - if (GetRecPointsDataLoader()->GetBaseDataLoader()->IsLoaded()) ReadRecPoints(); - if (GetTracksDataLoader()->GetBaseDataLoader()->IsLoaded()) ReadTracks(); - if (GetRecParticlesDataLoader()->GetBaseDataLoader()->IsLoaded()) ReadRecParticles(); - - - //Now, check if RecPart were loaded - return 0; -} - -//____________________________________________________________________________ -const AliEMCAL * AliEMCALLoader::EMCAL() -{ - // returns the EMCAL object - AliEMCAL * emcal = dynamic_cast(GetModulesFolder()->FindObject(fDetectorName)); - if ( emcal == 0x0) - if (fDebug) - cout << "WARNING: AliEMCALLoader::EMCAL -> EMCAL module not found in Folders" << endl ; - return emcal ; -} - -//____________________________________________________________________________ -const AliEMCALGeometry * AliEMCALLoader::EMCALGeometry() -{ - // Gets the EMCAL Geometry object - AliEMCALGeometry * rv = 0 ; - if (EMCAL() ) - rv = EMCAL()->GetGeometry(); - return rv ; -} - -//____________________________________________________________________________ -Int_t AliEMCALLoader::LoadHits(Option_t* opt) -{ - //------- Hits ---------------------- - //Overload (extends) LoadHits implemented in AliLoader - // - Int_t res; - - //First call the AliLoader's method to send the TreeH to folder - res = AliLoader::LoadHits(opt); + if(!fgCalibData) + AliFatal("Calibration parameters not found in CDB!"); - if (res) - {//oops, error - AliError("returned error"); - return res; - } - - //read the data from tree in folder and send it to folder - res = ReadHits(); - return 0; -} - -//____________________________________________________________________________ -Int_t AliEMCALLoader::LoadSDigits(Option_t* opt) -{ - // Loads the SDigits array in the folder structure - Int_t res; - //First call the AliLoader's method to send the TreeS to folder - res = AliLoader::LoadSDigits(opt); - if (res) - {//oops, error - Error("PostSDigits","AliLoader::LoadSDigits returned error"); - return res; - } - return ReadSDigits(); + return fgCalibData; -} - -//____________________________________________________________________________ -Int_t AliEMCALLoader::LoadDigits(Option_t* opt) -{ - // Loads the Digits array in the folder structure - - Int_t res; - //First call the AliLoader's method to send the TreeS to folder - res = AliLoader::LoadDigits(opt); - if (res) - {//oops, error - Error("LoadDigits","AliLoader::LoadDigits returned error"); - return res; - } - return ReadDigits(); } //____________________________________________________________________________ -Int_t AliEMCALLoader::LoadRecPoints(Option_t* opt) +AliCaloCalibPedestal* AliEMCALLoader::PedestalData() { - // Loads the RecPoints array in the folder structure - Int_t res; - //First call the AliLoader's method to send the TreeR to folder - res = AliLoader::LoadRecPoints(opt); - if (res) - {//oops, error - Error("LoadRecPoints","AliLoader::LoadRecPoints returned error"); - return res; - } - - TFolder * emcalFolder = GetDetectorDataFolder(); - if ( emcalFolder == 0x0 ) + // 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())) { - Error("LoadRecPoints","Can not get detector data folder"); - return 1; + AliCDBEntry *entry = (AliCDBEntry*) + AliCDBManager::Instance()->Get("EMCAL/Calib/Pedestals"); + if (entry) fgCaloPed = (AliCaloCalibPedestal*) entry->GetObject(); } - return ReadRecPoints(); + + if(!fgCaloPed) + AliFatal("Pedestal info not found in CDB!"); + + return fgCaloPed; + } //____________________________________________________________________________ -Int_t AliEMCALLoader::LoadTracks(Option_t* opt) -{ - //Loads Tracks: Open File, Reads Tree and posts, Read Data and Posts - AliDebug(1, Form("opt = %s",opt)); - Int_t res; - res = AliLoader::LoadTracks(opt); - if (res) - {//oops, error - AliError("returned error"); - return res; - } - return ReadTracks(); - -} - -//____________________________________________________________________________ -Int_t AliEMCALLoader::LoadRecParticles(Option_t* opt) +AliEMCALSimParam* AliEMCALLoader::SimulationParameters() { - // Loads the RecParticles array in the folder structure - Int_t res; - //First call the AliLoader's method to send the TreeS to folder - res = AliLoader::LoadRecParticles(opt); - if (res) - {//oops, error - Error("LoadRecParticles","AliLoader::LoadRecParticles returned error"); - return res; - } + // Check if the instance of AliEMCALSimParam exists, if not, create it if + // the OCDB is available, and finally return it. - TFolder * emcalFolder = GetDetectorDataFolder(); - if ( emcalFolder == 0x0 ) - { - Error("PostDigits","Can not get detector data folder"); - return 1; - } - return ReadRecParticles(); -} - -//____________________________________________________________________________ -Int_t AliEMCALLoader::PostHits() -{ - // Post Hits - Int_t reval = AliLoader::PostHits(); - if (reval) + if(!fgSimParam && (AliCDBManager::Instance()->IsDefaultStorageSet())) { - Error("PostHits","AliLoader:: returned error"); - return reval; - } - return ReadHits(); -} - -//____________________________________________________________________________ -Int_t AliEMCALLoader::PostSDigits() -{ - // Posts the SDigits array to the folder structure - Int_t reval = AliLoader::PostSDigits(); - if (reval) - { - Error("PostSDigits","AliLoader::PostSDigits returned error"); - return reval; - } - return ReadSDigits(); -} - -//____________________________________________________________________________ -Int_t AliEMCALLoader::PostDigits() -{ - // Posts the Digits array to the folder structure - Int_t reval = AliLoader::PostDigits(); - if (reval) - { - Error("PostDigits","AliLoader::PostDigits returned error"); - return reval; - } - return ReadDigits(); -} - -//____________________________________________________________________________ -Int_t AliEMCALLoader::PostRecPoints() -{ - // Posts the RecPoints array to the folder structure - Int_t reval = AliLoader::PostRecPoints(); - if (reval) - { - Error("PostRecPoints","AliLoader::PostRecPoints returned error"); - return reval; - } - return ReadRecPoints(); -} - -//____________________________________________________________________________ -Int_t AliEMCALLoader::PostRecParticles() -{ - // Posts the RecParticles array to the folder structure - - Int_t reval = AliLoader::PostRecParticles(); - if (reval) - { - Error("PostRecParticles","AliLoader::PostRecParticles returned error"); - return reval; - } - return ReadRecParticles(); -} - -//____________________________________________________________________________ -Int_t AliEMCALLoader::PostTracks() -{ - // Posts the Tracks array to the folder structure - Int_t reval = AliLoader::PostTracks(); - if (reval) - { - Error("PostTracks","AliLoader::PostTracks returned error"); - return reval; - } - return ReadTracks(); -} - -//____________________________________________________________________________ -Int_t AliEMCALLoader::ReadHits() -{ - // If there is no Clones Array in folder creates it and sends to folder - // then tries to read - // Reads the first entry of EMCAL branch in hit tree TreeH() - // Reads data from TreeH and stores it in TClonesArray that sits in DetectorDataFolder - // - TObject** hitref = HitsRef(); - if(hitref == 0x0) - { - MakeHitsArray(); - hitref = HitsRef(); - } - - TClonesArray* hits = dynamic_cast(*hitref); - - TTree* treeh = TreeH(); - - if(treeh == 0) - { - AliError("Cannot read TreeH from folder"); - return 1; - } - - TBranch * hitsbranch = treeh->GetBranch(fDetectorName); - if (hitsbranch == 0) - { - AliError("Cannot find branch EMCAL"); - return 1; - } - - AliDebug(1, "Reading Hits"); - - if (hitsbranch->GetEntries() > 1) - { - TClonesArray * tempo = new TClonesArray("AliEMCALHit",1000); + AliCDBEntry *entry = (AliCDBEntry*) + AliCDBManager::Instance()->Get("EMCAL/Calib/SimParam"); + if (entry) fgSimParam = (AliEMCALSimParam*) entry->GetObject(); - hitsbranch->SetAddress(&tempo); - Int_t index = 0 ; - Int_t i = 0 ; - for (i = 0 ; i < hitsbranch->GetEntries(); i++) - { - hitsbranch->GetEntry(i) ; - Int_t j = 0 ; - for ( j = 0 ; j < tempo->GetEntries() ; j++) - { - AliEMCALHit* hit = (AliEMCALHit*)tempo->At(j); - new((*hits)[index]) AliEMCALHit( *hit ) ; - index++ ; - } - } - tempo->Delete() ; - delete tempo; - } - else - { - hitsbranch->SetAddress(hitref); - hitsbranch->GetEntry(0) ; - } - - return 0; -} - -//____________________________________________________________________________ -Int_t AliEMCALLoader::ReadSDigits() -{ - // Read the summable digits tree TreeS(): - // Check if TClones is in folder - // if not create and add to folder - // connect to tree if available - // Read the data - - TObject** sdref = SDigitsRef(); - if(sdref == 0x0) - { - MakeSDigitsArray(); - sdref = SDigitsRef(); - } - - TTree * treeS = TreeS(); - if(treeS==0) - { - //May happen if file is truncated or new in LoadSDigits - //Error("ReadSDigits","There is no SDigit Tree"); - return 0; - } - - TBranch * branch = treeS->GetBranch(fDetectorName); - if (branch == 0) - {//easy, maybe just a new tree - //Error("ReadSDigits"," Cannot find branch EMCAL"); - return 0; - } - - branch->SetAddress(SDigitsRef()); - branch->GetEntry(0); - return 0; -} - -//____________________________________________________________________________ -Int_t AliEMCALLoader::ReadDigits() -{ - // Read the summable digits tree TreeS(): - // Check if TClones is in folder - // if not create and add to folder - // connect to tree if available - // Read the data - - TObject** dref = DigitsRef(); - if(dref == 0x0) - {//if there is not array in folder, create it and put it there - MakeDigitsArray(); - dref = DigitsRef(); - } - - TTree * treeD = TreeD(); - if(treeD==0) - { - //May happen if file is truncated or new in LoadSDigits - //Error("ReadDigits","There is no Digit Tree"); - return 0; } - TBranch * branch = treeD->GetBranch(fDetectorName); - if (branch == 0) - {//easy, maybe just a new tree - //Error("ReadDigits"," Cannot find branch ",fDetectorName.Data()); - return 0; - } + if(!fgSimParam) + AliFatal("Simulations parameters not found in CDB!"); - branch->SetAddress(dref);//connect branch to buffer sitting in folder - branch->GetEntry(0);//get first event + return fgSimParam; - return 0; } -//____________________________________________________________________________ -void AliEMCALLoader::UnloadRecParticles() -{ - // Unloads the RecParticles array fromthe folder structure - fRecParticlesLoaded = kFALSE; - CleanRecParticles(); - if (fTracksLoaded == kFALSE) UnloadTracks(); -} - -//____________________________________________________________________________ -void AliEMCALLoader::UnloadTracks() -{ - // Unloads the Tracks array fromthe folder structure - CleanTracks();//free the memory - //in case RecPart are loaded we can not onload tree and close the file - if (fRecParticlesLoaded == kFALSE) AliLoader::UnloadTracks(); - fTracksLoaded = kFALSE;//mark that nobody needs them -} //____________________________________________________________________________ -void AliEMCALLoader::Track(Int_t itrack) -{ - // Read the first entry of EMCAL branch in hit tree gAlice->TreeH() - if(TreeH()== 0) - { - if (LoadHits()) - { - Error("Track","Can not load hits."); - return; - } - } +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); + + } - TBranch * hitsbranch = dynamic_cast(TreeH()->GetListOfBranches()->FindObject("EMCAL")) ; - if ( !hitsbranch ) { - if (fDebug) - cout << "WARNING: AliEMCALLoader::ReadTreeH -> Cannot find branch EMCAL" << endl ; - return ; - } - if(!Hits()) PostHits(); + if(!fgRecParam) + AliFatal("Reconstruction parameters not found in CDB!"); - hitsbranch->SetAddress(HitsRef()); - hitsbranch->GetEntry(itrack); + return fgRecParam; } -//____________________________________________________________________________ -Int_t AliEMCALLoader::ReadRecPoints() -{ - //Creates and posts to folder an array container, - //connects branch in tree (if exists), and reads data to array - - MakeRecPointsArray(); - - TObjArray * eca = 0x0 ; - - TTree * treeR = TreeR(); - - if(treeR==0) - { - //May happen if file is truncated or new in LoadSDigits - return 0; - } - - Int_t retval = 0; - - TBranch * ecabranch = treeR->GetBranch(fgkECARecPointsBranchName); - if (ecabranch == 0x0) - { - Error("ReadRecPoints","Can not get branch with ECA Rec. Points named %s",fgkECARecPointsBranchName.Data()); - retval = 2; - } - else - { - ecabranch->SetAddress(&eca); - ecabranch->GetEntry(0) ; - } - - - Int_t ii ; - - Int_t maxeca = eca->GetEntries() ; - for ( ii= 0 ; ii < maxeca ; ii++ ) - ECARecPoints()->Add(eca->At(ii)) ; - - return retval; -} //____________________________________________________________________________ -Int_t AliEMCALLoader::ReadTracks() +Int_t AliEMCALLoader::GetEvent() { - //Creates and posts to folder an array container, - //connects branch in tree (if exists), and reads data to arry - - TObject** trkref = TracksRef(); - if ( trkref == 0x0 ) - {//Create and post array - MakeTrackSegmentsArray(); - trkref = TracksRef(); - } - - TTree * treeT = TreeT(); - if(treeT==0) - { - //May happen if file is truncated or new in LoadSDigits, or the file is in update mode, - //but tracking was not performed yet for a current event - //Error("ReadTracks","There is no Tree with Tracks"); - return 0; - } - - TBranch * branch = treeT->GetBranch(fgkTrackSegmentsBranchName); - if (branch == 0) - {//easy, maybe just a new tree - Error("ReadTracks"," Cannot find branch named %s",fgkTrackSegmentsBranchName.Data()); - return 0; - } - - branch->SetAddress(trkref);//connect branch to buffer sitting in folder - branch->GetEntry(0);//get first event - - return 0; -} + //Method to load all of the data + //members of the EMCAL for a given + //event from the Trees -//____________________________________________________________________________ -Int_t AliEMCALLoader::ReadRecParticles() -{ - //Reads Reconstructed Particles from file - //Creates and posts to folder an array container, - //connects branch in tree (if exists), and reads data to arry - - TObject** recpartref = RecParticlesRef(); - - if ( recpartref == 0x0 ) - {//Create and post array - MakeRecParticlesArray(); - recpartref = RecParticlesRef(); - } + AliLoader::GetEvent(); // First call AliLoader to do all the groundwork - TTree * treeP = TreeP(); - if(treeP==0) - { - //May happen if file is truncated or new in LoadSDigits, - //or the file is in update mode, - //but tracking was not performed yet for a current event - // Error("ReadRecParticles","There is no Tree with Tracks and Reconstructed Particles"); - return 0; - } + // *** 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(); - TBranch * branch = treeP->GetBranch(fgkRecParticlesBranchName); - if (branch == 0) - {//easy, maybe just a new tree - Error("ReadRecParticles"," Cannot find branch %s",fgkRecParticlesBranchName.Data()); - return 0; - } - - branch->SetAddress(recpartref);//connect branch to buffer sitting in folder - branch->GetEntry(0);//get first event - - return 0; -} - -//____________________________________________________________________________ -AliEMCALGeometry* AliEMCALLoader::GetEMCALGeometry() -{ - //returns EMCAL geometry from gAlice - //static Method used by some classes where it is not convienient to pass eventfoldername - if (gAlice == 0x0) - return 0x0; - AliEMCAL* emcal=dynamic_cast(gAlice->GetDetector("EMCAL")); - if (emcal == 0x0) - return 0x0; - return emcal->GetGeometry(); -} - -//____________________________________________________________________________ -AliEMCALLoader* AliEMCALLoader::GetEMCALLoader(const char* eventfoldername) -{ - // Get an instance of the EMCALLoader object - AliRunLoader* rn = AliRunLoader::GetRunLoader(eventfoldername); - if (rn == 0x0) - { - cerr<<"Error: : " - << "Can not find Run Loader in folder "<(rn->GetLoader("EMCALLoader")); -} - -//____________________________________________________________________________ -Bool_t AliEMCALLoader::BranchExists(const TString& recName) -{ - // Check is branch exists - if (fBranchTitle.IsNull()) return kFALSE; - TString dataname, zername ; - TTree* tree; - if(recName == "SDigits") { - tree = TreeS(); - dataname = GetDetectorName(); - zername = "AliEMCALSDigitizer" ; - } - else if(recName == "Digits"){ - tree = TreeD(); - dataname = GetDetectorName(); - zername = "AliEMCALDigitizer" ; - } - else if(recName == "ECARecPoints"){ - tree = TreeR(); - dataname = fgkECARecPointsBranchName; - zername = "AliEMCALClusterizer" ; + 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); } - else if(recName == "TrackSegments"){ - tree = TreeT(); - dataname = fgkTrackSegmentsBranchName; - zername = "AliEMCALTrackSegmentMaker"; - } - else if(recName == "RecParticles"){ - tree = TreeP(); - dataname = fgkRecParticlesBranchName; - zername = "AliEMCALPID"; - } - else - return kFALSE ; - if(!tree ) - return kFALSE ; + // *** 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); + } - TObjArray * lob = static_cast(tree->GetListOfBranches()) ; - TIter next(lob) ; - TBranch * branch = 0 ; - TString titleName(fBranchTitle); - titleName+=":"; + // *** RecPoints *** + // Initialize the RecPoints TObjArray, only if it did not existed before + MakeRecPointsArray(); - while ((branch = (static_cast(next())))) { - TString branchName(branch->GetName() ) ; - TString branchTitle(branch->GetTitle() ) ; - if ( branchName.BeginsWith(dataname) && branchTitle.BeginsWith(fBranchTitle) ){ - Warning("BranchExists","branch %s with title %s ",dataname.Data(),fBranchTitle.Data()); - return kTRUE ; - } - if ( branchName.BeginsWith(zername) && branchTitle.BeginsWith(titleName) ){ - Warning("BranchExists","branch AliEMCAL... with title %s ",branch->GetTitle()); - return kTRUE ; - } + 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 kFALSE ; + return 0; } -//____________________________________________________________________________ -void AliEMCALLoader::SetBranchTitle(const TString& btitle) -{ - // Gives a name to a branch in the folder structure - if (btitle.CompareTo(fBranchTitle) == 0) return; - fBranchTitle = btitle; - ReloadAll(); -} - -//____________________________________________________________________________ -void AliEMCALLoader::CleanHits() -{ - // Clean hits - AliLoader::CleanHits(); - //Clear an array - TClonesArray* hits = Hits(); - if (hits) - hits->Clear(); -} - -//____________________________________________________________________________ -void AliEMCALLoader::CleanSDigits() -{ - // Cleans the SDigits array in the folder structure - AliLoader::CleanSDigits(); - TClonesArray* sdigits = SDigits(); - if (sdigits) sdigits->Clear(); - -} -//____________________________________________________________________________ - -void AliEMCALLoader::CleanDigits() -{ - // Cleans the Digits array in the folder structure - AliLoader::CleanDigits(); - TClonesArray* digits = Digits(); - if (digits) digits->Clear(); -} - -//____________________________________________________________________________ -void AliEMCALLoader::CleanRecPoints() -{ - // Cleans the RecPoints array in the folder structure - AliLoader::CleanRecPoints(); - TObjArray* recpoints = ECARecPoints(); - if (recpoints) recpoints->Clear(); - -} - -//____________________________________________________________________________ -void AliEMCALLoader::CleanTracks() -{ - // Cleans the Tracks array in the folder structure - AliLoader::CleanTracks();//tree - //and clear the array - TClonesArray* tracks = TrackSegments(); - if (tracks) - tracks->Clear(); -} - -//____________________________________________________________________________ -void AliEMCALLoader::CleanRecParticles() -{ - // Cleans the RecParticles array in the folder structure - TClonesArray *recpar = RecParticles(); - if (recpar) - recpar->Clear(); -} - -//____________________________________________________________________________ -// void AliEMCALLoader::ReadCalibrationDB(const char * database,const char * filename) -// { - -// if(fcdb && (strcmp(database,fcdb->GetTitle())==0)) -// return ; - -// TFile * file = gROOT->GetFile(filename) ; -// if(!file) -// file = TFile::Open(filename); -// if(!file){ -// Error ("ReadCalibrationDB", "Cannot open file %s", filename) ; -// return ; -// } -// if(fcdb) -// fcdb->Delete() ; -// fcdb = dynamic_cast(file->Get("AliEMCALCalibrationDB")) ; -// if(!fcdb) -// Error ("ReadCalibrationDB", "No database %s in file %s", database, filename) ; -// } -//____________________________________________________________________________ - -// AliEMCALSDigitizer* AliEMCALLoader::EMCALSDigitizer() -// { -// //return EMCAL SDigitizer -// return dynamic_cast(SDigitizer()) ; -// } - -//____________________________________________________________________________ -void AliEMCALLoader::MakeHitsArray() -{ - // Create the array for Hits - if (Hits()) return; - TClonesArray* hits = new TClonesArray("AliEMCALHit",1000); - hits->SetName(fgkHitsName); - GetDetectorDataFolder()->Add(hits); -} - -//____________________________________________________________________________ -void AliEMCALLoader::MakeSDigitsArray() -{ - // Create the array for SDigits - if ( SDigits()) return; - TClonesArray* sdigits = new TClonesArray("AliEMCALDigit",1); - sdigits->SetName(fgkSDigitsName); +//____________________________________________________________________________ +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() -{ - // Create the array for Digits - if ( Digits()) return; - TClonesArray* digits = new TClonesArray("AliEMCALDigit",1); - digits->SetName(fgkDigitsName); +//____________________________________________________________________________ +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() -{ - // Make recpoints array - if ( ECARecPoints() == 0x0) - { - AliDebug(9, "Making array for ECA"); - TObjArray* eca = new TObjArray(100) ; - eca->SetName(fgkECARecPointsName) ; - GetDetectorDataFolder()->Add(eca); - } -} - -//____________________________________________________________________________ -void AliEMCALLoader::MakeTrackSegmentsArray() -{ - // Create the array for TrackSegments - if ( TrackSegments()) - return; - TClonesArray * ts = new TClonesArray("AliEMCALTrackSegment",100) ; - ts->SetName(fgkTracksName); - GetDetectorDataFolder()->Add(ts); } -//____________________________________________________________________________ -void AliEMCALLoader::MakeRecParticlesArray() -{ - // Create the array for RecParticles - if ( RecParticles()) return; - TClonesArray * rp = new TClonesArray("AliEMCALRecParticle",100) ; - rp->SetName(fgkRecParticlesName); +//____________________________________________________________________________ +void AliEMCALLoader::MakeRecPointsArray(){ + // Add RecPoints array to the data folder + if (RecPoints()) return; + TObjArray* rp = new TObjArray(0); + rp->SetName(fgkECARecPointsBranchName); GetDetectorDataFolder()->Add(rp); }