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