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