]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Added a collaborative work between Getter and Tasks (Digitizer and Clustrizer) so...
authorschutz <schutz@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 15 Jul 2002 12:29:44 +0000 (12:29 +0000)
committerschutz <schutz@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 15 Jul 2002 12:29:44 +0000 (12:29 +0000)
12 files changed:
EMCAL/AliEMCALClusterizer.cxx
EMCAL/AliEMCALClusterizer.h
EMCAL/AliEMCALDigitizer.cxx
EMCAL/AliEMCALDigitizer.h
EMCAL/AliEMCALGetter.cxx
EMCAL/AliEMCALGetter.h
PHOS/AliPHOSClusterizer.cxx
PHOS/AliPHOSClusterizer.h
PHOS/AliPHOSDigitizer.cxx
PHOS/AliPHOSDigitizer.h
PHOS/AliPHOSGetter.cxx
PHOS/AliPHOSGetter.h

index ed61757cb7a122b0c97e17e23169dddefc4f7ff5..71b3b6a13871e2c861235b9cc5401ad755717e48 100644 (file)
@@ -38,6 +38,9 @@
 #include "AliRun.h" 
 #include "AliEMCALClusterizer.h"
 #include "AliHeader.h" 
+#include "AliEMCALGetter.h"
+#include "AliEMCALSDigitizer.h"
+#include "AliEMCALDigitizer.h"
 
 ClassImp(AliEMCALClusterizer)
 
@@ -46,6 +49,10 @@ ClassImp(AliEMCALClusterizer)
 {
   // ctor
   fSplitFile = 0 ;  
+  fHitsFileName = "" ; 
+  fSDigitsFileName = "" ; 
+  fDigitsFileName = "" ; 
+
 }
 
 //____________________________________________________________________________
@@ -54,6 +61,13 @@ TTask(name, headerFile)
 {
   // ctor
   fSplitFile = 0 ;  
+  fDigitsFileName = headerFile ; 
+  AliEMCALGetter * gime = AliEMCALGetter::GetInstance(headerFile, name) ; 
+  gime->Event(0,"D") ; 
+  fSDigitsFileName = gime->Digitizer()->GetTitle() ; 
+  gime = AliEMCALGetter::GetInstance(fSDigitsFileName, name) ; 
+  gime->Event(0,"S") ; 
+  fHitsFileName = gime->SDigitizer()->GetTitle() ; 
 }
 
 //____________________________________________________________________________
@@ -62,7 +76,7 @@ AliEMCALClusterizer::~AliEMCALClusterizer()
   // dtor
   
   fSplitFile = 0 ;
-
 }
 
 //____________________________________________________________________________
index b9d53ba6b9cbdeb72520ec89260e4fe7f39fb5b0..70f16a07a4e613b7b048aa771df8079366535d5f 100644 (file)
@@ -26,6 +26,10 @@ public:
   AliEMCALClusterizer(const char * headerFile, const char * name) ;
   virtual ~AliEMCALClusterizer() ; // dtor
 
+  const TString GetHitsFileName() const { return fHitsFileName ; }
+  const TString GetSDigitsFileName() const { return fSDigitsFileName ; }
+  const TString GetDigitsFileName() const { return fDigitsFileName ; }
+
   virtual Float_t GetEmcClusteringThreshold()const = 0 ; 
   virtual Float_t GetEmcLocalMaxCut()const = 0 ; 
   virtual Float_t GetEmcLogWeight()const = 0 ; 
@@ -55,6 +59,9 @@ public:
 
 protected:
   
+  TString fHitsFileName ;          // file name that contains the original hits
+  TString fSDigitsFileName ;       // file name that contains the original SDigits
+  TString fDigitsFileName ;        // file name that contains the original Digits
   TFile * fSplitFile ;             //! file in which RecPoints will eventually be stored
 
   ClassDef(AliEMCALClusterizer,1)  // Clusterization algorithm class 
index 2820bb4cd7361e947aa2b66ad71c045200334492..b9380c1bbbcc99d8800907a507426835a7536f6e 100644 (file)
@@ -90,6 +90,9 @@ ClassImp(AliEMCALDigitizer)
 
   InitParameters() ; 
   fDefaultInit = kTRUE ; 
+  fHitsFileName    = "" ;
+  fSDigitsFileName = "" ; 
 
 }
 
@@ -103,7 +106,10 @@ AliEMCALDigitizer::AliEMCALDigitizer(const char *headerFile,const char *name)
   InitParameters() ; 
   Init() ;
   fDefaultInit = kFALSE ; 
-
+  fSDigitsFileName = headerFile ; 
+  AliEMCALGetter * gime = AliEMCALGetter::GetInstance() ; 
+  gime->Event(0, "S") ; 
+  fHitsFileName = gime->SDigitizer()->GetTitle() ; 
 }
 
 //____________________________________________________________________________ 
@@ -113,6 +119,15 @@ AliEMCALDigitizer::AliEMCALDigitizer(AliRunDigitizer * ard):AliDigitizer(ard)
   SetName("Default");    
   SetTitle("aliroot") ;  
   fDefaultInit = kFALSE ; 
+  
+  const AliRunDigitizer * rd = Manager() ; 
+  if (rd) {
+    AliStream * st = static_cast<AliStream*>(rd->GetInputStreams()->At(0))  ;
+    fSDigitsFileName = st->GetFileNames()->At(0)->GetName() ;
+  }
+  AliEMCALGetter * gime = AliEMCALGetter::GetInstance(fSDigitsFileName, GetName()) ; 
+  gime->Event(0,"S") ; 
+  fHitsFileName = gime->SDigitizer()->GetTitle() ; 
 }
 
 //____________________________________________________________________________ 
index f4e19c574ac0008e6f63ae32ee5d3c04fa416905..7c1b13d4ef96e47b7fedf969e622db1af36efb3c 100644 (file)
@@ -39,6 +39,8 @@ public:
   void    Digitize(const Int_t);            // Make Digits from SDigits stored in fSDigits
   void    Exec(Option_t *option);                // Supervising method
 
+  const TString GetHitsFileName() const { return fHitsFileName ; }
+  const TString GetSDigitsFileName() const { return fSDigitsFileName ; }
   const Float_t GetTowerThreshold() const { return fTowerDigitThreshold;}
   const Float_t GetPedestal()     const { return fPedestal; }
   const Float_t GetPinNoise()     const { return fPinNoise;}
@@ -80,6 +82,8 @@ private:
 
 private:
   
+  TString fHitsFileName ;           // file name that contains the original hits
+  TString fSDigitsFileName ;        // file name that contains the original SDigits
   Bool_t fDefaultInit;      //! Says if the task was created by defaut ctor (only parameters are initialized)
   // !!! the following is not necessary, it is in the folder !!!!!!!
   AliEMCALSDigitizer * fSDigitizer ; // ! SDigitizer to extract some sdigitizing parameters
