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