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