index d7f965057b8de56b7e95aacc865529a683cab5bb..f0f324e026250fdb01e77f5d87a5cf8ba61b00a3 100644 (file)
@@ -85,7 +85,9 @@ AliEMCALGetter::AliEMCALGetter(const char* headerFile, const char* branchTitle,
   //Initialize  all lists
 
   fDebug = 0 ; 
-
+  
+  fAlice = 0 ; 
   fHeaderFile         = headerFile ; 
   fBranchTitle        = branchTitle ;
   fSDigitsTitle       = branchTitle ; 
@@ -96,13 +98,14 @@ AliEMCALGetter::AliEMCALGetter(const char* headerFile, const char* branchTitle,
 
   fPrimaries = new TObjArray(1) ;
 
-  fModuleFolder  = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Run/Configuration/Modules")); 
-  fHitsFolder    = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/RunMC/Event/Data/Hits")); 
-  fSDigitsFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/RunMC/Event/Data/SDigits")); 
-  fDigitsFolder  = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Run/Event/Data")); 
-  fRecoFolder    = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Run/Event/RecData")); 
+  fModuleFolder    = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Run/Configuration/Modules")); 
+  fPrimariesFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/RunMC/Event/Data")); 
+  fHitsFolder      = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/RunMC/Event/Data/Hits")); 
+  fSDigitsFolder   = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/RunMC/Event/Data/SDigits")); 
+  fDigitsFolder    = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Run/Event/Data")); 
+  fRecoFolder      = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Run/Event/RecData")); 
   //fQAFolder      = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Run/Conditions/QA")); 
-  fTasksFolder   = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Tasks")) ; 
+  fTasksFolder     = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Tasks")) ; 
 
   fFailed = kFALSE ; 
                   
@@ -179,6 +182,8 @@ void AliEMCALGetter::CloseFile()
 {
   delete gAlice ; 
   gAlice = 0 ; 
+  delete fAlice ; 
+  fAlice = 0 ; 
 }
 
 //____________________________________________________________________________ 
@@ -259,6 +264,53 @@ AliEMCALGeometry * AliEMCALGetter::EMCALGeometry()
   return rv ; 
 } 
 
+//____________________________________________________________________________ 
+Bool_t AliEMCALGetter::PostPrimaries(void) const 
+{  //------- Primaries ----------------------
+
+  // the hierarchy is //Folders/RunMC/Event/Data/Primaries
+  
+  TFolder * primariesFolder = dynamic_cast<TFolder*>(fPrimariesFolder->FindObject("Primaries")) ; 
+  if ( !primariesFolder ) {
+    if (fDebug) {
+      cout << "WARNING: AliEMCALGetter::Post Primaries -> Folder //" << fPrimariesFolder->GetName() << "/Primaries/ not found!" << endl;
+      cout << "INFO:    AliEMCALGetter::Post Primaries -> Adding Folder //" << fPrimariesFolder->GetName() << "/Primaries/"  << endl;
+    }
+    primariesFolder = fPrimariesFolder->AddFolder("Primaries", "Primaries particles from TreeK") ; 
+  }    
+  TClonesArray *primaries=  new TClonesArray("TParticle",1000) ;
+  primaries->SetName("Primaries") ;
+  primariesFolder->Add(primaries) ; 
+  
+  return kTRUE;
+} 
+
+//____________________________________________________________________________ 
+TObject** AliEMCALGetter::PrimariesRef(void) const 
+{  //------- Primaries ----------------------
+
+  
+  // the hierarchy is //Folders/RunMC/Event/Data/Primaries
+  if ( !fPrimariesFolder ) {
+    cerr << "ERROR: AliEMCALGetter::PrimariesRef -> Folder //" << fPrimariesFolder << " not found!" << endl;
+    abort() ;
+  }    
+  TFolder * primariesFolder = dynamic_cast<TFolder *>(fPrimariesFolder->FindObject("Primaries")) ;
+  if ( !primariesFolder ) {
+    cerr << "ERROR: AliEMCALGetter::PrimariesRef -> Folder //" << fPrimariesFolder << "/Primaries/ not found!" << endl;  
+    abort() ;
+  }
+  TObject * p = primariesFolder->FindObject("Primaries") ;
+  if(!p) {
+    cerr << "ERROR: AliEMCALGetter::PrimariesRef -> " << primariesFolder->GetName() << "/Primaries not found !" << endl ; 
+    abort() ;
+  }
+  else
+    return primariesFolder->GetListOfFolders()->GetObjectRef(p) ;
+}
+
 //____________________________________________________________________________ 
 Bool_t AliEMCALGetter::PostHits(void) const 
 {  //------- Hits ----------------------
@@ -1207,31 +1259,48 @@ const TParticle * AliEMCALGetter::Primary(Int_t index) const
   
   if(index < 0) 
     return 0 ;
-  
-  Int_t primaryIndex = index % 10000000 ; 
-  Int_t primaryList = (Int_t ) ((index-primaryIndex)/10000000.)  ;
-  
-  if ( primaryList > 0  ) {
-    if (fDebug) {
-      cout << " Getter does not support currently Mixing of primary " << endl ;
-      cout << "   can not return primary: " << index<< " (list "<< primaryList<< " primary # " << primaryIndex << " )"<<endl ;
-    }
-    return 0;
-  }
-  
-  return gAlice->Particle(primaryIndex) ;
-  
+  TParticle *  p = 0 ;
+  if (fAlice) 
+    p = fAlice->Particle(index) ; 
+  else 
+    p = gAlice->Particle(index) ; 
+  //   if (p->GetFirstMother() != -1 ) {
+  //     cout << "AliEMCALGetter::Primary : Not a primary " << endl ; 
+  //   }
+  
+  return p ; 
+      
 }
 
 //____________________________________________________________________________ 
 void AliEMCALGetter::ReadTreeD()
 {
   // Read the digit tree gAlice->TreeD()  
-  if(gAlice->TreeD()== 0){
-    cerr <<   "ERROR: AliEMCALGetter::ReadTreeD: can not read TreeD " << endl ;
-  return ;
-  }
+
+  TTree * treeD = gAlice->TreeD() ;
   
+  if(!treeD) { // TreeD not found in header file
+    
+    if (fDebug) 
+      cout <<   "WARNING: AliEMCALGetter::ReadTreeD -> Cannot find TreeD in " << fHeaderFile << endl ;
+    
+    TString searchFileName("") ; 
+    
+    if (Digitizer())  // Digitizer found in header file
+      searchFileName = Digitizer()->GetTitle() ; 
+    
+    else if (Clusterizer())  // Clusterizer found in header file
+      searchFileName = Clusterizer()->GetDigitsFileName() ; 
+    
+    if (treeD = TreeD(searchFileName)) { //found TreeD in the file which contains the hits
+      if (fDebug) 
+       cout << "INFO: AliEMCALGetter::ReadTreeD -> TreeD found in " << searchFileName.Data() << endl ; 
+      
+    } else {
+      cerr << "ERROR: AliEMCALGetter::ReadTreeD -> TreeD not found " << endl ; 
+      return ;
+    }   
+  }
   TObjArray * lob = static_cast<TObjArray*>(gAlice->TreeD()->GetListOfBranches()) ;
   TIter next(lob) ; 
   TBranch * branch = 0 ; 
@@ -1279,10 +1348,33 @@ void AliEMCALGetter::ReadTreeH()
 {
   // Read the first entry of EMCAL branch in hit tree gAlice->TreeH()
 
-  if(gAlice->TreeH()== 0){
-    cerr <<   "ERROR: AliEMCALGetter::ReadTreeH: -> Cannot read TreeH " << endl ;
-    return ;
-  }
+  TTree * treeH = gAlice->TreeH() ;
+  
+  if(!treeH) {// TreeH not found in header file
+    
+    if (fDebug) 
+      cout <<   "WARNING: AliEMCALGetter::ReadTreeH -> Cannot find TreeH in " << fHeaderFile << endl ;
+    
+    TString searchFileName("") ; 
+    
+    if (SDigitizer())  // SDigitizer found in header file
+      searchFileName = SDigitizer()->GetTitle() ;
+    
+    else if (Digitizer())  // Digitizer found in header file
+      searchFileName = Digitizer()->GetHitsFileName() ; 
+    
+    else if (Clusterizer())  // Clusterizer found in header file
+      searchFileName = Clusterizer()->GetHitsFileName() ; 
+    
+    if (treeH = TreeH(searchFileName)) { //found TreeH in the file which contains the hits
+      if (fDebug) 
+       cout << "INFO: AliEMCALGetter::ReadTreeH -> TreeH found in " << searchFileName.Data() << endl ; 
+      
+    } else {
+      cerr << "ERROR: AliEMCALGetter::ReadTreeH -> TreeH not found " << endl ; 
+      return ;
+    }  
+  }  
   
   TBranch * hitsbranch = static_cast<TBranch*>(gAlice->TreeH()->GetBranch("EMCAL")) ;
   if ( !hitsbranch ) {
@@ -1339,6 +1431,108 @@ void AliEMCALGetter::Track(Int_t itrack)
 
   
 }
+
+
+//____________________________________________________________________________ 
+TTree * AliEMCALGetter::TreeK(TString filename)  
+{
+
+  // returns TreeK from file filename
+  // usefull in case of split file
+
+  if ( filename.IsNull() ) 
+    filename = fHeaderFile ; 
+
+  TFile * file = 0 ; 
+  // file = static_cast<TFile*>(gROOT->GetFile(filename.Data() ) ) ;
+  if (!file) {  // file not open yet
+    //   file->Close() ; 
+    file = TFile::Open(filename.Data(), "read") ; 
+    delete fAlice ; 
+    fAlice = static_cast<AliRun *>(file->Get("gAlice")) ; 
+  }
+
+  TString treeName("TreeK") ; 
+  treeName += EventNumber()  ; 
+  TTree * tree = static_cast<TTree *>(file->Get(treeName.Data())) ;
+  if (!tree && fDebug)  
+    cout << "WARNING: AliEMCALGetter::TreeK -> " << treeName.Data() << " not found in " << filename.Data() << endl ; 
+  
+  return tree ;                      
+}
+
+//____________________________________________________________________________ 
+TTree * AliEMCALGetter::TreeH(TString filename)  
+{
+
+  // returns TreeH from file filename
+  // usefull in case of split file
+
+  if ( filename.IsNull() ) 
+    filename = fHeaderFile ; 
+
+  TFile * file = 0 ; 
+  file = static_cast<TFile*>(gROOT->GetFile(filename.Data() ) ) ;
+  if (!file) { // file not open yet
+    file = TFile::Open(filename.Data(), "read") ; 
+  }
+  TString treeName("TreeH") ; 
+  treeName += EventNumber()  ; 
+  TTree * tree = static_cast<TTree *>(file->Get(treeName.Data())) ;
+  if (!tree && fDebug)  
+    cout << "WARNING: AliEMCALGetter::TreeH -> " << treeName.Data() << " not found in " << filename.Data() << endl ; 
+  
+  return tree ;                      
+}
+
+//____________________________________________________________________________ 
+TTree * AliEMCALGetter::TreeS(TString filename)  
+{
+
+  // returns TreeS from file filename
+  // usefull in case of split file
+
+  if ( filename.IsNull() ) 
+    filename = fHeaderFile ; 
+
+  TFile * file = 0 ; 
+  file = static_cast<TFile*>(gROOT->GetFile(filename.Data() ) ) ;
+  if (!file) { // file not open yet
+    file = TFile::Open(filename.Data(), "read") ; 
+  }
+  TString treeName("TreeS") ; 
+  treeName += EventNumber()  ; 
+  TTree * tree = static_cast<TTree *>(file->Get(treeName.Data())) ;
+  if (!tree && fDebug)  
+    cout << "WARNING: AliEMCALGetter::TreeS -> " << treeName.Data() << " not found in " << filename.Data() << endl ; 
+  
+  return tree ;                      
+}
+
+//____________________________________________________________________________ 
+TTree * AliEMCALGetter::TreeD(TString filename)  
+{
+
+  // returns TreeD from file filename
+  // usefull in case of split file
+
+  if ( filename.IsNull() ) 
+    filename = fHeaderFile ; 
+
+  TFile * file = 0 ; 
+  file = static_cast<TFile*>(gROOT->GetFile(filename.Data() ) ) ;
+  if (!file) { // file not open yet
+    file = TFile::Open(filename.Data(), "read") ; 
+  }
+  TString treeName("TreeD") ; 
+  treeName += EventNumber()  ; 
+  TTree * tree = static_cast<TTree *>(file->Get(treeName.Data())) ;
+  if (!tree && fDebug)  
+    cout << "WARNING: AliEMCALGetter::TreeD -> " << treeName.Data() << " not found in " << filename.Data() << endl ; 
+  
+  return tree ;                      
+}
+
 //____________________________________________________________________________ 
 // void AliEMCALGetter::ReadTreeQA()
 //{
@@ -1378,7 +1572,8 @@ void AliEMCALGetter::ReadTreeR()
       // Read the reconstrunction tree gAlice->TreeR()
 
   if(gAlice->TreeR()== 0){
-    cerr <<   "ERROR: AliEMCALGetter::ReadTreeR: can not read TreeR " << endl ;
+    if (fDebug) 
+      cout <<   "WARNING: AliEMCALGetter::ReadTreeR: can not read TreeR " << endl ;
     return ;
   }
   
@@ -1558,52 +1753,73 @@ void AliEMCALGetter::ReadTreeS(Int_t event)
       treeName += event ; 
       treeS = dynamic_cast<TTree*>(gDirectory->Get(treeName.Data()));
     }
-    if(treeS==0){
-      cerr << "ERROR: AliEMCALGetter::ReadTreeS There is no SDigit Tree" << endl;
-      return ;
-    }
+   if(!treeS){ // TreeS not found in header file
+     
+     if (fDebug)
+       cout << "WARNING: AliEMCALGetter::ReadTreeS -> Cannot find TreeS in " << fHeaderFile << endl;
+     
+     TString searchFileName("") ; 
+     
+     if (SDigitizer())  // SDigitizer found in header file
+       searchFileName = SDigitizer()->GetTitle() ;
+     
+     else if (Digitizer())  // Digitizer found in header file
+       searchFileName = Digitizer()->GetSDigitsFileName() ; 
+     
+     else if (Clusterizer())  // Clusterizer found in header file
+       searchFileName = Clusterizer()->GetSDigitsFileName() ; 
+     
+     if (treeS = TreeS(searchFileName)) { //found TreeS in the file which contains the hits
+       if (fDebug) 
+        cout << "INFO: AliEMCALGetter::ReadTreeS -> TreeS found in " << searchFileName.Data() << endl ; 
+       
+     } else {
+       cerr << "ERROR: AliEMCALGetter::ReadTreeS -> TreeS not found " << endl ; 
+       return ;
+     }
+   }   
+
+   //set address of the SDigits and SDigitizer
+   TBranch   * sdigitsBranch    = 0;
+   TBranch   * sdigitizerBranch = 0;
+   TBranch   * branch           = 0 ;  
+   TObjArray * lob = static_cast<TObjArray*>(treeS->GetListOfBranches()) ;
+   TIter next(lob) ; 
+   Bool_t emcalfound = kFALSE, sdigitizerfound = kFALSE ; 
    
-    //set address of the SDigits and SDigitizer
-    TBranch   * sdigitsBranch    = 0;
-    TBranch   * sdigitizerBranch = 0;
-    TBranch   * branch           = 0 ;  
-    TObjArray * lob = static_cast<TObjArray*>(treeS->GetListOfBranches()) ;
-    TIter next(lob) ; 
-    Bool_t emcalfound = kFALSE, sdigitizerfound = kFALSE ; 
-    
-    while ( (branch = static_cast<TBranch*>(next())) && (!emcalfound || !sdigitizerfound) ) {
-      if ( (strcmp(branch->GetName(), "EMCAL")==0) && (strcmp(branch->GetTitle(), fSDigitsTitle)==0) ) {
-       emcalfound = kTRUE ;
-       sdigitsBranch = branch ; 
-      }
-      
-      else if ( (strcmp(branch->GetName(), "AliEMCALSDigitizer")==0) && (strcmp(branch->GetTitle(), fSDigitsTitle)==0) ) {
-       sdigitizerfound = kTRUE ; 
-       sdigitizerBranch = branch ;
-      }
-    }
-    if ( !emcalfound || !sdigitizerfound ) {
-      if (fDebug)
-       cout << "WARNING: AliEMCALGetter::ReadSDigits -> Digits and/or Digitizer branch with name " <<  fSDigitsTitle
-            << " not found" << endl ;
-      return ; 
-    }   
-    
-    if ( !folder->FindObject(fSDigitsTitle) )  
-      PostSDigits(fSDigitsTitle,folder->GetName()) ;
-    sdigitsBranch->SetAddress(SDigitsRef(fSDigitsTitle,folder->GetName())) ;
-    sdigitsBranch->GetEntry(0) ;
-    
-    TString sdname(fSDigitsTitle) ;
-    sdname+=":" ;
-    sdname+=folder->GetName() ;
-    if(!SDigitizer(sdname) ) 
-      PostSDigitizer(fSDigitsTitle,folder->GetName()) ;
-
-    sdigitizerBranch->SetAddress(SDigitizerRef(sdname)) ;
-    sdigitizerBranch->GetEntry(0) ;
-    
-  }    
+   while ( (branch = static_cast<TBranch*>(next())) && (!emcalfound || !sdigitizerfound) ) {
+     if ( (strcmp(branch->GetName(), "EMCAL")==0) && (strcmp(branch->GetTitle(), fSDigitsTitle)==0) ) {
+       emcalfound = kTRUE ;
+       sdigitsBranch = branch ; 
+     }
+     
+     else if ( (strcmp(branch->GetName(), "AliEMCALSDigitizer")==0) && (strcmp(branch->GetTitle(), fSDigitsTitle)==0) ) {
+       sdigitizerfound = kTRUE ; 
+       sdigitizerBranch = branch ;
+     }
+   }
+   if ( !emcalfound || !sdigitizerfound ) {
+     if (fDebug)
+       cout << "WARNING: AliEMCALGetter::ReadSDigits -> Digits and/or Digitizer branch with name " <<  fSDigitsTitle
+           << " not found" << endl ;
+     return ; 
+   }   
+   
+   if ( !folder->FindObject(fSDigitsTitle) )  
+     PostSDigits(fSDigitsTitle,folder->GetName()) ;
+   sdigitsBranch->SetAddress(SDigitsRef(fSDigitsTitle,folder->GetName())) ;
+   sdigitsBranch->GetEntry(0) ;
+   
+   TString sdname(fSDigitsTitle) ;
+   sdname+=":" ;
+   sdname+=folder->GetName() ;
+   if(!SDigitizer(sdname) ) 
+     PostSDigitizer(fSDigitsTitle,folder->GetName()) ;
+   
+   sdigitizerBranch->SetAddress(SDigitizerRef(sdname)) ;
+   sdigitizerBranch->GetEntry(0) ;
+   
+  }
   
   // After SDigits have been read from all files, return to the first one
   
