]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EMCAL/AliEMCALGetter.cxx
Added proper way to delete tree in BranchList
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALGetter.cxx
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 /* $Log:
19    29.05.2001 Yuri Kharlov:
20               Everywhere reading the treese TTree->GetEvent(i)
21               is replaced by reading the branches TBranch->GetEntry(0)
22 */
23 /* $Log:
24    08.2002 Dmitri Peressounko:
25
26 */
27
28 //_________________________________________________________________________
29 //  A singleton. This class should be used in the analysis stage to get 
30 //  reconstructed objects: Digits, RecPoints, TrackSegments and RecParticles,
31 //  instead of directly reading them from galice.root file. This container 
32 //  ensures, that one reads Digits, made of these particular digits, RecPoints, 
33 //  made of these particular RecPoints, TrackSegments and RecParticles. 
34 //  This becomes non trivial if there are several identical branches, produced with
35 //  different set of parameters. 
36 //
37 //  An example of how to use (see also class AliEMCALAnalyser):
38 //  AliEMCALGetter * gime = AliEMCALGetter::GetInstance("galice.root","test") ;
39 //  for(Int_t irecp = 0; irecp < gime->NRecParticles() ; irecp++)
40 //     AliEMCALRecParticle * part = gime->RecParticle(1) ;
41 //     ................
42 //  please->GetEvent(event) ;    // reads new event from galice.root
43 //                  
44 //*-- Author: Yves Schutz (SUBATECH) & Dmitri Peressounko (RRC KI & SUBATECH)
45 //*--         Completely redesigned by Dmitri Peressounko March 2001  
46 //
47 //*-- YS June 2001 : renamed the original AliEMCALIndexToObject and make
48 //*--         systematic usage of TFolders without changing the interface     
49 //*-- YS August 2002 : clone PHOS as closely as possible and intoduction
50 //                     of new  IO (à la PHOS)
51 //////////////////////////////////////////////////////////////////////////////
52
53 // --- ROOT system ---
54 #include "TFile.h"
55 #include "TTree.h"
56 #include "TROOT.h"
57 #include "TObjString.h"
58 #include "TFolder.h"
59 #include "TParticle.h"
60
61 // --- Standard library ---
62 #include <iostream.h>
63
64 // --- AliRoot header files ---
65 #include "AliRun.h"
66 #include "AliConfig.h"
67 #include "AliEMCALGetter.h"
68 #include "AliEMCAL.h"
69 #include "AliEMCALDigitizer.h"
70 #include "AliEMCALSDigitizer.h"
71 #include "AliEMCALClusterizerv1.h"
72 //#include "AliEMCALTrackSegmentMakerv1.h"
73 //#include "AliEMCALTrackSegment.h"
74 //#include "AliEMCALPIDv1.h" 
75 #include "AliEMCALGeometry.h"
76
77 ClassImp(AliEMCALGetter)
78   
79   AliEMCALGetter * AliEMCALGetter::fgObjGetter = 0 ; 
80   TFile * AliEMCALGetter::fFile = 0 ; 
81
82 //____________________________________________________________________________ 
83 AliEMCALGetter::AliEMCALGetter(const char* headerFile, const char* branchTitle, const Bool_t toSplit)
84 {
85   // This is the ctor called by GetInstance and the only one that can be used 
86   
87   if ( fHeaderFile.Contains("_") ) {
88     cerr << "AliEMCALGetter::AliEMCALGetter -> Invalid file name (_ not allowed) " << fHeaderFile.Data() << endl ;
89     abort() ; 
90   }
91   
92   //Initialize  all data
93
94   fFailed = kFALSE ;   
95   fDebug  = 0 ; 
96   fAlice  = 0 ; 
97
98   fToSplit    = toSplit ;
99   fHeaderFile = headerFile ; 
100
101   fPrimaries = new TObjArray(1) ;
102
103   fModuleFolder    = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Run/Configuration/Modules")); 
104   fPrimariesFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/RunMC/Event/Data")); 
105   fHitsFolder      = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/RunMC/Event/Data/Hits")); 
106   fSDigitsFolder   = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/RunMC/Event/Data/SDigits")); 
107   fDigitsFolder    = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Run/Event/Data")); 
108   fRecoFolder      = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Run/Event/RecData")); 
109   //fQAFolder      = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Run/Conditions/QA")); 
110   fTasksFolder     = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Tasks")) ; 
111
112   //Set titles to branches and create PHOS specific folders
113   SetTitle(branchTitle) ;
114   
115   if ( fHeaderFile != "aliroot"  ) { // to call the getter without a file
116     //open headers file
117     fFile = static_cast<TFile*>(gROOT->GetFile(fHeaderFile.Data() ) ) ;
118   
119     if(!fFile){    //if file was not opened yet, read gAlice
120       fFile = TFile::Open(fHeaderFile.Data(), "update") ;   
121       if (!fFile->IsOpen()) {
122         cerr << "ERROR : AliEMCALGetter::AliEMCALGetter -> Cannot open " << fHeaderFile.Data() << endl ; 
123         fFailed = kTRUE ;
124         return ;  
125       }
126       gAlice = static_cast<AliRun *>(fFile->Get("gAlice")) ;
127     }
128   }
129   
130   if (!gAlice) {
131     cerr << "ERROR : AliEMCALGetter::AliEMCALGetter -> Cannot find gAlice in " << fHeaderFile.Data() << endl ; 
132     fFailed = kTRUE ;
133     return ; 
134   }
135   if (!EMCAL()) {
136     if (fDebug)
137       cout << "INFO: AliEMCALGetter -> Posting EMCAL to Folders" << endl ; 
138     if (gAlice->GetDetector("EMCAL")) {
139       AliConfig * conf = AliConfig::Instance() ;
140       conf->Add(static_cast<AliDetector*>(gAlice->GetDetector("EMCAL"))) ; 
141       conf->Add(static_cast<AliModule*>(gAlice->GetDetector("EMCAL"))) ;
142     }
143     else 
144       cerr << "ERROR: AliEMCALGetter -> detector EMCAL not found" << endl ;
145   }
146   
147   fDebug=0;
148 }
149
150 //____________________________________________________________________________ 
151 AliEMCALGetter::~AliEMCALGetter()
152 {
153   if (fPrimaries) {
154     fPrimaries->Delete() ; 
155     delete fPrimaries ; 
156   }
157
158   TFolder * emcalF = dynamic_cast<TFolder *>(fSDigitsFolder->FindObject("EMCAL")) ;
159   TCollection * folderslist = emcalF->GetListOfFolders() ; 
160   TIter next(folderslist) ; 
161   TFolder * folder = 0 ; 
162   while ( (folder = static_cast<TFolder*>(next())) ) 
163     emcalF->Remove(folder) ; 
164
165   if (fFile) { 
166     fFile->Close() ;  
167     delete fFile ; 
168     fFile = 0 ;
169   }
170   fgObjGetter = 0 ; 
171
172 }
173
174 //____________________________________________________________________________ 
175 void AliEMCALGetter::CloseFile()
176 {
177   delete gAlice ;  
178   gAlice = 0 ; 
179   delete fAlice ; 
180   fAlice = 0 ; 
181 }
182
183 //____________________________________________________________________________ 
184 const TFolder * AliEMCALGetter::Folder(const TString what) const {
185
186   // returns the EMCAL folder required by what
187   // what = hits, sdigits, digits
188
189   if ( what == "hits" ) 
190     return dynamic_cast<const TFolder *>(fHitsFolder->FindObject("EMCAL")) ; 
191   else if ( what == "sdigits" ) 
192     return  dynamic_cast<const TFolder *>(fSDigitsFolder->FindObject("EMCAL")) ; 
193   else if ( what == "digits" ) 
194     return  dynamic_cast<const TFolder *>(fDigitsFolder->FindObject("EMCAL")) ; 
195   else {
196     cerr << "ERROR: AliEMCALGetter::GetFolder -> " << what.Data() << " illegal option (hits, sdigits, digits) " << endl ; 
197     return 0 ; 
198   }
199 }
200
201 //____________________________________________________________________________ 
202 AliEMCALGetter * AliEMCALGetter::GetInstance()
203 {
204   // Returns the pointer of the unique instance already defined
205   
206   if ( fgObjGetter ) {
207     return fgObjGetter ;
208   }
209   else {
210     // cout << "AliEMCALGetter::GetInstance ERROR: not yet initialized" << endl ;
211     return 0 ;
212   }
213 }
214
215 //____________________________________________________________________________ 
216 AliEMCALGetter * AliEMCALGetter::GetInstance(const char* headerFile,
217                                              const char* branchTitle,
218                                              const Bool_t toSplit)
219 {
220   // Creates and returns the pointer of the unique instance
221   // Must be called only when the environment has changed 
222
223   if(!fgObjGetter){
224     fgObjGetter = new AliEMCALGetter(headerFile,branchTitle,toSplit) ;
225     if(fgObjGetter->fFailed)
226       return 0;
227     else
228       return fgObjGetter ;
229   }
230
231   //First checks, if header file already opened
232   if(!fgObjGetter->fFile){
233      fgObjGetter = new AliEMCALGetter(headerFile,branchTitle,toSplit) ;
234     if(fgObjGetter->fFailed)
235       return 0;
236     else
237       return fgObjGetter ;
238   }
239  
240   if(fgObjGetter->fHeaderFile.CompareTo(headerFile)==0){ //Opened the same header file   
241     if((fgObjGetter->fBranchTitle.CompareTo(branchTitle) == 0)&&   //Open the same branch title
242        (toSplit==fgObjGetter->fToSplit)){                          //Nothing should be cleaned
243       return fgObjGetter ;
244     }
245     else{ //Clean all data and AliEMCAL...zers
246       if(fgObjGetter->fToSplit)
247         fgObjGetter->CloseSplitFiles() ;          
248       fgObjGetter->CleanWhiteBoard() ;
249       fgObjGetter->fToSplit = toSplit ;
250       fgObjGetter->SetTitle(branchTitle) ;
251       return fgObjGetter ;
252     }
253   }
254   else{  //Close already opened files, clean memory and open new header file
255     if(gAlice)
256       delete gAlice ;
257     gAlice= 0;
258     if(fgObjGetter->fFile){
259       fgObjGetter->fFile->Close() ;
260       fgObjGetter->fFile=0;
261     }
262     if(fgObjGetter->fToSplit)
263       fgObjGetter->CloseSplitFiles() ;
264     fgObjGetter->CleanWhiteBoard() ;    
265     fgObjGetter = new AliEMCALGetter(headerFile,branchTitle,toSplit) ;
266     return fgObjGetter ; 
267   }
268   return fgObjGetter ; 
269   
270 }
271
272 //____________________________________________________________________________ 
273 const Bool_t AliEMCALGetter::BranchExists(const TString recName) const
274 {
275   //Looks in the tree Tree"name" if branch with current name olready exists
276   
277   TString filename("") ;
278   TString name, dataname, zername;
279   if(recName == "SDigits"){
280     filename=fSDigitsFileName ;
281     name = "TreeS0" ;
282     dataname = "PHOS" ;
283     zername = "AliPHOSSDigitizer" ;
284   }
285   else
286     if(recName == "Digits"){
287       filename=fDigitsFileName ;
288       name = "TreeD0" ;
289       dataname = "PHOS" ;
290       zername = "AliPHOSDigitizer" ;
291     }
292     else
293       if(recName =="RecPoints"){
294         filename=fRecPointsFileName ;
295         name = "TreeR0" ;
296         dataname = "PHOSEmcRP" ;
297         zername = "AliPHOSClusterizer" ;
298       }
299       else
300         if(recName == "TrackSegments"){
301           filename=fTrackSegmentsFileName ;
302           name = "TreeR0" ;
303           dataname = "PHOSTS" ;
304           zername = "AliPHOSTrackSegmentMaker" ;
305         }        
306         else
307           if(recName == "RecParticles"){
308             filename= fRecParticlesFileName ;
309             name = "TreeR0" ;
310             dataname = "PHOSRP" ;
311             zername = "AliPHOSPID" ;
312           }
313           else
314             return kFALSE ;
315   
316   TFile * file ;
317   TTree * tree ;
318   if(fToSplit){
319     file = static_cast<TFile*>(gROOT->GetFile(filename.Data() ) ) ;
320     if(!file)
321       file = TFile::Open(fSDigitsFileName.Data(),"update");
322   }
323   else
324     file = fFile ;
325   
326   tree = (TTree *)file->Get(name.Data()) ;
327   
328   if(!tree ) 
329     return kFALSE ;
330
331   TObjArray * lob = static_cast<TObjArray*>(tree->GetListOfBranches()) ;
332   TIter next(lob) ; 
333   TBranch * branch = 0 ;  
334   TString titleName(fBranchTitle);
335   titleName+=":";
336   while ((branch = (static_cast<TBranch*>(next())))) {
337     TString branchName(branch->GetName() ) ; 
338     TString branchTitle(branch->GetTitle() ) ;  
339     if ( branchName.BeginsWith(dataname) && branchTitle.BeginsWith(fBranchTitle) ){  
340       cerr << "WARNING: AliEMCALGetter::BranchExists -> branch " << dataname.Data() << " with title " << fBranchTitle << " already exits in "
341            << name.Data() << endl;
342       return kTRUE ;
343     }
344     if ( branchName.BeginsWith(zername) &&  branchTitle.BeginsWith(titleName) ){
345       cerr << "WARNING: AliEMCALGetter::BranchExists -> branch AliEMCAL... with title " << branch->GetTitle() << " already exits in "
346            << name.Data() << endl;     
347       return kTRUE ; 
348     }
349   }
350     //We can't delete three if gAlice points to it... To be redisigned somehow???!!!
351   if(!fToSplit){
352     if(name.Contains("TreeS"))
353       if(tree!=gAlice->TreeS())
354         tree->Delete();
355     if(name.Contains("TreeD"))
356       if(tree!=gAlice->TreeD())
357         tree->Delete();
358     if(name.Contains("TreeR"))
359       if(tree!=gAlice->TreeR())
360         tree->Delete();    
361   }
362   return kFALSE ;
363   
364 }
365
366 //____________________________________________________________________________ 
367 void AliEMCALGetter::ListBranches(Int_t event) const  
368 {
369   
370   TBranch * branch = 0 ; 
371   if (gAlice->GetEvent(event) == -1)
372     return ; 
373
374   TTree * t =  gAlice->TreeH() ; 
375   if(t){
376     cout << "INFO: AliEMCALGetter::ListBranches -> ****** Hits    : " << endl ; 
377     TObjArray * lob = t->GetListOfBranches() ;
378     TIter next(lob) ; 
379     while ( (branch = static_cast<TBranch*>(next())) )
380       cout << "             " << branch->GetName() << endl ; 
381   } else 
382     cerr << "WARNING::AliEMCALGetter::ListBranches -> TreeH not found for event " << event << endl ;  
383   
384   
385   t = gAlice->TreeS() ;
386   if(t){
387     cout << "INFO: AliEMCALGetter::ListBranches -> ****** SDigits : " << endl ; 
388     TObjArray * lob = t->GetListOfBranches() ;
389     TIter next(lob) ; 
390     while ( (branch = static_cast<TBranch*>(next())) )
391       cout << "             " << branch->GetName() << " " << branch->GetTitle() << endl ; 
392   } else 
393     cerr << "WARNING::AliEMCALGetter::ListBranches -> TreeS not found for event " << event << endl ;  
394     
395   t = gAlice->TreeD() ;
396   if(t){
397     cout << "INFO: AliEMCALGetter::ListBranches -> ****** Digits  : " << endl ; 
398     TObjArray * lob = t->GetListOfBranches() ;
399     TIter next(lob) ; 
400     while ( (branch = static_cast<TBranch*>(next())) )
401       cout << "             " << branch->GetName() << " " << branch->GetTitle() << endl ; 
402   } else 
403     cerr << "WARNING::AliEMCALGetter::ListBranches -> TreeD not found for event " << event << endl ;  
404   
405
406   t = gAlice->TreeR() ;
407   if(t){
408     cout << "INFO: AliEMCALGetter::ListBranches -> ****** Recon   : " << endl ; 
409     TObjArray * lob = t->GetListOfBranches() ;
410     TIter next(lob) ; 
411     while ( (branch = static_cast<TBranch*>(next())) )
412       cout << "             " << branch->GetName() << " " << branch->GetTitle() << endl ; 
413   } else 
414     cerr << "WARNING::AliEMCALGetter::ListBranches -> TreeR not found for event " << event << endl ;  
415   
416 }
417
418 //____________________________________________________________________________ 
419 void AliEMCALGetter::NewBranch(TString name, Int_t event)  
420 {
421   fBranchTitle = fSDigitsTitle = fDigitsTitle = fRecPointsTitle = fTrackSegmentsTitle = fRecParticlesTitle =  name ; 
422   Event(event) ; 
423 }
424
425 //____________________________________________________________________________ 
426 Bool_t AliEMCALGetter::NewFile(TString name)  
427 {
428   fHeaderFile = name ; 
429   fFile->Close() ; 
430   fFailed = kFALSE; 
431
432   fFile = static_cast<TFile*>(gROOT->GetFile(fHeaderFile.Data() ) ) ;
433   if(!fFile) {    //if file was not opened yet, read gAlice
434     fFile = TFile::Open(fHeaderFile.Data(),"update") ;
435     if (!fFile->IsOpen()) {
436       cerr << "ERROR : AliEMCALGetter::NewFile -> Cannot open " << fHeaderFile.Data() << endl ; 
437       fFailed = kTRUE ;
438       return fFailed ;  
439     }
440     gAlice = static_cast<AliRun *>(fFile->Get("gAlice")) ;
441   } 
442   
443   if (!gAlice) {
444     cerr << "ERROR : AliEMCALGetter::AliEMCALGetter -> Cannot find gAlice in " << fHeaderFile.Data() << endl ; 
445     fFailed = kTRUE ;
446     return fFailed ; 
447   }
448   return fFailed ; 
449 }
450
451 //____________________________________________________________________________ 
452 const AliEMCAL * AliEMCALGetter::EMCAL() 
453 {
454   // returns the EMCAL object 
455   AliEMCAL * emcal = dynamic_cast<AliEMCAL*>(fModuleFolder->FindObject("EMCAL")) ;  
456   if (!emcal) 
457     if (fDebug)
458       cout << "WARNING: AliEMCALGetter::EMCAL -> EMCAL module not found in Folders" << endl ; 
459   return emcal ; 
460 }  
461
462 //____________________________________________________________________________ 
463 AliEMCALGeometry * AliEMCALGetter::EMCALGeometry() 
464 {
465   AliEMCALGeometry * rv = 0 ; 
466   if (EMCAL() )
467     rv =  EMCAL()->GetGeometry() ;
468   return rv ; 
469
470
471 //____________________________________________________________________________ 
472 const Bool_t AliEMCALGetter::PostPrimaries(void) const 
473 {  //------- Primaries ----------------------
474
475   // the hierarchy is //Folders/RunMC/Event/Data/Primaries
476   
477   TFolder * primariesFolder = dynamic_cast<TFolder*>(fPrimariesFolder->FindObject("Primaries")) ; 
478   if ( !primariesFolder ) {
479     if (fDebug) {
480       cout << "WARNING: AliEMCALGetter::Post Primaries -> Folder //" << fPrimariesFolder->GetName() << "/Primaries/ not found!" << endl;
481       cout << "INFO:    AliEMCALGetter::Post Primaries -> Adding Folder //" << fPrimariesFolder->GetName() << "/Primaries/"  << endl;
482     }
483     primariesFolder = fPrimariesFolder->AddFolder("Primaries", "Primaries particles from TreeK") ; 
484   }    
485   TClonesArray *primaries=  new TClonesArray("TParticle",1000) ;
486   primaries->SetName("Primaries") ;
487   primariesFolder->Add(primaries) ; 
488   
489   return kTRUE;
490
491
492 //____________________________________________________________________________ 
493 TObject** AliEMCALGetter::PrimariesRef(void) const 
494 {  //------- Primaries ----------------------
495
496   
497   // the hierarchy is //Folders/RunMC/Event/Data/Primaries
498   if ( !fPrimariesFolder ) {
499     cerr << "ERROR: AliEMCALGetter::PrimariesRef -> Folder //" << fPrimariesFolder << " not found!" << endl;
500     abort() ;
501   }    
502  
503   TFolder * primariesFolder = dynamic_cast<TFolder *>(fPrimariesFolder->FindObject("Primaries")) ;
504   if ( !primariesFolder ) {
505     cerr << "ERROR: AliEMCALGetter::PrimariesRef -> Folder //" << fPrimariesFolder << "/Primaries/ not found!" << endl;  
506     abort() ;
507   }
508  
509   TObject * p = primariesFolder->FindObject("Primaries") ;
510   if(!p) {
511     cerr << "ERROR: AliEMCALGetter::PrimariesRef -> " << primariesFolder->GetName() << "/Primaries not found !" << endl ; 
512     abort() ;
513   }
514   else
515     return primariesFolder->GetListOfFolders()->GetObjectRef(p) ;
516 }
517
518 //____________________________________________________________________________ 
519 const Bool_t AliEMCALGetter::PostHits(void) const 
520 {  //------- Hits ----------------------
521
522   // the hierarchy is //Folders/RunMC/Event/Data/EMCAL/Hits
523   
524   TFolder * emcalFolder = dynamic_cast<TFolder*>(fHitsFolder->FindObject("EMCAL")) ; 
525   if ( !emcalFolder ) {
526     if (fDebug) {
527       cout << "WARNING: AliEMCALGetter::Post H -> Folder //" << fHitsFolder << "/EMCAL/ not found!" << endl;
528       cout << "INFO:    AliEMCALGetter::Post H -> Adding Folder //" << fHitsFolder << "/EMCAL/"  << endl;
529     }
530     emcalFolder = fHitsFolder->AddFolder("EMCAL", "Hits from EMCAL") ; 
531   }    
532   TClonesArray *hits=  new TClonesArray("AliEMCALHit",1000) ;
533   hits->SetName("Hits") ;
534   emcalFolder->Add(hits) ; 
535   
536   return kTRUE;
537
538
539 //____________________________________________________________________________ 
540 TObject ** AliEMCALGetter::HitsRef(void) const 
541 {  //------- Hits ----------------------
542
543   
544   // the hierarchy is //Folders/RunMC/Event/Data/EMCAL/Hits
545   if ( !fHitsFolder ) {
546     cerr << "ERROR: AliEMCALGetter::Post H -> Folder //" << fHitsFolder << " not found!" << endl;
547     return 0;
548   }    
549  
550   TFolder * emcalFolder = dynamic_cast<TFolder *>(fHitsFolder->FindObject("EMCAL")) ;
551   if ( !emcalFolder ) {
552     cerr << "ERROR: AliEMCALGetter::Post HRef -> Folder //" << fHitsFolder << "/EMCAL/ not found!" << endl;  
553     return 0;
554   }
555  
556   TObject * h = emcalFolder->FindObject("Hits") ;
557   if(!h) {
558     cerr << "ERROR: AliEMCALGetter::HRef -> " << emcalFolder->GetName() << "/Hits not found !" << endl ; 
559     return 0 ;
560   }
561   else
562     return emcalFolder->GetListOfFolders()->GetObjectRef(h) ;
563 }
564
565 //____________________________________________________________________________ 
566 const Bool_t AliEMCALGetter::PostSDigits(const char * name, const char * headerFile) const 
567 {  //---------- SDigits -------------------------
568
569   
570   // the hierarchy is //Folders/RunMC/Event/Data/EMCAL/SDigits/headerFile/sdigitsname
571   // because you can have sdigits from several hit files for mixing
572   
573   TFolder * emcalFolder = dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("EMCAL")) ;
574   if ( !emcalFolder ) {
575     if (fDebug) {
576       cout << "WARNING: AliEMCALGetter::Post S -> Folder //" << fSDigitsFolder << "/EMCAL/ not found!" << endl;
577       cout << "INFO:    AliEMCALGetter::Post S -> Adding Folder //" << fHitsFolder << "/EMCAL/" << endl;
578     }
579     emcalFolder = fSDigitsFolder->AddFolder("EMCAL", "SDigits from EMCAL") ; 
580   }    
581
582   TString subdir(headerFile) ;
583   subdir.ReplaceAll("/", "_") ; 
584   TFolder * emcalSubFolder = dynamic_cast<TFolder*>(emcalFolder->FindObject(subdir)) ; 
585   if ( !emcalSubFolder ) 
586     emcalSubFolder = emcalFolder->AddFolder(subdir, ""); 
587
588   
589   TObject * sd  = emcalSubFolder->FindObject(name); 
590   if ( !sd ) {
591     TClonesArray * sdigits = new TClonesArray("AliEMCALDigit",1) ;
592     sdigits->SetName(name) ;
593     emcalSubFolder->Add(sdigits) ;
594   }
595   
596   return kTRUE;
597
598 //____________________________________________________________________________ 
599 TObject ** AliEMCALGetter::SDigitsRef(const char * name, const char * file) const 
600 {  //------- SDigits ----------------------
601   
602   // the hierarchy is //Folders/RunMC/Event/Data/EMCAL/SDigits/filename/SDigits
603
604   if ( !fSDigitsFolder ) {
605     cerr << "ERROR: AliEMCALGetter::Post SRef -> Folder //" << fSDigitsFolder << " not found!" << endl;
606     abort() ;
607   }    
608  
609   TFolder * emcalFolder = dynamic_cast<TFolder *>(fSDigitsFolder->FindObject("EMCAL")) ;
610   if ( !emcalFolder ) {
611     cerr << "ERROR: AliEMCALGetter::Post SRef -> Folder //" << fSDigitsFolder << "/EMCAL/ not found!" << endl;
612     abort() ;
613   }
614
615   TFolder * emcalSubFolder = 0 ;
616   if(file)
617     emcalSubFolder = dynamic_cast<TFolder *>(emcalFolder->FindObject(file)) ;
618   else
619     emcalSubFolder = dynamic_cast<TFolder *>(emcalFolder->FindObject(fHeaderFile)) ;
620   
621   if(!emcalSubFolder) {
622     cerr << "ERROR: AliEMCALGetter::Post SRef -> Folder //Folders/RunMC/Event/Data/EMCAL/" << file << "not found!" << endl;
623     abort() ;
624   }
625
626   TObject * dis = emcalSubFolder->FindObject(name) ;
627   if(!dis) {
628     cerr << "ERROR: AliEMCALGetter::DigitesSRef -> object " << name << " not found! " << endl ; 
629     abort() ;
630   }
631   else
632     return emcalSubFolder->GetListOfFolders()->GetObjectRef(dis) ;
633
634 }
635
636 //____________________________________________________________________________ 
637 const Bool_t AliEMCALGetter::PostSDigitizer(AliEMCALSDigitizer * sdigitizer) const 
638 {  //---------- SDigitizer -------------------------
639     
640   // the hierarchy is //Folders/Tasks/SDigitizer/EMCAL/sdigitsname
641
642
643   TTask * sd  = dynamic_cast<TTask*>(fTasksFolder->FindObject("SDigitizer")) ; 
644
645   if ( !sd ) {
646     cerr << "ERROR: AliEMCALGetter::Post Ser -> Task //" << fTasksFolder << "/SDigitizer not found!" << endl;
647     return kFALSE ;
648   }        
649   TTask * emcal = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("EMCAL")) ; 
650   if ( !emcal )  {
651     if (fDebug) {
652       cout <<"WARNING: AliEMCALGetter::Post Ser ->//" << fTasksFolder << "/SDigitizer/EMCAL/ not found!" << endl;  
653       cout <<"INFO: AliEMCALGetter::Post Ser -> Adding //" << fTasksFolder << "/SDigitizer/EMCAL/" << endl;
654     }
655     emcal = new TTask("EMCAL", "") ; 
656     sd->Add(emcal) ; 
657   } 
658   AliEMCALSDigitizer * emcalsd  = dynamic_cast<AliEMCALSDigitizer *>(emcal->GetListOfTasks()->FindObject( sdigitizer->GetName() )); 
659   if (emcalsd) { 
660     if (fDebug)
661       cout << "INFO: AliEMCALGetter::Post Ser -> Task " << sdigitizer->GetName() << " already exists" << endl ; 
662     emcal->GetListOfTasks()->Remove(emcalsd) ;
663   }
664   emcal->Add(sdigitizer) ;      
665   return kTRUE; 
666   
667 }
668
669 //____________________________________________________________________________ 
670 TObject ** AliEMCALGetter::SDigitizerRef(const char * name) const 
671 {  
672
673   TTask * sd  = dynamic_cast<TTask*>(fTasksFolder->FindObject("SDigitizer")) ; 
674   if ( !sd ) {
675     cerr << "ERROR: AliEMCALGetter::Post SerRef -> Task //" << fTasksFolder << "/SDigitizer not found!" << endl;
676     abort();
677   }        
678
679   TTask * emcal = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("EMCAL")) ; 
680   if ( !emcal )  {
681     cerr <<"ERROR: AliEMCALGetter::Post SerRef ->  //" << fTasksFolder << "/SDigitizer/EMCAL not found!" << endl;
682     abort();
683   }        
684
685   TTask * task = dynamic_cast<TTask*>(emcal->GetListOfTasks()->FindObject(name)) ; 
686
687   return emcal->GetListOfTasks()->GetObjectRef(task) ;
688
689 }
690
691 //____________________________________________________________________________ 
692 const Bool_t AliEMCALGetter::PostSDigitizer(const char * name, const char * file) const 
693 {  //---------- SDigitizer -------------------------
694   
695  // the hierarchy is //Folders/Tasks/SDigitizer/EMCAL/sdigitsname
696
697   TTask * sd  = dynamic_cast<TTask*>(fTasksFolder->FindObject("SDigitizer")) ; 
698   if ( !sd ) {
699     cerr << "ERROR: AliEMCALGetter::Post Ser -> Task //" << fTasksFolder << "/SDigitizer not found!" << endl;
700     return kFALSE ;
701   }        
702
703   TTask * emcal = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("EMCAL")) ; 
704   if ( !emcal )  {
705     if (fDebug) {
706       cout <<"WARNING: AliEMCALGetter::Post Ser ->  //" << fTasksFolder << "/SDigitizer/EMCAL/ not found!" << endl;
707       cout <<"INFO: AliEMCALGetter::Post Ser -> Adding  //" << fTasksFolder << "/SDigitizer/EMCAL" << endl;
708     }
709     emcal = new TTask("EMCAL", "") ; 
710     sd->Add(emcal) ; 
711   } 
712
713   TString sdname(name) ;
714   sdname.Append(":") ;
715   sdname.Append(file);
716   sdname.ReplaceAll("/","_") ; 
717   AliEMCALSDigitizer * emcalsd  = dynamic_cast<AliEMCALSDigitizer *>(emcal->GetListOfTasks()->FindObject( sdname )); 
718   if (!emcalsd) {
719     emcalsd = new AliEMCALSDigitizer() ;  
720     //Note, we can not call constructor with parameters: it will call Getter and screw up everething
721     emcalsd->SetName(sdname) ;
722     emcalsd->SetTitle(file) ;
723     emcal->Add(emcalsd) ;       
724   }
725   return kTRUE; 
726   
727 }
728
729 //____________________________________________________________________________ 
730 const Bool_t AliEMCALGetter::PostDigits(const char * name) const 
731 {  //---------- Digits -------------------------
732
733   // the hierarchy is //Folders/Run/Event/Data/EMCAL/SDigits/name
734
735   TFolder * emcalFolder  = dynamic_cast<TFolder*>(fDigitsFolder->FindObject("EMCAL")) ;
736
737   if ( !emcalFolder ) {
738     if (fDebug) {
739       cout << "WARNING: AliEMCALGetter::Post D -> Folder //" << fDigitsFolder << "/EMCAL/ not found!" << endl;
740       cout << "INFO:    AliEMCALGetter::Post D -> Adding Folder //" << fDigitsFolder << "/EMCAL/" << endl;
741     }
742     emcalFolder = fDigitsFolder->AddFolder("EMCAL", "Digits from EMCAL") ;  
743   }    
744  
745   TObject*  dig = emcalFolder->FindObject( name ) ;
746   if ( !dig ) {
747     TClonesArray * digits = new TClonesArray("AliEMCALDigit",1000) ;
748     digits->SetName(name) ;
749     emcalFolder->Add(digits) ;  
750   }
751   return kTRUE; 
752 }
753
754 //____________________________________________________________________________ 
755 TObject ** AliEMCALGetter::DigitsRef(const char * name) const 
756 { //------- Digits ----------------------
757   
758   // the hierarchy is //Folders/Run/Event/Data/EMCAL/Digits/name
759
760   if ( !fDigitsFolder ) {
761     cerr << "ERROR: AliEMCALGetter::Post DRef -> Folder //" << fDigitsFolder << " not found!" << endl;
762     abort() ;
763   }    
764   
765   TFolder * emcalFolder  = dynamic_cast<TFolder*>(fDigitsFolder->FindObject("EMCAL")) ; 
766   if ( !emcalFolder ) {
767     cerr << "ERROR: AliEMCALGetter::DRef -> Folder //" << fDigitsFolder << "/EMCAL/ not found!" << endl;
768     abort() ;
769   }    
770
771   TObject * d = emcalFolder->FindObject(name) ;
772   if(!d) {
773     cerr << "ERROR: AliEMCALGetter::DigitsRef -> object " << name << " not found! " << endl ; 
774     abort() ;
775   }   
776   else
777     return emcalFolder->GetListOfFolders()->GetObjectRef(d) ;
778
779 }
780
781 //____________________________________________________________________________ 
782 const Bool_t AliEMCALGetter::PostDigitizer(AliEMCALDigitizer * digitizer) const 
783 {  //---------- Digitizer -------------------------
784   
785   TTask * sd  = dynamic_cast<TTask*>(fTasksFolder->FindObject("Digitizer")) ; 
786
787   if ( !sd ) {
788     cerr << "ERROR: AliEMCALGetter::Post Der -> Task //" << fTasksFolder << "/Digitizer not found!" << endl;
789     return kFALSE ;
790   }        
791   TTask * emcal = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("EMCAL")) ; 
792   if ( !emcal )  {
793     if (fDebug) {
794       cout <<"WARNING: AliEMCALGetter::Post Der ->  //" << fTasksFolder << "/Digitizer/EMCAL not found!" << endl;
795       cout <<"INFO: AliEMCALGetter::Post Der -> Adding //" << fTasksFolder << "/Digitizer/EMCAL" << endl; 
796     }
797     emcal = new TTask("EMCAL", "") ; 
798     sd->Add(emcal) ; 
799   } 
800
801     AliEMCALDigitizer * emcald = dynamic_cast<AliEMCALDigitizer*>(emcal->GetListOfTasks()->FindObject(digitizer->GetName())) ; 
802     if (emcald) { 
803       emcald->Delete() ;
804       emcal->GetListOfTasks()->Remove(emcald) ;
805     }
806     emcal->Add(digitizer) ; 
807     return kTRUE; 
808 }  
809
810 //____________________________________________________________________________ 
811 const Bool_t AliEMCALGetter::PostDigitizer(const char * name) const 
812 {  //---------- Digitizer -------------------------
813   
814  // the hierarchy is //Folders/Tasks/SDigitizer/EMCAL/sdigitsname
815
816   TTask * d  = dynamic_cast<TTask*>(fTasksFolder->FindObject("Digitizer")) ; 
817   if ( !d ) {
818     cerr << "ERROR: AliEMCALGetter::Post Der -> Task //" << fTasksFolder << "/Digitizer not found!" << endl;
819     return kFALSE ;
820   }        
821
822   TTask * emcal = dynamic_cast<TTask*>(d->GetListOfTasks()->FindObject("EMCAL")) ; 
823   if ( !emcal )  {
824     if (fDebug) {
825       cout <<"WARNING: AliEMCALGetter::Post Der -> //" << fTasksFolder << "/Digitizer/EMCAL not found!" << endl; 
826       cout <<"INFO: AliEMCALGetter::Post Der -> Adding //" << fTasksFolder << "/Digitizer/EMCAL" << endl;
827     }
828     emcal = new TTask("EMCAL", "") ; 
829     d->Add(emcal) ; 
830
831
832   AliEMCALDigitizer * emcald = dynamic_cast<AliEMCALDigitizer*>(emcal->GetListOfTasks()->FindObject(name)) ; 
833   if (!emcald) { 
834     emcald = new AliEMCALDigitizer() ;
835     emcald->SetName(fDigitsTitle) ;
836     emcald->SetTitle(fHeaderFile) ;
837     emcal->Add(emcald) ;
838   }
839   return kTRUE;  
840 }
841
842 //____________________________________________________________________________ 
843 TObject ** AliEMCALGetter::DigitizerRef(const char * name) const 
844 {  
845   TTask * sd  = dynamic_cast<TTask*>(fTasksFolder->FindObject("Digitizer")) ; 
846   if ( !sd ) {
847     cerr << "ERROR: AliEMCALGetter::Post DerRef -> Task //" << fTasksFolder->GetName() << "/Digitizer not found!" << endl;
848     abort();
849   }        
850
851   TTask * emcal = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("EMCAL")) ; 
852   if ( !emcal )  {
853     cerr <<"ERROR: AliEMCALGetter::Post DerRef ->  //" << fTasksFolder->GetName() << "/Digitizer/EMCAL" << endl;
854     abort();
855   }        
856
857   TTask * task = dynamic_cast<TTask*>(emcal->GetListOfTasks()->FindObject(name)) ; 
858
859   return emcal->GetListOfTasks()->GetObjectRef(task) ;
860
861 }
862  
863 //____________________________________________________________________________ 
864 const Bool_t AliEMCALGetter::PostRecPoints(const char * name) const 
865 { // -------------- RecPoints -------------------------------------------
866   
867   // the hierarchy is //Folders/Run/Event/RecData/EMCAL/TowerRecPoints/name
868   // the hierarchy is //Folders/Run/Event/RecData/EMCAL/PreShowerRecPoints/name
869
870   TFolder * emcalFolder  = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL")) ; 
871   
872   if ( !emcalFolder ) {
873     if (fDebug) {
874       cout << "WARNING: AliEMCALGetter::Post RPo -> Folder //" << fRecoFolder << "/EMCAL/ not found!" << endl;
875       cout << "INFO:    AliEMCALGetter::Post Rpo -> Adding Folder //" << fRecoFolder << "/EMCAL/" << endl;
876     }
877     emcalFolder = fRecoFolder->AddFolder("EMCAL", "Reconstructed data from EMCAL") ;  
878   }    
879   
880   // Tower RecPoints 
881   TFolder * emcalRPoTowerFolder  = dynamic_cast<TFolder*>(emcalFolder->FindObject("TowerRecPoints")) ;
882   if ( !emcalRPoTowerFolder ) {
883     if (fDebug) {
884       cout << "WARNING: AliEMCALGetter::Post RPo -> Folder //" << fRecoFolder << "/EMCAL/TowerRecPoints/ not found!" << endl;
885       cout << "INFO:    AliEMCALGetter::Post Rpo -> Adding Folder //" << fRecoFolder << "/EMCAL/TowerRecPoints not found!" << endl;
886     }
887     emcalRPoTowerFolder = emcalFolder->AddFolder("TowerRecPoints", "Tower RecPoints from EMCAL") ;  
888   }    
889   
890   TObject * erp = emcalFolder->FindObject( name ) ;
891   if ( !erp )   {
892     TObjArray * towerrp = new TObjArray(100) ;
893     towerrp->SetName(name) ;
894     emcalRPoTowerFolder->Add(towerrp) ;  
895   }
896
897   // Pre Shower RecPoints 
898   TFolder * emcalRPoPreShoFolder  = dynamic_cast<TFolder*>(emcalFolder->FindObject("PreShowerRecPoints")) ;
899   if ( !emcalRPoPreShoFolder ) {
900     if (fDebug) {
901       cout << "WARNING: AliEMCALGetter::Post RPo -> Folder //" << fRecoFolder << "/EMCAL/PreShowerRecPoints/ not found!" << endl;
902       cout << "INFO:    AliEMCALGetter::Post Rpo -> Adding Folder //" << fRecoFolder << "/EMCAL/PreShowerRecPoints/" << endl;
903     }
904     emcalRPoPreShoFolder = emcalFolder->AddFolder("PreShowerRecPoints", "PreSho RecPoints from EMCAL") ;  
905   }    
906   
907   TObject * crp =  emcalRPoPreShoFolder->FindObject( name ) ;
908   if ( !crp )   {
909     TObjArray * preshorp = new TObjArray(100) ;
910     preshorp->SetName(name) ;
911     emcalRPoPreShoFolder->Add(preshorp) ;  
912   }
913   return kTRUE; 
914 }
915
916 //____________________________________________________________________________ 
917 TObject ** AliEMCALGetter::TowerRecPointsRef(const char * name) const 
918 { // -------------- RecPoints -------------------------------------------
919   
920   // the hierarchy is //Folders/Run/Event/RecData/EMCAL/TowerRecPoints/name
921    
922   if ( !fRecoFolder ) {
923     cerr << "ERROR: AliEMCALGetter::TowerRecPointsRef -> Folder //" << fRecoFolder << " not found!" << endl;
924     abort() ; 
925   }    
926
927   TFolder * towerFolder  = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/TowerRecPoints")) ; 
928   if ( !towerFolder ) {
929     cerr << "ERROR: AliEMCALGetter::TowerRecPointsRef -> Folder //" << fRecoFolder << "/EMCAL/TowerRecPoints/ not found!" << endl;
930     abort() ;
931   }    
932
933
934   TObject * trp = towerFolder->FindObject(name ) ;
935   if ( !trp )   {
936     cerr << "ERROR: AliEMCALGetter::TowerRecPointsRef -> Object " << name << " not found!" << endl  ;
937     abort() ; 
938   }
939   return towerFolder->GetListOfFolders()->GetObjectRef(trp) ;
940
941
942
943 //____________________________________________________________________________ 
944 TObject ** AliEMCALGetter::PreShowerRecPointsRef(const char * name) const 
945 { // -------------- RecPoints -------------------------------------------
946   
947   // the hierarchy is //Folders/Run/Event/RecData/EMCAL/PreShowerRecPoints/name
948    
949   if ( !fRecoFolder ) {
950     cerr << "ERROR: AliEMCALGetter::PreShowerRecPointsRef -> Folder //" << fRecoFolder << " not found!" << endl;
951     abort() ; 
952   }    
953
954   TFolder * preshoFolder  = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/PreShowerRecPoints")) ; 
955   if ( !preshoFolder ) {
956     cerr << "ERROR: AliEMCALGetter::PreShowerRecPointsRef -> Folder //" << fRecoFolder << "/EMCAL/PreShowerRecPoints/" << endl;
957     abort() ;
958   }    
959
960   TObject * prp = preshoFolder->FindObject(name ) ;
961   if ( !prp )   {
962     cerr << "ERROR: AliEMCALGetter::PreShowerRecPointsRef -> Object " << name << " not found! " << endl ; 
963     abort() ;
964   }
965   return preshoFolder->GetListOfFolders()->GetObjectRef(prp) ;
966
967
968
969 //____________________________________________________________________________ 
970 const Bool_t AliEMCALGetter::PostClusterizer(AliEMCALClusterizer * clu) const 
971 { // ------------------ AliEMCALClusterizer ------------------------
972   
973   // the hierarchy is //Folders/Tasks/Reconstructioner/EMCAL/sdigitsname
974
975   TTask * tasks  = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ; 
976
977   if ( !tasks ) {
978     cerr << "ERROR: AliEMCALGetter::Post Rer -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
979     return kFALSE ;
980   }        
981         
982   TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ; 
983   if ( !emcal )  {
984     if (fDebug) {
985       cout <<"WARNING: AliEMCALGetter::Post Rer -> //" << fTasksFolder << "/ReconstructionerEMCAL not found!" << endl; 
986       cout <<"INFO: AliEMCALGetter::Post Rer -> Adding //" << fTasksFolder << "/Reconstructioner/EMCAL" << endl; 
987     }
988     emcal = new TTask("EMCAL", "") ; 
989     tasks->Add(emcal) ; 
990   } 
991
992   AliEMCALClusterizerv1 * emcalcl = dynamic_cast<AliEMCALClusterizerv1*>(emcal->GetListOfTasks()->FindObject(clu->GetName())) ; 
993   if (emcalcl) { 
994     if (fDebug)
995       cout << "INFO: AliEMCALGetter::Post Rer -> Task " << clu->GetName() << " already exists" << endl ; 
996     emcalcl->Delete() ; 
997     emcal->GetListOfTasks()->Remove(emcalcl) ;
998   }
999   emcal->Add(clu) ;      
1000   return kTRUE; 
1001
1002
1003 //____________________________________________________________________________ 
1004 TObject ** AliEMCALGetter::ClusterizerRef(const char * name) const 
1005 { // ------------------ AliEMCALClusterizer ------------------------
1006   
1007   TTask * tasks  = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ; 
1008
1009   if ( !tasks ) {
1010     cerr << "ERROR: AliEMCALGetter::Post RerRef -> Task //" << fTasksFolder->GetName() << "/Reconstructioner not found!" << endl;
1011     abort() ;
1012   }        
1013         
1014   TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ; 
1015   if ( !emcal )  {
1016     cerr <<"WARNING: AliEMCALGetter::Post RerRef -> //" << fTasksFolder->GetName() << "/Reconstructioner/EMCAL" << endl; 
1017     abort() ; 
1018   }   
1019
1020   TList * l = emcal->GetListOfTasks() ; 
1021   TIter it(l) ;
1022   TTask * task ;
1023   TTask * clu = 0 ;
1024   TString cluname(name) ;
1025   cluname+=":clu-" ;
1026   while((task = static_cast<TTask *>(it.Next()) )){
1027     TString taskname(task->GetName()) ;
1028     if(taskname.BeginsWith(cluname)){
1029       clu = task ;
1030       break ;
1031     }
1032   }
1033
1034   if(clu) 
1035     return l->GetObjectRef(clu) ;
1036   else {
1037     cerr << "ERROR: AliEMCALGetter::Post RerRef -> task " << task->GetName() << " not found! " << endl ; 
1038     abort() ;
1039   }
1040 }
1041
1042 //____________________________________________________________________________ 
1043 const Bool_t AliEMCALGetter::PostClusterizer(const char * name) const 
1044 { // ------------------ AliEMCALClusterizer ------------------------
1045
1046   // the hierarchy is //Folders/Tasks/Reconstructioner/EMCAL/sdigitsname
1047   
1048   TTask * tasks  = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ; 
1049
1050   if ( !tasks ) {
1051     cerr << "ERROR: AliEMCALGetter::Post Rer -> Task//" << fTasksFolder->GetName() << "/Reconstructioner not found!" << endl; 
1052     return kFALSE ;
1053   }        
1054   
1055   TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ; 
1056   if ( !emcal )  {
1057     if (fDebug) {
1058       cout <<"WARNING: AliEMCALGetter::Post Rer -> //" << fTasksFolder << "/Reconstructioner/EMCAL not found!" << endl;
1059       cout <<"INFO: AliEMCALGetter::Post Rer -> Adding //" << fTasksFolder << "/Reconstructioner/EMCAL" << endl;
1060     }
1061     emcal = new TTask("EMCAL", "") ; 
1062     tasks->Add(emcal) ; 
1063   } 
1064
1065   TList * l = emcal->GetListOfTasks() ;   
1066   TIter it(l) ;
1067   TString clun(name) ;
1068   clun+=":clu" ; 
1069   TTask * task ;
1070   while((task = static_cast<TTask *>(it.Next()) )){
1071     TString taskname(task->GetName()) ;
1072     if(taskname.BeginsWith(clun))
1073       return kTRUE ;
1074   }
1075
1076   AliEMCALClusterizerv1 * emcalcl = new AliEMCALClusterizerv1() ;
1077   clun+="-v1" ; 
1078   emcalcl->SetName(clun) ;
1079   emcalcl->SetTitle(fHeaderFile) ; 
1080   emcal->Add(emcalcl) ;
1081   return kTRUE; 
1082   
1083 }
1084
1085 //____________________________________________________________________________ 
1086 /*const Bool_t AliEMCALGetter::PostTrackSegments(const char * name) const 
1087 { // ---------------TrackSegments -----------------------------------
1088   
1089   // the hierarchy is //Folders/Run/Event/RecData/EMCAL/TrackSegments/name
1090
1091   TFolder * emcalFolder  = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL")) ; 
1092   
1093   if ( !emcalFolder ) {
1094     if (fDebug) {
1095       cout << "WARNING: AliEMCALGetter::Post TS -> Folder //" << fRecoFolder << "/EMCAL/ not found!" << endl;
1096       cout << "INFO:    AliEMCALGetter::Post TS -> Adding Folder //" << fRecoFolder << "/EMCAL" << endl;
1097     }
1098     emcalFolder = fRecoFolder->AddFolder("EMCAL", "Reconstructed data from EMCAL") ;  
1099   }    
1100
1101   TFolder * emcalTSFolder  = dynamic_cast<TFolder*>(emcalFolder->FindObject("TrackSegments")) ;
1102   if ( !emcalTSFolder ) {
1103     if (fDebug) {
1104       cout << "WARNING: AliEMCALGetter::Post TS -> Folder//" << fRecoFolder << "/EMCAL/TrackSegments/ not found!" << endl; 
1105       cout << "INFO:    AliEMCALGetter::Post TS -> Adding Folder //" << fRecoFolder << "/EMCAL/TrackSegments/" << endl; 
1106     }
1107     emcalTSFolder = emcalFolder->AddFolder("TrackSegments", "TrackSegments from EMCAL") ;  
1108   }    
1109   
1110   TObject * tss =  emcalTSFolder->FindObject( name ) ;
1111   if (!tss) {
1112     TClonesArray * ts = new TClonesArray("AliEMCALTrackSegment",100) ;
1113     ts->SetName(name) ;
1114     emcalTSFolder->Add(ts) ;  
1115   }
1116   return kTRUE; 
1117
1118
1119 //____________________________________________________________________________ 
1120 TObject ** AliEMCALGetter::TrackSegmentsRef(const char * name) const 
1121 { // ---------------TrackSegments -----------------------------------
1122   
1123   // the hierarchy is //Folders/Run/Event/RecData/EMCAL/TrackSegments/name
1124
1125  if ( !fRecoFolder ) {
1126     cerr << "ERROR: AliEMCALGetter::TrackSegmentsRef -> Folder //" << fRecoFolder << "not found!" << endl;
1127     abort() ; 
1128   }    
1129
1130   TFolder * emcalFolder  = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/TrackSegments")) ; 
1131   if ( !emcalFolder ) {
1132     cerr << "ERROR: AliEMCALGetter::TrackSegmentsRef -> Folder //" << fRecoFolder << "/EMCAL/TrackSegments/ not found!" << endl;
1133     abort();
1134   }    
1135   
1136   TObject * tss =  emcalFolder->FindObject(name) ;
1137   if (!tss) {
1138     cerr << "ERROR: AliEMCALGetter::TrackSegmentsRef -> object " << name << " not found! " << endl ;  
1139     abort() ;  
1140   }
1141   return emcalFolder->GetListOfFolders()->GetObjectRef(tss) ;
1142
1143
1144 //____________________________________________________________________________ 
1145 const Bool_t AliEMCALGetter::PostTrackSegmentMaker(AliEMCALTrackSegmentMaker * tsmaker) const 
1146 { //------------Track Segment Maker ------------------------------
1147   
1148   // the hierarchy is //Folders/Tasks/Reconstructioner/EMCAL/sdigitsname
1149
1150   TTask * tasks  = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ; 
1151
1152   if ( !tasks ) {
1153     cerr << "ERROR: AliEMCALGetter::Post Ter -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
1154     return kFALSE ;
1155   }        
1156         
1157   TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ; 
1158   if ( !emcal )  {
1159     if (fDebug) {
1160       cout <<"WARNING: AliEMCALGetter::Post Rer -> //" << fTasksFolder << "/Reconstructioner/EMCAL not found!" << endl; 
1161       cout <<"INFO: AliEMCALGetter::Post Rer -> Adding //" << fTasksFolder << "/Reconstructioner/EMCAL" << endl;
1162     }
1163     emcal = new TTask("EMCAL", "") ; 
1164     tasks->Add(emcal) ; 
1165   } 
1166
1167   AliEMCALTrackSegmentMaker * emcalts = 
1168     dynamic_cast<AliEMCALTrackSegmentMaker*>(emcal->GetListOfTasks()->FindObject(tsmaker->GetName())) ; 
1169   if (emcalts) { 
1170     emcalts->Delete() ;
1171     emcal->GetListOfTasks()->Remove(emcalts) ;
1172   }
1173   emcal->Add(tsmaker) ;      
1174   return kTRUE; 
1175   
1176
1177 //____________________________________________________________________________ 
1178 const Bool_t AliEMCALGetter::PostTrackSegmentMaker(const char * name) const 
1179 { //------------Track Segment Maker ------------------------------
1180   
1181   // the hierarchy is //Folders/Tasks/Reconstructioner/EMCAL/sdigitsname
1182
1183   TTask * tasks  = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ; 
1184   
1185   if ( !tasks ) {
1186     cerr << "ERROR: AliEMCALGetter::Post Ter -> Task //" << fTasksFolder->GetName() << "/Reconstructioner not found!" << endl;
1187     return kFALSE ;
1188   }        
1189   
1190   TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ; 
1191   if ( !emcal )  {
1192     if (fDebug) {
1193       cout <<"WARNING: AliEMCALGetter::Post Ter -> //" << fTasksFolder->GetName() << "/Reconstructioner/EMCAL not found!" << endl; 
1194       cout <<"INFO: AliEMCALGetter::Post Ter -> Adding //" << fTasksFolder->GetName() << "/Reconstructioner/EMCAL" << endl;
1195     }
1196     emcal = new TTask("EMCAL", "") ; 
1197     tasks->Add(emcal) ; 
1198   } 
1199
1200   TList * l = emcal->GetListOfTasks() ;   
1201   TIter it(l) ;
1202   TString tsn(name);
1203   tsn+=":tsm" ; 
1204   TTask * task ;
1205   while((task = static_cast<TTask *>(it.Next()) )){
1206     TString taskname(task->GetName()) ;
1207     if(taskname.BeginsWith(tsn))
1208       return kTRUE ;
1209   }
1210   
1211   AliEMCALTrackSegmentMakerv1 * emcalts = new AliEMCALTrackSegmentMakerv1() ;
1212   tsn+="-v1" ;
1213   emcalts->SetName(tsn) ;
1214   emcalts->SetTitle(fHeaderFile) ;
1215   emcal->Add(emcalts) ;      
1216   return kTRUE; 
1217   
1218
1219   
1220   
1221
1222
1223 //____________________________________________________________________________ 
1224 TObject ** AliEMCALGetter::TSMakerRef(const char * name) const 
1225 { //------------Track Segment Maker ------------------------------
1226   
1227   TTask * tasks  = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ; 
1228
1229   if ( !tasks ) {
1230     cerr << "ERROR: AliEMCALGetter::TSLakerRef TerRef -> Task //" << fTasksFolder->GetName() << "/Reconstructioner not found!" << endl;
1231     abort() ;
1232   }        
1233         
1234   TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ; 
1235   if ( !emcal )  {
1236     cerr <<"WARNING: AliEMCALGetter::TSMakerRef TerRef -> //" << fTasksFolder->GetName() << "/Reconstructioner/EMCAL not found!" << endl; 
1237     abort() ; 
1238   }   
1239
1240   TList * l = emcal->GetListOfTasks() ; 
1241   TIter it(l) ;
1242   TTask * task ;
1243   TTask * tsm = 0 ;
1244   TString tsmname(name) ;
1245   tsmname+=":tsm-" ;
1246   while((task = static_cast<TTask *>(it.Next()) )){
1247     TString taskname(task->GetName()) ;
1248     if(taskname.BeginsWith(tsmname)){
1249       tsm = task ;
1250       break ;
1251     }
1252   }
1253   
1254   if(tsm) 
1255     return l->GetObjectRef(tsm) ;
1256   else {
1257     cerr << "ERROR: AliEMCALGetter::TSLakerRef -> task " << task->GetName() << " not found! " << endl ; 
1258     abort() ;
1259   }
1260
1261
1262 //____________________________________________________________________________ 
1263 const Bool_t AliEMCALGetter::PostRecParticles(const char * name) const 
1264 {  // -------------------- RecParticles ------------------------
1265   
1266   // the hierarchy is //Folders/Run/Event/RecData/EMCAL/TrackSegments/name
1267
1268   TFolder * emcalFolder  = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL")) ; 
1269   
1270   if ( !emcalFolder ) {
1271     if (fDebug) {
1272       cout << "WARNING: AliEMCALGetter::Post RPa -> Folder //" << fRecoFolder << "/EMCAL/ not found!" << endl;
1273       cout << "INFO:    AliEMCALGetter::Post Rpa -> Adding Folder //" << fRecoFolder << "/EMCAL/" << endl;
1274     }
1275     emcalFolder = fRecoFolder->AddFolder("EMCAL", "Reconstructed data from EMCAL") ;  
1276   }    
1277
1278  TFolder * emcalRPaFolder  = dynamic_cast<TFolder*>(emcalFolder->FindObject("RecParticles")) ;
1279   if ( !emcalRPaFolder ) {
1280     if (fDebug) {
1281       cout << "WARNING: AliEMCALGetter::Post RPa -> Folder //" << fRecoFolder << "/EMCAL/RecParticles/ not found!" << endl;
1282       cout << "INFO:    AliEMCALGetter::Post RPa -> Adding Folder //" << fRecoFolder << "/EMCAL/RecParticles/" << endl;
1283     }
1284     emcalRPaFolder = emcalFolder->AddFolder("RecParticles", "RecParticles from EMCAL") ;  
1285   } 
1286
1287   TObject * rps = emcalRPaFolder->FindObject( name )  ;
1288   if ( !rps ) {
1289     TClonesArray * rp = new TClonesArray("AliEMCALRecParticle",100) ;
1290     rp->SetName(name) ;    
1291     emcalRPaFolder->Add(rp) ;  
1292   }
1293   return kTRUE; 
1294
1295
1296 //____________________________________________________________________________ 
1297 TObject ** AliEMCALGetter::RecParticlesRef(const char * name) const 
1298 { // ---------------RecParticles -----------------------------------
1299   
1300   // the hierarchy is //Folders/Run/Event/RecData/EMCAL/TrackSegments/name
1301
1302  if ( !fRecoFolder ) {
1303     cerr << "ERROR: AliEMCALGetter::RecParticlesRef -> Folder//" << fRecoFolder << " not found!" << endl; 
1304     abort() ; 
1305   }    
1306
1307   TFolder * emcalFolder  = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/RecParticles")) ; 
1308   if ( !emcalFolder ) {
1309     cerr << "ERROR: AliEMCALGetter::RecParticlesRef -> Folder //" << fRecoFolder << "/EMCAL/RecParticles/ not found!" << endl;
1310     abort() ;
1311   }    
1312
1313   TObject * tss =  emcalFolder->FindObject(name) ;
1314   if (!tss) {
1315     cerr << "ERROR: AliEMCALGetter::RecParticlesRef -> object " << name << " not found! " << endl ; 
1316     abort() ;  
1317   }
1318   return emcalFolder->GetListOfFolders()->GetObjectRef(tss) ;
1319 }
1320
1321 //____________________________________________________________________________ 
1322 const Bool_t AliEMCALGetter::PostPID(AliEMCALPID * pid) const 
1323 {      // ------------AliEMCAL PID -----------------------------
1324
1325   TTask * tasks  = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ; 
1326
1327   if ( !tasks ) {
1328     cerr << "ERROR: AliEMCALGetter::Post Per -> Task //" << fTasksFolder->GetName() << "/Reconstructioner not found!" << endl;
1329     return kFALSE ;
1330   }        
1331   
1332   TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ; 
1333   if ( !emcal )  {
1334     if (fDebug) {
1335       cout <<"WARNING: AliEMCALGetter::Post Per -> //" << fTasksFolder->GetName() << "/Reconstructioner/EMCAL not found!" << endl; 
1336       cout <<"INFO: AliEMCALGetter::Post Per -> Adding //" << fTasksFolder->GetName() << "/Reconstructioner/EMCAL" << endl;
1337     }
1338     emcal = new TTask("EMCAL", "") ; 
1339     tasks->Add(emcal) ; 
1340   } 
1341
1342   AliEMCALPID * emcalpid = dynamic_cast<AliEMCALPID*>(emcal->GetListOfTasks()->FindObject(pid->GetName())) ; 
1343   if (emcalpid) { 
1344     if (fDebug)
1345       cout << "INFO: AliEMCALGetter::Post Per -> Task " << pid->GetName()
1346            << " already exists" << endl ; 
1347     emcal->GetListOfTasks()->Remove(emcalpid) ;
1348   }
1349   
1350   emcal->Add(pid) ;      
1351   return kTRUE; 
1352
1353
1354 //____________________________________________________________________________ 
1355 const Bool_t AliEMCALGetter::PostPID(const char * name) const 
1356 {     
1357   // the hierarchy is //Folders/Tasks/Reconstructioner/EMCAL/sdigitsname
1358   
1359   TTask * tasks  = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ; 
1360
1361   if ( !tasks ) {
1362     cerr << "ERROR: AliEMCALGetter::Post Per -> Task //" << fTasksFolder->GetName() << "/Reconstructioner not found!" << endl;
1363     return kFALSE ;
1364   }        
1365   
1366   TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ; 
1367   if ( !emcal )  {
1368     if (fDebug) {
1369       cout <<"WARNING: AliEMCALGetter::Post Per -> //" << fTasksFolder->GetName() << "/Reconstructioner/EMCAL not found!" << endl; 
1370       cout <<"INFO: AliEMCALGetter::Post Per -> Adding //" << fTasksFolder->GetName() << "/Reconstructioner/EMCAL" << endl;
1371     }
1372     emcal = new TTask("EMCAL", "") ; 
1373     tasks->Add(emcal) ; 
1374   } 
1375
1376   TList * l = emcal->GetListOfTasks() ;   
1377   TIter it(l) ;
1378   TString pidname(name) ;
1379   pidname+=":pid" ; 
1380   TTask * task ;
1381   while((task = static_cast<TTask *>(it.Next()) )){
1382     TString taskname(task->GetName()) ;
1383     if(taskname.BeginsWith(pidname))
1384       return kTRUE ;
1385   }
1386  
1387   AliEMCALPIDv1 * emcalpid = new AliEMCALPIDv1() ;
1388   pidname+="-v1" ;
1389   emcalpid->SetName(pidname) ;
1390   emcalpid->SetTitle(fHeaderFile) ;
1391   emcal->Add(emcalpid) ;      
1392   
1393   return kTRUE; 
1394
1395
1396 //____________________________________________________________________________ 
1397 TObject ** AliEMCALGetter::PIDRef(const char * name) const 
1398 { //------------PID ------------------------------
1399
1400   TTask * tasks  = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ; 
1401
1402   if ( !tasks ) {
1403     cerr << "ERROR: AliEMCALGetter::PIDRef PerRef -> Task //" << fTasksFolder->GetName() << "/Reconstructioner not found!" << endl;
1404     abort() ;
1405   }        
1406         
1407   TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ; 
1408   if ( !emcal )  {
1409     cerr <<"WARNING: AliEMCALGetter::PIDRef PerRef -> //" << fTasksFolder->GetName() << "/ReconstructionerEMCAL not found!" << endl; 
1410     abort() ; 
1411   }   
1412   
1413   TList * l = emcal->GetListOfTasks() ; 
1414   TIter it(l) ;
1415   TTask * task ;
1416   TTask * pid = 0 ;
1417   TString pidname(name) ;
1418   pidname+=":pid-" ;
1419   while((task = static_cast<TTask *>(it.Next()) )){
1420     TString taskname(task->GetName()) ;
1421     if(taskname.BeginsWith(pidname)){
1422       pid = task ;
1423       break ;
1424     }
1425   }
1426   
1427   if(pid) 
1428     return l->GetObjectRef(pid) ;
1429   else {
1430     cerr << "ERROR: AliEMCALGetter::PIDRef -> task " << task->GetName() << " not found! " << endl ;  
1431     abort() ;
1432   }
1433
1434
1435
1436 //____________________________________________________________________________ 
1437 const Bool_t AliEMCALGetter::PostQA(void) const 
1438 { // ------------------ QA ---------------------------------
1439
1440   // the hierarchy is //Folders/Run/Conditions/QA/EMCAL/alarmsName
1441
1442   TFolder * emcalFolder = dynamic_cast<TFolder*>(fQAFolder->FindObject("EMCAL")) ; 
1443   if ( !emcalFolder ) {
1444     if (fDebug) {
1445       cout << "WARNING: AliEMCALGetter::Post Q -> Folder //" << fQAFolder << "/EMCAL/ not found!" << endl;
1446       cout << "INFO:    AliEMCALGetter::Post Q -> Adding Folder //" << fQAFolder << "/EMCAL/" << endl;
1447     }
1448     emcalFolder = fQAFolder->AddFolder("EMCAL", "QA from EMCAL") ; 
1449   }      
1450
1451   return kTRUE;
1452 }
1453
1454 //____________________________________________________________________________ 
1455 TObject ** AliEMCALGetter::AlarmsRef(void) const 
1456 {  //------- Alarms ----------------------
1457
1458   
1459   // the hierarchy is //Folders/Run/Conditions/QA/EMCAL
1460   if ( !fQAFolder ) {
1461     cerr << "ERROR: AliEMCALGetter::AlarmsRef QRef -> Folder //" << fQAFolder << " not found!" << endl;
1462     abort() ;
1463   }    
1464  
1465   TFolder * emcalFolder = dynamic_cast<TFolder *>(fQAFolder->FindObject("EMCAL")) ;
1466   if ( !emcalFolder ) {
1467     cerr << "ERROR: AliEMCALGetter::AlarmsRef QRef -> Folder //" << fQAFolder << "/EMCAL/ not found!" << endl;
1468     abort() ;
1469   }
1470    
1471   return fQAFolder->GetListOfFolders()->GetObjectRef(emcalFolder) ;
1472 }
1473 */
1474
1475 //____________________________________________________________________________ 
1476 TTree * AliEMCALGetter::TreeK(TString filename)  
1477 {
1478
1479   // returns TreeK from file filename
1480   // usefull in case of split file
1481
1482   if ( filename.IsNull() ) 
1483     filename = fHeaderFile ; 
1484
1485   TFile * file = 0 ; 
1486   file = static_cast<TFile*>(gROOT->GetFile(filename.Data() ) ) ;
1487   if (file && (filename != fHeaderFile) ) {  // file already open 
1488     file->Close() ; 
1489     delete fAlice ; 
1490   }    
1491   file = TFile::Open(filename.Data(), "read") ; 
1492   fAlice = static_cast<AliRun *>(file->Get("gAlice")) ; 
1493   TString treeName("TreeK") ; 
1494   treeName += EventNumber()  ; 
1495   TTree * tree = static_cast<TTree *>(file->Get(treeName.Data())) ;
1496   if (!tree && fDebug)  
1497     cout << "WARNING: AliEMCALGetter::TreeK -> " << treeName.Data() << " not found in " << filename.Data() << endl ; 
1498   
1499   return tree ;                       
1500 }
1501
1502 //____________________________________________________________________________ 
1503 TTree * AliEMCALGetter::TreeH(TString filename)  
1504 {
1505
1506   // returns TreeH from file filename
1507   // usefull in case of split file
1508
1509   if ( filename.IsNull() ) 
1510     filename = fHeaderFile ; 
1511
1512   TFile * file = 0 ; 
1513   file = static_cast<TFile*>(gROOT->GetFile(filename.Data() ) ) ;
1514   if (!file) { // file not open yet
1515     file = TFile::Open(filename.Data(), "read") ; 
1516   }
1517   TString treeName("TreeH") ; 
1518   treeName += EventNumber()  ; 
1519   TTree * tree = static_cast<TTree *>(file->Get(treeName.Data())) ;
1520   if (!tree && fDebug)  
1521     cout << "WARNING: AliEMCALGetter::TreeH -> " << treeName.Data() << " not found in " << filename.Data() << endl ; 
1522   
1523   return tree ;                       
1524 }
1525
1526 //____________________________________________________________________________ 
1527 TTree * AliEMCALGetter::TreeS(TString filename)  
1528 {
1529
1530   // returns TreeS from file filename
1531   // usefull in case of split file
1532
1533   if ( filename.IsNull() ) 
1534     filename = fHeaderFile ; 
1535
1536   TFile * file = 0 ; 
1537   file = static_cast<TFile*>(gROOT->GetFile(filename.Data() ) ) ;
1538   if (!file) { // file not open yet
1539     file = TFile::Open(filename.Data(), "read") ; 
1540   }
1541   TString treeName("TreeS") ; 
1542   treeName += EventNumber()  ; 
1543   TTree * tree = static_cast<TTree *>(file->Get(treeName.Data())) ;
1544   if (!tree && fDebug)  
1545     cout << "WARNING: AliEMCALGetter::TreeS -> " << treeName.Data() << " not found in " << filename.Data() << endl ; 
1546   
1547   return tree ;                       
1548 }
1549
1550 //____________________________________________________________________________ 
1551 TTree * AliEMCALGetter::TreeD(TString filename)  
1552 {
1553
1554   // returns TreeD from file filename
1555   // usefull in case of split file
1556
1557   if ( filename.IsNull() ) 
1558     filename = fHeaderFile ; 
1559
1560   TFile * file = 0 ; 
1561   file = static_cast<TFile*>(gROOT->GetFile(filename.Data() ) ) ;
1562   if (!file) { // file not open yet
1563     file = TFile::Open(filename.Data(), "read") ; 
1564   }
1565   TString treeName("TreeD") ; 
1566   treeName += EventNumber()  ; 
1567   TTree * tree = static_cast<TTree *>(file->Get(treeName.Data())) ;
1568   if (!tree && fDebug)  
1569     cout << "WARNING: AliEMCALGetter::TreeD -> " << treeName.Data() << " not found in " << filename.Data() << endl ; 
1570   
1571   return tree ;                       
1572 }
1573
1574 //____________________________________________________________________________ 
1575 const TParticle * AliEMCALGetter::Primary(Int_t index) const
1576 {
1577   // Return primary particle numbered by <index>
1578   
1579   if(index < 0) 
1580     return 0 ;
1581   TParticle *  p = 0 ;
1582   if (fAlice) 
1583     p = fAlice->Particle(index) ; 
1584   else 
1585     p = gAlice->Particle(index) ; 
1586   
1587   return p ; 
1588       
1589 }
1590
1591 //____________________________________________________________________________ 
1592 const TParticle * AliEMCALGetter::Secondary(TParticle* p, Int_t index) const
1593 {
1594   // Return first (index=1) or second (index=2) secondary particle of primary particle p 
1595
1596   if(index <= 0) 
1597     return 0 ;
1598   if(index > 2)
1599     return 0 ;
1600
1601   if(p) {
1602   Int_t daughterIndex = p->GetDaughter(index-1) ; 
1603   return  gAlice->Particle(daughterIndex) ; 
1604   }
1605   else
1606     return 0 ;
1607 }
1608
1609 //____________________________________________________________________________ 
1610 Int_t AliEMCALGetter::ReadTreeD(const Int_t event)
1611 {
1612   // Read the digit tree gAlice->TreeD()  
1613   
1614   TTree * treeD ;
1615   if(fToSplit){
1616     TFile * file = static_cast<TFile*>(gROOT->GetFile(fDigitsFileName)); 
1617     if(!file) 
1618       file = TFile::Open(fDigitsFileName) ;      
1619     // Get Digits Tree header from file
1620     TString treeName("TreeD") ;
1621     treeName += event ; 
1622     treeD = dynamic_cast<TTree*>(file->Get(treeName.Data()));
1623     if(!treeD){ // TreeD not found in header file
1624       if (fDebug)
1625         cout << "WARNING: AliEMCALGetter::ReadTreeD -> Cannot find TreeD in " << fDigitsFileName.Data() << endl;
1626       return 1;
1627     }
1628   }
1629   else
1630     treeD = gAlice->TreeD() ;
1631   
1632   TObjArray * lob = static_cast<TObjArray*>(treeD->GetListOfBranches()) ;
1633   TIter next(lob) ; 
1634   TBranch * branch = 0 ; 
1635   TBranch * digitsbranch = 0 ; 
1636   TBranch * digitizerbranch = 0 ; 
1637   Bool_t emcalfound = kFALSE, digitizerfound = kFALSE ; 
1638   
1639   while ( (branch = static_cast<TBranch*>(next())) && (!emcalfound || !digitizerfound) ) {
1640     if ( (strcmp(branch->GetName(), "EMCAL")==0) && (strcmp(branch->GetTitle(), fDigitsTitle)==0) ) {
1641       digitsbranch = branch ; 
1642       emcalfound = kTRUE ;
1643     }
1644     else if ( (strcmp(branch->GetName(), "AliEMCALDigitizer")==0) && (strcmp(branch->GetTitle(), fDigitsTitle)==0) ) {
1645       digitizerbranch = branch ; 
1646       digitizerfound = kTRUE ; 
1647     }
1648   }
1649
1650   if ( !emcalfound || !digitizerfound ) {
1651     if (fDebug)
1652       cout << "WARNING: AliEMCALGetter::ReadTreeD -> Cannot find Digits and/or Digitizer with name " 
1653            << fDigitsTitle << endl ;
1654     return 2; 
1655   }   
1656  
1657   //read digits
1658   if(!Digits(fDigitsTitle) ) 
1659     PostDigits(fDigitsTitle);
1660   digitsbranch->SetAddress(DigitsRef(fDigitsTitle)) ;
1661   digitsbranch->GetEntry(0) ;
1662   
1663   
1664   // read  the Digitizer
1665   RemoveTask("D", fDigitsTitle) ; // I do not understand why I need that 
1666   if(!Digitizer(fDigitsTitle))
1667     PostDigitizer(fDigitsTitle) ;
1668   digitizerbranch->SetAddress(DigitizerRef(fDigitsTitle)) ;
1669   digitizerbranch->GetEntry(0) ;
1670  
1671   lob  ->Delete();
1672   if(gAlice->TreeD()!=treeD)
1673     treeD->Delete();
1674   return 0 ; 
1675 }
1676
1677 //____________________________________________________________________________ 
1678 Int_t AliEMCALGetter::ReadTreeH()
1679 {
1680   // Read the first entry of EMCAL branch in hit tree gAlice->TreeH()
1681
1682   TTree * treeH = gAlice->TreeH() ;
1683   
1684   if(!treeH) {// TreeH not found in header file
1685     
1686     if (fDebug) 
1687       cout <<   "WARNING: AliEMCALGetter::ReadTreeH -> Cannot find TreeH in " << fHeaderFile << endl ;
1688     
1689     TString searchFileName("EMCAL.HITS") ; 
1690     if((strcmp(fBranchTitle.Data(),"Default")!=0)&&(strcmp(fBranchTitle.Data(),"")!=0)){
1691       searchFileName+="." ;
1692       searchFileName += fBranchTitle ;
1693     }
1694     searchFileName+=".root" ;
1695     
1696     if ( (treeH = TreeH(searchFileName)) ) { //found TreeH in the file which contains the hits
1697       if (fDebug) 
1698         cout << "INFO: AliEMCALGetter::ReadTreeH -> TreeH found in " << searchFileName.Data() << endl ; 
1699       
1700     } else {
1701       cerr << "ERROR: AliEMCALGetter::ReadTreeH -> TreeH not found " << endl ; 
1702       return 1;
1703     }  
1704   }
1705   
1706   TBranch * hitsbranch = static_cast<TBranch*>(gAlice->TreeH()->GetBranch("EMCAL")) ;
1707   if ( !hitsbranch ) {
1708     if (fDebug)
1709       cout << "WARNING:  AliEMCALGetter::ReadTreeH -> Cannot find branch EMCAL" << endl ; 
1710     return 2;
1711   }
1712   if(!Hits())
1713     PostHits() ;
1714  
1715   if (hitsbranch->GetEntries() > 1 ) {
1716     (dynamic_cast<TClonesArray*> (*HitsRef()))->Clear() ;
1717     TClonesArray * tempo =  new TClonesArray("AliEMCALHit",1000) ;
1718     TClonesArray * hits = dynamic_cast<TClonesArray*>(*HitsRef()) ; 
1719     hitsbranch->SetAddress(&tempo) ;
1720     Int_t index = 0 ; 
1721     Int_t i = 0 ;
1722     for (i = 0 ; i < hitsbranch->GetEntries() ; i++) {
1723       hitsbranch->GetEntry(i) ;
1724       Int_t j = 0 ; 
1725       for ( j = 0 ; j < tempo->GetEntries() ; j++) { 
1726         const AliEMCALHit * hit = static_cast<const AliEMCALHit *>(tempo->At(j)) ; 
1727         new((*hits)[index]) AliEMCALHit( *hit ) ;
1728         index++ ; 
1729       }
1730     }
1731     delete tempo ; 
1732   }
1733   else {
1734   (dynamic_cast<TClonesArray*> (*HitsRef()))->Clear() ;
1735   hitsbranch->SetAddress(HitsRef()) ;
1736   hitsbranch->GetEntry(0) ;
1737   }
1738   return 0 ; 
1739 }
1740
1741 //____________________________________________________________________________ 
1742 void AliEMCALGetter::Track(Int_t itrack)
1743 {
1744   // Read the first entry of EMCAL branch in hit tree gAlice->TreeH()
1745
1746   if(gAlice->TreeH()== 0){
1747     cerr <<   "ERROR: AliEMCALGetter::ReadTreeH: -> Cannot read TreeH " << endl ;
1748     return ;
1749   }
1750   
1751   TBranch * hitsbranch = dynamic_cast<TBranch*>(gAlice->TreeH()->GetListOfBranches()->FindObject("EMCAL")) ;
1752   if ( !hitsbranch ) {
1753     if (fDebug)
1754       cout << "WARNING:  AliEMCALGetter::ReadTreeH -> Cannot find branch EMCAL" << endl ; 
1755     return ;
1756   }  
1757   if(!Hits())
1758     PostHits() ;
1759
1760   (dynamic_cast<TClonesArray*> (*HitsRef()))->Clear() ;
1761   hitsbranch->SetAddress(HitsRef()) ;
1762   hitsbranch->GetEntry(itrack) ;
1763   
1764 }
1765
1766 //____________________________________________________________________________ 
1767 void AliEMCALGetter::ReadTreeQA()
1768 {
1769   if (fDebug)
1770     cout << "WARNING : " << ClassName() << "::ReadTreeQA -> not implemented" << endl ; 
1771   // Read the digit tree gAlice->TreeQA()
1772   // so far only EMCAL knows about this Tree  
1773
1774 //   if(EMCAL()->TreeQA()== 0){
1775 //     cerr <<   "ERROR: AliEMCALGetter::ReadTreeQA: can not read TreeQA " << endl ;
1776 //     return ;
1777 //   }
1778   
1779 //   TBranch * qabranch = EMCAL()->TreeQA()->GetBranch("EMCAL") ; 
1780 //   if (!qabranch) { 
1781 //     if (fDebug)
1782 //       cout << "WARNING: AliEMCALGetter::ReadTreeQA -> Cannot find QA Alarms for EMCAL" << endl ;
1783 //     return ; 
1784 //   }   
1785   
1786 //   if(!Alarms())
1787 //     PostQA() ; 
1788
1789 //   qabranch->SetAddress(AlarmsRef()) ;
1790
1791 //   qabranch->GetEntry(0) ;
1792  
1793 //   PostQA("EMCAL") ; 
1794 //   TFolder * alarmsF = Alarms() ; 
1795 //   alarmsF->Clear() ; 
1796 //   qabranch->SetAddress(&alarmsF) ;
1797 //   qabranch->GetEntry(0) ;
1798   
1799 }
1800   
1801 //____________________________________________________________________________ 
1802 Int_t AliEMCALGetter::ReadTreeR(const Int_t event)
1803 {
1804   // Read the reconstrunction tree gAlice->TreeR()
1805   // A particularity has been introduced here :
1806   //  if gime->Event(ievent,"R") is called branches with the current title are read, the current title
1807   //   being for example give in AliPHOSPID(fileName, title)
1808   //  if gime(Event(ievent, "RA") is called the title of the branches is not checked anymore, "A" stands for any
1809   // This is a feature needed by PID to be able to reconstruct several times particles (each time a ther title is given)
1810   // from a given set of TrackSegments (with a given name)
1811   // This is why any is NOT used to read the branch of RecParticles
1812   // any migh have become obsolete : to be checked
1813   // See AliEMCALPIDv1    
1814
1815  TTree * treeR ;
1816   if(fToSplit){
1817     TFile * file = static_cast<TFile*>(gROOT->GetFile(fRecPointsFileName)); 
1818     if(!file) 
1819       file = TFile::Open(fRecPointsFileName) ;      
1820     // Get Digits Tree header from file
1821     TString treeName("TreeR") ;
1822     treeName += event ; 
1823     treeR = dynamic_cast<TTree*>(file->Get(treeName.Data()));
1824     if(!treeR){ // TreeR not found in header file
1825       if (fDebug)
1826         cout << "WARNING: AliEMCALGetter::ReadTreeD -> Cannot find TreeR in " << fRecPointsFileName.Data() << endl;
1827       return 1;
1828     }
1829   }
1830   else
1831     treeR = gAlice->TreeR() ;
1832   
1833   // RecPoints 
1834   TObjArray * lob = static_cast<TObjArray*>(treeR->GetListOfBranches()) ;
1835   TIter next(lob) ; 
1836   TBranch * branch = 0 ; 
1837   TBranch * towerbranch = 0 ; 
1838   TBranch * preshowerbranch = 0 ; 
1839   TBranch * clusterizerbranch = 0 ; 
1840   Bool_t emcalTowerRPfound = kFALSE, emcalPreShoRPfound = kFALSE, clusterizerfound = kFALSE ; 
1841
1842   
1843   while ( (branch = static_cast<TBranch*>(next())) && (!emcalTowerRPfound || !emcalPreShoRPfound || !clusterizerfound) ) {
1844     if(strcmp(branch->GetTitle(), fRecPointsTitle)==0 ) {
1845       if ( strcmp(branch->GetName(), "EMCALTowerRP")==0) {
1846         towerbranch = branch ; 
1847         emcalTowerRPfound = kTRUE ;
1848       }
1849       else if ( strcmp(branch->GetName(), "EMCALPreShoRP")==0) {
1850         preshowerbranch = branch ; 
1851         emcalPreShoRPfound = kTRUE ;
1852       }
1853       else if(strcmp(branch->GetName(), "AliEMCALClusterizer")==0){
1854         clusterizerbranch = branch ; 
1855         clusterizerfound = kTRUE ; 
1856       }
1857     }
1858   }
1859
1860   if ( !emcalTowerRPfound || !emcalPreShoRPfound || !clusterizerfound) {
1861     if (fDebug)
1862       cout << "WARNING: AliEMCALGetter::ReadTreeR -> Cannot find RecPoints and/or Clusterizer with name " 
1863            << fRecPointsTitle << endl ;
1864  
1865   } else { 
1866     if(!TowerRecPoints(fRecPointsTitle) ) 
1867       PostRecPoints(fRecPointsTitle) ;
1868     
1869     towerbranch->SetAddress(TowerRecPointsRef(fRecPointsTitle)) ;
1870     towerbranch->GetEntry(0) ;
1871
1872     preshowerbranch->SetAddress(PreShowerRecPointsRef(fRecPointsTitle)) ; 
1873     preshowerbranch->GetEntry(0) ;  
1874     
1875     if(!Clusterizer(fRecPointsTitle) )
1876       PostClusterizer(fRecPointsTitle) ;
1877     
1878     clusterizerbranch->SetAddress(ClusterizerRef(fRecPointsTitle)) ;
1879     clusterizerbranch->GetEntry(0) ;
1880   }
1881   
1882 //   //------------------- TrackSegments ---------------------
1883 //   next.Reset() ; 
1884 //   TBranch * tsbranch = 0 ; 
1885 //   TBranch * tsmakerbranch = 0 ; 
1886 //   Bool_t emcaltsfound = kFALSE, tsmakerfound = kFALSE ; 
1887 //   while ( (branch = static_cast<TBranch*>(next())) && (!emcaltsfound || !tsmakerfound) ) {
1888 //     if(strcmp(branch->GetTitle(), fTrackSegmentsTitle)==0 )  {
1889 //       if ( strcmp(branch->GetName(), "EMCALTS")==0){
1890 //      tsbranch = branch ; 
1891 //      emcaltsfound = kTRUE ;
1892 //       }
1893 //       else if(strcmp(branch->GetName(), "AliEMCALTrackSegmentMaker")==0) {
1894 //      tsmakerbranch = branch ; 
1895 //      tsmakerfound  = kTRUE ; 
1896 //       }
1897 //     }
1898 //   }
1899
1900 //   if ( !emcaltsfound || !tsmakerfound ) {
1901 //     if (fDebug)
1902 //       cout << "WARNING: AliEMCALGetter::ReadTreeR -> Cannot find TrackSegments and/or TrackSegmentMaker with name "
1903 //         << fTrackSegmentsTitle << endl ;
1904 //   } else { 
1905 //     // Read and Post the TrackSegments
1906 //     if(!TrackSegments(fTrackSegmentsTitle))
1907 //       PostTrackSegments(fTrackSegmentsTitle) ;
1908 //     tsbranch->SetAddress(TrackSegmentsRef(fTrackSegmentsTitle)) ;
1909 //     tsbranch->GetEntry(0) ;
1910
1911 //     // Read and Post the TrackSegment Maker
1912 //     if(!TrackSegmentMaker(fTrackSegmentsTitle))
1913 //       PostTrackSegmentMaker(fTrackSegmentsTitle) ;
1914 //     tsmakerbranch->SetAddress(TSMakerRef(fTrackSegmentsTitle)) ;
1915 //     tsmakerbranch->GetEntry(0) ;
1916 //  }
1917   
1918   
1919 //   //------------ RecParticles ----------------------------
1920 //   next.Reset() ; 
1921 //   TBranch * rpabranch = 0 ; 
1922 //   TBranch * pidbranch = 0 ; 
1923 //   Bool_t emcalrpafound = kFALSE, pidfound = kFALSE ; 
1924   
1925 //   while ( (branch = static_cast<TBranch*>(next())) && (!emcalrpafound || !pidfound) ) 
1926 //     if(strcmp(branch->GetTitle(), fRecParticlesTitle)==0) {   
1927 //       if ( strcmp(branch->GetName(), "EMCALRP")==0) {   
1928 //      rpabranch = branch ; 
1929 //      emcalrpafound = kTRUE ;
1930 //       }
1931 //       else if (strcmp(branch->GetName(), "AliEMCALPID")==0) {
1932 //      pidbranch = branch ; 
1933 //      pidfound  = kTRUE ; 
1934 //       }
1935 //     }
1936   
1937 //   if ( !emcalrpafound || !pidfound ) {
1938 //     if (fDebug)
1939 //       cout << "WARNING: AliEMCALGetter::ReadTreeR -> Cannot find RecParticles and/or PID with name " 
1940 //         << fRecParticlesTitle << endl ; 
1941 //   } else { 
1942 //     // Read and Post the RecParticles
1943 //     if(!RecParticles(fRecParticlesTitle)) 
1944 //       PostRecParticles(fRecParticlesTitle) ;
1945 //     rpabranch->SetAddress(RecParticlesRef(fRecParticlesTitle)) ;
1946 //     rpabranch->GetEntry(0) ;
1947 //     // Read and Post the PID
1948 //     if(!PID(fRecParticlesTitle))
1949 //       PostPID(fRecParticlesTitle) ;
1950 //     pidbranch->SetAddress(PIDRef(fRecParticlesTitle)) ;
1951 //     pidbranch->GetEntry(0) ;
1952 //   }
1953
1954   if(gAlice->TreeR()!=treeR)
1955     treeR->Delete();
1956   return 0 ; 
1957 }
1958
1959 //____________________________________________________________________________ 
1960 Int_t AliEMCALGetter::ReadTreeS(Int_t event)
1961 {
1962   // Reads the SDigits treeS from all files  
1963   // Files, which should be opened are listed in emcalF
1964   // So, first get list of files
1965   TFolder * emcalF = dynamic_cast<TFolder *>(fSDigitsFolder->FindObject("EMCAL")) ;
1966   if (!emcalF) 
1967     emcalF = fSDigitsFolder->AddFolder("EMCAL", "SDigits from EMCAL") ; 
1968   TCollection * folderslist = emcalF->GetListOfFolders() ; 
1969   
1970   // Now iterate over the list of files and read TreeS into Whiteboard
1971   TIter next(folderslist) ; 
1972   TFolder * folder = 0 ; 
1973   TFile * file; 
1974   TTree * treeS = 0;
1975   while ( (folder = static_cast<TFolder*>(next())) ) {
1976     TString fileName("") ;
1977     if(fToSplit)
1978       fileName = folder->GetTitle() ;
1979     else
1980       fileName = folder->GetName() ; 
1981     fileName.ReplaceAll("_","/") ; 
1982     file = static_cast<TFile*>(gROOT->GetFile(fileName)); 
1983     if(!file) 
1984       file = TFile::Open(fileName) ;      
1985     // Get SDigits Tree header from file
1986     TString treeName("TreeS") ;
1987     treeName += event ; 
1988     treeS = dynamic_cast<TTree*>(file->Get(treeName.Data()));
1989
1990     if(!treeS){ // TreeS not found in header file
1991       if (fDebug)
1992         cout << "WARNING: AliEMCALGetter::ReadTreeS -> Cannot find TreeS in " << fileName.Data() << endl;
1993       return 1;
1994     }
1995     
1996     //set address of the SDigits and SDigitizer
1997     TBranch   * sdigitsBranch    = 0;
1998     TBranch   * sdigitizerBranch = 0;
1999     TBranch   * branch           = 0 ;  
2000     TObjArray * lob = static_cast<TObjArray*>(treeS->GetListOfBranches()) ;
2001     TIter next(lob) ; 
2002     Bool_t emcalfound = kFALSE, sdigitizerfound = kFALSE ; 
2003
2004     while ( (branch = static_cast<TBranch*>(next())) && (!emcalfound || !sdigitizerfound) ) {
2005       if ( (strcmp(branch->GetName(), "EMCAL")==0) && (strcmp(branch->GetTitle(), fSDigitsTitle)==0) ) {
2006         emcalfound = kTRUE ;
2007         sdigitsBranch = branch ; 
2008       }
2009       
2010       else if ( (strcmp(branch->GetName(), "AliEMCALSDigitizer")==0) && 
2011                 (strcmp(branch->GetTitle(), fSDigitsTitle)==0) ) {
2012         sdigitizerfound = kTRUE ; 
2013         sdigitizerBranch = branch ;
2014       }
2015     }
2016     if ( !emcalfound || !sdigitizerfound ) {
2017       if (fDebug)
2018         cout << "WARNING: AliEMCALDigitizer::ReadSDigits -> Digits and/or Digitizer branch with name " << GetName() 
2019              << " not found" << endl ;
2020       return 2; 
2021     }   
2022     
2023     if ( !folder->FindObject(fSDigitsTitle) )  
2024       PostSDigits(fSDigitsTitle,folder->GetName()) ;
2025
2026     ((TClonesArray*) (*SDigitsRef(fSDigitsTitle,folder->GetName())))->Clear() ;
2027     sdigitsBranch->SetAddress(SDigitsRef(fSDigitsTitle,folder->GetName())) ;
2028     sdigitsBranch->GetEntry(0) ;
2029     
2030     TString sdname(fSDigitsTitle) ;
2031     sdname+=":" ;
2032     sdname+=folder->GetName() ;
2033     if(!SDigitizer(sdname) ) 
2034       PostSDigitizer(fSDigitsTitle,folder->GetName()) ;
2035     sdigitizerBranch->SetAddress(SDigitizerRef(sdname)) ;
2036     sdigitizerBranch->GetEntry(0) ; 
2037     if(gAlice->TreeS()!=treeS)
2038       treeS->Delete();
2039   }    
2040    return 0 ;  
2041 }
2042
2043 //____________________________________________________________________________ 
2044 void AliEMCALGetter::ReadTreeS(TTree * treeS, Int_t input)
2045 {  // Read the summable digits fron treeS()  
2046
2047
2048   TString filename("mergefile") ;
2049   filename+= input ;
2050
2051   TFolder * emcalFolder = dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("EMCAL")) ; 
2052   if ( !emcalFolder ) { 
2053    emcalFolder = fSDigitsFolder->AddFolder("EMCAL", "SDigits from EMCAL") ; 
2054   } 
2055   TFolder * folder=(TFolder*)emcalFolder->FindObject(filename) ;
2056   //set address of the SDigits and SDigitizer
2057   TBranch   * sdigitsBranch    = 0;
2058   TBranch   * sdigitizerBranch = 0;
2059   TBranch   * branch           = 0 ;  
2060   TObjArray * lob = (TObjArray*)treeS->GetListOfBranches() ;
2061   TIter next(lob) ; 
2062   Bool_t emcalfound = kFALSE, sdigitizerfound = kFALSE ; 
2063   
2064   while ( (branch = (TBranch*)next()) && (!emcalfound || !sdigitizerfound) ) {
2065     if ( strcmp(branch->GetName(), "EMCAL")==0) {
2066       emcalfound = kTRUE ;
2067       sdigitsBranch = branch ; 
2068     }
2069     
2070     else if ( strcmp(branch->GetName(), "AliEMCALSDigitizer")==0) {
2071       sdigitizerfound = kTRUE ; 
2072       sdigitizerBranch = branch ;
2073     }
2074   }
2075   if ( !emcalfound || !sdigitizerfound ) {
2076     if (fDebug)
2077       cout << "WARNING: AliEMCALGetter::ReadTreeS -> Digits and/or Digitizer branch not found" << endl ;
2078     return ; 
2079   }   
2080   
2081   if (!folder || !(folder->FindObject(sdigitsBranch->GetTitle()) ) )
2082     PostSDigits(sdigitsBranch->GetTitle(),filename) ;
2083
2084   sdigitsBranch->SetAddress(SDigitsRef(sdigitsBranch->GetTitle(),filename)) ;
2085   sdigitsBranch->GetEntry(0) ;
2086   
2087   TString sdname(sdigitsBranch->GetTitle()) ;
2088   sdname+=":" ;
2089   sdname+=filename ;
2090
2091   if(!SDigitizer(sdigitsBranch->GetTitle()) )
2092     PostSDigitizer(sdigitsBranch->GetTitle(),filename) ;
2093   sdigitizerBranch->SetAddress(SDigitizerRef(sdname)) ;
2094   sdigitizerBranch->GetEntry(0) ;
2095   if(gAlice->TreeS()!=treeS)
2096     treeS->Delete();
2097 }    
2098
2099
2100 //____________________________________________________________________________ 
2101 void AliEMCALGetter::ReadPrimaries()
2102 {
2103   // Reads specific branches of primaries
2104   
2105   TClonesArray * ar = 0  ; 
2106   if(! (ar = Primaries()) ) { 
2107     PostPrimaries() ;
2108     ar = Primaries() ; 
2109   }
2110   ar->Delete() ; 
2111   
2112   if (TreeK(fHeaderFile)) { // treeK found in header file
2113     if (fDebug) 
2114       cout << "INFO: AliEMCALGetter::ReadPrimaries -> TreeK found in " << fHeaderFile.Data() << endl ; 
2115     fNPrimaries = gAlice->GetNtrack() ; 
2116     fAlice = 0 ; 
2117
2118   } else { // treeK not found in header file
2119
2120     cerr << "ERROR: AliEMCALGetter::ReadPrimaries -> TreeK not  found " << endl ; 
2121     return ;
2122     
2123   }
2124   Int_t index = 0 ; 
2125   for (index = 0 ; index < fNPrimaries; index++) { 
2126     new ((*ar)[index]) TParticle(*(Primary(index)));
2127   }
2128 }
2129
2130 //____________________________________________________________________________ 
2131 void AliEMCALGetter::Event(const Int_t event, const char* opt)
2132 {
2133   // Reads the content of all Tree's S, D and R
2134   
2135   if (event >= gAlice->TreeE()->GetEntries() ) {
2136     cerr << "ERROR: AliEMCALGetter::Event -> " << event << " not found in TreeE!" << endl ; 
2137     return ; 
2138   }
2139
2140   Bool_t any = kFALSE ; 
2141   if (strstr(opt,"A") ) // do not check the title of the branches
2142     any = kTRUE; 
2143
2144   gAlice->GetEvent(event) ; 
2145
2146   if( strstr(opt,"R") )
2147     ReadTreeR(event) ;
2148
2149   if( strstr(opt,"D") )
2150     ReadTreeD(event) ;
2151
2152   if(strstr(opt,"S") )
2153     ReadTreeS(event) ;
2154
2155   if(strstr(opt,"H") )
2156     ReadTreeH() ;
2157    
2158   if( strstr(opt,"Q") )
2159     ReadTreeQA() ;
2160  
2161   if( strstr(opt,"P") || (strcmp(opt,"")==0) )
2162     ReadPrimaries() ;
2163   
2164 }
2165
2166 //____________________________________________________________________________ 
2167 TObject * AliEMCALGetter::ReturnO(TString what, TString name, TString file) const 
2168 {
2169   // get the object named "what" from the folder
2170   // folders are named like //Folders
2171
2172   if ( file.IsNull() ) 
2173     file = fHeaderFile ; 
2174
2175   TFolder * folder = 0 ;
2176   TObject * emcalO  = 0 ; 
2177
2178   if ( what.CompareTo("Primaries") == 0 ) {
2179     folder = dynamic_cast<TFolder *>(fPrimariesFolder->FindObject("Primaries")) ; 
2180     if (folder) 
2181       emcalO  = dynamic_cast<TObject *>(folder->FindObject("Primaries")) ;  
2182     else 
2183       return 0 ; 
2184   }
2185   else if ( what.CompareTo("Hits") == 0 ) {
2186     folder = dynamic_cast<TFolder *>(fHitsFolder->FindObject("EMCAL")) ; 
2187     if (folder) 
2188       emcalO  = dynamic_cast<TObject *>(folder->FindObject("Hits")) ;  
2189   }
2190   else if ( what.CompareTo("SDigits") == 0 ) { 
2191     file.ReplaceAll("/","_") ; 
2192     TString path = "EMCAL/" + file  ; 
2193     folder = dynamic_cast<TFolder *>(fSDigitsFolder->FindObject(path.Data())) ; 
2194     if (folder) { 
2195       if (name.IsNull())
2196         name = fSDigitsTitle ; 
2197       emcalO  = dynamic_cast<TObject *>(folder->FindObject(name)) ; 
2198     }
2199   }
2200   else if ( what.CompareTo("Digits") == 0 ){
2201     folder = dynamic_cast<TFolder *>(fDigitsFolder->FindObject("EMCAL")) ; 
2202     if (folder) { 
2203       if (name.IsNull())
2204         name = fDigitsTitle ; 
2205       emcalO  = dynamic_cast<TObject *>(folder->FindObject(name)) ; 
2206     } 
2207   }
2208   else if ( what.CompareTo("TowerRecPoints") == 0 ) {
2209     folder = dynamic_cast<TFolder *>(fRecoFolder->FindObject("EMCAL/TowerRecPoints")) ; 
2210     if (folder) { 
2211       if (name.IsNull())
2212         name = fRecPointsTitle ; 
2213       emcalO  = dynamic_cast<TObject *>(folder->FindObject(name)) ; 
2214     } 
2215   }
2216   else if ( what.CompareTo("PreShowerRecPoints") == 0 ) {
2217     folder = dynamic_cast<TFolder *>(fRecoFolder->FindObject("EMCAL/PreShowerRecPoints")) ; 
2218     if (folder) { 
2219       if (name.IsNull())
2220         name = fRecPointsTitle ; 
2221       emcalO  = dynamic_cast<TObject *>(folder->FindObject(name)) ; 
2222     }   
2223   }
2224   /*
2225   else if ( what.CompareTo("TrackSegments") == 0 ) {
2226     folder = dynamic_cast<TFolder *>(fRecoFolder->FindObject("EMCAL/TrackSegments")) ; 
2227     if (folder) { 
2228       if (name.IsNull())
2229         name = fTrackSegmentsTitle ; 
2230       emcalO  = dynamic_cast<TObject *>(folder->FindObject(name)) ; 
2231     }   
2232   }
2233   else if ( what.CompareTo("RecParticles") == 0 ) {
2234     folder = dynamic_cast<TFolder *>(fRecoFolder->FindObject("EMCAL/RecParticles")) ; 
2235    if (folder) { 
2236       if (name.IsNull())
2237         name = fRecParticlesTitle ; 
2238       emcalO  = dynamic_cast<TObject *>(folder->FindObject(name)) ; 
2239     }   
2240  }
2241   else if ( what.CompareTo("Alarms") == 0 ){ 
2242     if (name.IsNull() ) 
2243       emcalO = dynamic_cast<TObject *>(fQAFolder->FindObject("EMCAL")) ;  
2244     else {
2245       folder = dynamic_cast<TFolder *>(fQAFolder->FindObject("EMCAL")) ; 
2246       if (!folder) 
2247         emcalO = 0 ; 
2248       else 
2249         emcalO = dynamic_cast<TObject *>(folder->FindObject(name)) ;  
2250     }
2251   }
2252 */
2253   if (!emcalO) {
2254     if(fDebug)
2255       cout << "WARNING : AliEMCALGetter::ReturnO -> Object " << what << " not found in " << folder->GetName() << endl ; 
2256     return 0 ;
2257   }
2258
2259   return emcalO ;
2260 }
2261   
2262 //____________________________________________________________________________ 
2263 const TTask * AliEMCALGetter::ReturnT(TString what, TString name) const 
2264 {
2265   // get the TTask named "what" from the folder
2266   // folders are named like //Folders/Tasks/what/EMCAL/name
2267
2268   TString search(what) ; 
2269   if ( what.CompareTo("Clusterizer") == 0 ) 
2270     search = "Reconstructioner" ; 
2271   else if ( what.CompareTo("TrackSegmentMaker") == 0 ) 
2272     search = "Reconstructioner" ; 
2273   else if ( what.CompareTo("PID") == 0 ) 
2274     search = "Reconstructioner" ; 
2275   else if ( what.CompareTo("QATasks") == 0 ) 
2276     search = "QA" ; 
2277   
2278   TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject(search)) ; 
2279
2280   if (!tasks) {
2281     cerr << "ERROR: AliEMCALGetter::ReturnT -> Task " << what << " not found!" << endl ;  
2282     return 0 ; 
2283   }
2284
2285   TTask * emcalT = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ; 
2286   if (!emcalT) { 
2287     cerr << "ERROR: AliEMCALGetter::ReturnT -> Task " << what << "/EMCAL not found!" << endl ;  
2288     return 0 ; 
2289   }
2290   
2291   TList * list = emcalT->GetListOfTasks() ; 
2292  
2293   if (what.CompareTo("SDigitizer") == 0) {  
2294     if ( name.IsNull() )
2295       name =  fSDigitsTitle ; 
2296   } else  if (what.CompareTo("Digitizer") == 0){ 
2297     if ( name.IsNull() )
2298       name =  fDigitsTitle ;
2299   } else  if (what.CompareTo("Clusterizer") == 0){ 
2300     if ( name.IsNull() )
2301       name =  fRecPointsTitle ;
2302     name.Append(":clu") ;
2303   }
2304  //  else  if (what.CompareTo("TrackSegmentMaker") == 0){ 
2305 //     if ( name.IsNull() )
2306 //       name =  fTrackSegmentsTitle ;
2307 //     name.Append(":tsm") ;
2308 //   }
2309 //   else  if (what.CompareTo("PID") == 0){ 
2310 //     if ( name.IsNull() )
2311 //       name =  fRecParticlesTitle ;
2312 //     name.Append(":pid") ;
2313 //   }
2314 //   else  if (what.CompareTo("QATasks") == 0){ 
2315 //     if ( name.IsNull() )
2316 //       return emcalT ;
2317 //   }
2318   
2319   TIter it(list) ;
2320   TTask * task = 0 ; 
2321   while((task = static_cast<TTask *>(it.Next()) )){
2322     TString taskname(task->GetName()) ;
2323     if(taskname.BeginsWith(name)){
2324     return task ;}
2325   }
2326   
2327   if(fDebug)
2328     cout << "WARNING: AliEMCALGetter::ReturnT -> Task " << search << "/" << name << " not found!" << endl ; 
2329   return 0 ;
2330 }
2331
2332 //____________________________________________________________________________ 
2333 void AliEMCALGetter::RemoveTask(TString opt, TString name) const 
2334 {
2335   // remove a task from the folder
2336   // path is fTasksFolder/SDigitizer/EMCAL/name
2337
2338   TTask * task  = 0 ; 
2339   TTask * emcal = 0 ; 
2340   TList * lofTasks = 0 ; 
2341
2342   if (opt == "S") { // SDigitizer
2343     task = dynamic_cast<TTask*>(fTasksFolder->FindObject("SDigitizer")) ;
2344     if (!task) 
2345       return ; 
2346   } 
2347   else if (opt == "D") { // Digitizer
2348     task = dynamic_cast<TTask*>(fTasksFolder->FindObject("Digitizer")) ;
2349     if (!task) 
2350       return ; 
2351   }
2352   else if (opt == "C") { // Clusterizer
2353     task = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
2354     if (!task) 
2355       return ; 
2356   }
2357   else {
2358     cerr << "WARNING: AliEMCALGetter::RemoveTask -> Unknown option " << opt.Data() << endl ; 
2359     return ; 
2360   }    
2361   emcal =  dynamic_cast<TTask*>(task->GetListOfTasks()->FindObject("EMCAL")) ;
2362   if (!emcal)
2363     return ; 
2364   lofTasks = emcal->GetListOfTasks() ;
2365   if (!lofTasks) 
2366     return ; 
2367   TObject * obj = lofTasks->FindObject(name) ; 
2368   if (obj) 
2369     lofTasks->Remove(obj) ;
2370
2371 }
2372   
2373 //____________________________________________________________________________ 
2374 void AliEMCALGetter::RemoveObjects(TString opt, TString name) const 
2375 {
2376   // remove SDigits from the folder
2377   // path is fSDigitsFolder/fHeaderFileName/name
2378
2379   TFolder * emcal     = 0 ; 
2380   TFolder * emcalmain = 0 ; 
2381
2382   if (opt == "H") { // Hits
2383     emcal = dynamic_cast<TFolder*>(fHitsFolder->FindObject("EMCAL")) ;
2384     if (!emcal) 
2385       return ;
2386     name = "Hits" ; 
2387   }
2388   
2389   else if ( opt == "S") { // SDigits
2390     emcalmain = dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("EMCAL")) ;
2391     if (!emcalmain) 
2392       return ;
2393     emcal = dynamic_cast<TFolder*>(emcalmain->FindObject(fHeaderFile)) ;
2394     if (!emcal) 
2395       return ;
2396   }
2397
2398   else if (opt == "D") { // Digits
2399     emcal = dynamic_cast<TFolder*>(fDigitsFolder->FindObject("EMCAL")) ;
2400     if (!emcal) 
2401       return ;
2402   }
2403
2404   else if (opt == "RT") { // Tower RecPoints
2405     emcal = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/TowerRecPoints")) ;
2406     if (!emcal) 
2407       return ;
2408   }
2409
2410   else if (opt == "RP") { // Preshower RecPoints
2411     emcal = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/PreShowerRecPoints")) ;
2412     if (!emcal) 
2413       return ;
2414   }
2415
2416   else if (opt == "T") { // TrackSegments
2417     emcal = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/TrackSegments")) ;
2418     if (!emcal) 
2419       return ;
2420   }
2421
2422   else if (opt == "P") { // RecParticles
2423     emcal = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/RecParticles")) ;
2424     if (!emcal) 
2425       return ;
2426   }
2427   
2428   else {
2429     cerr << "WARNING: AliEMCALGetter::RemoveObjects -> Unknown option " << opt.Data() << endl ; 
2430     return ; 
2431   }
2432   
2433   TObjArray * ar  = dynamic_cast<TObjArray*>(emcal->FindObject(name)) ; 
2434   if (ar) { 
2435     emcal->Remove(ar) ;
2436     ar->Delete() ; 
2437     delete ar ; 
2438   }
2439
2440   if (opt == "S") 
2441     emcalmain->Remove(emcal) ; 
2442   
2443 }
2444
2445 //____________________________________________________________________________ 
2446 void AliEMCALGetter::RemoveSDigits() const 
2447 {
2448   TFolder * emcal= dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("EMCAL")) ;
2449   if (!emcal) 
2450     return ;
2451   
2452   emcal->SetOwner() ; 
2453   emcal->Clear() ; 
2454 }
2455
2456 //____________________________________________________________________________ 
2457 void AliEMCALGetter::CleanWhiteBoard(void){
2458
2459   TFolder * emcalmain = 0 ; 
2460   TFolder * emcal ;
2461   TObjArray * ar ;
2462   TList * lofTasks = 0 ; 
2463   TTask * task = 0 ; 
2464   TTask * emcalt = 0 ; 
2465   
2466   // Hits  
2467   emcal = dynamic_cast<TFolder*>(fHitsFolder->FindObject("EMCAL")) ;
2468   if (emcal){  
2469     TObjArray * ar  = dynamic_cast<TObjArray*>(emcal->FindObject("Hits")) ; 
2470     if (ar) { 
2471       emcal->Remove(ar) ;
2472       ar->Delete() ; 
2473       delete ar ; 
2474     }
2475   }
2476   
2477   // SDigits
2478   emcalmain = dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("EMCAL")) ;
2479   if (emcalmain){ 
2480     emcal = dynamic_cast<TFolder*>(emcalmain->FindObject(fHeaderFile)) ;
2481     if (emcal) {
2482       ar  = dynamic_cast<TObjArray*>(emcal->FindObject(fSDigitsTitle)) ; 
2483       if (ar) { 
2484         emcal->Remove(ar) ;
2485         ar->Delete() ; 
2486         delete ar ; 
2487       }
2488     }
2489     emcalmain->Remove(emcal) ; 
2490   }
2491
2492   
2493   // Digits
2494   emcal = dynamic_cast<TFolder*>(fDigitsFolder->FindObject("EMCAL")) ;
2495   if (emcal){ 
2496     ar  = dynamic_cast<TObjArray*>(emcal->FindObject(fDigitsTitle)) ; 
2497     if (ar) { 
2498       emcal->Remove(ar) ;
2499       ar->Delete() ; 
2500       delete ar ; 
2501     }
2502   }
2503
2504
2505   // TowerRecPoints
2506   emcal = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/TowerRecPoints")) ;
2507   if (emcal){ 
2508     ar  = dynamic_cast<TObjArray*>(emcal->FindObject(fRecPointsTitle)) ; 
2509     if (ar) { 
2510       emcal->Remove(ar) ;
2511       ar->Delete() ; 
2512       delete ar ; 
2513     }
2514   }
2515
2516   
2517   // PreShowerRecPoints
2518   emcal = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/PreShowerRecPoints")) ;
2519   if (emcal){ 
2520     ar  = dynamic_cast<TObjArray*>(emcal->FindObject(fRecPointsTitle)) ; 
2521     if (ar) { 
2522       emcal->Remove(ar) ;
2523       ar->Delete() ; 
2524       delete ar ; 
2525     }
2526   }  
2527
2528   
2529   // TrackSegments
2530   emcal = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/TrackSegments")) ;
2531   if (emcal) { 
2532     ar  = dynamic_cast<TObjArray*>(emcal->FindObject(fTrackSegmentsTitle)) ; 
2533     if (ar) { 
2534       emcal->Remove(ar) ;
2535       ar->Delete() ; 
2536       delete ar ; 
2537     }
2538   }
2539   
2540
2541
2542   // RecParticles
2543   emcal = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/RecParticles")) ;
2544   if (emcal){ 
2545     ar  = dynamic_cast<TObjArray*>(emcal->FindObject(fRecParticlesTitle)) ; 
2546     if (ar) { 
2547       emcal->Remove(ar) ;
2548       ar->Delete() ; 
2549       delete ar ; 
2550     }
2551   }
2552
2553
2554   //---- Now Tasks ----------- 
2555
2556   TObject * obj ;
2557   TString sdname(fSDigitsTitle);
2558   
2559   // Digitizer
2560   task = dynamic_cast<TTask*>(fTasksFolder->FindObject("Digitizer")) ;
2561   if (task){ 
2562     emcalt =  dynamic_cast<TTask*>(task->GetListOfTasks()->FindObject("EMCAL")) ;
2563     if (emcalt){
2564       lofTasks = emcalt->GetListOfTasks() ;
2565       if (lofTasks){ 
2566         obj = lofTasks->FindObject(sdname.Data()) ; 
2567         if (obj) 
2568           lofTasks->Remove(obj) ;
2569       }
2570     }      
2571   }
2572   
2573
2574   sdname.Append(":") ;
2575   // Clusterizer, TrackSegmentMaker, PID
2576   task = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
2577   if (task){ 
2578     emcalt =  dynamic_cast<TTask*>(task->GetListOfTasks()->FindObject("EMCAL")) ;
2579     if (emcalt){
2580       lofTasks = emcalt->GetListOfTasks() ;
2581       TIter next(lofTasks);
2582       while((obj=next())){ 
2583         TString oname(obj->GetName()) ;
2584         if (oname.BeginsWith(sdname)){ 
2585           lofTasks->Remove(obj) ;
2586         }
2587       }
2588     }  
2589   }
2590
2591
2592   // SDigitizer
2593   sdname.Append(fHeaderFile) ;
2594   task = dynamic_cast<TTask*>(fTasksFolder->FindObject("SDigitizer")) ;
2595   if (task) {
2596     emcalt =  dynamic_cast<TTask*>(task->GetListOfTasks()->FindObject("EMCAL")) ;
2597     if (emcalt){
2598       lofTasks = emcalt->GetListOfTasks() ;
2599       if (lofTasks){ 
2600         obj = lofTasks->FindObject(sdname.Data()) ; 
2601         if (obj) 
2602           lofTasks->Remove(obj) ;
2603       }
2604     }
2605   }  
2606
2607 }
2608 //____________________________________________________________________________ 
2609 void AliEMCALGetter::SetTitle(const char * branchTitle ) 
2610 {
2611   fBranchTitle        = branchTitle ;
2612   fSDigitsTitle       = branchTitle ; 
2613   fDigitsTitle        = branchTitle ; 
2614   fRecPointsTitle     = branchTitle ; 
2615   fRecParticlesTitle  = branchTitle ; 
2616   fTrackSegmentsTitle = branchTitle ; 
2617   if(fToSplit){
2618     //First - extract full path if necessary
2619     TString sFileName(fHeaderFile) ;
2620     Ssiz_t islash = sFileName.Last('/') ;
2621     if(islash<sFileName.Length())
2622       sFileName.Remove(islash+1,sFileName.Length()) ;
2623     else
2624       sFileName="" ;
2625     //Now construct file names
2626     fSDigitsFileName       = sFileName ;
2627     fDigitsFileName        = sFileName ; 
2628     fRecPointsFileName     = sFileName ; 
2629     fRecParticlesFileName  = sFileName ; 
2630     fTrackSegmentsFileName = sFileName ; 
2631     fSDigitsFileName      += "EMCAL.SDigits." ;
2632     fDigitsFileName       += "EMCAL.Digits." ; 
2633     fRecPointsFileName    += "EMCAL.RecData." ; 
2634     fTrackSegmentsFileName+= "EMCAL.RecData." ; 
2635     fRecParticlesFileName += "EMCAL.RecData." ; 
2636     if((strcmp(fBranchTitle.Data(),"Default")!=0)&&(strcmp(fBranchTitle.Data(),"")!=0)){
2637       fSDigitsFileName      += fBranchTitle ;
2638       fSDigitsFileName      += "." ;
2639       fDigitsFileName       += fBranchTitle ; 
2640       fDigitsFileName       += "." ; 
2641       fRecPointsFileName    += fBranchTitle ; 
2642       fRecPointsFileName    += "." ; 
2643       fRecParticlesFileName += fBranchTitle ; 
2644       fRecParticlesFileName += "." ; 
2645       fTrackSegmentsFileName+= fBranchTitle ; 
2646       fTrackSegmentsFileName+= "." ; 
2647     }
2648     fSDigitsFileName      += "root" ;
2649     fDigitsFileName       += "root" ; 
2650     fRecPointsFileName    += "root" ; 
2651     fRecParticlesFileName += "root" ; 
2652     fTrackSegmentsFileName+= "root" ; 
2653   }else{
2654     fSDigitsFileName       = "" ; 
2655     fDigitsFileName        = "" ; 
2656     fRecPointsFileName     = "" ; 
2657     fRecParticlesFileName  = "" ; 
2658     fTrackSegmentsFileName = "" ; 
2659   }
2660   TFolder * emcalFolder ; 
2661   emcalFolder = dynamic_cast<TFolder*>(fHitsFolder->FindObject("EMCAL")) ; 
2662   if ( !emcalFolder ) 
2663     emcalFolder = fHitsFolder->AddFolder("EMCAL", "Hits from EMCAL") ; 
2664
2665   emcalFolder = dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("EMCAL")) ;
2666   if ( !emcalFolder ) 
2667     emcalFolder = fSDigitsFolder->AddFolder("EMCAL", "SDigits from EMCAL") ; 
2668   
2669   //Make folder for SDigits
2670   TString subdir(fHeaderFile) ;
2671   subdir.ReplaceAll("/","_") ;
2672   emcalFolder->AddFolder(subdir, fSDigitsFileName.Data());
2673
2674
2675   emcalFolder  = dynamic_cast<TFolder*>(fDigitsFolder->FindObject("EMCAL")) ;
2676   if ( !emcalFolder ) 
2677     emcalFolder = fDigitsFolder->AddFolder("EMCAL", "Digits from EMCAL") ;  
2678
2679   emcalFolder  = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL")) ; 
2680   if ( !emcalFolder )
2681     emcalFolder = fRecoFolder->AddFolder("EMCAL", "Reconstructed data from EMCAL") ;  
2682   
2683
2684 }
2685 //____________________________________________________________________________ 
2686 void AliEMCALGetter::CloseSplitFiles(void){
2687   TFile * file ;
2688   file = static_cast<TFile*>(gROOT->GetFile(fSDigitsFileName.Data() ) ) ;
2689   if(file)
2690     file->Close() ;
2691   file = static_cast<TFile*>(gROOT->GetFile(fDigitsFileName.Data() ) ) ;
2692   if(file)
2693     file->Close() ;
2694   file = static_cast<TFile*>(gROOT->GetFile(fRecPointsFileName.Data() ) ) ;
2695   if(file)
2696     file->Close() ;
2697   file = static_cast<TFile*>(gROOT->GetFile(fTrackSegmentsFileName.Data() ) ) ;
2698   if(file)
2699     file->Close() ;
2700   file = static_cast<TFile*>(gROOT->GetFile(fRecParticlesFileName.Data() ) ) ;
2701   if(file)
2702     file->Close() ;
2703
2704 }