- branch->SetAddress(dref);//connect branch to buffer sitting in folder
- branch->GetEntry(0);//get first event
-
- 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;
- }
- }
-
- TBranch * hitsbranch = dynamic_cast<TBranch*>(TreeH()->GetListOfBranches()->FindObject("EMCAL")) ;
- if ( !hitsbranch ) {
- if (fDebug)
- cout << "WARNING: AliEMCALLoader::ReadTreeH -> Cannot find branch EMCAL" << endl ;
- return ;
- }
- if(!Hits()) PostHits();
-
- hitsbranch->SetAddress(HitsRef());
- hitsbranch->GetEntry(itrack);
-
-}
-
-//____________________________________________________________________________
-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()
-{
- //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;
-}
-
-//____________________________________________________________________________
-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();
- }
-
- 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;
- }
-
- 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<AliEMCAL*>(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: <AliEMCALLoader::GetEMCALLoader>: "
- << "Can not find Run Loader in folder "<<eventfoldername<<endl;
- return 0x0;
- }
- return dynamic_cast<AliEMCALLoader*>(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" ;
- }
- else if(recName == "TrackSegments"){
- tree = TreeT();
- dataname = fgkTrackSegmentsBranchName;
- zername = "AliEMCALTrackSegmentMaker";
- }
- else if(recName == "RecParticles"){
- tree = TreeP();
- dataname = fgkRecParticlesBranchName;
- zername = "AliEMCALPID";