@@ -1617,6 +1833,7 @@ void AliEMCALGetter::ReadTreeS(Int_t event)
   }
   
 }
+
 //____________________________________________________________________________ 
 void AliEMCALGetter::ReadTreeS(TTree * treeS, Int_t input)
 {  // Read the summable digits fron treeS()  
@@ -1678,77 +1895,49 @@ void AliEMCALGetter::ReadPrimaries()
 {
   // Reads specific branches of primaries
   
-  fNPrimaries = gAlice->GetNtrack();
+  TClonesArray * ar = 0  ; 
+  if(! (ar = Primaries()) ) { 
+    PostPrimaries() ;
+    ar = Primaries() ; 
+  }
+  ar->Delete() ; 
+  
+  if (TreeK(fHeaderFile)) { // treeK found in header file
+    if (fDebug) 
+      cout << "INFO: AliEMCALGetter::ReadPrimaries -> TreeK found in " << fHeaderFile.Data() << endl ; 
+    fNPrimaries = gAlice->GetNtrack() ; 
   
-  //   //Check, is it necessary to open new files
-  //   TArrayI* events = fDigitizer->GetCurrentEvents() ; 
-  //   TClonesArray * filenames = fDigitizer->GetHeadersFiles() ;
-//   Int_t input ;
-//   for(input = 0; input < filenames->GetEntriesFast(); input++){
+  } else { // treeK not found in header file
 
-//     TObjString * filename = (TObjString *) filenames->At(input) ;
+    TString searchFileName("") ; 
 
-//     //Test, if this file already open
-//     TFile *file = (TFile*) gROOT->GetFile( filename->GetString() ) ;
-//     if(file == 0)
-//       file = new TFile( filename->GetString()) ;
-//     file->cd() ;
-    
-//     // Get Kine Tree from file
-// //     char treeName[20];
-// //     sprintf(treeName,"TreeK%d",events->At(input));
-// //     TTree * treeK = (TTree*)gDirectory->Get(treeName);
-// //     if (treeK) 
-// //       treeK->SetBranchAddress("Particles", &fParticleBuffer);
-// //     else    
-// //       cout << "AliEMCALGetter: cannot find Kine Tree for event:" << events->At(input) << endl;
-
-// //     // Create the particle stack
-// //     if(!fParticles) fParticles = new TClonesArray("TParticle",1000);
-// //     // Build the pointer list
-// //     if(fParticleMap) {     <----
-// //       fParticleMap->Clear();
-// //       fParticleMap->Expand(treeK->GetEntries());
-// //     } else
-// //       fParticleMap = new TObjArray(treeK->GetEntries());
-    
-//     // From gAlice->Particle(i) 
+    if (SDigitizer())  // SDigitizer found in header file
+      searchFileName = SDigitizer()->GetTitle() ;
 
+    else if (Digitizer())  // Digitizer found in header file
+      searchFileName = Digitizer()->GetHitsFileName() ; 
 
-// //   if(!(*fParticleMap)[i]) {
-// //     Int_t nentries = fParticles->GetEntries();
+    else if (Clusterizer())  // Clusterizer found in header file
+      searchFileName = Clusterizer()->GetHitsFileName() ; 
     
-// //     // algorithmic way of getting entry index
-// //     // (primary particles are filled after secondaries)
-// //     Int_t entry;
-// //     if (i<fHeader.GetNprimary())
-// //       entry = i+fHeader.GetNsecondary();
-// //     else 
-// //       entry = i-fHeader.GetNprimary();
+    if (TreeK(searchFileName)) { //found TreeK in the file which contains the hits
+      if (fDebug) 
+       cout << "INFO: AliEMCALGetter::ReadPrimaries -> TreeK found in " << searchFileName.Data() << endl ; 
+      fAlice->GetEvent(EventNumber()) ; 
+      fNPrimaries = fAlice->GetNtrack() ; 
       
-// //     // only check the algorithmic way and give
-// //     // the fatal error if it is wrong
-// //     if (entry != fParticleFileMap[i]) {
-// //       Fatal("Particle",
-// //         "!!!! The algorithmic way is WRONG: !!!\n entry: %d map: %d",
-// //  entry, fParticleFileMap[i]); 
-// //     }  
-      
-// //     fTreeK->GetEntry(fParticleFileMap[i]);
-// //     new ((*fParticles)[nentries]) TParticle(*fParticleBuffer);
-// //     fParticleMap->AddAt((*fParticles)[nentries],i);
-// //   }
-// //   return (TParticle *) (*fParticleMap)[i];
-
-   
+    } else {
+      cerr << "ERROR: AliEMCALGetter::ReadPrimaries -> TreeK not  found " << endl ; 
+      return ;
+    }
     
-//   }
-
-
-//   //scan over opened files and read corresponding TreeK##
-
-  return ;
+  }
+  Int_t index = 0 ; 
+  for (index = 0 ; index < fNPrimaries; index++) { 
+    new ((*ar)[index]) TParticle(*(Primary(index)));
+  }
 }
+
 //____________________________________________________________________________ 
 void AliEMCALGetter::Event(const Int_t event, const char* opt)
 {
@@ -1760,24 +1949,26 @@ void AliEMCALGetter::Event(const Int_t event, const char* opt)
   }
   gAlice->GetEvent(event) ;
 
-  if(strstr(opt,"H") )
-    ReadTreeH() ;
+  // Carefull the order of reading is important 
   
-  if(strstr(opt,"S") )
-    ReadTreeS(event) ;
+  if( strstr(opt,"R") )
+    ReadTreeR() ;
 
   if( strstr(opt,"D") )
     ReadTreeD() ;
 
-  if( strstr(opt,"R") )
-    ReadTreeR() ;
+  if(strstr(opt,"S") )
+    ReadTreeS(event) ;
+
+  if(strstr(opt,"H") )
+    ReadTreeH() ;
 
  // if( strstr(opt,"Q") )
   //  ReadTreeQA() ;
 
// if( strstr(opt,"P") || (strcmp(opt,"")==0) )
//   ReadPrimaries() ;
-
+  if( strstr(opt,"P") || (strcmp(opt,"")==0) )
+    ReadPrimaries() ;
+  
 }
 
 //____________________________________________________________________________ 
