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