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