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