LCOV - code coverage report
Current view: top level - PHOS/PHOSbase - AliPHOSLoader.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 158 388 40.7 %
Date: 2016-06-14 17:26:59 Functions: 38 58 65.5 %

          Line data    Source code
       1             : /**************************************************************************
       2             :  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
       3             :  *                                                                        *
       4             :  * Author: The ALICE Off-line Project.                                    *
       5             :  * Contributors are mentioned in the code where appropriate.              *
       6             :  *                                                                        *
       7             :  * Permission to use, copy, modify and distribute this software and its   *
       8             :  * documentation strictly for non-commercial purposes is hereby granted   *
       9             :  * without fee, provided that the above copyright notice appears in all   *
      10             :  * copies and that both the copyright notice and this permission notice   *
      11             :  * appear in the supporting documentation. The authors make no claims     *
      12             :  * about the suitability of this software for any purpose. It is          *
      13             :  * provided "as is" without express or implied warranty.                  *
      14             :  **************************************************************************/
      15             : 
      16             : /* $Id$ */
      17             : 
      18             : /* History of cvs commits:
      19             :  *
      20             :  * $Log$
      21             :  * Revision 1.18  2006/08/28 10:01:56  kharlov
      22             :  * Effective C++ warnings fixed (Timur Pocheptsov)
      23             :  *
      24             :  * Revision 1.17  2006/08/25 16:00:53  kharlov
      25             :  * Compliance with Effective C++AliPHOSHit.cxx
      26             :  *
      27             :  * Revision 1.16  2006/08/01 12:15:04  cvetan
      28             :  * Adding a constructor from TFolder. Needed by AliReconstruction plugin scheme
      29             :  *
      30             :  * Revision 1.15  2005/07/12 20:07:35  hristov
      31             :  * Changes needed to run simulation and reconstrruction in the same AliRoot session
      32             :  *
      33             :  * Revision 1.14  2005/05/28 14:19:04  schutz
      34             :  * Compilation warnings fixed by T.P.
      35             :  *
      36             :  */
      37             : 
      38             : //_________________________________________________________________________
      39             : //  A singleton. This class should be used in the analysis stage to get 
      40             : //  reconstructed objects: Digits, RecPoints, TrackSegments and RecParticles,
      41             : //  instead of directly reading them from galice.root file. This container 
      42             : //  ensures, that one reads Digits, made of these particular digits, RecPoints, 
      43             : //  made of these particular RecPoints, TrackSegments and RecParticles. 
      44             : //  This becomes non trivial if there are several identical branches, produced with
      45             : //  different set of parameters. 
      46             : //
      47             : //  An example of how to use (see also class AliPHOSAnalyser):
      48             : //  for(Int_t irecp = 0; irecp < gime->NRecParticles() ; irecp++)
      49             : //     AliPHOSRecParticle * part = gime->RecParticle(1) ;
      50             : //     ................
      51             : //  please->GetEvent(event) ;    // reads new event from galice.root
      52             : //                  
      53             : //-- Author: Yves Schutz (SUBATECH) & Dmitri Peressounko (RRC KI & SUBATECH)
      54             : //--         Completely redesigned by Dmitri Peressounko March 2001  
      55             : //
      56             : //-- YS June 2001 : renamed the original AliPHOSIndexToObject and make
      57             : //--         systematic usage of TFolders without changing the interface        
      58             : //////////////////////////////////////////////////////////////////////////////
      59             : 
      60             : 
      61             : // --- ROOT system ---
      62             : 
      63             : #include "TFile.h"
      64             : #include "TTree.h"
      65             : #include "TROOT.h"
      66             : 
      67             : // --- Standard library ---
      68             : 
      69             : // --- AliRoot header files ---
      70             : #include "AliObjectLoader.h"
      71             : #include "AliLog.h"
      72             : #include "AliPHOSLoader.h"
      73             : #include "AliPHOS.h"
      74             : #include "AliPHOSHit.h"
      75             : #include <iostream>
      76             : 
      77             : using std::cout;
      78             : using std::endl;
      79          22 : ClassImp(AliPHOSLoader)
      80             : 
      81             : 
      82          22 : const TString AliPHOSLoader::fgkHitsName("HITS");//Name for TClonesArray with hits from one event
      83          22 : const TString AliPHOSLoader::fgkSDigitsName("SDIGITS");//Name for TClonesArray 
      84          22 : const TString AliPHOSLoader::fgkDigitsName("DIGITS");//Name for TClonesArray 
      85          22 : const TString AliPHOSLoader::fgkEmcRecPointsName("EMCRECPOINTS");//Name for TClonesArray 
      86          22 : const TString AliPHOSLoader::fgkCpvRecPointsName("CPVRECPOINTS");//Name for TClonesArray 
      87          22 : const TString AliPHOSLoader::fgkTracksName("TRACKS");//Name for TClonesArray 
      88          22 : const TString AliPHOSLoader::fgkRecParticlesName("RECPARTICLES");//Name for TClonesArray
      89             : 
      90          22 : const TString AliPHOSLoader::fgkEmcRecPointsBranchName("PHOSEmcRP");//Name for branch with EMC Reconstructed Points
      91          22 : const TString AliPHOSLoader::fgkCpvRecPointsBranchName("PHOSCpvRP");//Name for branch with CPV Reconstructed Points
      92          22 : const TString AliPHOSLoader::fgkTrackSegmentsBranchName("PHOSTS");//Name for branch with TrackSegments
      93          22 : const TString AliPHOSLoader::fgkRecParticlesBranchName("PHOSRP");//Name for branch with Reconstructed Particles
      94             : //____________________________________________________________________________ 
      95          39 : AliPHOSLoader::AliPHOSLoader() : fBranchTitle(), fDebug(0), fTmpHits(0x0)
      96          65 : {
      97             :   //def ctor
      98          39 :   fTmpHits =  new TClonesArray("AliPHOSHit",1000);
      99          26 : }
     100             : //____________________________________________________________________________ 
     101             : AliPHOSLoader::AliPHOSLoader(const Char_t *detname,const Char_t *eventfoldername) :
     102           1 :       AliLoader(detname, eventfoldername),
     103           2 :       fBranchTitle(), fDebug(0), fTmpHits(0x0)
     104           5 : {
     105             :   //ctor
     106           2 : }
     107             : //____________________________________________________________________________ 
     108             : AliPHOSLoader::AliPHOSLoader(const Char_t *detname,TFolder *topfolder):
     109           1 :   AliLoader(detname,topfolder),
     110           2 :   fBranchTitle(), fDebug(0), fTmpHits(0x0)
     111             : 
     112           5 : {
     113             :   //ctor
     114           3 :   fTmpHits =  new TClonesArray("AliPHOSHit",1000);
     115           2 : }
     116             : 
     117             : //____________________________________________________________________________ 
     118             : 
     119             : AliPHOSLoader::~AliPHOSLoader()
     120          90 : {
     121             :   //remove and delete arrays
     122          15 :   Clean(fgkHitsName);
     123          15 :   Clean(fgkSDigitsName);
     124          15 :   Clean(fgkDigitsName);
     125          15 :   Clean(fgkEmcRecPointsName);
     126          15 :   Clean(fgkCpvRecPointsName);
     127          15 :   Clean(fgkTracksName);
     128          15 :   Clean(fgkRecParticlesName);
     129          15 :   CleanFolders() ;
     130          45 : }
     131             : 
     132             : //____________________________________________________________________________ 
     133             : void AliPHOSLoader::CleanFolders()
     134             :  {
     135          30 :    CleanRecParticles();
     136          15 :    AliLoader::CleanFolders();
     137          15 :  }
     138             : 
     139             : //____________________________________________________________________________ 
     140             : Int_t AliPHOSLoader::SetEvent()
     141             : {
     142             : //Cleans loaded stuff and and sets Files and Directories
     143             : // do not post any data to folder
     144             : 
     145             : 
     146         220 :  Int_t retval = AliLoader::SetEvent();
     147         110 :   if (retval)
     148             :    {
     149           0 :      AliError("returned error");
     150           0 :      return retval;
     151             :    }
     152             : 
     153             : 
     154         135 :   if (Hits()) Hits()->Clear();
     155         145 :   if (SDigits()) SDigits()->Clear();
     156         129 :   if (Digits()) Digits()->Clear();
     157         110 :   if (EmcRecPoints()) EmcRecPoints()->Clear();
     158         110 :   if (CpvRecPoints()) CpvRecPoints()->Clear();
     159         110 :   if (TrackSegments()) TrackSegments()->Clear();
     160         110 :   if (RecParticles()) RecParticles()->Clear();
     161             :    
     162         110 :   return 0;
     163         110 : }
     164             : 
     165             : //____________________________________________________________________________ 
     166             : Int_t AliPHOSLoader::GetEvent()
     167             : {
     168             : //Overloads GetEvent method called by AliRunLoader::GetEvent(Int_t) method
     169             : //to add Rec Particles specific for PHOS
     170             : 
     171             : //First call the original method to get whatever from std. setup is needed
     172             :   Int_t retval;
     173             :   
     174         208 :   retval = AliLoader::GetEvent();
     175         104 :   if (retval)
     176             :    {
     177           0 :      AliError("returned error");
     178           0 :      return retval;
     179             :    }
     180             :   
     181         118 :   if (GetHitsDataLoader()->GetBaseDataLoader()->IsLoaded()) ReadHits();
     182         128 :   if (GetSDigitsDataLoader()->GetBaseDataLoader()->IsLoaded()) ReadSDigits();
     183         107 :   if (GetDigitsDataLoader()->GetBaseDataLoader()->IsLoaded()) ReadDigits();
     184         104 :   if (GetRecPointsDataLoader()->GetBaseDataLoader()->IsLoaded()) ReadRecPoints();
     185         104 :   if (GetTracksDataLoader()->GetBaseDataLoader()->IsLoaded()) ReadTracks();
     186         104 :   if (GetRecParticlesDataLoader()->GetBaseDataLoader()->IsLoaded()) ReadRecParticles();
     187             : 
     188             : 
     189             : //Now, check if RecPart were loaded  
     190         104 :   return 0;
     191         104 : }
     192             : 
     193             : // //____________________________________________________________________________ 
     194             : // const AliPHOS * AliPHOSLoader::PHOS() 
     195             : // {
     196             : //   // returns the PHOS object 
     197             : //   AliPHOS * phos = dynamic_cast<AliPHOS*>(GetModulesFolder()->FindObject(fDetectorName));
     198             : //   if ( phos == 0x0) 
     199             : //     if (fDebug)
     200             : //       cout << "WARNING: AliPHOSLoader::PHOS -> PHOS module not found in Folders" << endl ; 
     201             : //   return phos ; 
     202             : // }  
     203             : 
     204             : //____________________________________________________________________________ 
     205             : Int_t AliPHOSLoader::LoadHits(Option_t* opt)
     206             : {  
     207             : //------- Hits ----------------------
     208             : //Overload (extends) LoadHits implemented in AliLoader
     209             : //
     210             :   Int_t res;
     211             :   
     212             :   //First call the AliLoader's method to send the TreeH to folder
     213           8 :   res = AliLoader::LoadHits(opt);
     214             :   
     215           4 :   if (res)
     216             :    {//oops, error
     217           0 :      AliError("returned error");
     218           0 :      return res;
     219             :    }
     220             : 
     221             :   //read the data from tree in folder and send it to folder
     222           4 :   res = ReadHits();
     223           4 :   return 0;
     224           4 : }
     225             : 
     226             : 
     227             : //____________________________________________________________________________ 
     228             : Int_t AliPHOSLoader::LoadSDigits(Option_t* opt)
     229             : {
     230             :   //---------- SDigits -------------------------
     231             :   Int_t res;
     232             :   //First call the AliLoader's method to send the TreeS to folder
     233           8 :   res = AliLoader::LoadSDigits(opt);
     234           4 :   if (res)
     235             :    {//oops, error
     236           0 :      AliError("returned error");
     237           0 :      return res;
     238             :    }
     239           4 :   return ReadSDigits();
     240             :    
     241           4 : } 
     242             : //____________________________________________________________________________ 
     243             : Int_t AliPHOSLoader::LoadDigits(Option_t* opt)
     244             : { 
     245             :   //---------- Digits -------------------------
     246             :   Int_t res;
     247             :   //First call the AliLoader's method to send the TreeS to folder
     248           8 :   res = AliLoader::LoadDigits(opt);
     249           4 :   if (res)
     250             :    {//oops, error
     251           0 :      AliError("returned error");
     252           0 :      return res;
     253             :    }
     254           4 :   return ReadDigits();
     255           4 : }
     256             : //____________________________________________________________________________ 
     257             : Int_t AliPHOSLoader::LoadRecPoints(Option_t* opt) 
     258             : {
     259             :   // -------------- RecPoints -------------------------------------------
     260             :   Int_t res;
     261             :   //First call the AliLoader's method to send the TreeR to folder
     262           0 :   res = AliLoader::LoadRecPoints(opt);
     263           0 :   if (res)
     264             :    {//oops, error
     265           0 :      AliError("returned error");
     266           0 :      return res;
     267             :    }
     268             : 
     269           0 :   TFolder * phosFolder = GetDetectorDataFolder();
     270           0 :   if ( phosFolder  == 0x0 ) 
     271             :    {
     272           0 :      AliError("Can not get detector data folder");
     273           0 :      return 1;
     274             :    }
     275           0 :   return ReadRecPoints();
     276           0 : }
     277             : //____________________________________________________________________________ 
     278             : 
     279             : Int_t  AliPHOSLoader::LoadTracks(Option_t* opt)
     280             : {
     281             :  //Loads Tracks: Open File, Reads Tree and posts, Read Data and Posts
     282           0 :   AliDebug(1, Form("opt = %s",opt));
     283             :  Int_t res;
     284           0 :  res = AliLoader::LoadTracks(opt);
     285           0 :  if (res)
     286             :    {//oops, error
     287           0 :       AliError("returned error");
     288           0 :       return res;
     289             :    }  
     290           0 :  return ReadTracks();
     291           0 : }
     292             : 
     293             : //____________________________________________________________________________ 
     294             : Int_t AliPHOSLoader::LoadRecParticles(Option_t* opt) 
     295             : {
     296             :   // -------------- RecPoints -------------------------------------------
     297             :   Int_t res;
     298             :   //First call the AliLoader's method to send the TreeT to folder
     299           0 :   res = AliLoader::LoadRecParticles(opt);
     300           0 :   if (res)
     301             :    {//oops, error
     302           0 :      AliError("returned error");
     303           0 :      return res;
     304             :    }
     305           0 :   return ReadRecParticles();
     306           0 : }
     307             : 
     308             : //____________________________________________________________________________ 
     309             : //PostHits etc. PostXXX must be const - not to hide virtual functions
     310             : //from base class AliLoader, but they call non-constant functions ReadXXX
     311             : //so I have to const_cast this pointer
     312             : Int_t AliPHOSLoader::PostHits()const
     313             : {
     314             :   // -------------- Hits -------------------------------------------
     315           0 :   Int_t reval = AliLoader::PostHits();
     316           0 :   if (reval)
     317             :    {
     318           0 :      AliError("returned error");
     319           0 :      return reval;
     320             :    }
     321             :    
     322           0 :   return const_cast<AliPHOSLoader *>(this)->ReadHits();
     323           0 : }
     324             : //____________________________________________________________________________ 
     325             : 
     326             : Int_t AliPHOSLoader::PostSDigits()const
     327             : {
     328             :   // -------------- SDigits -------------------------------------------
     329           0 :   Int_t reval = AliLoader::PostSDigits();
     330           0 :   if (reval)
     331             :    {
     332           0 :      AliError("returned error");
     333           0 :      return reval;
     334             :    }
     335           0 :   return const_cast<AliPHOSLoader *>(this)->ReadSDigits();
     336           0 : }
     337             : //____________________________________________________________________________ 
     338             : 
     339             : Int_t AliPHOSLoader::PostDigits()const
     340             : {
     341             :   // -------------- Digits -------------------------------------------
     342           0 :   Int_t reval = AliLoader::PostDigits();
     343           0 :   if (reval)
     344             :    {
     345           0 :      AliError("returned error");
     346           0 :      return reval;
     347             :    }
     348           0 :   return const_cast<AliPHOSLoader *>(this)->ReadDigits();
     349           0 : }
     350             : //____________________________________________________________________________ 
     351             : 
     352             : Int_t AliPHOSLoader::PostRecPoints()const
     353             : {
     354             :   // -------------- RecPoints -------------------------------------------
     355           0 :   Int_t reval = AliLoader::PostRecPoints();
     356           0 :   if (reval)
     357             :    {
     358           0 :      AliError("returned error");
     359           0 :      return reval;
     360             :    }
     361           0 :   return const_cast<AliPHOSLoader *>(this)->ReadRecPoints();
     362           0 : }
     363             : 
     364             : //____________________________________________________________________________ 
     365             : 
     366             : Int_t AliPHOSLoader::PostRecParticles()const
     367             : {
     368             :   // -------------- RecParticles -------------------------------------------
     369           0 :   Int_t reval = AliLoader::PostRecParticles();
     370           0 :   if (reval)
     371             :    {
     372           0 :      AliError("returned error");
     373           0 :      return reval;
     374             :    }
     375           0 :   return const_cast<AliPHOSLoader *>(this)->ReadRecParticles();
     376           0 : }
     377             : //____________________________________________________________________________ 
     378             : 
     379             : Int_t AliPHOSLoader::PostTracks()const
     380             : {
     381             :   // -------------- Tracks -------------------------------------------
     382           0 :   Int_t reval = AliLoader::PostTracks();
     383           0 :   if (reval)
     384             :    {
     385           0 :      AliError("returned error");
     386           0 :      return reval;
     387             :    }
     388           0 :   return const_cast<AliPHOSLoader *>(this)->ReadTracks();
     389           0 : }
     390             : //____________________________________________________________________________ 
     391             : 
     392             : 
     393             : 
     394             : //____________________________________________________________________________ 
     395             : Int_t AliPHOSLoader::ReadHits()
     396             : {
     397             : // If there is no Clones Array in folder creates it and sends to folder
     398             : // then tries to read
     399             : // Reads the first entry of PHOS branch in hit tree TreeH()
     400             : // Reads data from TreeH and stores it in TClonesArray that sits in DetectorDataFolder
     401             : //
     402          36 :   TObject** hitref = HitsRef();
     403          18 :   if(hitref == 0x0) {
     404           2 :     MakeHitsArray();
     405           2 :     hitref = HitsRef();
     406           2 :   }
     407             : 
     408          18 :   TClonesArray* hits = static_cast<TClonesArray*>(*hitref);
     409             : 
     410          18 :   TTree* treeh = TreeH();
     411             :   
     412          18 :   if(treeh == 0) {
     413           0 :     AliError("Cannot read TreeH from folder");
     414           0 :     return 1;
     415             :   }
     416             :   
     417          18 :   TBranch * hitsbranch = treeh->GetBranch(fDetectorName);
     418          18 :   if (hitsbranch == 0) {
     419           0 :     AliError("Cannot find branch PHOS"); 
     420           0 :     return 1;
     421             :   }
     422             : 
     423          54 :   AliDebug(1, "Reading Hits");
     424             :   
     425          36 :   if (hitsbranch->GetEntries() > 1) {
     426             : 
     427          36 :     hitsbranch->SetAddress(&fTmpHits);
     428             :     Int_t index = 0 ; 
     429        1044 :     for (Int_t i = 0 ; i < hitsbranch->GetEntries(); i++) {
     430         504 :       hitsbranch->GetEntry(i) ;
     431        4354 :       for (Int_t j = 0 ; j < fTmpHits->GetEntriesFast() ; j++) {
     432        1673 :         AliPHOSHit* hit = (AliPHOSHit*)fTmpHits->At(j); 
     433        1673 :         new((*hits)[index]) AliPHOSHit( *hit ) ;
     434        1673 :         index++ ; 
     435             :       }
     436             :     }
     437          18 :     fTmpHits->Clear();
     438          18 :   }
     439             :   else {
     440           0 :     hitsbranch->SetAddress(hitref);
     441           0 :     hitsbranch->GetEntry(0) ;
     442             :   }
     443             :   
     444          18 :   return 0;
     445          18 : }
     446             : //____________________________________________________________________________ 
     447             : Int_t AliPHOSLoader::ReadSDigits()
     448             : {
     449             : // Read the summable digits tree TreeS():
     450             : // Check if TClones is in folder
     451             : // if not create and add to folder
     452             : // connect to tree if available
     453             : // Read the data
     454             : 
     455          56 :   TObject** sdref = SDigitsRef();
     456          28 :   if(sdref == 0x0)
     457             :    {
     458           2 :      MakeSDigitsArray();
     459           2 :      sdref = SDigitsRef();
     460           2 :    }
     461             :    
     462          28 :   TTree * treeS = TreeS();
     463          28 :   if(treeS==0)
     464             :    {
     465             :      //May happen if file is truncated or new in LoadSDigits
     466             :      //AliError("There is no SDigit Tree");
     467           3 :      return 0;
     468             :    }
     469             :   
     470          25 :   TBranch * branch = treeS->GetBranch(fDetectorName);
     471          25 :   if (branch == 0) 
     472             :    {//easy, maybe just a new tree
     473             :     //AliError("Cannot find branch PHOS"); 
     474           0 :     return 0;
     475             :   }
     476             :     
     477          25 :   branch->SetAddress(sdref);
     478          25 :   branch->GetEntry(0);
     479          25 :   return 0;
     480          28 : }
     481             : 
     482             : //____________________________________________________________________________ 
     483             : Int_t AliPHOSLoader::ReadDigits()
     484             : {
     485             : // Read the summable digits tree TreeS():
     486             : // Check if TClones is in folder
     487             : // if not create and add to folder
     488             : // connect to tree if available
     489             : // Read the data
     490             :   
     491          14 :   TObject** dref = DigitsRef();
     492           7 :   if(dref == 0x0)
     493             :    {//if there is not array in folder, create it and put it there
     494           2 :      MakeDigitsArray();
     495           2 :      dref = DigitsRef();
     496           2 :    }
     497             : 
     498           7 :   TTree * treeD = TreeD();
     499           7 :   if(treeD==0)
     500             :    {
     501             :      //May happen if file is truncated or new in LoadSDigits
     502             :      //AliError("There is no Digit Tree");
     503           0 :      return 0;
     504             :    }
     505             : 
     506           7 :   TBranch * branch = treeD->GetBranch(fDetectorName);
     507           7 :   if (branch == 0) 
     508             :    {//easy, maybe just a new tree
     509             :     //AliError("Cannot find branch ",fDetectorName.Data()); 
     510           0 :     return 0;
     511             :    }
     512             :   
     513           7 :   branch->SetAddress(dref);//connect branch to buffer sitting in folder
     514           7 :   branch->GetEntry(0);//get first event 
     515             : 
     516           7 :   return 0;  
     517           7 : }
     518             : 
     519             : //____________________________________________________________________________ 
     520             : 
     521             : void AliPHOSLoader::Track(Int_t itrack)
     522             : {
     523             : // Read the first entry of PHOS branch in hit tree gAlice->TreeH()
     524           0 :   if(TreeH()== 0)
     525             :    {
     526           0 :      if (LoadHits())
     527             :       {
     528           0 :         AliError("Can not load hits.");
     529           0 :         return;
     530             :       } 
     531             :    }
     532             :   
     533           0 :   TBranch * hitsbranch = dynamic_cast<TBranch*>(TreeH()->GetListOfBranches()->FindObject("PHOS")) ;
     534           0 :   if ( !hitsbranch ) {
     535           0 :     if (fDebug)
     536           0 :       cout << "WARNING:  AliPHOSLoader::ReadTreeH -> Cannot find branch PHOS" << endl ; 
     537           0 :     return ;
     538             :   }  
     539           0 :   if(!Hits()) PostHits();
     540             : 
     541           0 :   hitsbranch->SetAddress(HitsRef());
     542           0 :   hitsbranch->GetEntry(itrack);
     543             : 
     544           0 : }
     545             : 
     546             : //____________________________________________________________________________ 
     547             : Int_t AliPHOSLoader::ReadRecPoints()
     548             : {
     549             : //Creates and posts to folder an array container, 
     550             : //connects branch in tree (if exists), and reads data to array
     551             :   
     552           0 :   MakeRecPointsArray();
     553             :   
     554           0 :   TObjArray * cpva = 0x0 ; 
     555           0 :   TObjArray * emca = 0x0 ; 
     556             :   
     557           0 :   TTree * treeR = TreeR();
     558             :  
     559           0 :   if(treeR==0)
     560             :    {
     561             :      //May happen if file is truncated or new in LoadSDigits
     562           0 :      return 0;
     563             :    }
     564             : 
     565             :   Int_t retval = 0;
     566           0 :   TBranch * emcbranch = treeR->GetBranch(fgkEmcRecPointsBranchName);
     567             : 
     568           0 :   if (emcbranch == 0x0)
     569             :    {
     570           0 :      AliError(Form("Can not get branch with EMC Rec. Points named %s",
     571             :                    fgkEmcRecPointsBranchName.Data()));
     572             :      retval = 1;
     573           0 :    }
     574             :   else
     575             :    {
     576           0 :      emcbranch->SetAddress(&emca) ;
     577           0 :      emcbranch->GetEntry(0) ;
     578             :    }
     579           0 :   TBranch * cpvbranch = treeR->GetBranch(fgkCpvRecPointsBranchName);
     580           0 :   if (cpvbranch == 0x0)
     581             :    {
     582           0 :      AliError(Form("Can not get branch with CPV Rec. Points named %s",
     583             :                    fgkCpvRecPointsBranchName.Data()));
     584             :      retval = 2;
     585           0 :    }
     586             :   else
     587             :    {
     588           0 :      cpvbranch->SetAddress(&cpva);
     589           0 :      cpvbranch->GetEntry(0) ;
     590             :    }
     591             : 
     592             :   Int_t ii ; 
     593           0 :   if (emca != 0) {
     594           0 :     Int_t maxemc = emca->GetEntries() ; 
     595           0 :     for ( ii= 0 ; ii < maxemc ; ii++ ) 
     596           0 :       EmcRecPoints()->Add(emca->At(ii)) ;
     597           0 :   }
     598             : 
     599           0 :   if (cpva != 0) {
     600           0 :     Int_t maxcpv = cpva->GetEntries() ;
     601           0 :     for ( ii= 0 ; ii < maxcpv ; ii++ )
     602           0 :       CpvRecPoints()->Add(cpva->At(ii)) ; 
     603           0 :   }
     604             : 
     605             :   return retval;
     606           0 : }
     607             : 
     608             : //____________________________________________________________________________ 
     609             : Int_t AliPHOSLoader::ReadTracks()
     610             : {
     611             : //Creates and posts to folder an array container, 
     612             : //connects branch in tree (if exists), and reads data to arry
     613             : 
     614           0 :   TObject** trkref = TracksRef();
     615           0 :   if ( trkref == 0x0 )   
     616             :    {//Create and post array
     617           0 :     MakeTrackSegmentsArray();
     618           0 :     trkref = TracksRef();
     619           0 :    }
     620             : 
     621           0 :   TTree * treeT = TreeT();
     622           0 :   if(treeT==0)
     623             :    {
     624             :      //May happen if file is truncated or new in LoadSDigits, or the file is in update mode, 
     625             :      //but tracking was not performed yet for a current event
     626             :      //AliError("There is no Tree with Tracks");
     627           0 :      return 0;
     628             :    }
     629             :   
     630           0 :   TBranch * branch = treeT->GetBranch(fgkTrackSegmentsBranchName);
     631             : //   AliInfo(Form("Branch named %s is opened: 0x%z",
     632             : //                fgkTrackSegmentsBranchName.Data(),branch));
     633           0 :   if (branch == 0) 
     634             :    {//easy, maybe just a new tree
     635           0 :     AliError(Form("Cannot find branch named %s",
     636             :                   fgkTrackSegmentsBranchName.Data()));
     637           0 :     return 0;
     638             :   }
     639             : 
     640           0 :   branch->SetAddress(trkref);//connect branch to buffer sitting in folder
     641           0 :   branch->GetEntry(0);//get first event 
     642             :   
     643           0 :   return 0;
     644           0 : }
     645             : //____________________________________________________________________________ 
     646             : 
     647             : Int_t AliPHOSLoader::ReadRecParticles()
     648             : {
     649             : //Reads Reconstructed  Particles from file
     650             : //Creates and posts to folder an array container, 
     651             : //connects branch in tree (if exists), and reads data to arry
     652             :   
     653           0 :   TObject** recpartref = RecParticlesRef();
     654             :   
     655           0 :   if ( recpartref == 0x0 )   
     656             :    {//Create and post array
     657           0 :     MakeRecParticlesArray();
     658           0 :     recpartref = RecParticlesRef();
     659           0 :    }
     660             : 
     661           0 :   TTree * treeP = TreeP();
     662           0 :   if(treeP==0)
     663             :    {
     664             :      //May happen if file is truncated or new in LoadSDigits, 
     665             :      //or the file is in update mode, 
     666             :      //but tracking was not performed yet for a current event
     667             :      //     AliError("There is no Tree with Tracks and Reconstructed Particles");
     668           0 :      return 0;
     669             :    }
     670             :   
     671           0 :   TBranch * branch = treeP->GetBranch(fgkRecParticlesBranchName);
     672           0 :   if (branch == 0) 
     673             :    {//easy, maybe just a new tree
     674           0 :     AliError(Form("Cannot find branch %s",
     675             :                   fgkRecParticlesBranchName.Data())); 
     676           0 :     return 0;
     677             :   }
     678             : 
     679           0 :   branch->SetAddress(recpartref);//connect branch to buffer sitting in folder
     680           0 :   branch->GetEntry(0);//get first event 
     681             :   
     682           0 :   return 0;
     683           0 : }
     684             : 
     685             : 
     686             : /***************************************************************************************/
     687             : 
     688             : AliPHOSLoader* AliPHOSLoader::GetPHOSLoader(const  char* eventfoldername)
     689             : {
     690             :   // Return PHOS loader
     691           0 :   AliRunLoader* rn  = AliRunLoader::GetRunLoader(eventfoldername);
     692           0 :   if (rn == 0x0) {
     693           0 :     printf("Can not find Run Loader in folder %s", eventfoldername);
     694           0 :     return 0x0 ; 
     695             :   }
     696           0 :   return dynamic_cast<AliPHOSLoader*>(rn->GetLoader("PHOSLoader"));
     697           0 : }
     698             : /***************************************************************************************/
     699             : 
     700             : Bool_t AliPHOSLoader::BranchExists(const TString& recName)
     701             : {
     702             :   // Check if a branch named redName exists
     703           0 :   if (fBranchTitle.IsNull()) return kFALSE;
     704           0 :   TString dataname, zername ;
     705             :   TTree* tree;
     706           0 :   if(recName == "SDigits")
     707             :    {
     708           0 :     tree = TreeS();
     709           0 :     dataname = GetDetectorName();
     710           0 :     zername = "AliPHOSSDigitizer" ;
     711             :    }
     712             :   else
     713           0 :     if(recName == "Digits"){
     714           0 :       tree = TreeD();
     715           0 :       dataname = GetDetectorName();
     716           0 :       zername = "AliPHOSDigitizer" ;
     717             :     }
     718             :     else
     719           0 :       if(recName == "RecPoints"){
     720           0 :        tree = TreeR();
     721           0 :        dataname = fgkEmcRecPointsBranchName;
     722           0 :        zername = "AliPHOSClusterizer" ;
     723             :       }
     724             :       else
     725           0 :        if(recName == "TrackSegments"){
     726           0 :          tree = TreeT();
     727           0 :          dataname = fgkTrackSegmentsBranchName;
     728           0 :          zername = "AliPHOSTrackSegmentMaker";
     729             :        }        
     730             :        else
     731           0 :          if(recName == "RecParticles"){
     732           0 :            tree = TreeP();
     733           0 :            dataname = fgkRecParticlesBranchName;
     734           0 :            zername = "AliPHOSPID";
     735             :          }
     736             :          else
     737           0 :            return kFALSE ;
     738             : 
     739             :   
     740           0 :   if(!tree ) 
     741           0 :     return kFALSE ;
     742             : 
     743           0 :   TObjArray * lob = static_cast<TObjArray*>(tree->GetListOfBranches()) ;
     744           0 :   TIter next(lob) ; 
     745             :   TBranch * branch = 0 ;  
     746           0 :   TString titleName(fBranchTitle);
     747           0 :   titleName+=":";
     748             : 
     749           0 :   while ((branch = (static_cast<TBranch*>(next())))) {
     750           0 :     TString branchName(branch->GetName() ) ; 
     751           0 :     TString branchTitle(branch->GetTitle() ) ;  
     752           0 :     if ( branchName.BeginsWith(dataname) && branchTitle.BeginsWith(fBranchTitle) ){  
     753           0 :       AliWarning(Form("branch %s  with title  %s ",
     754             :                       dataname.Data(),fBranchTitle.Data()));
     755           0 :       return kTRUE ;
     756             :     }
     757           0 :     if ( branchName.BeginsWith(zername) &&  branchTitle.BeginsWith(titleName) ){
     758           0 :       AliWarning(Form("branch AliPHOS... with title  %s ",
     759             :                       branch->GetTitle()));
     760           0 :       return kTRUE ; 
     761             :     }
     762           0 :   }
     763           0 :   return kFALSE ;
     764             : 
     765           0 :  }
     766             : 
     767             : void AliPHOSLoader::SetBranchTitle(const TString& btitle)
     768             : {
     769             :   // Set branch title
     770           0 :   if (btitle.CompareTo(fBranchTitle) == 0) return;
     771           0 :   fBranchTitle = btitle;
     772           0 :   ReloadAll();
     773           0 :  }
     774             :  
     775             : //____________________________________________________________________________ 
     776             : //Again, must be const not to hide virtual functions from AliLoader
     777             : //but there are calls to non-const functions, so I have to const_cast this pointer
     778             : void AliPHOSLoader::CleanHits()const
     779             : {
     780             :   // Clean Hits array
     781           8 :   AliLoader::CleanHits();
     782             :   //Clear an array 
     783           4 :   TClonesArray* hits = const_cast<AliPHOSLoader *>(this)->Hits();
     784           7 :   if (hits) hits->Clear();
     785           4 : }
     786             : //____________________________________________________________________________ 
     787             : 
     788             : void AliPHOSLoader::CleanSDigits()const
     789             : {
     790             :   // Clean SDigits array
     791           8 :   AliLoader::CleanSDigits();
     792           4 :   TClonesArray* sdigits = const_cast<AliPHOSLoader *>(this)->SDigits();
     793           7 :   if (sdigits) sdigits->Clear();
     794             :   
     795           4 : }
     796             : //____________________________________________________________________________ 
     797             : 
     798             : void AliPHOSLoader::CleanDigits()const
     799             : {
     800             :   // Clean Digits array
     801           8 :   AliLoader::CleanDigits();
     802           4 :   TClonesArray* digits = const_cast<AliPHOSLoader *>(this)->Digits();
     803           4 :   if (digits) digits->Clear();
     804           4 : }
     805             : //____________________________________________________________________________ 
     806             : 
     807             : void AliPHOSLoader::CleanRecPoints()const
     808             : {
     809             :   // Clean RecPoints array
     810          16 :   AliLoader::CleanRecPoints();
     811           8 :   TObjArray* recpoints = const_cast<AliPHOSLoader *>(this)->EmcRecPoints();
     812           8 :   if (recpoints) recpoints->Clear();
     813           8 :   recpoints = const_cast<AliPHOSLoader *>(this)->CpvRecPoints();
     814           8 :   if (recpoints) recpoints->Clear();
     815           8 : }
     816             : //____________________________________________________________________________ 
     817             : 
     818             : void AliPHOSLoader::CleanTracks()const
     819             : {
     820             :   //Cleans Tracks stuff
     821           0 :   AliLoader::CleanTracks();//tree
     822             :   
     823             :   //and clear the array
     824           0 :   TClonesArray* tracks = const_cast<AliPHOSLoader *>(this)->TrackSegments();
     825           0 :   if (tracks) tracks->Clear();
     826             : 
     827           0 : }
     828             : //____________________________________________________________________________ 
     829             : 
     830             : void AliPHOSLoader::CleanRecParticles()
     831             :  {
     832             :    // Clean RecParticles array
     833          30 :    TClonesArray *recpar = RecParticles();
     834          15 :    if (recpar) recpar->Clear();
     835             :   
     836             :  
     837          15 :  }
     838             : //____________________________________________________________________________ 
     839             : 
     840             : void AliPHOSLoader::MakeHitsArray()
     841             : {
     842             :   // Add Hits array to the data folder
     843           4 :   if (Hits()) return;
     844           2 :   TClonesArray* hits = new TClonesArray("AliPHOSHit",1000);
     845           2 :   hits->SetName(fgkHitsName);
     846           2 :   GetDetectorDataFolder()->Add(hits);
     847           4 : }
     848             : 
     849             : //____________________________________________________________________________ 
     850             : void AliPHOSLoader::MakeSDigitsArray()
     851             : {
     852             :   // Add SDigits array to the data folder
     853           6 :   if ( SDigits()) return;
     854           3 :   TClonesArray* sdigits = new TClonesArray("AliPHOSDigit",1);
     855           3 :   sdigits->SetName(fgkSDigitsName);
     856           3 :   GetDetectorDataFolder()->Add(sdigits);
     857           6 : }
     858             : 
     859             : //____________________________________________________________________________ 
     860             : void AliPHOSLoader::MakeDigitsArray()
     861             : {
     862             :   // Add Digits array to the data folder
     863           6 :   if ( Digits()) return;
     864           3 :   TClonesArray* digits = new TClonesArray("AliPHOSDigit",1);
     865           3 :   digits->SetName(fgkDigitsName);
     866           3 :   GetDetectorDataFolder()->Add(digits);
     867             :   
     868           6 : }
     869             : 
     870             : //____________________________________________________________________________ 
     871             : void AliPHOSLoader::MakeRecPointsArray()
     872             : {
     873             :   // Add RecPoints array to the data folder
     874           0 :   if ( EmcRecPoints() == 0x0)
     875             :    {
     876           0 :      AliDebug(9, "Making array for EMC");
     877           0 :     TObjArray* emc = new TObjArray(100) ;
     878           0 :     emc->SetName(fgkEmcRecPointsName) ;
     879           0 :     GetDetectorDataFolder()->Add(emc);
     880           0 :    }
     881             : 
     882           0 :   if ( CpvRecPoints() == 0x0)
     883             :    { 
     884           0 :      AliDebug(9, "Making array for CPV");
     885           0 :      TObjArray* cpv = new TObjArray(100) ;
     886           0 :      cpv->SetName(fgkCpvRecPointsName);
     887           0 :      GetDetectorDataFolder()->Add(cpv);
     888           0 :    }
     889           0 : }
     890             : 
     891             : //____________________________________________________________________________ 
     892             : void AliPHOSLoader::MakeTrackSegmentsArray()
     893             : {
     894             :   // Add TrackSegments array to the data folder
     895           0 :   if ( TrackSegments()) return;
     896           0 :   TClonesArray * ts = new TClonesArray("AliPHOSTrackSegment",100) ;
     897           0 :   ts->SetName(fgkTracksName);
     898           0 :   GetDetectorDataFolder()->Add(ts);
     899             : 
     900           0 : }
     901             : 
     902             : //____________________________________________________________________________ 
     903             : void AliPHOSLoader::MakeRecParticlesArray()
     904             : {
     905             :   // Add RecParticles array to the data folder
     906           0 :   if ( RecParticles()) return;
     907           0 :   TClonesArray * rp = new TClonesArray("AliPHOSRecParticle",100) ;
     908           0 :   rp->SetName(fgkRecParticlesName);
     909           0 :   GetDetectorDataFolder()->Add(rp);
     910           0 : }

Generated by: LCOV version 1.11