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