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