Added the fFailed data member that gives the status of the file and of galice
[u/mrichter/AliRoot.git] / PHOS / AliPHOSGetter.cxx
CommitLineData
4ae78bb1 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
24//_________________________________________________________________________
25// A singleton. This class should be used in the analysis stage to get
26// reconstructed objects: Digits, RecPoints, TrackSegments and RecParticles,
27// instead of directly reading them from galice.root file. This container
28// ensures, that one reads Digits, made of these particular digits, RecPoints,
29// made of these particular RecPoints, TrackSegments and RecParticles.
30// This becomes non trivial if there are several identical branches, produced with
31// different set of parameters.
32//
33// An example of how to use (see also class AliPHOSAnalyser):
34// AliPHOSGetter * gime = AliPHOSGetter::GetInstance("galice.root","test") ;
35// for(Int_t irecp = 0; irecp < gime->NRecParticles() ; irecp++)
36// AliPHOSRecParticle * part = gime->RecParticle(1) ;
37// ................
38// please->GetEvent(event) ; // reads new event from galice.root
39//
40//*-- Author: Yves Schutz (SUBATECH) & Dmitri Peressounko (RRC KI & SUBATECH)
41//*-- Completely redesigned by Dmitri Peressounko March 2001
42//
43//*-- YS June 2001 : renamed the original AliPHOSIndexToObject and make
44//*-- systematic usage of TFolders without changing the interface
45//////////////////////////////////////////////////////////////////////////////
46
47
48// --- ROOT system ---
49
50#include "TFile.h"
51#include "TTree.h"
52#include "TROOT.h"
53#include "TObjString.h"
54#include "TFolder.h"
cb34a1fa 55#include "TParticle.h"
4ae78bb1 56
57// --- Standard library ---
58#include <iostream.h>
59
60// --- AliRoot header files ---
61
62#include "AliRun.h"
7a9d98f9 63#include "AliConfig.h"
4ae78bb1 64#include "AliPHOSGetter.h"
65#include "AliPHOS.h"
66#include "AliPHOSDigitizer.h"
67#include "AliPHOSSDigitizer.h"
68#include "AliPHOSClusterizer.h"
69#include "AliPHOSClusterizerv1.h"
70#include "AliPHOSTrackSegmentMaker.h"
71#include "AliPHOSTrackSegmentMakerv1.h"
72#include "AliPHOSTrackSegment.h"
73#include "AliPHOSPID.h"
74#include "AliPHOSPIDv1.h"
75#include "AliPHOSGeometry.h"
76
77ClassImp(AliPHOSGetter)
78
79 AliPHOSGetter * AliPHOSGetter::fgObjGetter = 0 ;
80
81//____________________________________________________________________________
82AliPHOSGetter::AliPHOSGetter(const char* headerFile, const char* branchTitle )
83{
84 //Initialize all lists
85
54b82aa4 86 fDebug = 0 ;
87
4ae78bb1 88 fHeaderFile = headerFile ;
b0bba0af 89 fBranchTitle = branchTitle ;
4ae78bb1 90 fSDigitsTitle = branchTitle ;
91 fDigitsTitle = branchTitle ;
92 fRecPointsTitle = branchTitle ;
93 fRecParticlesTitle = branchTitle ;
94 fTrackSegmentsTitle = branchTitle ;
95
96 fPrimaries = new TObjArray(1) ;
97
cb34a1fa 98 fModuleFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Run/Configuration/Modules"));
99 fPrimariesFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/RunMC/Event/Data"));
100 fHitsFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/RunMC/Event/Data/Hits"));
101 fSDigitsFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/RunMC/Event/Data/SDigits"));
102 fDigitsFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Run/Event/Data"));
103 fRecoFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Run/Event/RecData"));
104 fQAFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Run/Conditions/QA"));
105 fTasksFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Tasks")) ;
7a9d98f9 106
b0bba0af 107 if ( fHeaderFile != "aliroot" ) { // to call the getter without a file
518b8b75 108
eb9763ac 109 //open headers file
7a9d98f9 110 TFile * file = static_cast<TFile*>(gROOT->GetFile(fHeaderFile.Data() ) ) ;
4ae78bb1 111
eb9763ac 112 if(file == 0){ //if file was not opened yet, read gAlice
113 if(fHeaderFile.Contains("rfio")) // if we read file using HPSS
114 file = TFile::Open(fHeaderFile.Data(),"update") ;
115 else
116 file = new TFile(fHeaderFile.Data(),"update") ;
117
118 if (!file->IsOpen()) {
119 cerr << "ERROR : AliPHOSGetter::AliPHOSGetter -> Cannot open " << fHeaderFile.Data() << endl ;
120 abort() ;
121 }
122
7a9d98f9 123 gAlice = static_cast<AliRun *>(file->Get("gAlice")) ;
4ae78bb1 124 }
93aeb834 125 }
7a9d98f9 126
93aeb834 127 if (!gAlice) {
128 cerr << "ERROR : AliPHOSGetter::AliPHOSGetter -> Cannot find gAlice in " << fHeaderFile.Data() << endl ;
129 abort() ;
130 }
131 if (!PHOS()) {
132 if (fDebug)
133 cout << "INFO: AliPHOSGetter -> Posting PHOS to Folders" << endl ;
134 AliConfig * conf = AliConfig::Instance() ;
135 conf->Add(static_cast<AliDetector*>(gAlice->GetDetector("PHOS"))) ;
136 conf->Add(static_cast<AliModule*>(gAlice->GetDetector("PHOS"))) ;
4ae78bb1 137 }
93aeb834 138
b0bba0af 139 fDebug=0;
4ae78bb1 140}
4ae78bb1 141//____________________________________________________________________________
81bb1a45 142AliPHOSGetter::~AliPHOSGetter(){
7a9d98f9 143
ededcd8c 144 if (fPrimaries) {
145 fPrimaries->Delete() ;
146 delete fPrimaries ;
147 }
148
81bb1a45 149}
7a9d98f9 150
81bb1a45 151//____________________________________________________________________________
4ae78bb1 152void AliPHOSGetter::CreateWhiteBoard() const
153{
7a9d98f9 154
4ae78bb1 155}
156
157//____________________________________________________________________________
158AliPHOSGetter * AliPHOSGetter::GetInstance()
159{
160 // Returns the pointer of the unique instance already defined
161
162 AliPHOSGetter * rv = 0 ;
163 if ( fgObjGetter )
164 rv = fgObjGetter ;
165 else
166 cout << "AliPHOSGetter::GetInstance ERROR: not yet initialized" << endl ;
167
168 return rv ;
169}
170
171//____________________________________________________________________________
172AliPHOSGetter * AliPHOSGetter::GetInstance(const char* headerFile,
173 const char* branchTitle)
174{
175 // Creates and returns the pointer of the unique instance
176 // Must be called only when the environment has changed
177
b0bba0af 178 if ( fgObjGetter )
179 if((fgObjGetter->fBranchTitle.CompareTo(branchTitle) == 0) &&
180 (fgObjGetter->fHeaderFile.CompareTo(headerFile)==0))
181 return fgObjGetter ;
182 else
ededcd8c 183 fgObjGetter->~AliPHOSGetter() ; // delete it already exists another version
b0bba0af 184
4ae78bb1 185 fgObjGetter = new AliPHOSGetter(headerFile,branchTitle) ;
186
187 // Posts a few item to the white board (folders)
7a9d98f9 188 // fgObjGetter->CreateWhiteBoard() ;
b0bba0af 189
4ae78bb1 190 return fgObjGetter ;
191
192}
193
194//____________________________________________________________________________
7a9d98f9 195const AliPHOS * AliPHOSGetter::PHOS()
4ae78bb1 196{
197 // returns the PHOS object
7a9d98f9 198 AliPHOS * phos = dynamic_cast<AliPHOS*>(fModuleFolder->FindObject("PHOS")) ;
199 if (!phos)
200 if (fDebug)
201 cout << "WARNING: AliPHOSGetter::PHOS -> PHOS module not found in Folders" << endl ;
202 return phos ;
4ae78bb1 203}
204
205//____________________________________________________________________________
7a9d98f9 206const AliPHOSGeometry * AliPHOSGetter::PHOSGeometry()
4ae78bb1 207{
7a9d98f9 208 AliPHOSGeometry * rv = 0 ;
209 if (PHOS() )
210 rv = PHOS()->GetGeometry() ;
211 return rv ;
212}
4ae78bb1 213
214//____________________________________________________________________________
cb34a1fa 215Bool_t AliPHOSGetter::PostPrimaries(void) const
216{ //------- Primaries ----------------------
217
218 // the hierarchy is //Folders/RunMC/Event/Data/Primaries
219
220 TFolder * primariesFolder = dynamic_cast<TFolder*>(fPrimariesFolder->FindObject("Primaries")) ;
221 if ( !primariesFolder ) {
222 if (fDebug) {
223 cout << "WARNING: AliPHOSGetter::Post Primaries -> Folder //" << fPrimariesFolder << "/Primaries/ not found!" << endl;
224 cout << "INFO: AliPHOSGetter::Post Primaries -> Adding Folder //" << fPrimariesFolder << "/Primaries/" << endl;
225 }
226 primariesFolder = fPrimariesFolder->AddFolder("Primaries", "Primaries particles from TreeK") ;
227 }
228 TClonesArray *primaries= new TClonesArray("TParticle",1000) ;
229 primaries->SetName("Primaries") ;
230 primariesFolder->Add(primaries) ;
231
232 return kTRUE;
233}
234
235//____________________________________________________________________________
65c0665e 236TObject** AliPHOSGetter::PrimariesRef(void) const
cb34a1fa 237{ //------- Primaries ----------------------
238
239
240 // the hierarchy is //Folders/RunMC/Event/Data/Primaries
241 if ( !fPrimariesFolder ) {
242 cerr << "ERROR: AliPHOSGetter::Post PrimariesRef -> Folder //" << fPrimariesFolder << " not found!" << endl;
243 return 0;
244 }
245
246 TFolder * primariesFolder = dynamic_cast<TFolder *>(fPrimariesFolder->FindObject("Primaries")) ;
247 if ( !primariesFolder ) {
248 cerr << "ERROR: AliPHOSGetter::Post PrimariesRef -> Folder //" << fPrimariesFolder << "/Primaries/ not found!" << endl;
249 return 0;
250 }
251
252 TObject * p = primariesFolder->FindObject("Primaries") ;
253 if(!p) {
254 cerr << "ERROR: AliPHOSGetter::PrimariesRef -> " << primariesFolder->GetName() << "/Primaries not found !" << endl ;
255 return 0 ;
256 }
257 else
65c0665e 258 return primariesFolder->GetListOfFolders()->GetObjectRef(p) ;
cb34a1fa 259}
260
261//____________________________________________________________________________
b0bba0af 262Bool_t AliPHOSGetter::PostHits(void) const
263{ //------- Hits ----------------------
dbad285c 264
7a9d98f9 265 // the hierarchy is //Folders/RunMC/Event/Data/PHOS/Hits
b0bba0af 266
7a9d98f9 267 TFolder * phosFolder = dynamic_cast<TFolder*>(fHitsFolder->FindObject("PHOS")) ;
268 if ( !phosFolder ) {
269 if (fDebug) {
270 cout << "WARNING: AliPHOSGetter::Post H -> Folder //" << fHitsFolder << "/PHOS/ not found!" << endl;
271 cout << "INFO: AliPHOSGetter::Post H -> Adding Folder //" << fHitsFolder << "/PHOS/" << endl;
272 }
273 phosFolder = fHitsFolder->AddFolder("PHOS", "Hits from PHOS") ;
b0bba0af 274 }
7a9d98f9 275 TClonesArray *hits= new TClonesArray("AliPHOSHit",1000) ;
276 hits->SetName("Hits") ;
277 phosFolder->Add(hits) ;
278
b0bba0af 279 return kTRUE;
280}
7a9d98f9 281
b0bba0af 282//____________________________________________________________________________
65c0665e 283TObject** AliPHOSGetter::HitsRef(void) const
b0bba0af 284{ //------- Hits ----------------------
4ae78bb1 285
b0bba0af 286
7a9d98f9 287 // the hierarchy is //Folders/RunMC/Event/Data/PHOS/Hits
288 if ( !fHitsFolder ) {
289 cerr << "ERROR: AliPHOSGetter::Post H -> Folder //" << fHitsFolder << " not found!" << endl;
b0bba0af 290 return 0;
291 }
4ae78bb1 292
7a9d98f9 293 TFolder * phosFolder = dynamic_cast<TFolder *>(fHitsFolder->FindObject("PHOS")) ;
294 if ( !phosFolder ) {
295 cerr << "ERROR: AliPHOSGetter::Post HRef -> Folder //" << fHitsFolder << "/PHOS/ not found!" << endl;
296 return 0;
297 }
298
299 TObject * h = phosFolder->FindObject("Hits") ;
300 if(!h) {
301 cerr << "ERROR: AliPHOSGetter::HRef -> " << phosFolder->GetName() << "/Hits not found !" << endl ;
b0bba0af 302 return 0 ;
7a9d98f9 303 }
b0bba0af 304 else
65c0665e 305 return phosFolder->GetListOfFolders()->GetObjectRef(h) ;
b0bba0af 306}
7a9d98f9 307
b0bba0af 308//____________________________________________________________________________
309Bool_t AliPHOSGetter::PostSDigits(const char * name, const char * headerFile) const
310{ //---------- SDigits -------------------------
311
b0bba0af 312
7a9d98f9 313 // the hierarchy is //Folders/RunMC/Event/Data/PHOS/SDigits/headerFile/sdigitsname
b0bba0af 314 // because you can have sdigits from several hit files for mixing
7a9d98f9 315
316 TFolder * phosFolder = dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("PHOS")) ;
317 if ( !phosFolder ) {
318 if (fDebug) {
319 cout << "WARNING: AliPHOSGetter::Post S -> Folder //" << fSDigitsFolder << "/PHOS/ not found!" << endl;
320 cout << "INFO: AliPHOSGetter::Post S -> Adding Folder //" << fHitsFolder << "/PHOS/" << endl;
321 }
322 phosFolder = fSDigitsFolder->AddFolder("PHOS", "SDigits from PHOS") ;
323 }
b0bba0af 324 TString subdir(headerFile) ;
f4f43939 325 subdir.ReplaceAll("/","_") ;
7a9d98f9 326 TFolder * phosSubFolder = dynamic_cast<TFolder*>(phosFolder->FindObject(subdir)) ;
327 if ( !phosSubFolder )
328 phosSubFolder = phosFolder->AddFolder(subdir, "");
329
330 TObject * sd = phosSubFolder->FindObject(name);
b0bba0af 331 if ( sd ) {
332 if (fDebug)
333 cerr <<"INFO: AliPHOSGetter::Post S -> Folder " << subdir
334 << " already exists!" << endl ;
335 }else{
93aeb834 336 TClonesArray * sdigits = new TClonesArray("AliPHOSDigit",1) ;
b0bba0af 337 sdigits->SetName(name) ;
7a9d98f9 338 phosSubFolder->Add(sdigits) ;
b0bba0af 339 }
340
341 return kTRUE;
342}
343//____________________________________________________________________________
65c0665e 344TObject** AliPHOSGetter::SDigitsRef(const char * name, const char * file) const
7a9d98f9 345{ //------- SDigits ----------------------
b0bba0af 346
7a9d98f9 347 // the hierarchy is //Folders/RunMC/Event/Data/PHOS/SDigits/filename/SDigits
348
349 if ( !fSDigitsFolder ) {
350 cerr << "ERROR: AliPHOSGetter::Post SRef -> Folder //" << fSDigitsFolder << " not found!" << endl;
b0bba0af 351 return 0;
352 }
7a9d98f9 353
354 TFolder * phosFolder = dynamic_cast<TFolder *>(fSDigitsFolder->FindObject("PHOS")) ;
355 if ( !phosFolder ) {
356 cerr << "ERROR: AliPHOSGetter::Post SRef -> Folder //" << fSDigitsFolder << "/PHOS/ not found!" << endl;
357 return 0;
358 }
359
360 TFolder * phosSubFolder = 0 ;
b0bba0af 361 if(file)
7a9d98f9 362 phosSubFolder = dynamic_cast<TFolder *>(phosFolder->FindObject(file)) ;
b0bba0af 363 else
7a9d98f9 364 phosSubFolder = dynamic_cast<TFolder *>(phosFolder->FindObject(fHeaderFile)) ;
365
366 if(!phosSubFolder) {
367 cerr << "ERROR: AliPHOSGetter::Post SRef -> Folder //Folders/RunMC/Event/Data/PHOS/" << file << "not found!" << endl;
368 return 0;
369 }
b0bba0af 370
7a9d98f9 371 TObject * dis = phosSubFolder->FindObject(name) ;
b0bba0af 372 if(!dis)
373 return 0 ;
374 else
65c0665e 375 return phosSubFolder->GetListOfFolders()->GetObjectRef(dis) ;
b0bba0af 376
377}
378
379//____________________________________________________________________________
380Bool_t AliPHOSGetter::PostSDigitizer(AliPHOSSDigitizer * sdigitizer) const
381{ //---------- SDigitizer -------------------------
7a9d98f9 382
383 // the hierarchy is //Folders/Tasks/SDigitizer/PHOS/sdigitsname
384
385
386 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("SDigitizer")) ;
387
388 if ( !sd ) {
389 cerr << "ERROR: AliPHOSGetter::Post Ser -> Task //" << fTasksFolder << "/SDigitizer not found!" << endl;
b0bba0af 390 return kFALSE ;
391 }
7a9d98f9 392 TTask * phos = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("PHOS")) ;
b0bba0af 393 if ( !phos ) {
7a9d98f9 394 if (fDebug) {
395 cout <<"WARNING: AliPHOSGetter::Post Ser ->//" << fTasksFolder << "/SDigitizer/PHOS/ not found!" << endl;
396 cout <<"INFO: AliPHOSGetter::Post Ser -> Adding //" << fTasksFolder << "/SDigitizer/PHOS/" << endl;
397 }
398 phos = new TTask("PHOS", "") ;
399 sd->Add(phos) ;
b0bba0af 400 }
7a9d98f9 401 AliPHOSSDigitizer * phossd = dynamic_cast<AliPHOSSDigitizer *>(phos->GetListOfTasks()->FindObject( sdigitizer->GetName() ));
b0bba0af 402 if (phossd) {
403 if (fDebug)
404 cout << "INFO: AliPHOSGetter::Post Ser -> Task " << sdigitizer->GetName() << " already exists" << endl ;
405 phos->GetListOfTasks()->Remove(phossd) ;
406 }
407 phos->Add(sdigitizer) ;
408 return kTRUE;
409
410}
7a9d98f9 411
b0bba0af 412//____________________________________________________________________________
65c0665e 413TObject** AliPHOSGetter::SDigitizerRef(const char * name) const
b0bba0af 414{
415
7a9d98f9 416 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("SDigitizer")) ;
417 if ( !sd ) {
418 cerr << "ERROR: AliPHOSGetter::Post SerRef -> Task //" << fTasksFolder << "/SDigitizer not found!" << endl;
419 abort();
420 }
4ae78bb1 421
7a9d98f9 422 TTask * phos = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("PHOS")) ;
423 if ( !phos ) {
424 cerr <<"ERROR: AliPHOSGetter::Post SerRef -> //" << fTasksFolder << "/SDigitizer/PHOS not found!" << endl;
425 abort();
426 }
b0bba0af 427
7a9d98f9 428 TTask * task = dynamic_cast<TTask*>(phos->GetListOfTasks()->FindObject(name)) ;
b0bba0af 429
65c0665e 430 return phos->GetListOfTasks()->GetObjectRef(task) ;
b0bba0af 431
432}
433
b0bba0af 434//____________________________________________________________________________
435Bool_t AliPHOSGetter::PostSDigitizer(const char * name, const char * file) const
436{ //---------- SDigitizer -------------------------
437
7a9d98f9 438 // the hierarchy is //Folders/Tasks/SDigitizer/PHOS/sdigitsname
439
440
441 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("SDigitizer")) ;
442 if ( !sd ) {
443 cerr << "ERROR: AliPHOSGetter::Post Ser -> Task //" << fTasksFolder << "/SDigitizer not found!" << endl;
b0bba0af 444 return kFALSE ;
445 }
7a9d98f9 446
447 TTask * phos = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("PHOS")) ;
b0bba0af 448 if ( !phos ) {
7a9d98f9 449 if (fDebug) {
450 cout <<"WARNING: AliPHOSGetter::Post Ser -> //" << fTasksFolder << "/SDigitizer/PHOS/ not found!" << endl;
451 cout <<"INFO: AliPHOSGetter::Post Ser -> Adding //" << fTasksFolder << "/SDigitizer/PHOS" << endl;
452 }
453 phos = new TTask("PHOS", "") ;
454 sd->Add(phos) ;
b0bba0af 455 }
7a9d98f9 456
b0bba0af 457 TString sdname(name) ;
458 sdname.Append(":") ;
459 sdname.Append(file);
54b82aa4 460 sdname.ReplaceAll("/","_") ;
7a9d98f9 461 AliPHOSSDigitizer * phossd = dynamic_cast<AliPHOSSDigitizer *>(phos->GetListOfTasks()->FindObject( sdname ));
b0bba0af 462 if (!phossd) {
463 phossd = new AliPHOSSDigitizer() ;
464 //Note, we can not call constructor with parameters: it will call Getter and scrud up everething
465 phossd->SetName(sdname) ;
466 phossd->SetTitle(file) ;
467 phos->Add(phossd) ;
468 }
469 return kTRUE;
470
471}
7a9d98f9 472
b0bba0af 473//____________________________________________________________________________
474Bool_t AliPHOSGetter::PostDigits(const char * name) const
475{ //---------- Digits -------------------------
476
7a9d98f9 477 // the hierarchy is //Folders/Run/Event/Data/PHOS/SDigits/name
478
479 TFolder * phosFolder = dynamic_cast<TFolder*>(fDigitsFolder->FindObject("PHOS")) ;
480
481 if ( !phosFolder ) {
482 if (fDebug) {
483 cout << "WARNING: AliPHOSGetter::Post D -> Folder //" << fDigitsFolder << "/PHOS/ not found!" << endl;
484 cout << "INFO: AliPHOSGetter::Post D -> Adding Folder //" << fDigitsFolder << "/PHOS/" << endl;
485 }
486 phosFolder = fDigitsFolder->AddFolder("PHOS", "Digits from PHOS") ;
b0bba0af 487 }
7a9d98f9 488
489 TObject* dig = phosFolder->FindObject( name ) ;
b0bba0af 490 if ( !dig ) {
491 TClonesArray * digits = new TClonesArray("AliPHOSDigit",1000) ;
492 digits->SetName(name) ;
7a9d98f9 493 phosFolder->Add(digits) ;
b0bba0af 494 }
495 return kTRUE;
496}
7a9d98f9 497
b0bba0af 498//____________________________________________________________________________
65c0665e 499TObject** AliPHOSGetter::DigitsRef(const char * name) const
7a9d98f9 500{ //------- Digits ----------------------
501
502 // the hierarchy is //Folders/Run/Event/Data/PHOS/Digits/name
b0bba0af 503
7a9d98f9 504 if ( !fDigitsFolder ) {
505 cerr << "ERROR: AliPHOSGetter::Post DRef -> Folder //" << fDigitsFolder << " not found!" << endl;
506 return 0;
507 }
b0bba0af 508
7a9d98f9 509 TFolder * phosFolder = dynamic_cast<TFolder*>(fDigitsFolder->FindObject("PHOS")) ;
510 if ( !phosFolder ) {
511 cerr << "ERROR: AliPHOSGetter::DRef -> Folder //" << fDigitsFolder << "/PHOS/ not found!" << endl;
b0bba0af 512 return 0;
513 }
514
7a9d98f9 515 TObject * d = phosFolder->FindObject(name) ;
b0bba0af 516 if(!d)
517 return 0 ;
518 else
65c0665e 519 return phosFolder->GetListOfFolders()->GetObjectRef(d) ;
b0bba0af 520
521}
522
b0bba0af 523//____________________________________________________________________________
524Bool_t AliPHOSGetter::PostDigitizer(AliPHOSDigitizer * digitizer) const
525{ //---------- Digitizer -------------------------
526
7a9d98f9 527 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("Digitizer")) ;
528
529 if ( !sd ) {
530 cerr << "ERROR: AliPHOSGetter::Post Der -> Task //" << fTasksFolder << "/Digitizer not found!" << endl;
531 return kFALSE ;
b0bba0af 532 }
7a9d98f9 533 TTask * phos = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("PHOS")) ;
b0bba0af 534 if ( !phos ) {
7a9d98f9 535 if (fDebug) {
536 cout <<"WARNING: AliPHOSGetter::Post Der -> //" << fTasksFolder << "/Digitizer/PHOS not found!" << endl;
537 cout <<"INFO: AliPHOSGetter::Post Der -> Adding //" << fTasksFolder << "/Digitizer/PHOS" << endl;
538 }
539 phos = new TTask("PHOS", "") ;
540 sd->Add(phos) ;
541 }
542
543 AliPHOSDigitizer * phosd = dynamic_cast<AliPHOSDigitizer*>(phos->GetListOfTasks()->FindObject(digitizer->GetName())) ;
b0bba0af 544 if (phosd) {
545 phosd->Delete() ;
546 phos->GetListOfTasks()->Remove(phosd) ;
4ae78bb1 547 }
7a9d98f9 548 phos->Add(digitizer) ;
b0bba0af 549 return kTRUE;
7a9d98f9 550}
551
b0bba0af 552//____________________________________________________________________________
553Bool_t AliPHOSGetter::PostDigitizer(const char * name) const
554{ //---------- Digitizer -------------------------
555
7a9d98f9 556 // the hierarchy is //Folders/Tasks/SDigitizer/PHOS/sdigitsname
557
558 TTask * d = dynamic_cast<TTask*>(fTasksFolder->FindObject("Digitizer")) ;
559 if ( !d ) {
560 cerr << "ERROR: AliPHOSGetter::Post Der -> Task //" << fTasksFolder << "/Digitizer not found!" << endl;
561 return kFALSE ;
b0bba0af 562 }
7a9d98f9 563
564 TTask * phos = dynamic_cast<TTask*>(d->GetListOfTasks()->FindObject("PHOS")) ;
b0bba0af 565 if ( !phos ) {
7a9d98f9 566 if (fDebug) {
567 cout <<"WARNING: AliPHOSGetter::Post Der -> //" << fTasksFolder << "/Digitizer/PHOS not found!" << endl;
568 cout <<"INFO: AliPHOSGetter::Post Der -> Adding //" << fTasksFolder << "/Digitizer/PHOS" << endl;
569 }
570 phos = new TTask("PHOS", "") ;
571 d->Add(phos) ;
572}
b0bba0af 573
7a9d98f9 574 AliPHOSDigitizer * phosd = dynamic_cast<AliPHOSDigitizer*>(phos->GetListOfTasks()->FindObject(name)) ;
b0bba0af 575 if (!phosd) {
576 phosd = new AliPHOSDigitizer() ;
577 phosd->SetName(fDigitsTitle) ;
578 phosd->SetTitle(fHeaderFile) ;
579 phos->Add(phosd) ;
580 }
581 return kTRUE;
582}
583
584//____________________________________________________________________________
65c0665e 585TObject** AliPHOSGetter::DigitizerRef(const char * name) const
b0bba0af 586{
7a9d98f9 587 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("Digitizer")) ;
588 if ( !sd ) {
589 cerr << "ERROR: AliPHOSGetter::Post DerRef -> Task //" << fTasksFolder << "/Digitizer not found!" << endl;
590 abort();
591 }
b0bba0af 592
7a9d98f9 593 TTask * phos = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("PHOS")) ;
594 if ( !phos ) {
595 cerr <<"ERROR: AliPHOSGetter::Post DerRef -> //" << fTasksFolder << "/Digitizer/PHOS" << endl;
596 abort();
597 }
b0bba0af 598
7a9d98f9 599 TTask * task = dynamic_cast<TTask*>(phos->GetListOfTasks()->FindObject(name)) ;
b0bba0af 600
65c0665e 601 return phos->GetListOfTasks()->GetObjectRef(task) ;
b0bba0af 602
603}
604
605//____________________________________________________________________________
606Bool_t AliPHOSGetter::PostRecPoints(const char * name) const
607{ // -------------- RecPoints -------------------------------------------
608
7a9d98f9 609 // the hierarchy is //Folders/Run/Event/RecData/PHOS/EMCARecPoints/name
610 // the hierarchy is //Folders/Run/Event/RecData/PHOS/CPVRecPoints/name
611
612 TFolder * phosFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("PHOS")) ;
b0bba0af 613
7a9d98f9 614 if ( !phosFolder ) {
615 if (fDebug) {
616 cout << "WARNING: AliPHOSGetter::Post RPo -> Folder //" << fRecoFolder << "/PHOS/ not found!" << endl;
617 cout << "INFO: AliPHOSGetter::Post Rpo -> Adding Folder //" << fRecoFolder << "/PHOS/" << endl;
618 }
619 phosFolder = fRecoFolder->AddFolder("PHOS", "Reconstructed data from PHOS") ;
620 }
b0bba0af 621
7a9d98f9 622 // EMCA RecPoints
623 TFolder * phosRPoEMCAFolder = dynamic_cast<TFolder*>(phosFolder->FindObject("EMCARecPoints")) ;
624 if ( !phosRPoEMCAFolder ) {
625 if (fDebug) {
626 cout << "WARNING: AliPHOSGetter::Post RPo -> Folder //" << fRecoFolder << "/PHOS/EMCARecPoints/ not found!" << endl;
627 cout << "INFO: AliPHOSGetter::Post Rpo -> Adding Folder //" << fRecoFolder << "/PHOS/EMCARecPoints not found!" << endl;
628 }
629 phosRPoEMCAFolder = phosFolder->AddFolder("EMCARecPoints", "EMCA RecPoints from PHOS") ;
b0bba0af 630 }
7a9d98f9 631
632 TObject * erp = phosFolder->FindObject( name ) ;
b0bba0af 633 if ( !erp ) {
634 TObjArray * emcrp = new TObjArray(100) ;
635 emcrp->SetName(name) ;
7a9d98f9 636 phosRPoEMCAFolder->Add(emcrp) ;
b0bba0af 637 }
638
7a9d98f9 639 // CPV RecPoints
640 TFolder * phosRPoCPVFolder = dynamic_cast<TFolder*>(phosFolder->FindObject("CPVRecPoints")) ;
641 if ( !phosRPoCPVFolder ) {
642 if (fDebug) {
643 cout << "WARNING: AliPHOSGetter::Post RPo -> Folder //" << fRecoFolder << "/PHOS/CPVRecPoints/ not found!" << endl;
644 cout << "INFO: AliPHOSGetter::Post Rpo -> Adding Folder //" << fRecoFolder << "/PHOS/CPVRecPoints/" << endl;
645 }
646 phosRPoCPVFolder = phosFolder->AddFolder("CPVRecPoints", "CPV RecPoints from PHOS") ;
b0bba0af 647 }
7a9d98f9 648
649 TObject * crp = phosRPoCPVFolder->FindObject( name ) ;
b0bba0af 650 if ( !crp ) {
651 TObjArray * cpvrp = new TObjArray(100) ;
652 cpvrp->SetName(name) ;
7a9d98f9 653 phosRPoCPVFolder->Add(cpvrp) ;
b0bba0af 654 }
655 return kTRUE;
656}
657
658//____________________________________________________________________________
65c0665e 659TObject** AliPHOSGetter::EmcRecPointsRef(const char * name) const
b0bba0af 660{ // -------------- RecPoints -------------------------------------------
661
7a9d98f9 662 // the hierarchy is //Folders/Run/Event/RecData/PHOS/EMCARecPoints/name
b0bba0af 663
7a9d98f9 664 if ( !fRecoFolder ) {
665 cerr << "ERROR: AliPHOSGetter::EmcRecPointsRef -> Folder //" << fRecoFolder << " not found!" << endl;
b0bba0af 666 return 0 ;
667 }
668
7a9d98f9 669 TFolder * phosFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("PHOS/EMCARecPoints")) ;
670 if ( !phosFolder ) {
671 cerr << "ERROR: AliPHOSGetter::EmcRecPointsRef -> Folder //" << fRecoFolder << "/PHOS/EMCARecPoints/ not found!" << endl;
672 return 0;
673 }
674
675
676 TObject * erp = phosFolder->FindObject(name ) ;
b0bba0af 677 if ( !erp ) {
678 return 0 ;
679 }
65c0665e 680 return phosFolder->GetListOfFolders()->GetObjectRef(erp) ;
b0bba0af 681
682}
7a9d98f9 683
b0bba0af 684//____________________________________________________________________________
65c0665e 685TObject** AliPHOSGetter::CpvRecPointsRef(const char * name) const
b0bba0af 686{ // -------------- RecPoints -------------------------------------------
687
7a9d98f9 688 // the hierarchy is //Folders/Run/Event/RecData/PHOS/CPVRecPoints/name
b0bba0af 689
7a9d98f9 690 if ( !fRecoFolder ) {
691 cerr << "ERROR: AliPHOSGetter::EmcRecPointsRef -> Folder //" << fRecoFolder << " not found!" << endl;
b0bba0af 692 return 0 ;
693 }
7a9d98f9 694
695 TFolder * phosFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("PHOS/CPVRecPoints")) ;
696 if ( !phosFolder ) {
697 cerr << "ERROR: AliPHOSGetter::CpvRecPointsRef -> Folder //" << fRecoFolder << "/PHOS/CPVRecPoints/" << endl;
698 return 0;
699 }
700
701 TObject * crp = phosFolder->FindObject(name ) ;
b0bba0af 702 if ( !crp ) {
703 return 0 ;
704 }
65c0665e 705 return phosFolder->GetListOfFolders()->GetObjectRef(crp) ;
b0bba0af 706
707}
708
709//____________________________________________________________________________
710Bool_t AliPHOSGetter::PostClusterizer(AliPHOSClusterizer * clu) const
711{ // ------------------ AliPHOSClusterizer ------------------------
712
7a9d98f9 713 // the hierarchy is //Folders/Tasks/Reconstructioner/PHOS/sdigitsname
714
715 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
716
717 if ( !tasks ) {
718 cerr << "ERROR: AliPHOSGetter::Post Rer -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
719 return kFALSE ;
720 }
721
722 TTask * phos = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
b0bba0af 723 if ( !phos ) {
7a9d98f9 724 if (fDebug) {
725 cout <<"WARNING: AliPHOSGetter::Post Rer -> //" << fTasksFolder << "/ReconstructionerPHOS not found!" << endl;
726 cout <<"INFO: AliPHOSGetter::Post Rer -> Adding //" << fTasksFolder << "/Reconstructioner/PHOS" << endl;
4ae78bb1 727 }
7a9d98f9 728 phos = new TTask("PHOS", "") ;
729 tasks->Add(phos) ;
b0bba0af 730 }
7a9d98f9 731
732 AliPHOSClusterizer * phoscl = dynamic_cast<AliPHOSClusterizer*>(phos->GetListOfTasks()->FindObject(clu->GetName())) ;
733 if (phoscl) {
734 if (fDebug)
735 cout << "INFO: AliPHOSGetter::Post Rer -> Task " << clu->GetName() << " already exists" << endl ;
736 phoscl->Delete() ;
737 phos->GetListOfTasks()->Remove(phoscl) ;
738 }
739 phos->Add(clu) ;
740 return kTRUE;
741}
b0bba0af 742
743//____________________________________________________________________________
65c0665e 744TObject** AliPHOSGetter::ClusterizerRef(const char * name) const
b0bba0af 745{ // ------------------ AliPHOSClusterizer ------------------------
4ae78bb1 746
7a9d98f9 747 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
748
749 if ( !tasks ) {
750 cerr << "ERROR: AliPHOSGetter::Post RerRef -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
b897ea88 751 return 0 ;
7a9d98f9 752 }
753
754 TTask * phos = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
b0bba0af 755 if ( !phos ) {
7a9d98f9 756 cerr <<"WARNING: AliPHOSGetter::Post RerRef -> //" << fTasksFolder << "/Reconstructioner/PHOS" << endl;
b0bba0af 757 return 0 ;
7a9d98f9 758 }
759
b0bba0af 760 TList * l = phos->GetListOfTasks() ;
761 TIter it(l) ;
762 TTask * task ;
763 TTask * clu = 0 ;
764 TString cluname(name) ;
765 cluname+=":clu-" ;
7a9d98f9 766 while((task = static_cast<TTask *>(it.Next()) )){
b0bba0af 767 TString taskname(task->GetName()) ;
768 if(taskname.BeginsWith(cluname)){
769 clu = task ;
770 break ;
4ae78bb1 771 }
b0bba0af 772 }
773
774 if(clu)
65c0665e 775 return l->GetObjectRef(clu) ;
b0bba0af 776 else
777 return 0 ;
778}
779
780//____________________________________________________________________________
781Bool_t AliPHOSGetter::PostClusterizer(const char * name) const
782{ // ------------------ AliPHOSClusterizer ------------------------
7a9d98f9 783
784 // the hierarchy is //Folders/Tasks/Reconstructioner/PHOS/sdigitsname
b0bba0af 785
7a9d98f9 786 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
787
788 if ( !tasks ) {
789 cerr << "ERROR: AliPHOSGetter::Post Rer -> Task//" << fTasksFolder << "/Reconstructioner not found!" << endl;
790 return kFALSE ;
791 }
b0bba0af 792
7a9d98f9 793 TTask * phos = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
b0bba0af 794 if ( !phos ) {
7a9d98f9 795 if (fDebug) {
796 cout <<"WARNING: AliPHOSGetter::Post Rer -> //" << fTasksFolder << "/Reconstructioner/PHOS not found!" << endl;
797 cout <<"INFO: AliPHOSGetter::Post Rer -> Adding //" << fTasksFolder << "/Reconstructioner/PHOS" << endl;
798 }
799 phos = new TTask("PHOS", "") ;
800 tasks->Add(phos) ;
b0bba0af 801 }
7a9d98f9 802
b0bba0af 803 AliPHOSClusterizer * phoscl = new AliPHOSClusterizerv1() ;
804 TString clun(name) ;
805 clun+=":clu-v1" ;
806 phoscl->SetName(clun) ;
807 phos->Add(phoscl) ;
808 return kTRUE;
809
810}
7a9d98f9 811
b0bba0af 812//____________________________________________________________________________
813Bool_t AliPHOSGetter::PostTrackSegments(const char * name) const
814{ // ---------------TrackSegments -----------------------------------
815
7a9d98f9 816 // the hierarchy is //Folders/Run/Event/RecData/PHOS/TrackSegments/name
817
818 TFolder * phosFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("PHOS")) ;
819
820 if ( !phosFolder ) {
821 if (fDebug) {
822 cout << "WARNING: AliPHOSGetter::Post TS -> Folder //" << fRecoFolder << "/PHOS/ not found!" << endl;
823 cout << "INFO: AliPHOSGetter::Post TS -> Adding Folder //" << fRecoFolder << "/PHOS" << endl;
824 }
825 phosFolder = fRecoFolder->AddFolder("PHOS", "Reconstructed data from PHOS") ;
826 }
827
828 TFolder * phosTSFolder = dynamic_cast<TFolder*>(phosFolder->FindObject("TrackSegments")) ;
829 if ( !phosTSFolder ) {
830 if (fDebug) {
831 cout << "WARNING: AliPHOSGetter::Post TS -> Folder//" << fRecoFolder << "/PHOS/TrackSegments/ not found!" << endl;
832 cout << "INFO: AliPHOSGetter::Post TS -> Adding Folder //" << fRecoFolder << "/PHOS/TrackSegments/" << endl;
833 }
834 phosTSFolder = phosFolder->AddFolder("TrackSegments", "TrackSegments from PHOS") ;
b0bba0af 835 }
7a9d98f9 836
837 TObject * tss = phosTSFolder->FindObject( name ) ;
b0bba0af 838 if (!tss) {
839 TClonesArray * ts = new TClonesArray("AliPHOSTrackSegment",100) ;
840 ts->SetName(name) ;
7a9d98f9 841 phosTSFolder->Add(ts) ;
b0bba0af 842 }
843 return kTRUE;
844}
845
846//____________________________________________________________________________
65c0665e 847TObject** AliPHOSGetter::TrackSegmentsRef(const char * name) const
b0bba0af 848{ // ---------------TrackSegments -----------------------------------
849
7a9d98f9 850 // the hierarchy is //Folders/Run/Event/RecData/PHOS/TrackSegments/name
851
852 if ( !fRecoFolder ) {
853 cerr << "ERROR: AliPHOSGetter::TrackSegmentsRef -> Folder //" << fRecoFolder << "not found!" << endl;
b0bba0af 854 return 0 ;
855 }
7a9d98f9 856
857 TFolder * phosFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("PHOS/TrackSegments")) ;
858 if ( !phosFolder ) {
859 cerr << "ERROR: AliPHOSGetter::TrackSegmentsRef -> Folder //" << fRecoFolder << "/PHOS/TrackSegments/ not found!" << endl;
860 return 0;
861 }
b0bba0af 862
7a9d98f9 863 TObject * tss = phosFolder->FindObject(name) ;
b0bba0af 864 if (!tss) {
865 return 0 ;
866 }
65c0665e 867 return phosFolder->GetListOfFolders()->GetObjectRef(tss) ;
b0bba0af 868}
869
870//____________________________________________________________________________
871Bool_t AliPHOSGetter::PostTrackSegmentMaker(AliPHOSTrackSegmentMaker * tsmaker) const
872{ //------------Track Segment Maker ------------------------------
873
7a9d98f9 874 // the hierarchy is //Folders/Tasks/Reconstructioner/PHOS/sdigitsname
875
876 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
877
878 if ( !tasks ) {
879 cerr << "ERROR: AliPHOSGetter::Post Ter -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
880 return kFALSE ;
b0bba0af 881 }
7a9d98f9 882
883 TTask * phos = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
b0bba0af 884 if ( !phos ) {
7a9d98f9 885 if (fDebug) {
886 cout <<"WARNING: AliPHOSGetter::Post Rer -> //" << fTasksFolder << "/Reconstructioner/PHOS not found!" << endl;
887 cout <<"INFO: AliPHOSGetter::Post Rer -> Adding //" << fTasksFolder << "/Reconstructioner/PHOS" << endl;
888 }
889 phos = new TTask("PHOS", "") ;
890 tasks->Add(phos) ;
891 }
892
b0bba0af 893 AliPHOSTrackSegmentMaker * phosts =
7a9d98f9 894 dynamic_cast<AliPHOSTrackSegmentMaker*>(phos->GetListOfTasks()->FindObject(tsmaker->GetName())) ;
b0bba0af 895 if (phosts) {
896 phosts->Delete() ;
897 phos->GetListOfTasks()->Remove(phosts) ;
898 }
899 phos->Add(tsmaker) ;
900 return kTRUE;
901
902}
903//____________________________________________________________________________
904Bool_t AliPHOSGetter::PostTrackSegmentMaker(const char * name) const
905{ //------------Track Segment Maker ------------------------------
906
7a9d98f9 907 // the hierarchy is //Folders/Tasks/Reconstructioner/PHOS/sdigitsname
908
b0bba0af 909
7a9d98f9 910 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
911
912 if ( !tasks ) {
913 cerr << "ERROR: AliPHOSGetter::Post Ter -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
914 return kFALSE ;
b0bba0af 915 }
7a9d98f9 916
917 TTask * phos = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
b0bba0af 918 if ( !phos ) {
7a9d98f9 919 if (fDebug) {
920 cout <<"WARNING: AliPHOSGetter::Post Rer -> //" << fTasksFolder << "/Reconstructioner/PHOS not found!" << endl;
921 cout <<"INFO: AliPHOSGetter::Post Rer -> Adding //" << fTasksFolder << "/Reconstructioner/PHOS" << endl;
922 }
923 phos = new TTask("PHOS", "") ;
924 tasks->Add(phos) ;
b0bba0af 925 }
7a9d98f9 926
b0bba0af 927 AliPHOSTrackSegmentMaker * phosts =
7a9d98f9 928 dynamic_cast<AliPHOSTrackSegmentMaker*>(phos->GetListOfTasks()->FindObject(name)) ;
b0bba0af 929 if (!phosts) {
930 phosts = new AliPHOSTrackSegmentMakerv1() ;
931 TString tsn(name);
932 tsn+=":tsm-v1" ;
933 phosts->SetName(tsn) ;
934 phos->Add(phosts) ;
935 }
936 return kTRUE;
937
938}
7a9d98f9 939
b0bba0af 940//____________________________________________________________________________
65c0665e 941TObject** AliPHOSGetter::TSMakerRef(const char * name) const
b0bba0af 942{ //------------Track Segment Maker ------------------------------
943
7a9d98f9 944 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
945
946 if ( !tasks ) {
947 cerr << "ERROR: AliPHOSGetter::Post TerRef -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
b897ea88 948 return 0 ;
b0bba0af 949 }
7a9d98f9 950
951 TTask * phos = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
952 if ( !phos ) {
953 cerr <<"WARNING: AliPHOSGetter::Post TerRef -> //" << fTasksFolder << "/Reconstructioner/PHOS not found!" << endl;
b0bba0af 954 return 0 ;
7a9d98f9 955 }
956
b0bba0af 957 TList * l = phos->GetListOfTasks() ;
958 TIter it(l) ;
959 TTask * task ;
960 TTask * tsm = 0 ;
961 TString tsmname(name) ;
962 tsmname+=":tsm-" ;
7a9d98f9 963 while((task = static_cast<TTask *>(it.Next()) )){
b0bba0af 964 TString taskname(task->GetName()) ;
965 if(taskname.BeginsWith(tsmname)){
966 tsm = task ;
967 break ;
4ae78bb1 968 }
b0bba0af 969 }
970
971 if(tsm)
65c0665e 972 return l->GetObjectRef(tsm) ;
b0bba0af 973 else
974 return 0 ;
975
976}
977
978//____________________________________________________________________________
979Bool_t AliPHOSGetter::PostRecParticles(const char * name) const
980{ // -------------------- RecParticles ------------------------
981
7a9d98f9 982 // the hierarchy is //Folders/Run/Event/RecData/PHOS/TrackSegments/name
983
984 TFolder * phosFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("PHOS")) ;
b0bba0af 985
7a9d98f9 986 if ( !phosFolder ) {
987 if (fDebug) {
988 cout << "WARNING: AliPHOSGetter::Post RPa -> Folder //" << fRecoFolder << "/PHOS/ not found!" << endl;
989 cout << "INFO: AliPHOSGetter::Post Rpa -> Adding Folder //" << fRecoFolder << "/PHOS/" << endl;
990 }
991 phosFolder = fRecoFolder->AddFolder("PHOS", "Reconstructed data from PHOS") ;
b0bba0af 992 }
7a9d98f9 993
994 TFolder * phosRPaFolder = dynamic_cast<TFolder*>(phosFolder->FindObject("RecParticles")) ;
995 if ( !phosRPaFolder ) {
996 if (fDebug) {
997 cout << "WARNING: AliPHOSGetter::Post RPa -> Folder //" << fRecoFolder << "/PHOS/RecParticles/ not found!" << endl;
998 cout << "INFO: AliPHOSGetter::Post RPa -> Adding Folder //" << fRecoFolder << "/PHOS/RecParticles/" << endl;
999 }
1000 phosRPaFolder = phosFolder->AddFolder("RecParticles", "RecParticles from PHOS") ;
1001 }
1002
1003 TObject * rps = phosRPaFolder->FindObject( name ) ;
b0bba0af 1004 if ( !rps ) {
1005 TClonesArray * rp = new TClonesArray("AliPHOSRecParticle",100) ;
1006 rp->SetName(name) ;
7a9d98f9 1007 phosRPaFolder->Add(rp) ;
b0bba0af 1008 }
1009 return kTRUE;
1010}
7a9d98f9 1011
b0bba0af 1012//____________________________________________________________________________
65c0665e 1013TObject** AliPHOSGetter::RecParticlesRef(const char * name) const
b0bba0af 1014{ // ---------------TrackSegments -----------------------------------
1015
7a9d98f9 1016 // the hierarchy is //Folders/Run/Event/RecData/PHOS/TrackSegments/name
1017
1018 if ( !fRecoFolder ) {
1019 cerr << "ERROR: AliPHOSGetter::RecParticlesRef -> Folder//" << fRecoFolder << " not found!" << endl;
b0bba0af 1020 return 0 ;
1021 }
7a9d98f9 1022
1023 TFolder * phosFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("PHOS/RecParticles")) ;
1024 if ( !phosFolder ) {
1025 cerr << "ERROR: AliPHOSGetter::RecParticlesRef -> Folder //" << fRecoFolder << "/PHOS/RecParticles/ not found!" << endl;
1026 return 0;
1027 }
1028
1029 TObject * tss = phosFolder->FindObject(name ) ;
b0bba0af 1030 if (!tss) {
1031 return 0 ;
1032 }
65c0665e 1033 return phosFolder->GetListOfFolders()->GetObjectRef(tss) ;
b0bba0af 1034}
1035
1036//____________________________________________________________________________
1037Bool_t AliPHOSGetter::PostPID(AliPHOSPID * pid) const
7a9d98f9 1038{ // ------------AliPHOS PID -----------------------------
1039
1040 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
1041
1042 if ( !tasks ) {
1043 cerr << "ERROR: AliPHOSGetter::Post Per -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
1044 return kFALSE ;
b0bba0af 1045 }
7a9d98f9 1046
1047 TTask * phos = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
b0bba0af 1048 if ( !phos ) {
7a9d98f9 1049 if (fDebug) {
1050 cout <<"WARNING: AliPHOSGetter::Post Per -> //" << fTasksFolder << "/Reconstructioner/PHOS not found!" << endl;
1051 cout <<"INFO: AliPHOSGetter::Post Per -> Adding //" << fTasksFolder << "/Reconstructioner/PHOS" << endl;
1052 }
1053 phos = new TTask("PHOS", "") ;
1054 tasks->Add(phos) ;
4ae78bb1 1055 }
7a9d98f9 1056
1057 AliPHOSPID * phospid = dynamic_cast<AliPHOSPID*>(phos->GetListOfTasks()->FindObject(pid->GetName())) ;
b0bba0af 1058 if (phospid) {
1059 if (fDebug)
1060 cout << "INFO: AliPHOSGetter::Post Per -> Task " << pid->GetName()
1061 << " already exists" << endl ;
1062 phos->GetListOfTasks()->Remove(phospid) ;
1063 }
1064
1065 phos->Add(pid) ;
1066 return kTRUE;
1067}
7a9d98f9 1068
b0bba0af 1069//____________________________________________________________________________
1070Bool_t AliPHOSGetter::PostPID(const char * name) const
1071{
7a9d98f9 1072 // the hierarchy is //Folders/Tasks/Reconstructioner/PHOS/sdigitsname
1073
1074 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
1075
1076 if ( !tasks ) {
1077 cerr << "ERROR: AliPHOSGetter::Post Per -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
1078 return kFALSE ;
b0bba0af 1079 }
7a9d98f9 1080
1081 TTask * phos = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
b0bba0af 1082 if ( !phos ) {
7a9d98f9 1083 if (fDebug) {
1084 cout <<"WARNING: AliPHOSGetter::Post Per -> //" << fTasksFolder << "/Reconstructioner/PHOS not found!" << endl;
1085 cout <<"INFO: AliPHOSGetter::Post Per -> Adding //" << fTasksFolder << "/Reconstructioner/PHOS" << endl;
1086 }
1087 phos = new TTask("PHOS", "") ;
1088 tasks->Add(phos) ;
1089 }
4ae78bb1 1090
b0bba0af 1091 TList * l = phos->GetListOfTasks() ;
1092 TIter it(l) ;
1093 TString pidname(name) ;
1094 pidname+=":pid" ;
1095 TTask * task ;
7a9d98f9 1096 while((task = static_cast<TTask *>(it.Next()) )){
b0bba0af 1097 TString taskname(task->GetName()) ;
1098 if(taskname.BeginsWith(pidname))
1099 return kTRUE ;
1100 }
1101
1102 AliPHOSPIDv1 * phospid = new AliPHOSPIDv1() ;
1103 pidname+="-v1" ;
1104 phospid->SetName(pidname) ;
1105 phos->Add(phospid) ;
1106
1107 return kTRUE;
1108}
7a9d98f9 1109
b0bba0af 1110//____________________________________________________________________________
65c0665e 1111TObject** AliPHOSGetter::PIDRef(const char * name) const
b0bba0af 1112{ //------------PID ------------------------------
1113
7a9d98f9 1114 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
1115
1116 if ( !tasks ) {
1117 cerr << "ERROR: AliPHOSGetter::Post PerRef -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
b897ea88 1118 return 0 ;
b0bba0af 1119 }
7a9d98f9 1120
1121 TTask * phos = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
1122 if ( !phos ) {
1123 cerr <<"WARNING: AliPHOSGetter::Post PerRef -> //" << fTasksFolder << "/ReconstructionerPHOS not found!" << endl;
b0bba0af 1124 return 0 ;
7a9d98f9 1125 }
1126
b0bba0af 1127 TList * l = phos->GetListOfTasks() ;
1128 TIter it(l) ;
1129 TTask * task ;
1130 TTask * pid = 0 ;
1131 TString pidname(name) ;
1132 pidname+=":pid-" ;
7a9d98f9 1133 while((task = static_cast<TTask *>(it.Next()) )){
b0bba0af 1134 TString taskname(task->GetName()) ;
1135 if(taskname.BeginsWith(pidname)){
1136 pid = task ;
1137 break ;
1138 }
4ae78bb1 1139 }
b0bba0af 1140
1141 if(pid)
65c0665e 1142 return l->GetObjectRef(pid) ;
b0bba0af 1143 else
1144 return 0 ;
1145
1146}
1147
1148//____________________________________________________________________________
7a9d98f9 1149Bool_t AliPHOSGetter::PostQA(void) const
1150{ // ------------------ QA ---------------------------------
1151
1152 // the hierarchy is //Folders/Run/Conditions/QA/PHOS/alarmsName
1153
1154 TFolder * phosFolder = dynamic_cast<TFolder*>(fQAFolder->FindObject("PHOS")) ;
1155 if ( !phosFolder ) {
1156 if (fDebug) {
1157 cout << "WARNING: AliPHOSGetter::Post Q -> Folder //" << fQAFolder << "/PHOS/ not found!" << endl;
1158 cout << "INFO: AliPHOSGetter::Post Q -> Adding Folder //" << fQAFolder << "/PHOS/" << endl;
1159 }
1160 phosFolder = fQAFolder->AddFolder("PHOS", "QA from PHOS") ;
1161 }
1162
b0bba0af 1163 return kTRUE;
4ae78bb1 1164}
1165
1166//____________________________________________________________________________
65c0665e 1167TObject** AliPHOSGetter::AlarmsRef(void) const
7a9d98f9 1168{ //------- Alarms ----------------------
1169
1170
1171 // the hierarchy is //Folders/Run/Conditions/QA/PHOS
1172 if ( !fQAFolder ) {
1173 cerr << "ERROR: AliPHOSGetter::Post QRef -> Folder //" << fQAFolder << " not found!" << endl;
1174 return 0;
1175 }
1176
1177 TFolder * phosFolder = dynamic_cast<TFolder *>(fQAFolder->FindObject("PHOS")) ;
1178 if ( !phosFolder ) {
1179 cerr << "ERROR: AliPHOSGetter::Post QRef -> Folder //" << fQAFolder << "/PHOS/ not found!" << endl;
1180 return 0;
1181 }
1182
65c0665e 1183 return fQAFolder->GetListOfFolders()->GetObjectRef(phosFolder) ;
7a9d98f9 1184}
1185
1186//____________________________________________________________________________
4ae78bb1 1187const TParticle * AliPHOSGetter::Primary(Int_t index) const
1188{
1189 // Return primary particle numbered by <index>
1190
1191 if(index < 0)
1192 return 0 ;
cb34a1fa 1193 TParticle * p = gAlice->Particle(index) ;
1194 if (p->GetFirstMother() != -1 ) {
1195 cout << "AliPHOSGetter::Primary : Not a primary " << endl ;
1196 }
1197 return p ;
4ae78bb1 1198
4ae78bb1 1199
cb34a1fa 1200// Int_t primaryIndex = index % 10000000 ;
1201// Int_t primaryList = (Int_t ) ((index-primaryIndex)/10000000.) ;
1202
1203// if ( primaryList > 0 ) {
1204// if (fDebug) {
1205// cout << " Getter does not support currently Mixing of primary " << endl ;
1206// cout << " can not return primary: " << index<< " (list "<< primaryList<< " primary # " << primaryIndex << " )"<<endl ;
1207// }
1208// return 0;
1209// }
4ae78bb1 1210
cb34a1fa 1211// return gAlice->Particle(primaryIndex) ;
4ae78bb1 1212
1213}
1214
1215//____________________________________________________________________________
cb34a1fa 1216const TParticle * AliPHOSGetter::Secondary(TParticle* p, Int_t index) const
1217{
1218 // Return first (index=1) or second (index=2) secondary particle of primary particle p
1219
1220 if(index <= 0)
1221 return 0 ;
1222 if(index > 2)
1223 return 0 ;
1224
1225 if(p) {
1226 Int_t daughterIndex = p->GetDaughter(index-1) ;
1227 return gAlice->Particle(daughterIndex) ;
1228 }
1229 else
1230 return 0 ;
1231}
1232
1233//____________________________________________________________________________
ab3ecbea 1234Int_t AliPHOSGetter::ReadTreeD()
4ae78bb1 1235{
1236 // Read the digit tree gAlice->TreeD()
1237 if(gAlice->TreeD()== 0){
ab3ecbea 1238 cerr << "WARNING: AliPHOSGetter::ReadTreeD: can not read TreeD " << endl ;
1239 return 1;
4ae78bb1 1240 }
1241
7a9d98f9 1242 TObjArray * lob = static_cast<TObjArray*>(gAlice->TreeD()->GetListOfBranches()) ;
4ae78bb1 1243 TIter next(lob) ;
1244 TBranch * branch = 0 ;
1245 TBranch * digitsbranch = 0 ;
1246 TBranch * digitizerbranch = 0 ;
1247 Bool_t phosfound = kFALSE, digitizerfound = kFALSE ;
1248
7a9d98f9 1249 while ( (branch = static_cast<TBranch*>(next())) && (!phosfound || !digitizerfound) ) {
4ae78bb1 1250 if ( (strcmp(branch->GetName(), "PHOS")==0) && (strcmp(branch->GetTitle(), fDigitsTitle)==0) ) {
1251 digitsbranch = branch ;
1252 phosfound = kTRUE ;
1253 }
1254 else if ( (strcmp(branch->GetName(), "AliPHOSDigitizer")==0) && (strcmp(branch->GetTitle(), fDigitsTitle)==0) ) {
1255 digitizerbranch = branch ;
1256 digitizerfound = kTRUE ;
1257 }
1258 }
1259
1260 if ( !phosfound || !digitizerfound ) {
7a9d98f9 1261 if (fDebug)
1262 cout << "WARNING: AliPHOSGetter::ReadTreeD -> Cannot find Digits and/or Digitizer with name "
1263 << fDigitsTitle << endl ;
ab3ecbea 1264 return 2;
4ae78bb1 1265 }
1266
b0bba0af 1267 //read digits
1268 if(!Digits(fDigitsTitle) )
1269 PostDigits(fDigitsTitle);
1270 digitsbranch->SetAddress(DigitsRef(fDigitsTitle)) ;
1271 digitsbranch->GetEntry(0) ;
4ae78bb1 1272
b0bba0af 1273
1274 // read the Digitizer
1275 if(!Digitizer(fDigitsTitle))
1276 PostDigitizer(fDigitsTitle) ;
1277 digitizerbranch->SetAddress(DigitizerRef(fDigitsTitle)) ;
4ae78bb1 1278 digitizerbranch->GetEntry(0) ;
b0bba0af 1279
ab3ecbea 1280 return 0 ;
4ae78bb1 1281}
1282
1283//____________________________________________________________________________
ab3ecbea 1284Int_t AliPHOSGetter::ReadTreeH()
4ae78bb1 1285{
1286 // Read the first entry of PHOS branch in hit tree gAlice->TreeH()
1287
1288 if(gAlice->TreeH()== 0){
ab3ecbea 1289 cerr << "WARNING: AliPHOSGetter::ReadTreeH: -> Cannot read TreeH " << endl ;
1290 return 1;
4ae78bb1 1291 }
1292
7a9d98f9 1293 TBranch * hitsbranch = static_cast<TBranch*>(gAlice->TreeH()->GetBranch("PHOS")) ;
4ae78bb1 1294 if ( !hitsbranch ) {
7a9d98f9 1295 if (fDebug)
1296 cout << "WARNING: AliPHOSGetter::ReadTreeH -> Cannot find branch PHOS" << endl ;
ab3ecbea 1297 return 2;
4ae78bb1 1298 }
b0bba0af 1299 if(!Hits())
1300 PostHits() ;
1301
65c0665e 1302 if (hitsbranch->GetEntries() > 1 ) {
1303 TClonesArray * tempo = new TClonesArray("AliPHOSHit",1000) ;
1304 TClonesArray * hits = dynamic_cast<TClonesArray*>(*HitsRef()) ;
1305 hitsbranch->SetAddress(&tempo) ;
1306 Int_t index = 0 ;
1307 Int_t i = 0 ;
1308 for (i = 0 ; i < hitsbranch->GetEntries() ; i++) {
1309 hitsbranch->GetEntry(i) ;
1310 Int_t j = 0 ;
1311 for ( j = 0 ; j < tempo->GetEntries() ; j++) {
1312 const AliPHOSHit * hit = static_cast<const AliPHOSHit *>(tempo->At(j)) ;
1313 new((*hits)[index]) AliPHOSHit( *hit ) ;
1314 index++ ;
1315 }
1316 }
1317 delete tempo ;
1318 }
1319 else {
1320 hitsbranch->SetAddress(HitsRef()) ;
1321 hitsbranch->GetEntry(0) ;
1322 }
ab3ecbea 1323 return 0 ;
4ae78bb1 1324}
1325
1326//____________________________________________________________________________
b0bba0af 1327void AliPHOSGetter::Track(Int_t itrack)
1328{
1329 // Read the first entry of PHOS branch in hit tree gAlice->TreeH()
1330
1331 if(gAlice->TreeH()== 0){
1332 cerr << "ERROR: AliPHOSGetter::ReadTreeH: -> Cannot read TreeH " << endl ;
1333 return ;
1334 }
1335
7a9d98f9 1336 TBranch * hitsbranch = dynamic_cast<TBranch*>(gAlice->TreeH()->GetListOfBranches()->FindObject("PHOS")) ;
b0bba0af 1337 if ( !hitsbranch ) {
7a9d98f9 1338 if (fDebug)
1339 cout << "WARNING: AliPHOSGetter::ReadTreeH -> Cannot find branch PHOS" << endl ;
b0bba0af 1340 return ;
1341 }
1342 if(!Hits())
1343 PostHits() ;
65c0665e 1344
b0bba0af 1345 hitsbranch->SetAddress(HitsRef()) ;
1346 hitsbranch->GetEntry(itrack) ;
1347
1348
1349}
1350//____________________________________________________________________________
4ae78bb1 1351void AliPHOSGetter::ReadTreeQA()
1352{
1353 // Read the digit tree gAlice->TreeQA()
1354 // so far only PHOS knows about this Tree
1355
1356 if(PHOS()->TreeQA()== 0){
1357 cerr << "ERROR: AliPHOSGetter::ReadTreeQA: can not read TreeQA " << endl ;
1358 return ;
1359 }
1360
1361 TBranch * qabranch = PHOS()->TreeQA()->GetBranch("PHOS") ;
1362 if (!qabranch) {
7a9d98f9 1363 if (fDebug)
1364 cout << "WARNING: AliPHOSGetter::ReadTreeQA -> Cannot find QA Alarms for PHOS" << endl ;
4ae78bb1 1365 return ;
1366 }
b0bba0af 1367
7a9d98f9 1368 if(!Alarms())
1369 PostQA() ;
1370
1371 qabranch->SetAddress(AlarmsRef()) ;
1372
4ae78bb1 1373 qabranch->GetEntry(0) ;
7a9d98f9 1374
1375// PostQA("PHOS") ;
1376// TFolder * alarmsF = Alarms() ;
1377// alarmsF->Clear() ;
1378// qabranch->SetAddress(&alarmsF) ;
1379// qabranch->GetEntry(0) ;
4ae78bb1 1380
1381}
1382
1383//____________________________________________________________________________
ab3ecbea 1384Int_t AliPHOSGetter::ReadTreeR()
4ae78bb1 1385{
1386 // Read the reconstrunction tree gAlice->TreeR()
1387
1388 if(gAlice->TreeR()== 0){
ab3ecbea 1389 cerr << "WARNING: AliPHOSGetter::ReadTreeR: can not read TreeR " << endl ;
1390 return 1;
4ae78bb1 1391 }
b0bba0af 1392
4ae78bb1 1393 // RecPoints
7a9d98f9 1394 TObjArray * lob = static_cast<TObjArray*>(gAlice->TreeR()->GetListOfBranches()) ;
4ae78bb1 1395 TIter next(lob) ;
1396 TBranch * branch = 0 ;
1397 TBranch * emcbranch = 0 ;
1398 TBranch * cpvbranch = 0 ;
1399 TBranch * clusterizerbranch = 0 ;
1400 Bool_t phosemcrpfound = kFALSE, phoscpvrpfound = kFALSE, clusterizerfound = kFALSE ;
1401
7a9d98f9 1402 while ( (branch = static_cast<TBranch*>(next())) && (!phosemcrpfound || !phoscpvrpfound || !clusterizerfound) )
b0bba0af 1403 if(strcmp(branch->GetTitle(), fRecPointsTitle)==0) {
1404 if ( strcmp(branch->GetName(), "PHOSEmcRP")==0) {
1405 emcbranch = branch ;
1406 phosemcrpfound = kTRUE ;
1407 }
1408 else if ( strcmp(branch->GetName(), "PHOSCpvRP")==0) {
1409 cpvbranch = branch ;
1410 phoscpvrpfound = kTRUE ;
1411 }
1412 else if(strcmp(branch->GetName(), "AliPHOSClusterizer")==0){
1413 clusterizerbranch = branch ;
1414 clusterizerfound = kTRUE ;
1415 }
4ae78bb1 1416 }
4ae78bb1 1417
b0bba0af 1418 if ( !phosemcrpfound ) {
7a9d98f9 1419 if (fDebug)
1420 cout << "WARNING: AliPHOSGetter::ReadTreeR -> Cannot find EmcRecPoints with title "
1421 << fRecPointsTitle << endl ;
ab3ecbea 1422 return 2 ;
4ae78bb1 1423 }
b0bba0af 1424 if ( !phoscpvrpfound ) {
7a9d98f9 1425 if (fDebug)
1426 cout << "WARNING: AliPHOSGetter::ReadTreeR -> Cannot find CpvRecPoints with title "
1427 << fRecPointsTitle << endl ;
ab3ecbea 1428 return 3;
b0bba0af 1429 }
1430 if ( !clusterizerfound ) {
7a9d98f9 1431 if (fDebug)
1432 cout << "WARNING: AliPHOSGetter::ReadTreeR -> Can not find Clusterizer with title "
1433 << fRecPointsTitle << endl ;
ab3ecbea 1434 return 4;
b0bba0af 1435 }
1436
1437 // Read and Post the RecPoints
65c0665e 1438 if(!EmcRecPoints(fRecPointsTitle) )
b0bba0af 1439 PostRecPoints(fRecPointsTitle) ;
65c0665e 1440
b0bba0af 1441 emcbranch->SetAddress(EmcRecPointsRef(fRecPointsTitle)) ;
1442 emcbranch->GetEntry(0) ;
1443
65c0665e 1444 cpvbranch->SetAddress(CpvRecPointsRef(fRecPointsTitle)) ;
b0bba0af 1445 cpvbranch->GetEntry(0) ;
1446
1447 if(!Clusterizer(fRecPointsTitle) )
1448 PostClusterizer(fRecPointsTitle) ;
65c0665e 1449
b0bba0af 1450 clusterizerbranch->SetAddress(ClusterizerRef(fRecPointsTitle)) ;
4ae78bb1 1451 clusterizerbranch->GetEntry(0) ;
1452
b0bba0af 1453
1454 //------------------- TrackSegments ---------------------
4ae78bb1 1455 next.Reset() ;
1456 TBranch * tsbranch = 0 ;
1457 TBranch * tsmakerbranch = 0 ;
1458 Bool_t phostsfound = kFALSE, tsmakerfound = kFALSE ;
b0bba0af 1459
7a9d98f9 1460 while ( (branch = static_cast<TBranch*>(next())) && (!phostsfound || !tsmakerfound) )
b0bba0af 1461 if(strcmp(branch->GetTitle(), fTrackSegmentsTitle)==0) {
1462 if ( strcmp(branch->GetName(), "PHOSTS")==0){
1463 tsbranch = branch ;
1464 phostsfound = kTRUE ;
1465 }
1466 else if(strcmp(branch->GetName(), "AliPHOSTrackSegmentMaker")==0) {
1467 tsmakerbranch = branch ;
1468 tsmakerfound = kTRUE ;
1469 }
4ae78bb1 1470 }
b0bba0af 1471
4ae78bb1 1472 if ( !phostsfound || !tsmakerfound ) {
7a9d98f9 1473 if (fDebug)
1474 cout << "WARNING: AliPHOSGetter::ReadTreeR -> Cannot find TrackSegments and/or TrackSegmentMaker with name "
1475 << fTrackSegmentsTitle << endl ;
ab3ecbea 1476 return 5;
4ae78bb1 1477 }
b0bba0af 1478
1479 // Read and Post the TrackSegments
1480 if(!TrackSegments(fTrackSegmentsTitle))
1481 PostTrackSegments(fTrackSegmentsTitle) ;
65c0665e 1482
b0bba0af 1483 tsbranch->SetAddress(TrackSegmentsRef(fTrackSegmentsTitle)) ;
1484 tsbranch->GetEntry(0) ;
1485
1486 // Read and Post the TrackSegment Maker
1487 if(!TrackSegmentMaker(fTrackSegmentsTitle))
1488 PostTrackSegmentMaker(fTrackSegmentsTitle) ;
65c0665e 1489
b0bba0af 1490 tsmakerbranch->SetAddress(TSMakerRef(fTrackSegmentsTitle)) ;
4ae78bb1 1491 tsmakerbranch->GetEntry(0) ;
b0bba0af 1492
1493
1494 //------------ RecParticles ----------------------------
4ae78bb1 1495 next.Reset() ;
1496 TBranch * rpabranch = 0 ;
1497 TBranch * pidbranch = 0 ;
1498 Bool_t phosrpafound = kFALSE, pidfound = kFALSE ;
1499
7a9d98f9 1500 while ( (branch = static_cast<TBranch*>(next())) && (!phosrpafound || !pidfound) )
b0bba0af 1501 if(strcmp(branch->GetTitle(), fRecParticlesTitle)==0) {
1502 if ( strcmp(branch->GetName(), "PHOSRP")==0) {
1503 rpabranch = branch ;
1504 phosrpafound = kTRUE ;
1505 }
1506 else if (strcmp(branch->GetName(), "AliPHOSPID")==0) {
1507 pidbranch = branch ;
1508 pidfound = kTRUE ;
1509 }
4ae78bb1 1510 }
b0bba0af 1511
4ae78bb1 1512 if ( !phosrpafound || !pidfound ) {
7a9d98f9 1513 if (fDebug)
1514 cout << "WARNING: AliPHOSGetter::ReadTreeR -> Cannot find RecParticles and/or PID with name "
1515 << fRecParticlesTitle << endl ;
ab3ecbea 1516 return 6;
4ae78bb1 1517 }
b0bba0af 1518
1519 // Read and Post the RecParticles
1520 if(!RecParticles(fRecParticlesTitle))
1521 PostRecParticles(fRecParticlesTitle) ;
65c0665e 1522
b0bba0af 1523 rpabranch->SetAddress(RecParticlesRef(fRecParticlesTitle)) ;
1524 rpabranch->GetEntry(0) ;
1525
1526 // Read and Post the PID
1527 if(!PID(fRecParticlesTitle))
1528 PostPID(fRecParticlesTitle) ;
65c0665e 1529
b0bba0af 1530 pidbranch->SetAddress(PIDRef(fRecParticlesTitle)) ;
4ae78bb1 1531 pidbranch->GetEntry(0) ;
4ae78bb1 1532
ab3ecbea 1533 return 0 ;
4ae78bb1 1534}
1535
1536//____________________________________________________________________________
ab3ecbea 1537Int_t AliPHOSGetter::ReadTreeS(Int_t event)
4ae78bb1 1538{
1539 // Read the summable digits tree gAlice->TreeS()
b0bba0af 1540
1541 // loop over all opened files and read their SDigits to the White Board
7a9d98f9 1542 TFolder * phosF = dynamic_cast<TFolder *>(fSDigitsFolder->FindObject("PHOS")) ;
1543 if (!phosF)
1544 phosF = fSDigitsFolder->AddFolder("PHOS", "SDigits from PHOS") ;
b0bba0af 1545 TCollection * folderslist = phosF->GetListOfFolders() ;
1546
1547 //Add current file to list if it is not there yet
206ce9d6 1548
1549 TString subdir(fHeaderFile) ;
1550 subdir.ReplaceAll("/","_") ;
1551
1552 if ( (subdir != "aliroot") && ( !folderslist->Contains(subdir) ) ){
1553 phosF->AddFolder(subdir, "");
b0bba0af 1554 }
7a9d98f9 1555
b0bba0af 1556 TIter next(folderslist) ;
1557 TFolder * folder = 0 ;
1558 TFile * file;
1559 TTree * treeS = 0;
7a9d98f9 1560 while ( (folder = static_cast<TFolder*>(next())) ) {
206ce9d6 1561 TString fileName(folder->GetName()) ;
1562 fileName.ReplaceAll("_","/") ;
1563 if(fHeaderFile.CompareTo(fileName) == 0 )
b0bba0af 1564 treeS=gAlice->TreeS() ;
1565 else{
206ce9d6 1566 file = static_cast<TFile*>(gROOT->GetFile(fileName));
b0bba0af 1567 file->cd() ;
1568
1569 // Get SDigits Tree header from file
1570 TString treeName("TreeS") ;
1571 treeName += event ;
7a9d98f9 1572 treeS = dynamic_cast<TTree*>(gDirectory->Get(treeName.Data()));
b0bba0af 1573 }
1574 if(treeS==0){
ab3ecbea 1575 cerr << "WARNING: AliPHOSGetter::ReadTreeS There is no SDigit Tree" << endl;
1576 return 1;
b0bba0af 1577 }
1578
1579 //set address of the SDigits and SDigitizer
1580 TBranch * sdigitsBranch = 0;
1581 TBranch * sdigitizerBranch = 0;
1582 TBranch * branch = 0 ;
7a9d98f9 1583 TObjArray * lob = static_cast<TObjArray*>(treeS->GetListOfBranches()) ;
b0bba0af 1584 TIter next(lob) ;
1585 Bool_t phosfound = kFALSE, sdigitizerfound = kFALSE ;
1586
7a9d98f9 1587 while ( (branch = static_cast<TBranch*>(next())) && (!phosfound || !sdigitizerfound) ) {
b0bba0af 1588 if ( (strcmp(branch->GetName(), "PHOS")==0) && (strcmp(branch->GetTitle(), fSDigitsTitle)==0) ) {
1589 phosfound = kTRUE ;
1590 sdigitsBranch = branch ;
1591 }
1592
1593 else if ( (strcmp(branch->GetName(), "AliPHOSSDigitizer")==0) && (strcmp(branch->GetTitle(), fSDigitsTitle)==0) ) {
1594 sdigitizerfound = kTRUE ;
1595 sdigitizerBranch = branch ;
1596 }
1597 }
1598 if ( !phosfound || !sdigitizerfound ) {
7a9d98f9 1599 if (fDebug)
1600 cout << "WARNING: AliPHOSDigitizer::ReadSDigits -> Digits and/or Digitizer branch with name " << GetName()
1601 << " not found" << endl ;
ab3ecbea 1602 return 2;
b0bba0af 1603 }
1604
1605 if ( !folder->FindObject(fSDigitsTitle) )
1606 PostSDigits(fSDigitsTitle,folder->GetName()) ;
65c0665e 1607
b0bba0af 1608 sdigitsBranch->SetAddress(SDigitsRef(fSDigitsTitle,folder->GetName())) ;
1609 sdigitsBranch->GetEntry(0) ;
1610
1611 TString sdname(fSDigitsTitle) ;
1612 sdname+=":" ;
1613 sdname+=folder->GetName() ;
1614 if(!SDigitizer(sdname) )
1615 PostSDigitizer(fSDigitsTitle,folder->GetName()) ;
65c0665e 1616
b0bba0af 1617 sdigitizerBranch->SetAddress(SDigitizerRef(sdname)) ;
1618 sdigitizerBranch->GetEntry(0) ;
1619
1620 }
1621
1622 // After SDigits have been read from all files, return to the first one
1623
1624 next.Reset();
7a9d98f9 1625 folder = static_cast<TFolder*>(next());
b0bba0af 1626 if(folder){
206ce9d6 1627 TString fileName(folder->GetName()) ;
1628 fileName.ReplaceAll("_","/") ;
1629 file = static_cast<TFile*>(gROOT->GetFile(fileName));
b0bba0af 1630 file ->cd() ;
4ae78bb1 1631 }
ab3ecbea 1632 return 0 ;
b0bba0af 1633}
1634//____________________________________________________________________________
1635void AliPHOSGetter::ReadTreeS(TTree * treeS, Int_t input)
1636{ // Read the summable digits fron treeS()
1637
7a9d98f9 1638
b0bba0af 1639 TString filename("mergefile") ;
1640 filename+= input ;
7a9d98f9 1641
1642 TFolder * phosFolder = dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("PHOS")) ;
1643 if ( !phosFolder ) {
1644 phosFolder = fSDigitsFolder->AddFolder("PHOS", "SDigits from PHOS") ;
1645 }
1646 TFolder * folder=(TFolder*)phosFolder->FindObject(filename) ;
b0bba0af 1647 //set address of the SDigits and SDigitizer
1648 TBranch * sdigitsBranch = 0;
1649 TBranch * sdigitizerBranch = 0;
1650 TBranch * branch = 0 ;
1651 TObjArray * lob = (TObjArray*)treeS->GetListOfBranches() ;
4ae78bb1 1652 TIter next(lob) ;
4ae78bb1 1653 Bool_t phosfound = kFALSE, sdigitizerfound = kFALSE ;
1654
1655 while ( (branch = (TBranch*)next()) && (!phosfound || !sdigitizerfound) ) {
b0bba0af 1656 if ( strcmp(branch->GetName(), "PHOS")==0) {
4ae78bb1 1657 phosfound = kTRUE ;
b0bba0af 1658 sdigitsBranch = branch ;
4ae78bb1 1659 }
b0bba0af 1660
1661 else if ( strcmp(branch->GetName(), "AliPHOSSDigitizer")==0) {
4ae78bb1 1662 sdigitizerfound = kTRUE ;
b0bba0af 1663 sdigitizerBranch = branch ;
4ae78bb1 1664 }
1665 }
4ae78bb1 1666 if ( !phosfound || !sdigitizerfound ) {
7a9d98f9 1667 if (fDebug)
1668 cout << "WARNING: AliPHOSGetter::ReadTreeS -> Digits and/or Digitizer branch not found" << endl ;
4ae78bb1 1669 return ;
1670 }
4ae78bb1 1671
b0bba0af 1672 if (!folder || !(folder->FindObject(sdigitsBranch->GetTitle()) ) )
1673 PostSDigits(sdigitsBranch->GetTitle(),filename) ;
4ae78bb1 1674
b0bba0af 1675 sdigitsBranch->SetAddress(SDigitsRef(sdigitsBranch->GetTitle(),filename)) ;
93aeb834 1676 sdigitsBranch->GetEntry(0) ;
b0bba0af 1677
1678 TString sdname(sdigitsBranch->GetTitle()) ;
1679 sdname+=":" ;
1680 sdname+=filename ;
1681 if(!SDigitizer(sdigitsBranch->GetTitle()) )
1682 PostSDigitizer(sdigitsBranch->GetTitle(),filename) ;
93aeb834 1683
b0bba0af 1684 sdigitizerBranch->SetAddress(SDigitizerRef(sdname)) ;
b0bba0af 1685 sdigitizerBranch->GetEntry(0) ;
1686
1687}
4ae78bb1 1688
4ae78bb1 1689
1690//____________________________________________________________________________
1691void AliPHOSGetter::ReadPrimaries()
1692{
be28ada9 1693 // a lot simplified.... if 2 files are opened then we have a problem
cb34a1fa 1694
be28ada9 1695 TClonesArray * ar = 0 ;
cb34a1fa 1696 if(! (ar = Primaries()) ) {
1697 PostPrimaries() ;
1698 ar = Primaries() ;
1699 }
1700 ar->Delete() ;
4ae78bb1 1701
be28ada9 1702 fNPrimaries = gAlice->GetNtrack() ;
cb34a1fa 1703 Int_t index = 0 ;
be28ada9 1704 for (index = 0 ; index < fNPrimaries; index++) {
1705 new ((*ar)[index]) TParticle(*(Primary(index)));
cb34a1fa 1706 }
4ae78bb1 1707}
1708//____________________________________________________________________________
cbfb577a 1709void AliPHOSGetter::Event(const Int_t event, const char* opt)
4ae78bb1 1710{
1711 // Reads the content of all Tree's S, D and R
1712
7a9d98f9 1713 if (event >= gAlice->TreeE()->GetEntries() ) {
1714 cerr << "ERROR: AliPHOSGetter::Event -> " << event << " not found in TreeE!" << endl ;
1715 return ;
4ae78bb1 1716 }
cb34a1fa 1717 gAlice->GetEvent(event) ;
65c0665e 1718
ab3ecbea 1719 Int_t rvRH = 0 ;
1720 Int_t rvRS = 0 ;
1721 Int_t rvRD = 0 ;
1722 Int_t rvRR = 0 ;
1723
b0bba0af 1724 if(strstr(opt,"H") )
ab3ecbea 1725 rvRH = ReadTreeH() ;
b0bba0af 1726
1727 if(strstr(opt,"S") )
ab3ecbea 1728 rvRS = ReadTreeS(event) ;
b0bba0af 1729
1730 if( strstr(opt,"D") )
ab3ecbea 1731 rvRD = ReadTreeD() ;
b0bba0af 1732
1733 if( strstr(opt,"R") )
ab3ecbea 1734 rvRR = ReadTreeR() ;
b0bba0af 1735
1736 if( strstr(opt,"Q") )
1737 ReadTreeQA() ;
1738
be28ada9 1739 if( strstr(opt,"P") || (strcmp(opt,"")==0) )
ab3ecbea 1740 if ( gAlice->Stack() )
1741 ReadPrimaries() ;
b0bba0af 1742
4ae78bb1 1743}
1744
1745//____________________________________________________________________________
cb34a1fa 1746TObject * AliPHOSGetter::ReturnO(TString what, TString name, TString file) const
4ae78bb1 1747{
1748 // get the object named "what" from the folder
7a9d98f9 1749 // folders are named like //Folders
4ae78bb1 1750
1751 if ( file.IsNull() )
1752 file = fHeaderFile ;
7a9d98f9 1753
1754 TFolder * folder = 0 ;
1755 TObject * phosO = 0 ;
1756
1757 // if ( name.IsNull() ) {
cb34a1fa 1758 if ( what.CompareTo("Primaries") == 0 ) {
1759 folder = dynamic_cast<TFolder *>(fPrimariesFolder->FindObject("Primaries")) ;
1760 if (folder)
1761 phosO = dynamic_cast<TObject *>(folder->FindObject("Primaries")) ;
1762 }
1763 else if ( what.CompareTo("Hits") == 0 ) {
7a9d98f9 1764 folder = dynamic_cast<TFolder *>(fHitsFolder->FindObject("PHOS")) ;
1765 if (folder)
1766 phosO = dynamic_cast<TObject *>(folder->FindObject("Hits")) ;
1767 }
206ce9d6 1768 else if ( what.CompareTo("SDigits") == 0 ) {
1769 file.ReplaceAll("/","_") ;
1770 TString path = "PHOS/" + file ;
7a9d98f9 1771 folder = dynamic_cast<TFolder *>(fSDigitsFolder->FindObject(path.Data())) ;
1772 if (folder) {
1773 if (name.IsNull())
1774 name = fSDigitsTitle ;
1775 phosO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
4ae78bb1 1776 }
7a9d98f9 1777 }
1778 else if ( what.CompareTo("Digits") == 0 ){
1779 folder = dynamic_cast<TFolder *>(fDigitsFolder->FindObject("PHOS")) ;
1780 if (folder) {
1781 if (name.IsNull())
1782 name = fDigitsTitle ;
1783 phosO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
4ae78bb1 1784 }
7a9d98f9 1785 }
1786 else if ( what.CompareTo("EmcRecPoints") == 0 ) {
1787 folder = dynamic_cast<TFolder *>(fRecoFolder->FindObject("PHOS/EMCARecPoints")) ;
1788 if (folder) {
1789 if (name.IsNull())
1790 name = fRecPointsTitle ;
1791 phosO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
4ae78bb1 1792 }
7a9d98f9 1793 }
1794 else if ( what.CompareTo("CpvRecPoints") == 0 ) {
1795 folder = dynamic_cast<TFolder *>(fRecoFolder->FindObject("PHOS/CPVRecPoints")) ;
1796 if (folder) {
1797 if (name.IsNull())
1798 name = fRecPointsTitle ;
1799 phosO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1800 }
1801 }
1802 else if ( what.CompareTo("TrackSegments") == 0 ) {
1803 folder = dynamic_cast<TFolder *>(fRecoFolder->FindObject("PHOS/TrackSegments")) ;
1804 if (folder) {
1805 if (name.IsNull())
1806 name = fTrackSegmentsTitle ;
1807 phosO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1808 }
1809 }
1810 else if ( what.CompareTo("RecParticles") == 0 ) {
1811 folder = dynamic_cast<TFolder *>(fRecoFolder->FindObject("PHOS/RecParticles")) ;
1812 if (folder) {
1813 if (name.IsNull())
1814 name = fRecParticlesTitle ;
1815 phosO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1816 }
1817 }
1818 else if ( what.CompareTo("Alarms") == 0 ){
1819 if (name.IsNull() )
1820 phosO = dynamic_cast<TObject *>(fQAFolder->FindObject("PHOS")) ;
1821 else {
1822 folder = dynamic_cast<TFolder *>(fQAFolder->FindObject("PHOS")) ;
1823 if (!folder)
1824 phosO = 0 ;
1825 else
1826 phosO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
4ae78bb1 1827 }
4ae78bb1 1828 }
4ae78bb1 1829 if (!phosO) {
b0bba0af 1830 if(fDebug)
7a9d98f9 1831 cerr << "ERROR : AliPHOSGetter::ReturnO -> Object " << what << " not found in " << folder->GetName() << endl ;
b0bba0af 1832 return 0 ;
4ae78bb1 1833 }
cb34a1fa 1834
4ae78bb1 1835 return phosO ;
1836}
1837
1838//____________________________________________________________________________
1839const TTask * AliPHOSGetter::ReturnT(TString what, TString name) const
1840{
1841 // get the TTask named "what" from the folder
7a9d98f9 1842 // folders are named like //Folders/Tasks/what/PHOS/name
4ae78bb1 1843
7a9d98f9 1844 TString search(what) ;
1845 if ( what.CompareTo("Clusterizer") == 0 )
1846 search = "Reconstructioner" ;
4ae78bb1 1847 else if ( what.CompareTo("TrackSegmentMaker") == 0 )
7a9d98f9 1848 search = "Reconstructioner" ;
4ae78bb1 1849 else if ( what.CompareTo("PID") == 0 )
7a9d98f9 1850 search = "Reconstructioner" ;
eb9763ac 1851 else if ( what.CompareTo("QATasks") == 0 )
7a9d98f9 1852 search = "QA" ;
4ae78bb1 1853
7a9d98f9 1854 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject(search)) ;
4ae78bb1 1855
7a9d98f9 1856 if (!tasks) {
1857 cerr << "ERROR: AliPHOSGetter::ReturnT -> Task " << what << " not found!" << endl ;
1858 return 0 ;
4ae78bb1 1859 }
1860
7a9d98f9 1861 TTask * phosT = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
4ae78bb1 1862 if (!phosT) {
7a9d98f9 1863 cerr << "ERROR: AliPHOSGetter::ReturnT -> Task " << what << "/PHOS not found!" << endl ;
1864 return 0 ;
4ae78bb1 1865 }
7a9d98f9 1866
1867 TList * list = phosT->GetListOfTasks() ;
4ae78bb1 1868
1869 if (what.CompareTo("SDigitizer") == 0) {
1870 if ( name.IsNull() )
1871 name = fSDigitsTitle ;
1872 } else if (what.CompareTo("Digitizer") == 0){
1873 if ( name.IsNull() )
1874 name = fDigitsTitle ;
1875 } else if (what.CompareTo("Clusterizer") == 0){
1876 if ( name.IsNull() )
1877 name = fRecPointsTitle ;
b0bba0af 1878 name.Append(":clu") ;
4ae78bb1 1879 }
1880 else if (what.CompareTo("TrackSegmentMaker") == 0){
1881 if ( name.IsNull() )
1882 name = fTrackSegmentsTitle ;
b0bba0af 1883 name.Append(":tsm") ;
4ae78bb1 1884 }
1885 else if (what.CompareTo("PID") == 0){
1886 if ( name.IsNull() )
1887 name = fRecParticlesTitle ;
b0bba0af 1888 name.Append(":pid") ;
4ae78bb1 1889 }
b0bba0af 1890 else if (what.CompareTo("QATasks") == 0){
eb9763ac 1891 if ( name.IsNull() )
1892 return phosT ;
1893 }
4ae78bb1 1894
7a9d98f9 1895 TIter it(list) ;
b0bba0af 1896 TTask * task = 0 ;
7a9d98f9 1897 while((task = static_cast<TTask *>(it.Next()) )){
b0bba0af 1898 TString taskname(task->GetName()) ;
1899 if(taskname.BeginsWith(name))
1900 return task ;
1901 }
1902
1903 if(fDebug)
7a9d98f9 1904 cout << "WARNING: AliPHOSGetter::ReturnT -> Task " << search << "/" << name << " not found!" << endl ;
b0bba0af 1905 return 0 ;
4ae78bb1 1906}