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