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