@@ -1863,7 +2054,7 @@ TObject * AliEMCALGetter::ReturnO(TString what, TString name, TString file) cons
 */
   if (!emcalO) {
     if(fDebug)
-      cerr << "WARNING : AliEMCALGetter::ReturnO -> Object " << what << " not found in " << folder->GetName() << endl ; 
+      cout << "WARNING : AliEMCALGetter::ReturnO -> Object " << what << " not found in " << folder->GetName() << endl ; 
     return 0 ;
   }
   return emcalO ;
@@ -1944,7 +2135,7 @@ const TTask * AliEMCALGetter::ReturnT(TString what, TString name) const
 void AliEMCALGetter::RemoveTask(TString opt, TString name) const 
 {
   // remove a task from the folder
-  // path is fTasksFolder/SDigitizer/PHOS/name
+  // path is fTasksFolder/SDigitizer/EMCAL/name
 
   TTask * task  = 0 ; 
   TTask * emcal = 0 ; 
index db11014f6216af290e7d4a32e41438057e65af17..310b6f0ae16832f76dc5f449c260fb1f327e8910 100644 (file)
@@ -65,6 +65,7 @@ class AliEMCALGetter : public TObject {
   void CloseFile() ;  
   const TFolder * Folder(const TString what) const ;
   const Bool_t HasFailed(void) const {return fFailed ;} 
+  Bool_t PostPrimaries(void ) const ;  
   Bool_t PostHits(void ) const ;  
   Bool_t PostSDigits(      const char * name,  const char * file = 0) const ;  
   Bool_t PostDigits(       const char * name ) const ;  
@@ -111,10 +112,12 @@ class AliEMCALGetter : public TObject {
   
   
   // Hits
+  TTree *               TreeH(TString filename="") ; 
   const TClonesArray *  Hits(void) { return static_cast<const TClonesArray*>(ReturnO("Hits")) ; }
-  const AliEMCALHit * Hit(Int_t index)  { return static_cast<const AliEMCALHit*>(Hits()->At(index) );}
+  const AliEMCALHit *   Hit(Int_t index)  { return static_cast<const AliEMCALHit*>(Hits()->At(index) );}
   
   // SDigits
+  TTree *         TreeS(TString filename="") ; 
   TClonesArray *  SDigits(const char * name = 0, const char * file=0) { 
     return static_cast<TClonesArray*>(ReturnO("SDigits", name, file)) ; 
   }
@@ -125,7 +128,8 @@ class AliEMCALGetter : public TObject {
   }
  
   // Digits
-   TClonesArray *  Digits(const char * name = 0)const  { 
+  TTree *         TreeD(TString filename="") ; 
+  TClonesArray *  Digits(const char * name = 0)const  { 
     return static_cast<TClonesArray*>(ReturnO("Digits", name)) ; 
   }
   const AliEMCALDigit *  Digit(Int_t index) { return static_cast<const AliEMCALDigit *>(Digits()->At(index)) ;}
@@ -159,6 +163,7 @@ class AliEMCALGetter : public TObject {
       //             { return (AliEMCALPID*)(ReturnT("PID", name)) ; }
 
   // Primaries
+  TTree *                     TreeK(TString filename="") ; 
   const TParticle *           Primary(Int_t index) const ;
   const Int_t                 NPrimaries()const { return fNPrimaries; }
 
@@ -189,6 +194,7 @@ class AliEMCALGetter : public TObject {
   //void ReadTreeQA() ;
   void ReadPrimaries() ;
 
+  TObject ** PrimariesRef(void) const ;
   TObject ** HitsRef(void) const ;
   TObject ** SDigitsRef(const char * name, const char * file = 0 ) const;
   TObject ** DigitsRef (const char * name)   const ;
@@ -218,11 +224,13 @@ class AliEMCALGetter : public TObject {
   Bool_t         fFailed ;            //! true if file is not opened and/or galice not found
   Int_t          fDebug ;             // Debug level
 
+  AliRun *       fAlice ;             //! needed to read TreeK if in an other file than fHeaderFile
   Int_t          fNPrimaries ;        //! # of primaries
   
   TObjArray *    fPrimaries ;         //! list of lists of primaries-for the case of mixing
 
   TFolder *      fModuleFolder ;      //!Folder that contains the modules 
+  TFolder *      fPrimariesFolder ;   //!Folder that contains the Primary Particles 
   TFolder *      fHitsFolder ;        //!Folder that contains the Hits 
   TFolder *      fSDigitsFolder ;     //!Folder that contains the SDigits 
   TFolder *      fDigitsFolder ;      //!Folder that contains the Digits 
index 2cef5a424f5b4f3152db035a0f8bd84eff899834..a355eea5f77106586111375722688f0f04a4b922 100644 (file)
@@ -36,6 +36,9 @@
 #include "AliRun.h" 
 #include "AliPHOSClusterizer.h"
 #include "AliHeader.h" 
+#include "AliPHOSGetter.h"
+#include "AliPHOSSDigitizer.h"
+#include "AliPHOSDigitizer.h"
 
 ClassImp(AliPHOSClusterizer)
 
@@ -44,6 +47,10 @@ ClassImp(AliPHOSClusterizer)
 {
   // ctor
   fSplitFile= 0 ; 
+  fHitsFileName = "" ; 
+  fSDigitsFileName = "" ; 
+  fDigitsFileName = "" ; 
+
 }
 
 //____________________________________________________________________________
@@ -52,7 +59,13 @@ TTask(name, headerFile)
 {
   // ctor
   fSplitFile= 0 ; 
-
+  fDigitsFileName = headerFile ; 
+  AliPHOSGetter * gime = AliPHOSGetter::GetInstance(headerFile, name) ; 
+  gime->Event(0,"D") ; 
+  fSDigitsFileName = gime->Digitizer()->GetTitle() ; 
+  gime = AliPHOSGetter::GetInstance(fSDigitsFileName, name) ; 
+  gime->Event(0,"S") ; 
+  fHitsFileName = gime->SDigitizer()->GetTitle() ; 
 }
 
 //____________________________________________________________________________
index b3238251371832a6ea1e2b5fd4884120689a4838..d73d63c2a4687937d12211b8f04578254dc6ffd1 100644 (file)
@@ -27,6 +27,10 @@ public:
   AliPHOSClusterizer(const char * headerFile, const char * name) ;
   virtual ~AliPHOSClusterizer() ; // dtor
 
+  const TString GetHitsFileName() const { return fHitsFileName ; }
+  const TString GetSDigitsFileName() const { return fSDigitsFileName ; }
+  const TString GetDigitsFileName() const { return fDigitsFileName ; }
+
   virtual Float_t GetEmcClusteringThreshold()const {cout << "Not Defined" << endl ; return 0. ; }  
   virtual Float_t GetEmcLocalMaxCut()const {cout << "Not Defined" << endl ; return 0. ; } 
   virtual Float_t GetEmcLogWeight()const {cout << "Not Defined" << endl ; return 0. ; } 
@@ -56,8 +60,12 @@ public:
 
 protected:
 
+  TString fHitsFileName ;          // file name that contains the original hits
+  TString fSDigitsFileName ;       // file name that contains the original SDigits
+  TString fDigitsFileName ;        // file name that contains the original Digits
   TFile * fSplitFile ;             //! file in which RecPoints will eventually be stored
 
+
   ClassDef(AliPHOSClusterizer,2)  // Clusterization algorithm class 
 
 } ;
index 0d057f09885972634d6c25575b052e0adaacd267..f4ca01aeffb91c2a69e981b3b25ab121fa5fdd37 100644 (file)
@@ -90,8 +90,11 @@ ClassImp(AliPHOSDigitizer)
   // ctor
 
   InitParameters() ; 
-  fDefaultInit = kTRUE ; 
-}
+  fDefaultInit = kTRUE ;
+  fHitsFileName    = "" ;
+  fSDigitsFileName = "" ; 
+ }
 
 //____________________________________________________________________________ 
 AliPHOSDigitizer::AliPHOSDigitizer(const char *headerFile,const char * name)
@@ -105,7 +108,10 @@ AliPHOSDigitizer::AliPHOSDigitizer(const char *headerFile,const char * name)
   InitParameters() ; 
   Init() ;
   fDefaultInit = kFALSE ; 
-  
+  fSDigitsFileName = headerFile ; 
+  AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ; 
+  gime->Event(0, "S") ; 
+  fHitsFileName = gime->SDigitizer()->GetTitle() ; 
 }
 
 //____________________________________________________________________________ 
@@ -116,6 +122,16 @@ AliPHOSDigitizer::AliPHOSDigitizer(AliRunDigitizer * ard):AliDigitizer(ard)
   SetName("Default") ;
   InitParameters() ; 
   fDefaultInit = kTRUE ; 
+  
+  const AliRunDigitizer * rd = Manager() ; 
+  if (rd) {
+    AliStream * st = static_cast<AliStream*>(rd->GetInputStreams()->At(0))  ;
+    fSDigitsFileName = st->GetFileNames()->At(0)->GetName() ;
+  }
+  AliPHOSGetter * gime = AliPHOSGetter::GetInstance(fSDigitsFileName, GetName()) ; 
+  gime->Event(0,"S") ; 
+  fHitsFileName = gime->SDigitizer()->GetTitle() ; 
+  
 }
 
 //____________________________________________________________________________ 
index 3d82c3d810e5de54f12eeb11295fa1b375dfb693..7423d01d9b0b1d73d3c37cc90945456070a0d946 100644 (file)
@@ -67,6 +67,8 @@ public:
 
   //General
   const Int_t   GetDigitsInRun()  const { return fDigitsInRun ;}  
+  const TString GetHitsFileName() const { return fHitsFileName ; }
+  const TString GetSDigitsFileName() const { return fSDigitsFileName ; }
 
   void    MixWith(const char* HeaderFile) ; // Add another one file to mix
   void    Print(Option_t* option)const ;
@@ -94,6 +96,8 @@ private:
 
 private:
 
+  TString fHitsFileName ;           // file name that contains the original hits
+  TString fSDigitsFileName ;        // file name that contains the original SDigits
   Bool_t  fDefaultInit;             //! Says if the task was created by defaut ctor (only parameters are initialized)
   Int_t   fEmcCrystals ;            // Number of EMC crystalls in the given geometry
 
index a2656621f1d512c06e71375cf5befd6f4bc5ef60..1d92e277a23eea690270858d2218b50a89502084 100644 (file)
@@ -81,6 +81,8 @@ AliPHOSGetter::AliPHOSGetter(const char* headerFile, const char* branchTitle )
   //Initialize  all lists
 
   fDebug = 0 ; 
+
+  fAlice = 0 ; 
   
   fHeaderFile         = headerFile ; 
   fBranchTitle        = branchTitle ;
@@ -170,6 +172,8 @@ void AliPHOSGetter::CloseFile()
 {
   delete gAlice ;  
   gAlice = 0 ; 
+  delete fAlice ; 
+  fAlice = 0 ; 
 }
 
 //____________________________________________________________________________ 
@@ -1333,21 +1337,128 @@ TObject** AliPHOSGetter::AlarmsRef(void) const
   return fQAFolder->GetListOfFolders()->GetObjectRef(phosFolder) ;
 }
 
+
+//____________________________________________________________________________ 
+TTree * AliPHOSGetter::TreeK(TString filename)  
+{
+
+  // returns TreeK from file filename
+  // usefull in case of split file
+
+  if ( filename.IsNull() ) 
+    filename = fHeaderFile ; 
+
+  TFile * file = 0 ; 
+  // file = static_cast<TFile*>(gROOT->GetFile(filename.Data() ) ) ;
+  if (!file) {  // file not open yet
+    //   file->Close() ; 
+    file = TFile::Open(filename.Data(), "read") ; 
+    delete fAlice ; 
+    fAlice = static_cast<AliRun *>(file->Get("gAlice")) ; 
+  }
+
+  TString treeName("TreeK") ; 
+  treeName += EventNumber()  ; 
+  TTree * tree = static_cast<TTree *>(file->Get(treeName.Data())) ;
+  if (!tree && fDebug)  
+    cout << "WARNING: AliPHOSGetter::TreeK -> " << treeName.Data() << " not found in " << filename.Data() << endl ; 
+  
+  return tree ;                      
+}
+
+//____________________________________________________________________________ 
+TTree * AliPHOSGetter::TreeH(TString filename)  
+{
+
+  // returns TreeH from file filename
+  // usefull in case of split file
+
+  if ( filename.IsNull() ) 
+    filename = fHeaderFile ; 
+
+  TFile * file = 0 ; 
+  file = static_cast<TFile*>(gROOT->GetFile(filename.Data() ) ) ;
+  if (!file) { // file not open yet
+    file = TFile::Open(filename.Data(), "read") ; 
+  }
+  TString treeName("TreeH") ; 
+  treeName += EventNumber()  ; 
+  TTree * tree = static_cast<TTree *>(file->Get(treeName.Data())) ;
+  if (!tree && fDebug)  
+    cout << "WARNING: AliPHOSGetter::TreeH -> " << treeName.Data() << " not found in " << filename.Data() << endl ; 
+  
+  return tree ;                      
+}
+
 //____________________________________________________________________________ 
-const TParticle * AliPHOSGetter::Primary(Int_t index) const
+TTree * AliPHOSGetter::TreeS(TString filename)  
+{
+
+  // returns TreeS from file filename
+  // usefull in case of split file
+
+  if ( filename.IsNull() ) 
+    filename = fHeaderFile ; 
+
+  TFile * file = 0 ; 
+  file = static_cast<TFile*>(gROOT->GetFile(filename.Data() ) ) ;
+  if (!file) { // file not open yet
+    file = TFile::Open(filename.Data(), "read") ; 
+  }
+  TString treeName("TreeS") ; 
+  treeName += EventNumber()  ; 
+  TTree * tree = static_cast<TTree *>(file->Get(treeName.Data())) ;
+  if (!tree && fDebug)  
+    cout << "WARNING: AliPHOSGetter::TreeS -> " << treeName.Data() << " not found in " << filename.Data() << endl ; 
+  
+  return tree ;                      
+}
+
+//____________________________________________________________________________ 
+TTree * AliPHOSGetter::TreeD(TString filename)  
+{
+
+  // returns TreeD from file filename
+  // usefull in case of split file
+
+  if ( filename.IsNull() ) 
+    filename = fHeaderFile ; 
+
+  TFile * file = 0 ; 
+  file = static_cast<TFile*>(gROOT->GetFile(filename.Data() ) ) ;
+  if (!file) { // file not open yet
+    file = TFile::Open(filename.Data(), "read") ; 
+  }
+  TString treeName("TreeD") ; 
+  treeName += EventNumber()  ; 
+  TTree * tree = static_cast<TTree *>(file->Get(treeName.Data())) ;
+  if (!tree && fDebug)  
+    cout << "WARNING: AliPHOSGetter::TreeD -> " << treeName.Data() << " not found in " << filename.Data() << endl ; 
+  
+  return tree ;                      
+}
+
+//____________________________________________________________________________ 
+const TParticle * AliPHOSGetter::Primary(Int_t index) 
 {
   // Return primary particle numbered by <index>
 
   if(index < 0) 
     return 0 ;
-  TParticle *  p = gAlice->Particle(index) ; 
-//   if (p->GetFirstMother() != -1 ) {
-//     cout << "AliPHOSGetter::Primary : Not a primary " << endl ; 
-//   }
+  TParticle *  p = 0 ;
+  if (fAlice) 
+    p = fAlice->Particle(index) ; 
+  else 
+    p = gAlice->Particle(index) ; 
+  //   if (p->GetFirstMother() != -1 ) {
+  //     cout << "AliPHOSGetter::Primary : Not a primary " << endl ; 
+  //   }
+  
   return p ; 
+    
   
   
-//   Int_t primaryIndex = index % 10000000 ; 
+  //   Int_t primaryIndex = index % 10000000 ; 
 //   Int_t primaryList = (Int_t ) ((index-primaryIndex)/10000000.)  ;
   
 //   if ( primaryList > 0  ) {
@@ -1384,12 +1495,33 @@ const TParticle * AliPHOSGetter::Secondary(TParticle* p, Int_t index) const
 Int_t AliPHOSGetter::ReadTreeD()
 {
   // Read the digit tree gAlice->TreeD()  
-  if(gAlice->TreeD()== 0){
-    cerr <<   "WARNING: AliPHOSGetter::ReadTreeD: can not read TreeD " << endl ;
-  return 1;
+  
+  TTree * treeD = gAlice->TreeD() ;
+
+  if(!treeD) { // TreeD not found in header file
+    
+    if (fDebug) 
+      cout <<   "WARNING: AliPHOSGetter::ReadTreeD -> Cannot find TreeD in " << fHeaderFile << endl ;
+    
+    TString searchFileName("") ; 
+    
+    if (Digitizer())  // Digitizer found in header file
+      searchFileName = Digitizer()->GetTitle() ; 
+    
+    else if (Clusterizer())  // Clusterizer found in header file
+      searchFileName = Clusterizer()->GetDigitsFileName() ; 
+    
+    if (treeD = TreeD(searchFileName)) { //found TreeD in the file which contains the hits
+      if (fDebug) 
+       cout << "INFO: AliPHOSGetter::ReadTreeD -> TreeD found in " << searchFileName.Data() << endl ; 
+      
+    } else {
+      cerr << "ERROR: AliPHOSGetter::ReadTreeD -> TreeD not found " << endl ; 
+      return 1;
+    }   
   }
   
-  TObjArray * lob = static_cast<TObjArray*>(gAlice->TreeD()->GetListOfBranches()) ;
+  TObjArray * lob = static_cast<TObjArray*>(treeD->GetListOfBranches()) ;
   TIter next(lob) ; 
   TBranch * branch = 0 ; 
   TBranch * digitsbranch = 0 ; 
@@ -1422,7 +1554,7 @@ Int_t AliPHOSGetter::ReadTreeD()
   
   
   // read  the Digitizer
-  RemoveTask("D", fDigitsTitle) ;
+  RemoveTask("D", fDigitsTitle) ; // I do not understand why I need that 
   if(!Digitizer(fDigitsTitle))
     PostDigitizer(fDigitsTitle) ;
   digitizerbranch->SetAddress(DigitizerRef(fDigitsTitle)) ;
@@ -1435,13 +1567,36 @@ Int_t AliPHOSGetter::ReadTreeD()
 Int_t AliPHOSGetter::ReadTreeH()
 {
   // Read the first entry of PHOS branch in hit tree gAlice->TreeH()
+  
+  TTree * treeH = gAlice->TreeH() ;
 
-  if(gAlice->TreeH()== 0){
-    cerr <<   "WARNING: AliPHOSGetter::ReadTreeH: -> Cannot read TreeH " << endl ;
-    return 1;
+  if(!treeH) {// TreeH not found in header file
+    if (fDebug) 
+      cout <<   "WARNING: AliPHOSGetter::ReadTreeH -> Cannot find TreeH in " << fHeaderFile << endl ;
+    
+    TString searchFileName("") ; 
+    
+    if (SDigitizer())  // SDigitizer found in header file
+       searchFileName = SDigitizer()->GetTitle() ;
+    else if (Digitizer())  // Digitizer found in header file
+      searchFileName = Digitizer()->GetHitsFileName() ; 
+    
+    else if (Clusterizer())  // Clusterizer found in header file
+      searchFileName = Clusterizer()->GetHitsFileName() ; 
+      
+    if (treeH = TreeH(searchFileName)) { //found TreeH in the file which contains the hits
+      if (fDebug) 
+       cout << "INFO: AliPHOSGetter::ReadTreeH -> TreeH found in " << searchFileName.Data() << endl ; 
+      
+    } else {
+      cerr << "ERROR: AliPHOSGetter::ReadTreeH -> TreeH not found " << endl ; 
+      return 1;
+    }  
   }
   
-  TBranch * hitsbranch = static_cast<TBranch*>(gAlice->TreeH()->GetBranch("PHOS")) ;
+  TBranch * hitsbranch = static_cast<TBranch*>(treeH->GetBranch("PHOS")) ;
   if ( !hitsbranch ) {
     if (fDebug)
       cout << "WARNING:  AliPHOSGetter::ReadTreeH -> Cannot find branch PHOS" << endl ; 
@@ -1546,7 +1701,8 @@ Int_t AliPHOSGetter::ReadTreeR(Bool_t any)
   // See AliPHOSPIDv1    
 
   if(gAlice->TreeR()== 0){
-    cerr <<   "WARNING: AliPHOSGetter::ReadTreeR: can not read TreeR " << endl ;
+    if (fDebug) 
+      cout <<   "WARNING: AliPHOSGetter::ReadTreeR -> Cannot find TreeR" << endl ;
     return 1;
   }
   // RecPoints 
@@ -1709,9 +1865,30 @@ Int_t AliPHOSGetter::ReadTreeS(Int_t event)
       treeName += event ; 
       treeS = dynamic_cast<TTree*>(gDirectory->Get(treeName.Data()));
     }
-    if(treeS==0){
-      cerr << "WARNING: AliPHOSGetter::ReadTreeS There is no SDigit Tree" << endl;
+    if(!treeS){ // TreeS not found in header file
+
+      if (fDebug)
+       cout << "WARNING: AliPHOSGetter::ReadTreeS -> Cannot find TreeS in " << fHeaderFile << endl;
+    
+      TString searchFileName("") ; 
+
+      if (SDigitizer())  // SDigitizer found in header file
+       searchFileName = SDigitizer()->GetTitle() ;
+      else if (Digitizer())  // Digitizer found in header file
+       searchFileName = Digitizer()->GetSDigitsFileName() ; 
+      
+      else if (Clusterizer())  // Clusterizer found in header file
+       searchFileName = Clusterizer()->GetSDigitsFileName() ; 
+      
+      if (treeS = TreeS(searchFileName)) { //found TreeS in the file which contains the hits
+       if (fDebug) 
+         cout << "INFO: AliPHOSGetter::ReadTreeS -> TreeS found in " << searchFileName.Data() << endl ; 
+       
+      } else {
+      cerr << "ERROR: AliPHOSGetter::ReadTreeS -> TreeS not found " << endl ; 
       return 1;
+      }
     }
     
     //set address of the SDigits and SDigitizer
@@ -1834,12 +2011,42 @@ void AliPHOSGetter::ReadPrimaries()
   }
   ar->Delete() ; 
   
-  fNPrimaries = gAlice->GetNtrack() ; 
+  if (TreeK(fHeaderFile)) { // treeK found in header file
+    if (fDebug) 
+      cout << "INFO: AliPHOSGetter::ReadPrimaries -> TreeK found in " << fHeaderFile.Data() << endl ; 
+    fNPrimaries = gAlice->GetNtrack() ; 
+  
+  } else { // treeK not found in header file
+
+    TString searchFileName("") ; 
+
+    if (SDigitizer())  // SDigitizer found in header file
+      searchFileName = SDigitizer()->GetTitle() ;
+
+    else if (Digitizer())  // Digitizer found in header file
+      searchFileName = Digitizer()->GetHitsFileName() ; 
+
+    else if (Clusterizer())  // Clusterizer found in header file
+      searchFileName = Clusterizer()->GetHitsFileName() ; 
+    
+    if (TreeK(searchFileName)) { //found TreeK in the file which contains the hits
+      if (fDebug) 
+       cout << "INFO: AliPHOSGetter::ReadPrimaries -> TreeK found in " << searchFileName.Data() << endl ; 
+      fAlice->GetEvent(EventNumber()) ; 
+      fNPrimaries = fAlice->GetNtrack() ; 
+      
+    } else {
+      cerr << "ERROR: AliPHOSGetter::ReadPrimaries -> TreeK not  found " << endl ; 
+      return ;
+    }
+    
+  }
   Int_t index = 0 ; 
   for (index = 0 ; index < fNPrimaries; index++) { 
     new ((*ar)[index]) TParticle(*(Primary(index)));
   }
 }
+
 //____________________________________________________________________________ 
 void AliPHOSGetter::Event(const Int_t event, const char* opt)
 {
@@ -1861,25 +2068,24 @@ void AliPHOSGetter::Event(const Int_t event, const char* opt)
   Int_t rvRD = 0 ;
   Int_t rvRR = 0 ;
 
-  if(strstr(opt,"H") )
-    rvRH = ReadTreeH() ;
-
-  if(strstr(opt,"S") )
-    rvRS = ReadTreeS(event) ;
+  if( strstr(opt,"R") )
+    rvRR = ReadTreeR(any) ;
 
   if( strstr(opt,"D") )
     rvRD = ReadTreeD() ;
 
-  if( strstr(opt,"R") )
-    rvRR = ReadTreeR(any) ;
+  if(strstr(opt,"S") )
+    rvRS = ReadTreeS(event) ;
 
+  if(strstr(opt,"H") )
+    rvRH = ReadTreeH() ;
+   
   if( strstr(opt,"Q") )
     ReadTreeQA() ;
-
   if( strstr(opt,"P") || (strcmp(opt,"")==0) )
-    if ( gAlice->Stack() ) 
-      ReadPrimaries() ;
-
+    ReadPrimaries() ;
+  
 }
 
 //____________________________________________________________________________ 
index 42af48356cc056904468e5c81e4b08d2a613b49b..fafceae760240c03efe763481078d1a8b5be2294 100644 (file)
@@ -112,11 +112,14 @@ class AliPHOSGetter : public TObject {
 
   // Primaries
   TClonesArray *  Primaries(void) const { return (TClonesArray*)(ReturnO("Primaries")) ; }
   // Hits
+  TTree *               TreeH(TString filename="") ; 
   const TClonesArray *  Hits(void) { return static_cast<const TClonesArray*>(ReturnO("Hits")) ; }
-  const AliPHOSHit * Hit(Int_t index)  { return static_cast<const AliPHOSHit*>(Hits()->At(index) );}
+  const AliPHOSHit *    Hit(Int_t index)  { return static_cast<const AliPHOSHit*>(Hits()->At(index) );}
   
   // SDigits
+  TTree *         TreeS(TString filename="") ; 
   TClonesArray *  SDigits(const char * name = 0, const char * file=0) { 
     return static_cast<TClonesArray*>(ReturnO("SDigits", name, file)) ; 
   }
@@ -127,6 +130,7 @@ class AliPHOSGetter : public TObject {
   }
   
   // Digits
+  TTree *         TreeD(TString filename="") ; 
   TClonesArray *  Digits(const char * name = 0)const  { 
     return static_cast<TClonesArray*>(ReturnO("Digits", name)) ; 
   }
@@ -176,7 +180,8 @@ class AliPHOSGetter : public TObject {
   }
   
   // Primaries
-  const TParticle *           Primary(Int_t index) const ;
+  TTree *                     TreeK(TString filename="") ; 
+  const TParticle *           Primary(Int_t index) ;
   const Int_t                 NPrimaries()const { return fNPrimaries; }
   const TParticle *           Secondary(TParticle * p, Int_t index=1) const ;
   
@@ -239,6 +244,7 @@ private:
   Bool_t         fFailed ;            //! set if file not opend or galice not found
   Int_t          fDebug ;             // Debug level
 
+  AliRun *       fAlice ;             //! needed to read TreeK if in an other file than fHeaderFile
   Int_t          fNPrimaries ;        //! # of primaries
   
   TObjArray *    fPrimaries ;         //! list of lists of primaries-for the case of mixing
@@ -251,7 +257,7 @@ private:
   TFolder *      fRecoFolder ;        //!Folder that contains the reconstructed objects (RecPoints, TrackSegments, RecParticles) 
   TFolder *      fQAFolder ;          //!Folder that contains the QA objects  
   TFolder *      fTasksFolder ;       //!Folder that contains the Tasks (sdigitizer, digitizer, reconstructioner)
+   
   static AliPHOSGetter * fgObjGetter; // pointer to the unique instance of the singleton 
 
   ClassDef(AliPHOSGetter,1)  // Algorithm class that provides methods to retrieve objects from a list knowing the index