Partial redesign of identification bits and coding rule corrections
[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*/
fbf811ec 23/* $Log:
24 08.2002 Dmitri Peressounko:
25
26*/
4ae78bb1 27
28//_________________________________________________________________________
29// A singleton. This class should be used in the analysis stage to get
30// reconstructed objects: Digits, RecPoints, TrackSegments and RecParticles,
31// instead of directly reading them from galice.root file. This container
32// ensures, that one reads Digits, made of these particular digits, RecPoints,
33// made of these particular RecPoints, TrackSegments and RecParticles.
34// This becomes non trivial if there are several identical branches, produced with
35// different set of parameters.
36//
37// An example of how to use (see also class AliPHOSAnalyser):
38// AliPHOSGetter * gime = AliPHOSGetter::GetInstance("galice.root","test") ;
39// for(Int_t irecp = 0; irecp < gime->NRecParticles() ; irecp++)
40// AliPHOSRecParticle * part = gime->RecParticle(1) ;
41// ................
2a657981 42// gime->Event(event) ; // reads new event from galice.root
4ae78bb1 43//
2a657981 44//*-- Author: Yves Schutz (SUBATECH) & Dmitri Peressounko (RRC KI & SUBATECH)
45//*-- Completely redesigned by Dmitri Peressounko March 2001
4ae78bb1 46//
47//*-- YS June 2001 : renamed the original AliPHOSIndexToObject and make
48//*-- systematic usage of TFolders without changing the interface
49//////////////////////////////////////////////////////////////////////////////
50
4ae78bb1 51// --- ROOT system ---
4ae78bb1 52#include "TFile.h"
53#include "TTree.h"
54#include "TROOT.h"
55#include "TObjString.h"
56#include "TFolder.h"
cb34a1fa 57#include "TParticle.h"
4ae78bb1 58
59// --- Standard library ---
4ae78bb1 60
61// --- AliRoot header files ---
4ae78bb1 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"
479975d9 68#include "AliPHOSClusterizerv1.h"
69#include "AliPHOSTrackSegmentMakerv1.h"
4ae78bb1 70#include "AliPHOSTrackSegment.h"
479975d9 71#include "AliPHOSPIDv1.h"
4ae78bb1 72#include "AliPHOSGeometry.h"
c2cd5471 73#include "AliPHOSRaw2Digits.h"
7bb289a7 74//#include "AliPHOSCalibrationDB.h"
75#include "AliPHOSBeamTestEvent.h"
4ae78bb1 76ClassImp(AliPHOSGetter)
77
78 AliPHOSGetter * AliPHOSGetter::fgObjGetter = 0 ;
0bc3b8ed 79 TFile * AliPHOSGetter::fgFile = 0 ;
4ae78bb1 80
81//____________________________________________________________________________
fbf811ec 82AliPHOSGetter::AliPHOSGetter(const char* headerFile, const char* branchTitle, const Bool_t toSplit )
4ae78bb1 83{
fbf811ec 84 // This is the ctor called by GetInstance and the only one that can be used
4ae78bb1 85
fbf811ec 86 if( fHeaderFile.Contains("_") ) {
f1611b7c 87 Fatal("AliPHOSGetter", "Invalid file name (_ not allowed) %s", fHeaderFile.Data() ) ;
fbf811ec 88 }
9bd3caba 89
fbf811ec 90 //Initialize all data
91
92 fFailed = kFALSE ;
93 fDebug = 0 ;
c2cd5471 94 fAlice = 0 ;
7bb289a7 95 fBTE = 0 ;
fbf811ec 96
97 fToSplit = toSplit ;
98 fHeaderFile = headerFile ;
4ae78bb1 99
100 fPrimaries = new TObjArray(1) ;
101
cb34a1fa 102 fModuleFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Run/Configuration/Modules"));
103 fPrimariesFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/RunMC/Event/Data"));
104 fHitsFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/RunMC/Event/Data/Hits"));
105 fSDigitsFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/RunMC/Event/Data/SDigits"));
106 fDigitsFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Run/Event/Data"));
107 fRecoFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Run/Event/RecData"));
108 fQAFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Run/Conditions/QA"));
109 fTasksFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Tasks")) ;
dca3a7c4 110
fbf811ec 111 //Set titles to branches and create PHOS specific folders
112 SetTitle(branchTitle) ;
7bb289a7 113
b0bba0af 114 if ( fHeaderFile != "aliroot" ) { // to call the getter without a file
eb9763ac 115 //open headers file
0bc3b8ed 116 fgFile = static_cast<TFile*>(gROOT->GetFile(fHeaderFile.Data() ) ) ;
7bb289a7 117
0bc3b8ed 118 if(!fgFile) { //if file was not opened yet, read gAlice
119 fgFile = TFile::Open(fHeaderFile.Data(),"update") ;
120 if (!fgFile->IsOpen()) {
21cd0c07 121 Error("AliPHOSGetter", "Cannot open %s", fHeaderFile.Data() ) ;
dca3a7c4 122 fFailed = kTRUE ;
123 return ;
eb9763ac 124 }
7bb289a7 125 }
0bc3b8ed 126 gAlice = dynamic_cast<AliRun *>(fgFile->Get("gAlice")) ;
93aeb834 127 }
85290134 128
93aeb834 129 if (!gAlice) {
21cd0c07 130 Error("AliPHOSGetter", "Cannot find gAlice in %s", fHeaderFile.Data() ) ;
dca3a7c4 131 fFailed = kTRUE ;
132 return ;
93aeb834 133 }
134 if (!PHOS()) {
135 if (fDebug)
21cd0c07 136 Info("AliPHOSGetter", "-> Posting PHOS to Folders") ;
5bf7ace9 137 if (gAlice->GetDetector("PHOS")) {
138 AliConfig * conf = AliConfig::Instance() ;
139 conf->Add(static_cast<AliDetector*>(gAlice->GetDetector("PHOS"))) ;
140 conf->Add(static_cast<AliModule*>(gAlice->GetDetector("PHOS"))) ;
141 }
142 else
21cd0c07 143 Error("AliPHOSGetter", "detector PHOS not found") ;
4ae78bb1 144 }
4b808d52 145
b0bba0af 146 fDebug=0;
4ae78bb1 147}
fbf811ec 148
4ae78bb1 149//____________________________________________________________________________
0bc3b8ed 150AliPHOSGetter::~AliPHOSGetter()
151{
152 // dtor
ededcd8c 153 if (fPrimaries) {
154 fPrimaries->Delete() ;
155 delete fPrimaries ;
156 }
d489fb96 157
158 TFolder * phosF = dynamic_cast<TFolder *>(fSDigitsFolder->FindObject("PHOS")) ;
159 TCollection * folderslist = phosF->GetListOfFolders() ;
160 TIter next(folderslist) ;
161 TFolder * folder = 0 ;
162 while ( (folder = static_cast<TFolder*>(next())) )
163 phosF->Remove(folder) ;
65549808 164
0bc3b8ed 165 if (fgFile) {
166 fgFile->Close() ;
167 delete fgFile ;
168 fgFile = 0 ;
89165262 169 }
65549808 170 fgObjGetter = 0 ;
171
81bb1a45 172}
7a9d98f9 173
65549808 174//____________________________________________________________________________
175void AliPHOSGetter::CloseFile()
176{
0bc3b8ed 177 // delete gAlice
178
7bb289a7 179 if(gAlice)
180 delete gAlice ;
b134c32f 181 gAlice = 0 ;
7bb289a7 182 if(fAlice)
183 delete fAlice ;
c2cd5471 184 fAlice = 0 ;
65549808 185}
4ae78bb1 186
187//____________________________________________________________________________
0c87da39 188const TFolder * AliPHOSGetter::Folder(const TString what) const {
189
190 // returns the PHOS folder required by what
191 // what = hits, sdigits, digits
192
193 if ( what == "hits" )
194 return dynamic_cast<const TFolder *>(fHitsFolder->FindObject("PHOS")) ;
195 else if ( what == "sdigits" )
196 return dynamic_cast<const TFolder *>(fSDigitsFolder->FindObject("PHOS")) ;
197 else if ( what == "digits" )
198 return dynamic_cast<const TFolder *>(fDigitsFolder->FindObject("PHOS")) ;
199 else {
21cd0c07 200 Error("GetFolder", " %s illegal option (hits, sdigits, digits)", what.Data() ) ;
0c87da39 201 return 0 ;
202 }
203}
204
205//____________________________________________________________________________
4ae78bb1 206AliPHOSGetter * AliPHOSGetter::GetInstance()
207{
208 // Returns the pointer of the unique instance already defined
209
b134c32f 210 if ( fgObjGetter ) {
b134c32f 211 return fgObjGetter ;
212 }
213 else {
21cd0c07 214 //Warning("GetInstance", "not yet initialized") ;
b134c32f 215 return 0 ;
216 }
4ae78bb1 217}
218
219//____________________________________________________________________________
220AliPHOSGetter * AliPHOSGetter::GetInstance(const char* headerFile,
fbf811ec 221 const char* branchTitle,
222 const Bool_t toSplit)
4ae78bb1 223{
224 // Creates and returns the pointer of the unique instance
fbf811ec 225 // Must be called only when the environment has changed
548f0134 226
fbf811ec 227 if(!fgObjGetter){
228 fgObjGetter = new AliPHOSGetter(headerFile,branchTitle,toSplit) ;
229 if(fgObjGetter->fFailed)
230 return 0;
231 else
232 return fgObjGetter ;
233 }
4ae78bb1 234
fbf811ec 235 //First checks, if header file already opened
0bc3b8ed 236 if(!fgObjGetter->fgFile){
fbf811ec 237 fgObjGetter = new AliPHOSGetter(headerFile,branchTitle,toSplit) ;
238 if(fgObjGetter->fFailed)
239 return 0;
240 else
241 return fgObjGetter ;
242 }
df25f7dd 243
fbf811ec 244 if(fgObjGetter->fHeaderFile.CompareTo(headerFile)==0){ //Opened the same header file
245 if((fgObjGetter->fBranchTitle.CompareTo(branchTitle) == 0)&& //Open the same branch title
246 (toSplit==fgObjGetter->fToSplit)){ //Nothing should be cleaned
59b46416 247 }
fbf811ec 248 else{ //Clean all data and AliPHOS...zers
249 if(fgObjGetter->fToSplit)
250 fgObjGetter->CloseSplitFiles() ;
251 fgObjGetter->CleanWhiteBoard() ;
252 fgObjGetter->fToSplit = toSplit ;
253 fgObjGetter->SetTitle(branchTitle) ;
fbf811ec 254 }
255 }
256 else{ //Close already opened files, clean memory and open new header file
7bb289a7 257 if(gAlice){ //should first delete gAlice, then close file
258 //Should be in dtor of PHOS, but if one changes path ...
259 fgObjGetter->fModuleFolder->Remove(fgObjGetter->fModuleFolder->FindObject("PHOS")) ;
260 delete gAlice ;
261 }
0bc3b8ed 262 if(fgObjGetter->fgFile){
263 fgObjGetter->fgFile->Close() ;
264 fgObjGetter->fgFile=0;
fbf811ec 265 }
266 if(fgObjGetter->fToSplit)
267 fgObjGetter->CloseSplitFiles() ;
268 fgObjGetter->CleanWhiteBoard() ;
269 fgObjGetter = new AliPHOSGetter(headerFile,branchTitle,toSplit) ;
7bb289a7 270
fbf811ec 271 }
272 return fgObjGetter ;
b134c32f 273
fbf811ec 274}
d489fb96 275
fbf811ec 276//____________________________________________________________________________
277const Bool_t AliPHOSGetter::BranchExists(const TString recName) const
278{
279 //Looks in the tree Tree"name" if branch with current name olready exists
280
281 TString filename("") ;
282 TString name, dataname, zername ;
283 if(recName == "SDigits"){
284 filename=fSDigitsFileName ;
285 name = "TreeS0" ;
286 dataname = "PHOS" ;
287 zername = "AliPHOSSDigitizer" ;
288 }
289 else
290 if(recName == "Digits"){
291 filename=fDigitsFileName ;
292 name = "TreeD0" ;
293 dataname = "PHOS" ;
294 zername = "AliPHOSDigitizer" ;
295 }
296 else
297 if(recName == "RecPoints"){
298 filename=fRecPointsFileName ;
299 name = "TreeR0" ;
300 dataname = "PHOSEmcRP" ;
301 zername = "AliPHOSClusterizer" ;
302 }
303 else
304 if(recName == "TrackSegments"){
305 filename=fTrackSegmentsFileName ;
306 name = "TreeR0" ;
307 dataname = "PHOSTS" ;
308 zername = "AliPHOSTrackSegmentMaker" ;
309 }
310 else
311 if(recName == "RecParticles"){
312 filename= fRecParticlesFileName ;
313 name = "TreeR0" ;
314 dataname = "PHOSRP" ;
315 zername = "AliPHOSPID" ;
316 }
317 else
318 return kFALSE ;
319
320 TFile * file ;
321 TTree * tree ;
322 if(fToSplit){
323 file = static_cast<TFile*>(gROOT->GetFile(filename.Data() ) ) ;
324 if(!file)
325 file = TFile::Open(fSDigitsFileName.Data(),"update");
326 }
327 else
0bc3b8ed 328 file = fgFile ;
fbf811ec 329
330 tree = (TTree *)file->Get(name.Data()) ;
d489fb96 331
fbf811ec 332 if(!tree )
333 return kFALSE ;
4b808d52 334
fbf811ec 335 TObjArray * lob = static_cast<TObjArray*>(tree->GetListOfBranches()) ;
336 TIter next(lob) ;
337 TBranch * branch = 0 ;
338 TString titleName(fBranchTitle);
339 titleName+=":";
340 while ((branch = (static_cast<TBranch*>(next())))) {
341 TString branchName(branch->GetName() ) ;
342 TString branchTitle(branch->GetTitle() ) ;
343 if ( branchName.BeginsWith(dataname) && branchTitle.BeginsWith(fBranchTitle) ){
21cd0c07 344 Warning("BranchExists", "branch %s with title %s already exists in %s", dataname.Data(), fBranchTitle.Data(), name.Data() ) ;
fbf811ec 345 return kTRUE ;
346 }
347 if ( branchName.BeginsWith(zername) && branchTitle.BeginsWith(titleName) ){
21cd0c07 348 Warning("BranchExists", "branch AliPHOS... with title %s already exists in %s", branch->GetTitle(), name.Data() ) ;
fbf811ec 349 return kTRUE ;
350 }
351 }
48f12df6 352 //We can't delete three if gAlice points to it... To be redisigned somehow???!!!
353 if(!fToSplit){
354 if(name.Contains("TreeS"))
355 if(tree!=gAlice->TreeS())
356 tree->Delete();
357 if(name.Contains("TreeD"))
358 if(tree!=gAlice->TreeD())
359 tree->Delete();
360 if(name.Contains("TreeR"))
361 if(tree!=gAlice->TreeR())
362 tree->Delete();
363 }
fbf811ec 364 return kFALSE ;
4ae78bb1 365
366}
367
368//____________________________________________________________________________
6ad0e528 369void AliPHOSGetter::ListBranches(Int_t event) const
370{
0bc3b8ed 371 // Iterates over branches in each TreeH, TreeS, TreeD and TreeR and
372 // prints lists of branches to stdout
373 // (I don't know why this method is needed. Yu.Kharlov)
6ad0e528 374
375 TBranch * branch = 0 ;
376 if (gAlice->GetEvent(event) == -1)
377 return ;
fbf811ec 378
6ad0e528 379 TTree * t = gAlice->TreeH() ;
380 if(t){
21cd0c07 381 Info("ListBranches", "-> ****** Hits : ") ;
6ad0e528 382 TObjArray * lob = t->GetListOfBranches() ;
383 TIter next(lob) ;
384 while ( (branch = static_cast<TBranch*>(next())) )
21cd0c07 385 Info("ListBranches", " %s", branch->GetName()) ;
fbf811ec 386 } else
21cd0c07 387 Warning("ListBranches", "TreeH not found for event %d", event ) ;
6ad0e528 388
389 t = gAlice->TreeS() ;
390 if(t){
21cd0c07 391 Info("ListBranches", "-> ****** SDigits : ") ;
6ad0e528 392 TObjArray * lob = t->GetListOfBranches() ;
393 TIter next(lob) ;
394 while ( (branch = static_cast<TBranch*>(next())) )
21cd0c07 395 Info("ListBranches", " %s %s", branch->GetName(), branch->GetTitle()) ;
fbf811ec 396 } else
21cd0c07 397 Warning("ListBranches", "TreeS not found for event %d", event) ;
fbf811ec 398
399
6ad0e528 400 t = gAlice->TreeD() ;
401 if(t){
21cd0c07 402 Info("ListBranches", "-> ****** Digits : ") ;
6ad0e528 403 TObjArray * lob = t->GetListOfBranches() ;
404 TIter next(lob) ;
405 while ( (branch = static_cast<TBranch*>(next())) )
21cd0c07 406 Info("ListBranches", " %s %s", branch->GetName(), branch->GetTitle()) ;
fbf811ec 407 } else
21cd0c07 408 Warning("ListBranches", "TreeD not found for event %d", event) ;
fbf811ec 409
6ad0e528 410
411 t = gAlice->TreeR() ;
412 if(t){
21cd0c07 413 Info("ListBranches", "-> ****** Recon : ") ;
6ad0e528 414 TObjArray * lob = t->GetListOfBranches() ;
415 TIter next(lob) ;
416 while ( (branch = static_cast<TBranch*>(next())) )
21cd0c07 417 Info("ListBranches", " %s %s", branch->GetName(), branch->GetTitle()) ;
fbf811ec 418 } else
21cd0c07 419 Warning("ListBranches", "TreeR not found for event %d", event) ;
fbf811ec 420
6ad0e528 421}
422
423//____________________________________________________________________________
424void AliPHOSGetter::NewBranch(TString name, Int_t event)
425{
0bc3b8ed 426 // Set titles for (S)Digits, RecPoints, TSegments and RecParticles branches
427
6ad0e528 428 fBranchTitle = fSDigitsTitle = fDigitsTitle = fRecPointsTitle = fTrackSegmentsTitle = fRecParticlesTitle = name ;
429 Event(event) ;
430}
431
432//____________________________________________________________________________
433Bool_t AliPHOSGetter::NewFile(TString name)
434{
0bc3b8ed 435 // Open a new file
6ad0e528 436 fHeaderFile = name ;
0bc3b8ed 437 fgFile->Close() ;
6ad0e528 438 fFailed = kFALSE;
439
0bc3b8ed 440 fgFile = static_cast<TFile*>(gROOT->GetFile(fHeaderFile.Data() ) ) ;
441 if(!fgFile) { //if file was not opened yet, read gAlice
442 fgFile = TFile::Open(fHeaderFile.Data(),"update") ;
443 if (!fgFile->IsOpen()) {
21cd0c07 444 Error("NewFile", "Cannot open %s", fHeaderFile.Data() ) ;
6ad0e528 445 fFailed = kTRUE ;
446 return fFailed ;
447 }
0bc3b8ed 448 gAlice = static_cast<AliRun *>(fgFile->Get("gAlice")) ;
6ad0e528 449 }
450
451 if (!gAlice) {
21cd0c07 452 Error("AliPHOSGetter", "Cannot find gAlice in %s", fHeaderFile.Data() ) ;
6ad0e528 453 fFailed = kTRUE ;
454 return fFailed ;
455 }
456 return fFailed ;
457}
458
459//____________________________________________________________________________
7a9d98f9 460const AliPHOS * AliPHOSGetter::PHOS()
4ae78bb1 461{
462 // returns the PHOS object
7a9d98f9 463 AliPHOS * phos = dynamic_cast<AliPHOS*>(fModuleFolder->FindObject("PHOS")) ;
464 if (!phos)
465 if (fDebug)
21cd0c07 466 Warning("PHOS", "-> PHOS module not found in Folders") ;
7a9d98f9 467 return phos ;
4ae78bb1 468}
469
470//____________________________________________________________________________
7a9d98f9 471const AliPHOSGeometry * AliPHOSGetter::PHOSGeometry()
4ae78bb1 472{
0bc3b8ed 473 // Returns PHOS geometry
474
7a9d98f9 475 AliPHOSGeometry * rv = 0 ;
476 if (PHOS() )
477 rv = PHOS()->GetGeometry() ;
478 return rv ;
479}
4ae78bb1 480
481//____________________________________________________________________________
fbf811ec 482const Bool_t AliPHOSGetter::PostPrimaries(void) const
cb34a1fa 483{ //------- Primaries ----------------------
484
485 // the hierarchy is //Folders/RunMC/Event/Data/Primaries
486
487 TFolder * primariesFolder = dynamic_cast<TFolder*>(fPrimariesFolder->FindObject("Primaries")) ;
488 if ( !primariesFolder ) {
489 if (fDebug) {
21cd0c07 490 Warning("PostPrimaries", "-> Folder //%s/Primaries/ not found!", fPrimariesFolder->GetName()) ;
491 Info("PostPrimaries", "-> Adding Folder //%s/Primaries", fPrimariesFolder->GetName()) ;
cb34a1fa 492 }
493 primariesFolder = fPrimariesFolder->AddFolder("Primaries", "Primaries particles from TreeK") ;
494 }
495 TClonesArray *primaries= new TClonesArray("TParticle",1000) ;
496 primaries->SetName("Primaries") ;
497 primariesFolder->Add(primaries) ;
498
499 return kTRUE;
500}
501
502//____________________________________________________________________________
65c0665e 503TObject** AliPHOSGetter::PrimariesRef(void) const
cb34a1fa 504{ //------- Primaries ----------------------
505
506
507 // the hierarchy is //Folders/RunMC/Event/Data/Primaries
508 if ( !fPrimariesFolder ) {
f1611b7c 509 Fatal("PrimariesRef", "Folder //%s not found", fPrimariesFolder) ;
cb34a1fa 510 }
511
512 TFolder * primariesFolder = dynamic_cast<TFolder *>(fPrimariesFolder->FindObject("Primaries")) ;
513 if ( !primariesFolder ) {
f1611b7c 514 Fatal("PrimariesRef", "Folder //%s/Primaries/ not found", fPrimariesFolder) ;
cb34a1fa 515 }
516
517 TObject * p = primariesFolder->FindObject("Primaries") ;
518 if(!p) {
f1611b7c 519 Fatal("PrimariesRef","%s /Primaries not found !", primariesFolder->GetName() ) ;
cb34a1fa 520 }
f1611b7c 521
522 return primariesFolder->GetListOfFolders()->GetObjectRef(p) ;
cb34a1fa 523}
524
525//____________________________________________________________________________
fbf811ec 526const Bool_t AliPHOSGetter::PostHits(void) const
b0bba0af 527{ //------- Hits ----------------------
dbad285c 528
7a9d98f9 529 // the hierarchy is //Folders/RunMC/Event/Data/PHOS/Hits
b0bba0af 530
7a9d98f9 531 TFolder * phosFolder = dynamic_cast<TFolder*>(fHitsFolder->FindObject("PHOS")) ;
532 if ( !phosFolder ) {
533 if (fDebug) {
21cd0c07 534 Warning("PostHits", "-> Folder //%s/PHOS/ not found!", fHitsFolder) ;
535 Info("PostHits", "-> Adding Folder //%s/PHOS/", fHitsFolder) ;
7a9d98f9 536 }
537 phosFolder = fHitsFolder->AddFolder("PHOS", "Hits from PHOS") ;
b0bba0af 538 }
7a9d98f9 539 TClonesArray *hits= new TClonesArray("AliPHOSHit",1000) ;
540 hits->SetName("Hits") ;
541 phosFolder->Add(hits) ;
542
b0bba0af 543 return kTRUE;
544}
7a9d98f9 545
b0bba0af 546//____________________________________________________________________________
65c0665e 547TObject** AliPHOSGetter::HitsRef(void) const
b0bba0af 548{ //------- Hits ----------------------
4ae78bb1 549
b0bba0af 550
7a9d98f9 551 // the hierarchy is //Folders/RunMC/Event/Data/PHOS/Hits
552 if ( !fHitsFolder ) {
f1611b7c 553 Fatal("HitsRef", "Folder //%s not found !", fHitsFolder) ;
b0bba0af 554 }
4ae78bb1 555
7a9d98f9 556 TFolder * phosFolder = dynamic_cast<TFolder *>(fHitsFolder->FindObject("PHOS")) ;
557 if ( !phosFolder ) {
f1611b7c 558 Fatal("HitsRef", "Folder //%s/PHOS/ not found !", fHitsFolder) ;
7a9d98f9 559 }
560
561 TObject * h = phosFolder->FindObject("Hits") ;
562 if(!h) {
f1611b7c 563 Fatal("HitsRef", "%s/Hits not fount !", phosFolder->GetName() ) ;
7a9d98f9 564 }
f1611b7c 565
566 return phosFolder->GetListOfFolders()->GetObjectRef(h) ;
b0bba0af 567}
7a9d98f9 568
b0bba0af 569//____________________________________________________________________________
fbf811ec 570const Bool_t AliPHOSGetter::PostSDigits(const char * name, const char * headerFile) const
b0bba0af 571{ //---------- SDigits -------------------------
572
b0bba0af 573
7a9d98f9 574 // the hierarchy is //Folders/RunMC/Event/Data/PHOS/SDigits/headerFile/sdigitsname
b0bba0af 575 // because you can have sdigits from several hit files for mixing
7a9d98f9 576
577 TFolder * phosFolder = dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("PHOS")) ;
578 if ( !phosFolder ) {
579 if (fDebug) {
21cd0c07 580 Warning("PostSDigits", "-> Folder //%s/PHOS/ not found!", fSDigitsFolder) ;
581 Info("PostSDigits", "-> Adding Folder //%s/PHOS/", fHitsFolder) ;
7a9d98f9 582 }
583 phosFolder = fSDigitsFolder->AddFolder("PHOS", "SDigits from PHOS") ;
584 }
fbf811ec 585
407ae4df 586
b0bba0af 587 TString subdir(headerFile) ;
407ae4df 588 if(fToSplit){
589 subdir.Remove(subdir.Last('/')+1,subdir.Length()) ;
590 subdir.ReplaceAll("/","_") ;
591 subdir+="PHOS.SDigits." ;
592 if(name && (strcmp(name,"Default")!=0)){
593 subdir+=name ;
594 subdir+="." ;
595 }
596 subdir+="root" ;
597 }
598
7a9d98f9 599 TFolder * phosSubFolder = dynamic_cast<TFolder*>(phosFolder->FindObject(subdir)) ;
600 if ( !phosSubFolder )
601 phosSubFolder = phosFolder->AddFolder(subdir, "");
602
fbf811ec 603
7a9d98f9 604 TObject * sd = phosSubFolder->FindObject(name);
fbf811ec 605 if ( !sd ) {
93aeb834 606 TClonesArray * sdigits = new TClonesArray("AliPHOSDigit",1) ;
b0bba0af 607 sdigits->SetName(name) ;
7a9d98f9 608 phosSubFolder->Add(sdigits) ;
b0bba0af 609 }
610
611 return kTRUE;
612}
613//____________________________________________________________________________
407ae4df 614TObject** AliPHOSGetter::SDigitsRef(const char * name, const char * foldername) const
7a9d98f9 615{ //------- SDigits ----------------------
b0bba0af 616
7a9d98f9 617 // the hierarchy is //Folders/RunMC/Event/Data/PHOS/SDigits/filename/SDigits
618
619 if ( !fSDigitsFolder ) {
f1611b7c 620 Fatal("SDigitsRef", "Folder //%s not found !", fSDigitsFolder) ;
b0bba0af 621 }
7a9d98f9 622
407ae4df 623 TFolder * phosFolder = static_cast<TFolder *>(fSDigitsFolder->FindObject("PHOS")) ;
7a9d98f9 624 if ( !phosFolder ) {
f1611b7c 625 Fatal("SDigitsRef", "Folder //%s/PHOS not found !", fSDigitsFolder) ;
7a9d98f9 626 }
627
628 TFolder * phosSubFolder = 0 ;
407ae4df 629
630 phosSubFolder = dynamic_cast<TFolder *>(phosFolder->FindObject(foldername)) ;
7a9d98f9 631
632 if(!phosSubFolder) {
407ae4df 633 Fatal("SDigitsRef", "Folder //Folders/RunMC/Event/Data/PHOS/%s not found !", foldername) ;
7a9d98f9 634 }
b0bba0af 635
7a9d98f9 636 TObject * dis = phosSubFolder->FindObject(name) ;
59b46416 637 if(!dis){
f1611b7c 638 Fatal("SDigitsRef", "object %s not found !", name) ;
59b46416 639 }
f1611b7c 640
641 return phosSubFolder->GetListOfFolders()->GetObjectRef(dis) ;
b0bba0af 642
643}
644
645//____________________________________________________________________________
fbf811ec 646const Bool_t AliPHOSGetter::PostSDigitizer(AliPHOSSDigitizer * sdigitizer) const
0bc3b8ed 647{
648 //---------- SDigitizer -------------------------
7a9d98f9 649 // the hierarchy is //Folders/Tasks/SDigitizer/PHOS/sdigitsname
650
651
652 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("SDigitizer")) ;
653
654 if ( !sd ) {
21cd0c07 655 Error("PostDigitizer", "Task //%s/SDigitizer not found !", fTasksFolder) ;
b0bba0af 656 return kFALSE ;
657 }
7a9d98f9 658 TTask * phos = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("PHOS")) ;
b0bba0af 659 if ( !phos ) {
7a9d98f9 660 if (fDebug) {
21cd0c07 661 Warning("PostSDigitizer", "->//%s/SDigitizer/PHOS/ not found!", fTasksFolder) ;
662 Info("PostSDigitizer", "-> Adding //%s/SDigitizer/PHOS/", fTasksFolder) ;
7a9d98f9 663 }
664 phos = new TTask("PHOS", "") ;
665 sd->Add(phos) ;
b0bba0af 666 }
7a9d98f9 667 AliPHOSSDigitizer * phossd = dynamic_cast<AliPHOSSDigitizer *>(phos->GetListOfTasks()->FindObject( sdigitizer->GetName() ));
b0bba0af 668 if (phossd) {
669 if (fDebug)
21cd0c07 670 Info("PostSDigitizer", "-> Task %s already exists", sdigitizer->GetName()) ;
b0bba0af 671 phos->GetListOfTasks()->Remove(phossd) ;
672 }
673 phos->Add(sdigitizer) ;
674 return kTRUE;
675
676}
7a9d98f9 677
b0bba0af 678//____________________________________________________________________________
65c0665e 679TObject** AliPHOSGetter::SDigitizerRef(const char * name) const
b0bba0af 680{
0bc3b8ed 681 //---------- return task SDigitizer -------------------------
b0bba0af 682
7a9d98f9 683 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("SDigitizer")) ;
684 if ( !sd ) {
f1611b7c 685 Fatal("SDigitizerRef", "Task //%s/SDigitizer not found !", fTasksFolder) ;
7a9d98f9 686 }
4ae78bb1 687
7a9d98f9 688 TTask * phos = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("PHOS")) ;
689 if ( !phos ) {
f1611b7c 690 Fatal("SDigitizerRef", "//%s/SDigitizer/PHOS not found !", fTasksFolder) ;
7a9d98f9 691 }
b0bba0af 692
7a9d98f9 693 TTask * task = dynamic_cast<TTask*>(phos->GetListOfTasks()->FindObject(name)) ;
b0bba0af 694
65c0665e 695 return phos->GetListOfTasks()->GetObjectRef(task) ;
b0bba0af 696
697}
698
b0bba0af 699//____________________________________________________________________________
fbf811ec 700const Bool_t AliPHOSGetter::PostSDigitizer(const char * name, const char * file) const
0bc3b8ed 701{
702 //---------- SDigitizer -------------------------
703 // the hierarchy is //Folders/Tasks/SDigitizer/PHOS/sdigitsname
7a9d98f9 704
7a9d98f9 705 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("SDigitizer")) ;
706 if ( !sd ) {
21cd0c07 707 Error("PostSDigitizer", "Task //%s/SDigitizer not found !", fTasksFolder) ;
b0bba0af 708 return kFALSE ;
709 }
7a9d98f9 710
711 TTask * phos = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("PHOS")) ;
b0bba0af 712 if ( !phos ) {
7a9d98f9 713 if (fDebug) {
21cd0c07 714 Error("PostSDigitizer", "-> //%s/SDigitizer/PHOS/ not found!", fTasksFolder) ;
715 Info("PostSDigitizer", "-> Adding //%s/SDigitizer/PHOS", fTasksFolder) ;
7a9d98f9 716 }
717 phos = new TTask("PHOS", "") ;
718 sd->Add(phos) ;
b0bba0af 719 }
7a9d98f9 720
b0bba0af 721 TString sdname(name) ;
722 sdname.Append(":") ;
723 sdname.Append(file);
54b82aa4 724 sdname.ReplaceAll("/","_") ;
7a9d98f9 725 AliPHOSSDigitizer * phossd = dynamic_cast<AliPHOSSDigitizer *>(phos->GetListOfTasks()->FindObject( sdname ));
b0bba0af 726 if (!phossd) {
727 phossd = new AliPHOSSDigitizer() ;
85290134 728 //Note, we can not call constructor with parameters: it will call Getter and scew up everething
b0bba0af 729 phossd->SetName(sdname) ;
730 phossd->SetTitle(file) ;
731 phos->Add(phossd) ;
732 }
733 return kTRUE;
734
735}
548f0134 736
b0bba0af 737//____________________________________________________________________________
fbf811ec 738const Bool_t AliPHOSGetter::PostDigits(const char * name) const
b0bba0af 739{ //---------- Digits -------------------------
740
7a9d98f9 741 // the hierarchy is //Folders/Run/Event/Data/PHOS/SDigits/name
742
743 TFolder * phosFolder = dynamic_cast<TFolder*>(fDigitsFolder->FindObject("PHOS")) ;
744
745 if ( !phosFolder ) {
746 if (fDebug) {
21cd0c07 747 Warning("PostDigitizer", "-> Folder //%s/PHOS/ not found!", fDigitsFolder) ;
748 Info("PostDigitizer", "-> Adding Folder //%s/PHOS/", fDigitsFolder) ;
7a9d98f9 749 }
750 phosFolder = fDigitsFolder->AddFolder("PHOS", "Digits from PHOS") ;
b0bba0af 751 }
7a9d98f9 752
753 TObject* dig = phosFolder->FindObject( name ) ;
b0bba0af 754 if ( !dig ) {
755 TClonesArray * digits = new TClonesArray("AliPHOSDigit",1000) ;
756 digits->SetName(name) ;
7a9d98f9 757 phosFolder->Add(digits) ;
b0bba0af 758 }
759 return kTRUE;
760}
7a9d98f9 761
b0bba0af 762//____________________________________________________________________________
65c0665e 763TObject** AliPHOSGetter::DigitsRef(const char * name) const
0bc3b8ed 764{
765 //------- Digits ----------------------
766 // the hierarchy is //Folders/Run/Event/Data/PHOS/Digits/name
b0bba0af 767
7a9d98f9 768 if ( !fDigitsFolder ) {
f1611b7c 769 Fatal("DigitsRef", "Folder //%s not found !", fDigitsFolder) ;
7a9d98f9 770 }
b0bba0af 771
7a9d98f9 772 TFolder * phosFolder = dynamic_cast<TFolder*>(fDigitsFolder->FindObject("PHOS")) ;
773 if ( !phosFolder ) {
f1611b7c 774 Fatal("DigitsRef", "Folder //%s/PHOS/ not found !", fDigitsFolder) ;
b0bba0af 775 }
776
7a9d98f9 777 TObject * d = phosFolder->FindObject(name) ;
59b46416 778 if(!d) {
f1611b7c 779 Fatal("DigitsRef", "object %s not found !", name) ;
59b46416 780 }
f1611b7c 781
782 return phosFolder->GetListOfFolders()->GetObjectRef(d) ;
b0bba0af 783
784}
785
b0bba0af 786//____________________________________________________________________________
fbf811ec 787const Bool_t AliPHOSGetter::PostDigitizer(AliPHOSDigitizer * digitizer) const
0bc3b8ed 788{
789 //---------- Digitizer -------------------------
b0bba0af 790
7a9d98f9 791 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("Digitizer")) ;
792
793 if ( !sd ) {
21cd0c07 794 Error("PostDigitizer", "Task //%s/Digitizer not found !", fTasksFolder) ;
7a9d98f9 795 return kFALSE ;
b0bba0af 796 }
7a9d98f9 797 TTask * phos = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("PHOS")) ;
b0bba0af 798 if ( !phos ) {
7a9d98f9 799 if (fDebug) {
21cd0c07 800 Error("PostDigitizer", "//%s/Digitizer/PHOS not found!", fTasksFolder) ;
801 Info("PostDigitizer", "Adding //%s/Digitizer/PHOS", fTasksFolder) ;
7a9d98f9 802 }
803 phos = new TTask("PHOS", "") ;
804 sd->Add(phos) ;
805 }
806
807 AliPHOSDigitizer * phosd = dynamic_cast<AliPHOSDigitizer*>(phos->GetListOfTasks()->FindObject(digitizer->GetName())) ;
b0bba0af 808 if (phosd) {
809 phosd->Delete() ;
810 phos->GetListOfTasks()->Remove(phosd) ;
4ae78bb1 811 }
7a9d98f9 812 phos->Add(digitizer) ;
b0bba0af 813 return kTRUE;
7a9d98f9 814}
815
b0bba0af 816//____________________________________________________________________________
fbf811ec 817const Bool_t AliPHOSGetter::PostDigitizer(const char * name) const
0bc3b8ed 818{
819 //---------- Digitizer -------------------------
820 // the hierarchy is //Folders/Tasks/SDigitizer/PHOS/sdigitsname
7a9d98f9 821
822 TTask * d = dynamic_cast<TTask*>(fTasksFolder->FindObject("Digitizer")) ;
823 if ( !d ) {
21cd0c07 824 Error("PostDigitizer", "Task //%s/Digitizer not found !", fTasksFolder) ;
7a9d98f9 825 return kFALSE ;
b0bba0af 826 }
7a9d98f9 827
828 TTask * phos = dynamic_cast<TTask*>(d->GetListOfTasks()->FindObject("PHOS")) ;
b0bba0af 829 if ( !phos ) {
7a9d98f9 830 if (fDebug) {
21cd0c07 831 Warning("PostDigitizer", "//%s/Digitizer/PHOS not found!", fTasksFolder) ;
832 Info("PostDigitizer", "Adding //%s/Digitizer/PHOS", fTasksFolder) ;
7a9d98f9 833 }
834 phos = new TTask("PHOS", "") ;
835 d->Add(phos) ;
836}
b0bba0af 837
c2cd5471 838 TTask * phosd = dynamic_cast<TTask*>(phos->GetListOfTasks()->FindObject(fDigitsTitle)) ;
b0bba0af 839 if (!phosd) {
c2cd5471 840 if(strcmp(name, "Digitizer")==0){
841 phosd = new AliPHOSDigitizer() ;
842 phosd->SetName(fDigitsTitle) ;
843 phosd->SetTitle(fHeaderFile) ;
844 phos->Add(phosd) ;
845 }
846 else{
847 phosd = new AliPHOSRaw2Digits() ;
848 phosd->SetName(fDigitsTitle) ;
849 phosd->SetTitle(fHeaderFile) ;
850 phos->Add(phosd) ;
851 }
b0bba0af 852 }
853 return kTRUE;
854}
855
856//____________________________________________________________________________
65c0665e 857TObject** AliPHOSGetter::DigitizerRef(const char * name) const
b0bba0af 858{
0bc3b8ed 859 // -------------- Return Digitizer task ------------------------------------
7a9d98f9 860 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("Digitizer")) ;
861 if ( !sd ) {
f1611b7c 862 Fatal("DigitizerRef", "Task //%s/Digitizer not found !", fTasksFolder) ;
7a9d98f9 863 }
b0bba0af 864
7a9d98f9 865 TTask * phos = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("PHOS")) ;
866 if ( !phos ) {
f1611b7c 867 Fatal("DigitizerRef", "//%s/Digitizer/PHOS", fTasksFolder) ;
7a9d98f9 868 }
b0bba0af 869
7a9d98f9 870 TTask * task = dynamic_cast<TTask*>(phos->GetListOfTasks()->FindObject(name)) ;
b0bba0af 871
65c0665e 872 return phos->GetListOfTasks()->GetObjectRef(task) ;
b0bba0af 873
874}
875
876//____________________________________________________________________________
fbf811ec 877const Bool_t AliPHOSGetter::PostRecPoints(const char * name) const
b0bba0af 878{ // -------------- RecPoints -------------------------------------------
879
7a9d98f9 880 // the hierarchy is //Folders/Run/Event/RecData/PHOS/EMCARecPoints/name
881 // the hierarchy is //Folders/Run/Event/RecData/PHOS/CPVRecPoints/name
882
883 TFolder * phosFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("PHOS")) ;
b0bba0af 884
7a9d98f9 885 if ( !phosFolder ) {
886 if (fDebug) {
21cd0c07 887 Warning("PostRecPoints", "-> Folder //%s/PHOS/ not found!", fRecoFolder->GetName()) ;
888 Info("PostRecPoints", "-> Adding Folder //%s/PHOS/", fRecoFolder->GetName()) ;
7a9d98f9 889 }
890 phosFolder = fRecoFolder->AddFolder("PHOS", "Reconstructed data from PHOS") ;
891 }
b0bba0af 892
7a9d98f9 893 // EMCA RecPoints
894 TFolder * phosRPoEMCAFolder = dynamic_cast<TFolder*>(phosFolder->FindObject("EMCARecPoints")) ;
895 if ( !phosRPoEMCAFolder ) {
896 if (fDebug) {
21cd0c07 897 Warning("PostRecPoints", "-> Folder //%s/PHOS/EMCARecPoints/ not found!", fRecoFolder->GetName()) ;
898 Info("PostRecPoints", "-> Adding Folder //%s/PHOS/EMCARecPoints", fRecoFolder->GetName()) ;
7a9d98f9 899 }
900 phosRPoEMCAFolder = phosFolder->AddFolder("EMCARecPoints", "EMCA RecPoints from PHOS") ;
b0bba0af 901 }
7a9d98f9 902
903 TObject * erp = phosFolder->FindObject( name ) ;
b0bba0af 904 if ( !erp ) {
905 TObjArray * emcrp = new TObjArray(100) ;
906 emcrp->SetName(name) ;
7a9d98f9 907 phosRPoEMCAFolder->Add(emcrp) ;
b0bba0af 908 }
909
7a9d98f9 910 // CPV RecPoints
911 TFolder * phosRPoCPVFolder = dynamic_cast<TFolder*>(phosFolder->FindObject("CPVRecPoints")) ;
912 if ( !phosRPoCPVFolder ) {
913 if (fDebug) {
21cd0c07 914 Warning("PostRecPoints", "-> Folder //%s/PHOS/CPVRecPoints/ not found!", fRecoFolder->GetName()) ;
915 Info("PostRecPoints", "-> Adding Folder //%s/PHOS/CPVRecPoints/", fRecoFolder->GetName()) ;
7a9d98f9 916 }
917 phosRPoCPVFolder = phosFolder->AddFolder("CPVRecPoints", "CPV RecPoints from PHOS") ;
b0bba0af 918 }
7a9d98f9 919
920 TObject * crp = phosRPoCPVFolder->FindObject( name ) ;
b0bba0af 921 if ( !crp ) {
922 TObjArray * cpvrp = new TObjArray(100) ;
923 cpvrp->SetName(name) ;
7a9d98f9 924 phosRPoCPVFolder->Add(cpvrp) ;
b0bba0af 925 }
926 return kTRUE;
927}
928
929//____________________________________________________________________________
65c0665e 930TObject** AliPHOSGetter::EmcRecPointsRef(const char * name) const
b0bba0af 931{ // -------------- RecPoints -------------------------------------------
932
7a9d98f9 933 // the hierarchy is //Folders/Run/Event/RecData/PHOS/EMCARecPoints/name
b0bba0af 934
7a9d98f9 935 if ( !fRecoFolder ) {
f1611b7c 936 Fatal("EmcRecPointsRef", "Folder //%s not found !", fRecoFolder->GetName() ) ;
b0bba0af 937 }
938
7a9d98f9 939 TFolder * phosFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("PHOS/EMCARecPoints")) ;
940 if ( !phosFolder ) {
f1611b7c 941 Fatal("EmcRecPointsRef", "Folder //%s/PHOS/EMCARecPoints/ not found !", fRecoFolder->GetName() ) ;
7a9d98f9 942 }
943
944
945 TObject * erp = phosFolder->FindObject(name ) ;
b0bba0af 946 if ( !erp ) {
f1611b7c 947 Fatal("EmcRecPointsRef", "object %s not found !", name) ;
b0bba0af 948 }
65c0665e 949 return phosFolder->GetListOfFolders()->GetObjectRef(erp) ;
59b46416 950
b0bba0af 951}
7a9d98f9 952
b0bba0af 953//____________________________________________________________________________
65c0665e 954TObject** AliPHOSGetter::CpvRecPointsRef(const char * name) const
b0bba0af 955{ // -------------- RecPoints -------------------------------------------
956
7a9d98f9 957 // the hierarchy is //Folders/Run/Event/RecData/PHOS/CPVRecPoints/name
b0bba0af 958
7a9d98f9 959 if ( !fRecoFolder ) {
f1611b7c 960 Fatal("CpvRecPointsRef", "Folder //%s not found !", fRecoFolder->GetName() ) ;
b0bba0af 961 }
7a9d98f9 962
963 TFolder * phosFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("PHOS/CPVRecPoints")) ;
964 if ( !phosFolder ) {
f1611b7c 965 Fatal("CpvRecPointsRef", "Folder //%s/PHOS/CPVRecPoints/ not found !", fRecoFolder->GetName() ) ;
7a9d98f9 966 }
967
968 TObject * crp = phosFolder->FindObject(name ) ;
b0bba0af 969 if ( !crp ) {
f1611b7c 970 Fatal("CpvRecPointsRef", "object %s nott found", name ) ;
b0bba0af 971 }
65c0665e 972 return phosFolder->GetListOfFolders()->GetObjectRef(crp) ;
59b46416 973
b0bba0af 974}
975
976//____________________________________________________________________________
fbf811ec 977const Bool_t AliPHOSGetter::PostClusterizer(AliPHOSClusterizer * clu) const
b0bba0af 978{ // ------------------ AliPHOSClusterizer ------------------------
979
7a9d98f9 980 // the hierarchy is //Folders/Tasks/Reconstructioner/PHOS/sdigitsname
981
982 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
983
984 if ( !tasks ) {
21cd0c07 985 Error("PostClusterizer", "Task //%s/Reconstructioner not found !", fTasksFolder) ;
7a9d98f9 986 return kFALSE ;
987 }
988
989 TTask * phos = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
b0bba0af 990 if ( !phos ) {
7a9d98f9 991 if (fDebug) {
21cd0c07 992 Warning("PostClusterizer", "//%s/Reconstructioner/PHOS not found!", fTasksFolder) ;
993 Info("PostClusterizer", "Adding //%s/Reconstructioner/PHOS", fTasksFolder) ;
4ae78bb1 994 }
7a9d98f9 995 phos = new TTask("PHOS", "") ;
996 tasks->Add(phos) ;
b0bba0af 997 }
7a9d98f9 998
999 AliPHOSClusterizer * phoscl = dynamic_cast<AliPHOSClusterizer*>(phos->GetListOfTasks()->FindObject(clu->GetName())) ;
1000 if (phoscl) {
1001 if (fDebug)
21cd0c07 1002 Info("PostClusterizer", "Task %s already exists", clu->GetName()) ;
7a9d98f9 1003 phoscl->Delete() ;
1004 phos->GetListOfTasks()->Remove(phoscl) ;
1005 }
1006 phos->Add(clu) ;
1007 return kTRUE;
1008}
b0bba0af 1009
1010//____________________________________________________________________________
65c0665e 1011TObject** AliPHOSGetter::ClusterizerRef(const char * name) const
0bc3b8ed 1012{
1013 // ------------------ AliPHOSClusterizer ------------------------
4ae78bb1 1014
7a9d98f9 1015 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
1016
1017 if ( !tasks ) {
f1611b7c 1018 Fatal("ClusterizerRef", "Task //%s/Reconstructioner not found !", fTasksFolder->GetName() ) ;
7a9d98f9 1019 }
1020
1021 TTask * phos = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
b0bba0af 1022 if ( !phos ) {
f1611b7c 1023 Fatal("ClusterizerRef", " //%s/Reconstructioner/PHOS not founf !", fTasksFolder->GetName() ) ;
7a9d98f9 1024 }
1025
b0bba0af 1026 TList * l = phos->GetListOfTasks() ;
1027 TIter it(l) ;
1028 TTask * task ;
1029 TTask * clu = 0 ;
1030 TString cluname(name) ;
bb460cf0 1031 cluname+=":clu" ;
7a9d98f9 1032 while((task = static_cast<TTask *>(it.Next()) )){
b0bba0af 1033 TString taskname(task->GetName()) ;
1034 if(taskname.BeginsWith(cluname)){
1035 clu = task ;
1036 break ;
4ae78bb1 1037 }
b0bba0af 1038 }
1039
f1611b7c 1040 if(!clu) {
1041 Fatal("ClusterizerRef", "Task //%s/Reconstructioner/clusterizer/%s not found", fTasksFolder->GetName(), name) ;
479975d9 1042 }
f1611b7c 1043
1044 return l->GetObjectRef(clu) ;
1045
b0bba0af 1046}
1047
1048//____________________________________________________________________________
fbf811ec 1049const Bool_t AliPHOSGetter::PostClusterizer(const char * name) const
b0bba0af 1050{ // ------------------ AliPHOSClusterizer ------------------------
7a9d98f9 1051
1052 // the hierarchy is //Folders/Tasks/Reconstructioner/PHOS/sdigitsname
b0bba0af 1053
7a9d98f9 1054 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
1055
1056 if ( !tasks ) {
21cd0c07 1057 Error("PostClusterizer", "Task//%s/Reconstructioner not found !", fTasksFolder) ;
7a9d98f9 1058 return kFALSE ;
1059 }
b0bba0af 1060
7a9d98f9 1061 TTask * phos = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
b0bba0af 1062 if ( !phos ) {
7a9d98f9 1063 if (fDebug) {
21cd0c07 1064 Warning("PostClusterizer", "//%s/Reconstructioner/PHOS not found!", fTasksFolder) ;
1065 Info("PostClusterizer", "Adding //%s/Reconstructioner/PHOS", fTasksFolder) ;
7a9d98f9 1066 }
1067 phos = new TTask("PHOS", "") ;
1068 tasks->Add(phos) ;
b0bba0af 1069 }
7a9d98f9 1070
bb460cf0 1071 TList * l = phos->GetListOfTasks() ;
1072 TIter it(l) ;
b0bba0af 1073 TString clun(name) ;
bb460cf0 1074 clun+=":clu" ;
1075 TTask * task ;
1076 while((task = static_cast<TTask *>(it.Next()) )){
1077 TString taskname(task->GetName()) ;
1078 if(taskname.BeginsWith(clun))
1079 return kTRUE ;
1080 }
1081
1082 AliPHOSClusterizerv1 * phoscl = new AliPHOSClusterizerv1() ;
fbf811ec 1083 clun+="-v1" ;
1084 phoscl->SetName(clun) ;
1085 phoscl->SetTitle(fHeaderFile) ;
b0bba0af 1086 phos->Add(phoscl) ;
1087 return kTRUE;
1088
1089}
7a9d98f9 1090
b0bba0af 1091//____________________________________________________________________________
fbf811ec 1092const Bool_t AliPHOSGetter::PostTrackSegments(const char * name) const
b0bba0af 1093{ // ---------------TrackSegments -----------------------------------
1094
7a9d98f9 1095 // the hierarchy is //Folders/Run/Event/RecData/PHOS/TrackSegments/name
1096
1097 TFolder * phosFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("PHOS")) ;
1098
1099 if ( !phosFolder ) {
1100 if (fDebug) {
21cd0c07 1101 Warning("PostTrackSegments", "-> Folder //%s/PHOS/ not found", fRecoFolder->GetName()) ;
1102 Info("PostTrackSegments", "-> Adding Folder //%s/PHOS", fRecoFolder->GetName()) ;
7a9d98f9 1103 }
1104 phosFolder = fRecoFolder->AddFolder("PHOS", "Reconstructed data from PHOS") ;
1105 }
1106
1107 TFolder * phosTSFolder = dynamic_cast<TFolder*>(phosFolder->FindObject("TrackSegments")) ;
1108 if ( !phosTSFolder ) {
1109 if (fDebug) {
21cd0c07 1110 Warning("PostTrackSegments", "-> Folder //%s/PHOS/TrackSegments/ not found!", fRecoFolder->GetName() ) ;
1111 Info("PostTrackSegments", "-> Adding Folder //%s/PHOS/TrackSegments/", fRecoFolder->GetName()) ;
7a9d98f9 1112 }
1113 phosTSFolder = phosFolder->AddFolder("TrackSegments", "TrackSegments from PHOS") ;
b0bba0af 1114 }
7a9d98f9 1115
1116 TObject * tss = phosTSFolder->FindObject( name ) ;
b0bba0af 1117 if (!tss) {
1118 TClonesArray * ts = new TClonesArray("AliPHOSTrackSegment",100) ;
1119 ts->SetName(name) ;
7a9d98f9 1120 phosTSFolder->Add(ts) ;
b0bba0af 1121 }
1122 return kTRUE;
1123}
1124
1125//____________________________________________________________________________
65c0665e 1126TObject** AliPHOSGetter::TrackSegmentsRef(const char * name) const
b0bba0af 1127{ // ---------------TrackSegments -----------------------------------
1128
7a9d98f9 1129 // the hierarchy is //Folders/Run/Event/RecData/PHOS/TrackSegments/name
1130
1131 if ( !fRecoFolder ) {
f1611b7c 1132 Fatal("TrackSegmentsRef", "Folder //%s not found !", fRecoFolder->GetName() ) ;
b0bba0af 1133 }
7a9d98f9 1134
1135 TFolder * phosFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("PHOS/TrackSegments")) ;
1136 if ( !phosFolder ) {
f1611b7c 1137 Fatal("TrackSegmentsRef", "Folder //%s/PHOS/TrackSegments/ not found !", fRecoFolder->GetName() ) ;
7a9d98f9 1138 }
b0bba0af 1139
7a9d98f9 1140 TObject * tss = phosFolder->FindObject(name) ;
b0bba0af 1141 if (!tss) {
f1611b7c 1142 Fatal("TrackSegmentsRef", "object %s not found !", name) ;
b0bba0af 1143 }
65c0665e 1144 return phosFolder->GetListOfFolders()->GetObjectRef(tss) ;
b0bba0af 1145}
1146
1147//____________________________________________________________________________
fbf811ec 1148const Bool_t AliPHOSGetter::PostTrackSegmentMaker(AliPHOSTrackSegmentMaker * tsmaker) const
b0bba0af 1149{ //------------Track Segment Maker ------------------------------
1150
7a9d98f9 1151 // the hierarchy is //Folders/Tasks/Reconstructioner/PHOS/sdigitsname
1152
1153 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
1154
1155 if ( !tasks ) {
21cd0c07 1156 Error("PostTrackSegmentMaker", "Task //%s/Reconstructioner not found !", fTasksFolder) ;
7a9d98f9 1157 return kFALSE ;
b0bba0af 1158 }
7a9d98f9 1159
1160 TTask * phos = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
b0bba0af 1161 if ( !phos ) {
7a9d98f9 1162 if (fDebug) {
21cd0c07 1163 Warning("PostTrackSegmentMaker", "//%s/Reconstructioner/PHOS not found!", fTasksFolder) ;
1164 Info("PostTrackSegmentMaker", "Adding //%s/Reconstructioner/PHOS", fTasksFolder) ;
7a9d98f9 1165 }
1166 phos = new TTask("PHOS", "") ;
1167 tasks->Add(phos) ;
1168 }
1169
b0bba0af 1170 AliPHOSTrackSegmentMaker * phosts =
7a9d98f9 1171 dynamic_cast<AliPHOSTrackSegmentMaker*>(phos->GetListOfTasks()->FindObject(tsmaker->GetName())) ;
b0bba0af 1172 if (phosts) {
1173 phosts->Delete() ;
1174 phos->GetListOfTasks()->Remove(phosts) ;
1175 }
1176 phos->Add(tsmaker) ;
1177 return kTRUE;
1178
1179}
1180//____________________________________________________________________________
fbf811ec 1181const Bool_t AliPHOSGetter::PostTrackSegmentMaker(const char * name) const
0bc3b8ed 1182{
1183 //------------Track Segment Maker ------------------------------
7a9d98f9 1184 // the hierarchy is //Folders/Tasks/Reconstructioner/PHOS/sdigitsname
1185
7a9d98f9 1186 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
1187
1188 if ( !tasks ) {
21cd0c07 1189 Error("PostTrackSegmentMaker", "Task //%s/Reconstructioner not found !", fTasksFolder->GetName() ) ;
7a9d98f9 1190 return kFALSE ;
b0bba0af 1191 }
7a9d98f9 1192
1193 TTask * phos = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
b0bba0af 1194 if ( !phos ) {
7a9d98f9 1195 if (fDebug) {
21cd0c07 1196 Warning("PostTrackSegmentMaker", "//%s/Reconstructioner/PHOS not found!", fTasksFolder->GetName() ) ;
1197 Info("PostTrackSegmentMaker", "Adding //%s/Reconstructioner/PHOS", fTasksFolder->GetName()) ;
7a9d98f9 1198 }
1199 phos = new TTask("PHOS", "") ;
1200 tasks->Add(phos) ;
b0bba0af 1201 }
7a9d98f9 1202
bb460cf0 1203 TList * l = phos->GetListOfTasks() ;
1204 TIter it(l) ;
1205 TString tsn(name);
92f521a9 1206 tsn+=":tsm" ;
bb460cf0 1207 TTask * task ;
1208 while((task = static_cast<TTask *>(it.Next()) )){
1209 TString taskname(task->GetName()) ;
1210 if(taskname.BeginsWith(tsn))
1211 return kTRUE ;
b0bba0af 1212 }
bb460cf0 1213
1214 AliPHOSTrackSegmentMakerv1 * phosts = new AliPHOSTrackSegmentMakerv1() ;
fbf811ec 1215 tsn+="-v1" ;
bb460cf0 1216 phosts->SetName(tsn) ;
fbf811ec 1217 phosts->SetTitle(fHeaderFile) ;
bb460cf0 1218 phos->Add(phosts) ;
b0bba0af 1219 return kTRUE;
1220
1221}
7a9d98f9 1222
b0bba0af 1223//____________________________________________________________________________
65c0665e 1224TObject** AliPHOSGetter::TSMakerRef(const char * name) const
0bc3b8ed 1225{
1226 //------------Track Segment Maker ------------------------------
b0bba0af 1227
7a9d98f9 1228 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
1229
1230 if ( !tasks ) {
f1611b7c 1231 Fatal("TSMakerRef", "Task //%s/Reconstructioner not found !", fTasksFolder->GetName() ) ;
b0bba0af 1232 }
7a9d98f9 1233
1234 TTask * phos = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
1235 if ( !phos ) {
f1611b7c 1236 Fatal("TSMakerRef", "//%s/Reconstructioner/PHOS not found !", fTasksFolder->GetName() ) ;
7a9d98f9 1237 }
1238
b0bba0af 1239 TList * l = phos->GetListOfTasks() ;
1240 TIter it(l) ;
1241 TTask * task ;
1242 TTask * tsm = 0 ;
1243 TString tsmname(name) ;
bb460cf0 1244 tsmname+=":tsm" ;
7a9d98f9 1245 while((task = static_cast<TTask *>(it.Next()) )){
b0bba0af 1246 TString taskname(task->GetName()) ;
1247 if(taskname.BeginsWith(tsmname)){
1248 tsm = task ;
1249 break ;
4ae78bb1 1250 }
b0bba0af 1251 }
1252
f1611b7c 1253 if(!tsm) {
1254 Fatal("TSMakerRef", "Task //%s/Reconstructioner/PHOS/TrackSegmentMarker/%s not found !", fTasksFolder->GetName(), name) ;
1255 }
1256
1257 return l->GetObjectRef(tsm) ;
1258
b0bba0af 1259}
1260
1261//____________________________________________________________________________
fbf811ec 1262const Bool_t AliPHOSGetter::PostRecParticles(const char * name) const
b0bba0af 1263{ // -------------------- RecParticles ------------------------
1264
b134c32f 1265 // the hierarchy is //Folders/Run/Event/RecData/PHOS/RecParticles/name
7a9d98f9 1266
1267 TFolder * phosFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("PHOS")) ;
b0bba0af 1268
7a9d98f9 1269 if ( !phosFolder ) {
1270 if (fDebug) {
21cd0c07 1271 Warning("PostRecParticles", "-> Folder //%s/PHOS/ not found!", fRecoFolder->GetName()) ;
1272 Info("PostRecParticles", "-> Adding Folder //%s/PHOS/", fRecoFolder->GetName()) ;
7a9d98f9 1273 }
1274 phosFolder = fRecoFolder->AddFolder("PHOS", "Reconstructed data from PHOS") ;
b0bba0af 1275 }
7a9d98f9 1276
1277 TFolder * phosRPaFolder = dynamic_cast<TFolder*>(phosFolder->FindObject("RecParticles")) ;
1278 if ( !phosRPaFolder ) {
1279 if (fDebug) {
21cd0c07 1280 Warning("PostRecParticles", "-> Folder //%s/PHOS/RecParticles/ not found!", fRecoFolder->GetName()) ;
1281 Info("PostRecParticles", "-> Adding Folder //%s/PHOS/RecParticles/", fRecoFolder->GetName()) ;
7a9d98f9 1282 }
1283 phosRPaFolder = phosFolder->AddFolder("RecParticles", "RecParticles from PHOS") ;
1284 }
1285
1286 TObject * rps = phosRPaFolder->FindObject( name ) ;
b0bba0af 1287 if ( !rps ) {
1288 TClonesArray * rp = new TClonesArray("AliPHOSRecParticle",100) ;
1289 rp->SetName(name) ;
7a9d98f9 1290 phosRPaFolder->Add(rp) ;
b0bba0af 1291 }
1292 return kTRUE;
1293}
7a9d98f9 1294
b0bba0af 1295//____________________________________________________________________________
65c0665e 1296TObject** AliPHOSGetter::RecParticlesRef(const char * name) const
548f0134 1297{ // ---------------RecParticles -----------------------------------
b0bba0af 1298
7a9d98f9 1299 // the hierarchy is //Folders/Run/Event/RecData/PHOS/TrackSegments/name
1300
1301 if ( !fRecoFolder ) {
f1611b7c 1302 Fatal("RecParticlesRef", "Folder//%s not found !", fRecoFolder->GetName() ) ;
b0bba0af 1303 }
7a9d98f9 1304
1305 TFolder * phosFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("PHOS/RecParticles")) ;
1306 if ( !phosFolder ) {
f1611b7c 1307 Fatal("RecParticlesRef", "Folder //%s/PHOS/RecParticles/ not found !", fRecoFolder->GetName() ) ;
7a9d98f9 1308 }
1309
1310 TObject * tss = phosFolder->FindObject(name ) ;
b0bba0af 1311 if (!tss) {
f1611b7c 1312 Fatal("RecParticlesRef", "object %s not found !", name) ;
b0bba0af 1313 }
65c0665e 1314 return phosFolder->GetListOfFolders()->GetObjectRef(tss) ;
b0bba0af 1315}
7bb289a7 1316//____________________________________________________________________________
0bc3b8ed 1317const UShort_t AliPHOSGetter::EventPattern(void)
1318{
1319 // Return the pattern (trigger bit register) of the beam-test event
7bb289a7 1320 if(fBTE)
1321 return fBTE->GetPattern() ;
1322 else
1323 return 0 ;
1324}
1325//____________________________________________________________________________
0bc3b8ed 1326const Float_t AliPHOSGetter::BeamEnergy(void)
1327{
1328 // Return the beam energy of the beam-test event
7bb289a7 1329 if(fBTE)
1330 return fBTE->GetBeamEnergy() ;
1331 else
1332 return 0 ;
1333}
b0bba0af 1334//____________________________________________________________________________
fbf811ec 1335const Bool_t AliPHOSGetter::PostPID(AliPHOSPID * pid) const
0bc3b8ed 1336{
1337 // ------------AliPHOS PID -----------------------------
7a9d98f9 1338
1339 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
1340
1341 if ( !tasks ) {
21cd0c07 1342 Error("PostPID", "Task //%s/Reconstructioner not found !", fTasksFolder) ;
7a9d98f9 1343 return kFALSE ;
b0bba0af 1344 }
7a9d98f9 1345
1346 TTask * phos = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
b0bba0af 1347 if ( !phos ) {
7a9d98f9 1348 if (fDebug) {
21cd0c07 1349 Warning("PostPID", "//%s/Reconstructioner/PHOS not found!", fTasksFolder) ;
1350 Info("PostPID", "Adding //%s/Reconstructioner/PHOS", fTasksFolder) ;
7a9d98f9 1351 }
1352 phos = new TTask("PHOS", "") ;
1353 tasks->Add(phos) ;
4ae78bb1 1354 }
7a9d98f9 1355
1356 AliPHOSPID * phospid = dynamic_cast<AliPHOSPID*>(phos->GetListOfTasks()->FindObject(pid->GetName())) ;
b0bba0af 1357 if (phospid) {
1358 if (fDebug)
21cd0c07 1359 Info("PostPID", "-> Task %s qlready exists", pid->GetName()) ;
b0bba0af 1360 phos->GetListOfTasks()->Remove(phospid) ;
1361 }
1362
1363 phos->Add(pid) ;
1364 return kTRUE;
1365}
7a9d98f9 1366
b0bba0af 1367//____________________________________________________________________________
fbf811ec 1368const Bool_t AliPHOSGetter::PostPID(const char * name) const
b0bba0af 1369{
7a9d98f9 1370 // the hierarchy is //Folders/Tasks/Reconstructioner/PHOS/sdigitsname
1371
1372 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
1373
1374 if ( !tasks ) {
21cd0c07 1375 Error("PostPID", "Task //%s/Reconstructioner not found !", fTasksFolder->GetName() ) ;
7a9d98f9 1376 return kFALSE ;
b0bba0af 1377 }
7a9d98f9 1378
1379 TTask * phos = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
b0bba0af 1380 if ( !phos ) {
7a9d98f9 1381 if (fDebug) {
21cd0c07 1382 Warning("PostPID", "//%s/Reconstructioner/PHOS not found!", fTasksFolder->GetName()) ;
1383 Info("PostPID", "Adding //%s/Reconstructioner/PHOS", fTasksFolder->GetName()) ;
7a9d98f9 1384 }
1385 phos = new TTask("PHOS", "") ;
1386 tasks->Add(phos) ;
1387 }
4ae78bb1 1388
b0bba0af 1389 TList * l = phos->GetListOfTasks() ;
1390 TIter it(l) ;
1391 TString pidname(name) ;
92f521a9 1392 pidname+=":pid" ;
b0bba0af 1393 TTask * task ;
7a9d98f9 1394 while((task = static_cast<TTask *>(it.Next()) )){
b0bba0af 1395 TString taskname(task->GetName()) ;
1396 if(taskname.BeginsWith(pidname))
1397 return kTRUE ;
1398 }
1399
479975d9 1400 AliPHOSPIDv1 * phospid = new AliPHOSPIDv1() ;
fbf811ec 1401 pidname+="-v1" ;
79bf6a2f 1402 phospid->SetName(pidname) ;
fbf811ec 1403 phospid->SetTitle(fHeaderFile) ;
b0bba0af 1404 phos->Add(phospid) ;
1405
1406 return kTRUE;
1407}
7a9d98f9 1408
b0bba0af 1409//____________________________________________________________________________
65c0665e 1410TObject** AliPHOSGetter::PIDRef(const char * name) const
0bc3b8ed 1411{
1412 //------------PID ------------------------------
b0bba0af 1413
7a9d98f9 1414 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
1415
1416 if ( !tasks ) {
f1611b7c 1417 Fatal("PIDRef", "Task //%s/Reconstructioner not found !", fTasksFolder->GetName() ) ;
b0bba0af 1418 }
7a9d98f9 1419
1420 TTask * phos = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
1421 if ( !phos ) {
f1611b7c 1422 Fatal("PIDRef", "//%s/Reconstructioner/PHOS not found !", fTasksFolder->GetName() ) ;
7a9d98f9 1423 }
1424
b0bba0af 1425 TList * l = phos->GetListOfTasks() ;
1426 TIter it(l) ;
1427 TTask * task ;
1428 TTask * pid = 0 ;
1429 TString pidname(name) ;
479975d9 1430 pidname+=":pid" ;
7a9d98f9 1431 while((task = static_cast<TTask *>(it.Next()) )){
b0bba0af 1432 TString taskname(task->GetName()) ;
1433 if(taskname.BeginsWith(pidname)){
1434 pid = task ;
1435 break ;
1436 }
4ae78bb1 1437 }
b0bba0af 1438
f1611b7c 1439 if(!pid) {
1440 Fatal("PIDRef", "Task //%s/Reconstructioner/PHOS/PID/%s not found !", fTasksFolder->GetName(), name) ;
479975d9 1441 }
b0bba0af 1442
f1611b7c 1443 return l->GetObjectRef(pid) ;
b0bba0af 1444}
1445
1446//____________________________________________________________________________
fbf811ec 1447const Bool_t AliPHOSGetter::PostQA(void) const
7a9d98f9 1448{ // ------------------ QA ---------------------------------
1449
1450 // the hierarchy is //Folders/Run/Conditions/QA/PHOS/alarmsName
1451
1452 TFolder * phosFolder = dynamic_cast<TFolder*>(fQAFolder->FindObject("PHOS")) ;
1453 if ( !phosFolder ) {
1454 if (fDebug) {
21cd0c07 1455 Warning("PostQA", "-> Folder //%s/PHOS/ not found!", fQAFolder) ;
1456 Info("PostQA", "-> Adding Folder //%s/PHOS", fQAFolder) ;
7a9d98f9 1457 }
1458 phosFolder = fQAFolder->AddFolder("PHOS", "QA from PHOS") ;
1459 }
1460
b0bba0af 1461 return kTRUE;
4ae78bb1 1462}
1463
1464//____________________________________________________________________________
65c0665e 1465TObject** AliPHOSGetter::AlarmsRef(void) const
7a9d98f9 1466{ //------- Alarms ----------------------
1467
1468
1469 // the hierarchy is //Folders/Run/Conditions/QA/PHOS
1470 if ( !fQAFolder ) {
f1611b7c 1471 Fatal("AlarmsRef", "Folder //%s not found !", fQAFolder) ;
7a9d98f9 1472 }
1473
1474 TFolder * phosFolder = dynamic_cast<TFolder *>(fQAFolder->FindObject("PHOS")) ;
1475 if ( !phosFolder ) {
f1611b7c 1476 Fatal("AlarmsRef", "Folder //%s/PHOS/ not found !", fQAFolder) ;
7a9d98f9 1477 }
1478
65c0665e 1479 return fQAFolder->GetListOfFolders()->GetObjectRef(phosFolder) ;
7a9d98f9 1480}
1481
9bd3caba 1482
1483//____________________________________________________________________________
1484TTree * AliPHOSGetter::TreeK(TString filename)
1485{
1486
1487 // returns TreeK from file filename
1488 // usefull in case of split file
1489
1490 if ( filename.IsNull() )
1491 filename = fHeaderFile ;
1492
1493 TFile * file = 0 ;
464ba856 1494 file = static_cast<TFile*>(gROOT->GetFile(filename.Data() ) ) ;
7bb289a7 1495// if (file && (filename != fHeaderFile) ) { // file already open
1496// file->Close() ;
1497// //delete fAlice ;
1498// }
1499 if(!file || !file->IsOpen())
1500 file = TFile::Open(filename.Data(), "read") ;
1501 if(filename != fHeaderFile ){
1502 fAlice = dynamic_cast<AliRun *>(file->Get("gAlice")) ;
1503 }
9bd3caba 1504 TString treeName("TreeK") ;
1505 treeName += EventNumber() ;
7bb289a7 1506 TTree * tree = dynamic_cast<TTree *>(file->Get(treeName.Data())) ;
9bd3caba 1507 if (!tree && fDebug)
21cd0c07 1508 Warning("TreeK", "-> %s not found in %s", treeName.Data(), filename.Data()) ;
9bd3caba 1509
1510 return tree ;
1511}
1512
1513//____________________________________________________________________________
1514TTree * AliPHOSGetter::TreeH(TString filename)
1515{
1516
1517 // returns TreeH from file filename
1518 // usefull in case of split file
1519
1520 if ( filename.IsNull() )
1521 filename = fHeaderFile ;
1522
1523 TFile * file = 0 ;
1524 file = static_cast<TFile*>(gROOT->GetFile(filename.Data() ) ) ;
1525 if (!file) { // file not open yet
1526 file = TFile::Open(filename.Data(), "read") ;
1527 }
1528 TString treeName("TreeH") ;
1529 treeName += EventNumber() ;
1530 TTree * tree = static_cast<TTree *>(file->Get(treeName.Data())) ;
1531 if (!tree && fDebug)
21cd0c07 1532 Warning("TreeH", "-> %s not found in %s", treeName.Data(), filename.Data()) ;
9bd3caba 1533
1534 return tree ;
1535}
1536
1537//____________________________________________________________________________
1538TTree * AliPHOSGetter::TreeS(TString filename)
1539{
1540
1541 // returns TreeS from file filename
1542 // usefull in case of split file
1543
1544 if ( filename.IsNull() )
1545 filename = fHeaderFile ;
1546
1547 TFile * file = 0 ;
1548 file = static_cast<TFile*>(gROOT->GetFile(filename.Data() ) ) ;
1549 if (!file) { // file not open yet
1550 file = TFile::Open(filename.Data(), "read") ;
1551 }
1552 TString treeName("TreeS") ;
1553 treeName += EventNumber() ;
1554 TTree * tree = static_cast<TTree *>(file->Get(treeName.Data())) ;
1555 if (!tree && fDebug)
21cd0c07 1556 Warning("TreeS", "-> %s not found in %s", treeName.Data(), filename.Data() );
9bd3caba 1557
1558 return tree ;
1559}
1560
7a9d98f9 1561//____________________________________________________________________________
9bd3caba 1562TTree * AliPHOSGetter::TreeD(TString filename)
1563{
1564
1565 // returns TreeD from file filename
1566 // usefull in case of split file
1567
1568 if ( filename.IsNull() )
1569 filename = fHeaderFile ;
1570
1571 TFile * file = 0 ;
1572 file = static_cast<TFile*>(gROOT->GetFile(filename.Data() ) ) ;
1573 if (!file) { // file not open yet
1574 file = TFile::Open(filename.Data(), "read") ;
1575 }
1576 TString treeName("TreeD") ;
1577 treeName += EventNumber() ;
1578 TTree * tree = static_cast<TTree *>(file->Get(treeName.Data())) ;
1579 if (!tree && fDebug)
21cd0c07 1580 Warning("TreeD", "-> %s not found in %s", treeName.Data(), filename.Data()) ;
9bd3caba 1581
1582 return tree ;
1583}
1584
1585//____________________________________________________________________________
fbf811ec 1586const TParticle * AliPHOSGetter::Primary(Int_t index) const
4ae78bb1 1587{
1588 // Return primary particle numbered by <index>
1589
1590 if(index < 0)
1591 return 0 ;
9bd3caba 1592 TParticle * p = 0 ;
c2cd5471 1593 if (fAlice)
1594 p = fAlice->Particle(index) ;
1595 else
1596 p = gAlice->Particle(index) ;
9bd3caba 1597
cb34a1fa 1598 return p ;
9bd3caba 1599
4ae78bb1 1600}
1601
1602//____________________________________________________________________________
cb34a1fa 1603const TParticle * AliPHOSGetter::Secondary(TParticle* p, Int_t index) const
1604{
1605 // Return first (index=1) or second (index=2) secondary particle of primary particle p
1606
1607 if(index <= 0)
1608 return 0 ;
1609 if(index > 2)
1610 return 0 ;
1611
1612 if(p) {
1613 Int_t daughterIndex = p->GetDaughter(index-1) ;
1614 return gAlice->Particle(daughterIndex) ;
1615 }
1616 else
1617 return 0 ;
1618}
1619
1620//____________________________________________________________________________
fbf811ec 1621Int_t AliPHOSGetter::ReadTreeD(const Int_t event)
4ae78bb1 1622{
1623 // Read the digit tree gAlice->TreeD()
9bd3caba 1624
fbf811ec 1625 TTree * treeD ;
1626 if(fToSplit){
1627 TFile * file = static_cast<TFile*>(gROOT->GetFile(fDigitsFileName));
1628 if(!file)
1629 file = TFile::Open(fDigitsFileName) ;
1630 // Get Digits Tree header from file
1631 TString treeName("TreeD") ;
1632 treeName += event ;
1633 treeD = dynamic_cast<TTree*>(file->Get(treeName.Data()));
1634 if(!treeD){ // TreeD not found in header file
1635 if (fDebug)
21cd0c07 1636 Warning("ReadTreeD", "-> Cannot find TreeD in %s", fDigitsFileName.Data()) ;
fbf811ec 1637 return 1;
1638 }
1639 }
1640 else
1641 treeD = gAlice->TreeD() ;
1642
9bd3caba 1643 TObjArray * lob = static_cast<TObjArray*>(treeD->GetListOfBranches()) ;
4ae78bb1 1644 TIter next(lob) ;
1645 TBranch * branch = 0 ;
1646 TBranch * digitsbranch = 0 ;
1647 TBranch * digitizerbranch = 0 ;
1648 Bool_t phosfound = kFALSE, digitizerfound = kFALSE ;
1649
7a9d98f9 1650 while ( (branch = static_cast<TBranch*>(next())) && (!phosfound || !digitizerfound) ) {
4ae78bb1 1651 if ( (strcmp(branch->GetName(), "PHOS")==0) && (strcmp(branch->GetTitle(), fDigitsTitle)==0) ) {
1652 digitsbranch = branch ;
1653 phosfound = kTRUE ;
1654 }
c2cd5471 1655 else if ( ((strcmp(branch->GetName(), "AliPHOSDigitizer")==0)||
1656 (strcmp(branch->GetName(), "AliPHOSRaw2Digits")==0)) &&
1657 (strcmp(branch->GetTitle(), fDigitsTitle)==0) ) {
4ae78bb1 1658 digitizerbranch = branch ;
1659 digitizerfound = kTRUE ;
1660 }
1661 }
c2cd5471 1662
4ae78bb1 1663 if ( !phosfound || !digitizerfound ) {
7a9d98f9 1664 if (fDebug)
21cd0c07 1665 Warning("ReadTreeD", "-> Cannot find Digits and/or Digitizer with name %s", fDigitsTitle.Data()) ;
ab3ecbea 1666 return 2;
4ae78bb1 1667 }
c2cd5471 1668
b0bba0af 1669 //read digits
1670 if(!Digits(fDigitsTitle) )
1671 PostDigits(fDigitsTitle);
68f2b88a 1672 else
1673 Digits(fDigitsTitle)->Clear() ;
b0bba0af 1674 digitsbranch->SetAddress(DigitsRef(fDigitsTitle)) ;
1675 digitsbranch->GetEntry(0) ;
4ae78bb1 1676
b0bba0af 1677 // read the Digitizer
c2cd5471 1678 if(Digitizer()){
1679 if(strcmp(Digitizer()->IsA()->GetName(),digitizerbranch->GetName())!=0){
1680 RemoveTask("D", fDigitsTitle) ;
1681 if(strcmp(digitizerbranch->GetName(), "AliPHOSDigitizer")==0)
1682 PostDigitizer("Digitizer") ;
1683 else
1684 PostDigitizer("Raw2Digits") ;
1685 }
1686 }
1687 else{
1688 if(strcmp(digitizerbranch->GetName(), "AliPHOSDigitizer")==0)
1689 PostDigitizer("Digitizer") ;
1690 else
1691 PostDigitizer("Raw2Digits") ;
1692 }
1693
1694
92f521a9 1695 digitizerbranch->SetAddress(DigitizerRef(fDigitsTitle)) ;
1696 digitizerbranch->GetEntry(0) ;
c2cd5471 1697
1698
7bb289a7 1699// if((!fcdb)&&(strcmp(digitizerbranch->GetName(), "AliPHOSRaw2Digits")==0))
1700// ReadCalibrationDB("Primordial","beamtest.root") ;
1701
1702
fbf811ec 1703 if(gAlice->TreeD()!=treeD)
1704 treeD->Delete();
c2cd5471 1705
ab3ecbea 1706 return 0 ;
4ae78bb1 1707}
c2cd5471 1708//____________________________________________________________________________
7bb289a7 1709//void AliPHOSGetter::ReadCalibrationDB(const char * database,const char * filename){
1710//
1711// if(fcdb && (strcmp(database,fcdb->GetTitle())==0))
1712// return ;
1713//
1714// TFile * file = gROOT->GetFile(filename) ;
1715// if(!file)
1716// file = TFile::Open(filename);
1717// if(!file){
1718// Error ("ReadCalibrationDB", "Cannot open file %s", filename) ;
1719// return ;
1720// }
1721// if(fcdb)
1722// fcdb->Delete() ;
1723// fcdb = dynamic_cast<AliPHOSCalibrationDB *>(file->Get("AliPHOSCalibrationDB")) ;
1724// if(!fcdb)
1725// Error ("ReadCalibrationDB", "No database %s in file %s", database, filename) ;
1726//}
4ae78bb1 1727
1728//____________________________________________________________________________
ab3ecbea 1729Int_t AliPHOSGetter::ReadTreeH()
4ae78bb1 1730{
1731 // Read the first entry of PHOS branch in hit tree gAlice->TreeH()
9bd3caba 1732
1733 TTree * treeH = gAlice->TreeH() ;
4ae78bb1 1734
9bd3caba 1735 if(!treeH) {// TreeH not found in header file
1736
1737 if (fDebug)
21cd0c07 1738 Warning("ReadTreeH", "-> Cannot find TreeH in %s", fHeaderFile.Data() ) ;
9bd3caba 1739
fbf811ec 1740 TString searchFileName("PHOS.Hits") ;
1741 if((strcmp(fBranchTitle.Data(),"Default")!=0)&&(strcmp(fBranchTitle.Data(),"")!=0)){
1742 searchFileName+="." ;
1743 searchFileName += fBranchTitle ;
1744 }
1745 searchFileName+=".root" ;
9bd3caba 1746
464ba856 1747 if ( (treeH = TreeH(searchFileName)) ) { //found TreeH in the file which contains the hits
9bd3caba 1748 if (fDebug)
21cd0c07 1749 Info("ReadTreeH", "-> TreeH found in %s", searchFileName.Data()) ;
9bd3caba 1750
1751 } else {
21cd0c07 1752 Error("ReadTreeH", "TreeH not found") ;
9bd3caba 1753 return 1;
1754 }
4ae78bb1 1755 }
1756
9bd3caba 1757 TBranch * hitsbranch = static_cast<TBranch*>(treeH->GetBranch("PHOS")) ;
4ae78bb1 1758 if ( !hitsbranch ) {
7a9d98f9 1759 if (fDebug)
21cd0c07 1760 Warning("ReadTreeH", "-> Cannot find branch PHOS") ;
ab3ecbea 1761 return 2;
4ae78bb1 1762 }
b0bba0af 1763 if(!Hits())
1764 PostHits() ;
1765
65c0665e 1766 if (hitsbranch->GetEntries() > 1 ) {
fbf811ec 1767 (dynamic_cast<TClonesArray*> (*HitsRef()))->Clear() ;
65c0665e 1768 TClonesArray * tempo = new TClonesArray("AliPHOSHit",1000) ;
1769 TClonesArray * hits = dynamic_cast<TClonesArray*>(*HitsRef()) ;
1770 hitsbranch->SetAddress(&tempo) ;
1771 Int_t index = 0 ;
1772 Int_t i = 0 ;
1773 for (i = 0 ; i < hitsbranch->GetEntries() ; i++) {
1774 hitsbranch->GetEntry(i) ;
1775 Int_t j = 0 ;
1776 for ( j = 0 ; j < tempo->GetEntries() ; j++) {
1777 const AliPHOSHit * hit = static_cast<const AliPHOSHit *>(tempo->At(j)) ;
1778 new((*hits)[index]) AliPHOSHit( *hit ) ;
1779 index++ ;
1780 }
1781 }
1782 delete tempo ;
1783 }
1784 else {
fbf811ec 1785 (dynamic_cast<TClonesArray*> (*HitsRef()))->Clear() ;
65c0665e 1786 hitsbranch->SetAddress(HitsRef()) ;
1787 hitsbranch->GetEntry(0) ;
1788 }
ab3ecbea 1789 return 0 ;
4ae78bb1 1790}
1791
1792//____________________________________________________________________________
21cd0c07 1793void AliPHOSGetter::Track(const Int_t itrack)
b0bba0af 1794{
1795 // Read the first entry of PHOS branch in hit tree gAlice->TreeH()
1796
1797 if(gAlice->TreeH()== 0){
21cd0c07 1798 Error("Track", "Cannot read TreeH") ;
b0bba0af 1799 return ;
1800 }
1801
7a9d98f9 1802 TBranch * hitsbranch = dynamic_cast<TBranch*>(gAlice->TreeH()->GetListOfBranches()->FindObject("PHOS")) ;
b0bba0af 1803 if ( !hitsbranch ) {
7a9d98f9 1804 if (fDebug)
21cd0c07 1805 Warning("Track", "Cannot find branch PHOS") ;
b0bba0af 1806 return ;
1807 }
1808 if(!Hits())
1809 PostHits() ;
65c0665e 1810
fbf811ec 1811 (dynamic_cast<TClonesArray*> (*HitsRef()))->Clear() ;
b0bba0af 1812 hitsbranch->SetAddress(HitsRef()) ;
1813 hitsbranch->GetEntry(itrack) ;
1814
b0bba0af 1815}
548f0134 1816
b0bba0af 1817//____________________________________________________________________________
4ae78bb1 1818void AliPHOSGetter::ReadTreeQA()
1819{
1820 // Read the digit tree gAlice->TreeQA()
1821 // so far only PHOS knows about this Tree
1822
1823 if(PHOS()->TreeQA()== 0){
21cd0c07 1824 Error("ReadTreeQA", "Cannot read TreeQA") ;
4ae78bb1 1825 return ;
1826 }
1827
1828 TBranch * qabranch = PHOS()->TreeQA()->GetBranch("PHOS") ;
1829 if (!qabranch) {
7a9d98f9 1830 if (fDebug)
21cd0c07 1831 Warning("ReadTreeQA", "Cannot find QA Alarms for PHOS");
4ae78bb1 1832 return ;
1833 }
b0bba0af 1834
7a9d98f9 1835 if(!Alarms())
1836 PostQA() ;
1837
1838 qabranch->SetAddress(AlarmsRef()) ;
1839
4ae78bb1 1840 qabranch->GetEntry(0) ;
7a9d98f9 1841
1842// PostQA("PHOS") ;
1843// TFolder * alarmsF = Alarms() ;
1844// alarmsF->Clear() ;
1845// qabranch->SetAddress(&alarmsF) ;
1846// qabranch->GetEntry(0) ;
4ae78bb1 1847
1848}
1849
1850//____________________________________________________________________________
fbf811ec 1851Int_t AliPHOSGetter::ReadTreeR(const Int_t event)
4ae78bb1 1852{
1853 // Read the reconstrunction tree gAlice->TreeR()
5bf7ace9 1854 // A particularity has been introduced here :
1855 // if gime->Event(ievent,"R") is called branches with the current title are read, the current title
1856 // being for example give in AliPHOSPID(fileName, title)
1857 // if gime(Event(ievent, "RA") is called the title of the branches is not checked anymore, "A" stands for any
1858 // This is a feature needed by PID to be able to reconstruct several times particles (each time a ther title is given)
1859 // from a given set of TrackSegments (with a given name)
1860 // This is why any is NOT used to read the branch of RecParticles
59b46416 1861 // any migh have become obsolete : to be checked
479975d9 1862 // See AliPHOSPIDv1
4ae78bb1 1863
68f2b88a 1864 //first - clean if necessary
1865 if(EmcRecPoints(fRecPointsTitle)){
1866 EmcRecPoints(fRecPointsTitle)->Delete() ;
1867 CpvRecPoints(fRecPointsTitle)->Delete() ;
1868 }
1869 //clear TrackSegments
1870 if(TrackSegments(fTrackSegmentsTitle))
1871 TrackSegments(fTrackSegmentsTitle)->Clear() ;
1872 if(RecParticles(fRecParticlesTitle))
1873 RecParticles(fRecParticlesTitle)->Clear() ;
1874
fbf811ec 1875 TTree * treeR ;
1876 if(fToSplit){
1877 TFile * file = static_cast<TFile*>(gROOT->GetFile(fRecPointsFileName));
1878 if(!file)
1879 file = TFile::Open(fRecPointsFileName) ;
1880 // Get Digits Tree header from file
1881 TString treeName("TreeR") ;
1882 treeName += event ;
1883 treeR = dynamic_cast<TTree*>(file->Get(treeName.Data()));
1884 if(!treeR){ // TreeR not found in header file
1885 if (fDebug)
21cd0c07 1886 Warning("ReadTreeD", "-> Cannot find TreeR in %s", fRecPointsFileName.Data()) ;
fbf811ec 1887 return 1;
1888 }
4ae78bb1 1889 }
fbf811ec 1890 else
1891 treeR = gAlice->TreeR() ;
1892
4ae78bb1 1893 // RecPoints
fbf811ec 1894 TObjArray * lob = static_cast<TObjArray*>(treeR->GetListOfBranches()) ;
4ae78bb1 1895 TIter next(lob) ;
1896 TBranch * branch = 0 ;
1897 TBranch * emcbranch = 0 ;
1898 TBranch * cpvbranch = 0 ;
1899 TBranch * clusterizerbranch = 0 ;
1900 Bool_t phosemcrpfound = kFALSE, phoscpvrpfound = kFALSE, clusterizerfound = kFALSE ;
59b46416 1901
4ae78bb1 1902
fbf811ec 1903 while ( (branch = static_cast<TBranch*>(next())) && (!phosemcrpfound || !phoscpvrpfound || !clusterizerfound) ) {
1904 if(strcmp(branch->GetTitle(), fRecPointsTitle)==0 ) {
b0bba0af 1905 if ( strcmp(branch->GetName(), "PHOSEmcRP")==0) {
1906 emcbranch = branch ;
1907 phosemcrpfound = kTRUE ;
1908 }
1909 else if ( strcmp(branch->GetName(), "PHOSCpvRP")==0) {
1910 cpvbranch = branch ;
1911 phoscpvrpfound = kTRUE ;
1912 }
1913 else if(strcmp(branch->GetName(), "AliPHOSClusterizer")==0){
1914 clusterizerbranch = branch ;
1915 clusterizerfound = kTRUE ;
1916 }
4ae78bb1 1917 }
fbf811ec 1918 }
4ae78bb1 1919
d5b79ad7 1920 if ( !phosemcrpfound || !phoscpvrpfound || !clusterizerfound) {
7a9d98f9 1921 if (fDebug)
21cd0c07 1922 Warning("ReadTreeR", "-> Cannot find RecPoints and/or Clusterizer with name %s", fRecPointsTitle.Data() ) ;
bb460cf0 1923
6ad0e528 1924 } else {
1925 if(!EmcRecPoints(fRecPointsTitle) )
1926 PostRecPoints(fRecPointsTitle) ;
1927 emcbranch->SetAddress(EmcRecPointsRef(fRecPointsTitle)) ;
1928 emcbranch->GetEntry(0) ;
d5b79ad7 1929
6ad0e528 1930 cpvbranch->SetAddress(CpvRecPointsRef(fRecPointsTitle)) ;
d5b79ad7 1931 cpvbranch->GetEntry(0) ;
1932
fbf811ec 1933 if(!Clusterizer(fRecPointsTitle) )
6ad0e528 1934 PostClusterizer(fRecPointsTitle) ;
92f521a9 1935
1936 clusterizerbranch->SetAddress(ClusterizerRef(fRecPointsTitle)) ;
1937 clusterizerbranch->GetEntry(0) ;
6ad0e528 1938 }
b0bba0af 1939
1940 //------------------- TrackSegments ---------------------
4ae78bb1 1941 next.Reset() ;
1942 TBranch * tsbranch = 0 ;
1943 TBranch * tsmakerbranch = 0 ;
1944 Bool_t phostsfound = kFALSE, tsmakerfound = kFALSE ;
fbf811ec 1945 while ( (branch = static_cast<TBranch*>(next())) && (!phostsfound || !tsmakerfound) ) {
1946 if(strcmp(branch->GetTitle(), fTrackSegmentsTitle)==0 ) {
b0bba0af 1947 if ( strcmp(branch->GetName(), "PHOSTS")==0){
1948 tsbranch = branch ;
1949 phostsfound = kTRUE ;
1950 }
1951 else if(strcmp(branch->GetName(), "AliPHOSTrackSegmentMaker")==0) {
1952 tsmakerbranch = branch ;
1953 tsmakerfound = kTRUE ;
1954 }
4ae78bb1 1955 }
fbf811ec 1956 }
1957
4ae78bb1 1958 if ( !phostsfound || !tsmakerfound ) {
7a9d98f9 1959 if (fDebug)
21cd0c07 1960 Warning("ReadTreeR", "-> Cannot find TrackSegments and/or TrackSegmentMaker with name %s", fTrackSegmentsTitle.Data() ) ;
6ad0e528 1961 } else {
1962 // Read and Post the TrackSegments
1963 if(!TrackSegments(fTrackSegmentsTitle))
1964 PostTrackSegments(fTrackSegmentsTitle) ;
1965 tsbranch->SetAddress(TrackSegmentsRef(fTrackSegmentsTitle)) ;
1966 tsbranch->GetEntry(0) ;
fbf811ec 1967
6ad0e528 1968 // Read and Post the TrackSegment Maker
1969 if(!TrackSegmentMaker(fTrackSegmentsTitle))
1970 PostTrackSegmentMaker(fTrackSegmentsTitle) ;
92f521a9 1971 tsmakerbranch->SetAddress(TSMakerRef(fTrackSegmentsTitle)) ;
1972 tsmakerbranch->GetEntry(0) ;
bb460cf0 1973 }
b0bba0af 1974
1975
1976 //------------ RecParticles ----------------------------
4ae78bb1 1977 next.Reset() ;
1978 TBranch * rpabranch = 0 ;
1979 TBranch * pidbranch = 0 ;
1980 Bool_t phosrpafound = kFALSE, pidfound = kFALSE ;
1981
7a9d98f9 1982 while ( (branch = static_cast<TBranch*>(next())) && (!phosrpafound || !pidfound) )
b0bba0af 1983 if(strcmp(branch->GetTitle(), fRecParticlesTitle)==0) {
1984 if ( strcmp(branch->GetName(), "PHOSRP")==0) {
1985 rpabranch = branch ;
1986 phosrpafound = kTRUE ;
1987 }
1988 else if (strcmp(branch->GetName(), "AliPHOSPID")==0) {
1989 pidbranch = branch ;
1990 pidfound = kTRUE ;
1991 }
4ae78bb1 1992 }
b0bba0af 1993
4ae78bb1 1994 if ( !phosrpafound || !pidfound ) {
7a9d98f9 1995 if (fDebug)
21cd0c07 1996 Warning("ReadTreeR", "-> Cannot find RecParticles and/or PID with name %s", fRecParticlesTitle.Data() ) ;
6ad0e528 1997 } else {
1998 // Read and Post the RecParticles
1999 if(!RecParticles(fRecParticlesTitle))
2000 PostRecParticles(fRecParticlesTitle) ;
2001 rpabranch->SetAddress(RecParticlesRef(fRecParticlesTitle)) ;
2002 rpabranch->GetEntry(0) ;
2003 // Read and Post the PID
2004 if(!PID(fRecParticlesTitle))
2005 PostPID(fRecParticlesTitle) ;
92f521a9 2006 pidbranch->SetAddress(PIDRef(fRecParticlesTitle)) ;
2007 pidbranch->GetEntry(0) ;
6ad0e528 2008 }
fbf811ec 2009
548f0134 2010 if(gAlice->TreeR()!=treeR)
fbf811ec 2011 treeR->Delete();
ab3ecbea 2012 return 0 ;
4ae78bb1 2013}
2014
2015//____________________________________________________________________________
fbf811ec 2016Int_t AliPHOSGetter::ReadTreeS(const Int_t event)
4ae78bb1 2017{
fbf811ec 2018 // Reads the SDigits treeS from all files
2019 // Files, which should be opened are listed in phosF
2020 // So, first get list of files
7a9d98f9 2021 TFolder * phosF = dynamic_cast<TFolder *>(fSDigitsFolder->FindObject("PHOS")) ;
2022 if (!phosF)
2023 phosF = fSDigitsFolder->AddFolder("PHOS", "SDigits from PHOS") ;
b0bba0af 2024 TCollection * folderslist = phosF->GetListOfFolders() ;
2025
fbf811ec 2026 // Now iterate over the list of files and read TreeS into Whiteboard
b0bba0af 2027 TIter next(folderslist) ;
2028 TFolder * folder = 0 ;
2029 TFile * file;
2030 TTree * treeS = 0;
7a9d98f9 2031 while ( (folder = static_cast<TFolder*>(next())) ) {
fbf811ec 2032 TString fileName("") ;
407ae4df 2033 fileName = folder->GetName() ;
206ce9d6 2034 fileName.ReplaceAll("_","/") ;
fbf811ec 2035 file = static_cast<TFile*>(gROOT->GetFile(fileName));
2036 if(!file)
2037 file = TFile::Open(fileName) ;
2038 // Get SDigits Tree header from file
2039 TString treeName("TreeS") ;
2040 treeName += event ;
2041 treeS = dynamic_cast<TTree*>(file->Get(treeName.Data()));
9bd3caba 2042
fbf811ec 2043 if(!treeS){ // TreeS not found in header file
9bd3caba 2044 if (fDebug)
21cd0c07 2045 Warning("ReadTreeS", "-> Cannot find TreeS in %s", fileName.Data()) ;
ab3ecbea 2046 return 1;
b0bba0af 2047 }
2048
2049 //set address of the SDigits and SDigitizer
2050 TBranch * sdigitsBranch = 0;
2051 TBranch * sdigitizerBranch = 0;
2052 TBranch * branch = 0 ;
7a9d98f9 2053 TObjArray * lob = static_cast<TObjArray*>(treeS->GetListOfBranches()) ;
b0bba0af 2054 TIter next(lob) ;
2055 Bool_t phosfound = kFALSE, sdigitizerfound = kFALSE ;
fbf811ec 2056
7a9d98f9 2057 while ( (branch = static_cast<TBranch*>(next())) && (!phosfound || !sdigitizerfound) ) {
b0bba0af 2058 if ( (strcmp(branch->GetName(), "PHOS")==0) && (strcmp(branch->GetTitle(), fSDigitsTitle)==0) ) {
2059 phosfound = kTRUE ;
2060 sdigitsBranch = branch ;
2061 }
2062
fbf811ec 2063 else if ( (strcmp(branch->GetName(), "AliPHOSSDigitizer")==0) &&
2064 (strcmp(branch->GetTitle(), fSDigitsTitle)==0) ) {
b0bba0af 2065 sdigitizerfound = kTRUE ;
2066 sdigitizerBranch = branch ;
2067 }
2068 }
2069 if ( !phosfound || !sdigitizerfound ) {
7a9d98f9 2070 if (fDebug)
21cd0c07 2071 Warning("ReadSDigits", "-> Digits and/or Digitizer branch with name %s not found", GetName()) ;
ab3ecbea 2072 return 2;
b0bba0af 2073 }
2074
407ae4df 2075 if ( !folder->FindObject(fSDigitsTitle) ){
2076 TClonesArray * sdigits = new TClonesArray("AliPHOSDigit",1) ;
2077 sdigits->SetName(fSDigitsTitle) ;
2078 folder->Add(sdigits) ;
2079 }
65c0665e 2080
fbf811ec 2081 ((TClonesArray*) (*SDigitsRef(fSDigitsTitle,folder->GetName())))->Clear() ;
b0bba0af 2082 sdigitsBranch->SetAddress(SDigitsRef(fSDigitsTitle,folder->GetName())) ;
2083 sdigitsBranch->GetEntry(0) ;
2084
2085 TString sdname(fSDigitsTitle) ;
2086 sdname+=":" ;
2087 sdname+=folder->GetName() ;
2088 if(!SDigitizer(sdname) )
2089 PostSDigitizer(fSDigitsTitle,folder->GetName()) ;
92f521a9 2090 sdigitizerBranch->SetAddress(SDigitizerRef(sdname)) ;
2091 sdigitizerBranch->GetEntry(0) ;
fbf811ec 2092 if(gAlice->TreeS()!=treeS)
2093 treeS->Delete();
b0bba0af 2094 }
ab3ecbea 2095 return 0 ;
b0bba0af 2096}
548f0134 2097
b0bba0af 2098//____________________________________________________________________________
2099void AliPHOSGetter::ReadTreeS(TTree * treeS, Int_t input)
0bc3b8ed 2100{
2101 // Read the summable digits fron treeS()
7a9d98f9 2102
b0bba0af 2103 TString filename("mergefile") ;
2104 filename+= input ;
7a9d98f9 2105
2106 TFolder * phosFolder = dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("PHOS")) ;
2107 if ( !phosFolder ) {
2108 phosFolder = fSDigitsFolder->AddFolder("PHOS", "SDigits from PHOS") ;
2109 }
2110 TFolder * folder=(TFolder*)phosFolder->FindObject(filename) ;
b0bba0af 2111 //set address of the SDigits and SDigitizer
2112 TBranch * sdigitsBranch = 0;
2113 TBranch * sdigitizerBranch = 0;
2114 TBranch * branch = 0 ;
2115 TObjArray * lob = (TObjArray*)treeS->GetListOfBranches() ;
4ae78bb1 2116 TIter next(lob) ;
4ae78bb1 2117 Bool_t phosfound = kFALSE, sdigitizerfound = kFALSE ;
2118
2119 while ( (branch = (TBranch*)next()) && (!phosfound || !sdigitizerfound) ) {
b0bba0af 2120 if ( strcmp(branch->GetName(), "PHOS")==0) {
4ae78bb1 2121 phosfound = kTRUE ;
b0bba0af 2122 sdigitsBranch = branch ;
4ae78bb1 2123 }
b0bba0af 2124
2125 else if ( strcmp(branch->GetName(), "AliPHOSSDigitizer")==0) {
4ae78bb1 2126 sdigitizerfound = kTRUE ;
b0bba0af 2127 sdigitizerBranch = branch ;
4ae78bb1 2128 }
2129 }
4ae78bb1 2130 if ( !phosfound || !sdigitizerfound ) {
7a9d98f9 2131 if (fDebug)
21cd0c07 2132 Warning("ReadTreeS", "-> Digits and/or Digitizer branch not found") ;
4ae78bb1 2133 return ;
2134 }
4ae78bb1 2135
b0bba0af 2136 if (!folder || !(folder->FindObject(sdigitsBranch->GetTitle()) ) )
2137 PostSDigits(sdigitsBranch->GetTitle(),filename) ;
4ae78bb1 2138
407ae4df 2139 sdigitsBranch->SetAddress(SDigitsRef(sdigitsBranch->GetTitle(),folder->GetName())) ;
93aeb834 2140 sdigitsBranch->GetEntry(0) ;
b0bba0af 2141
2142 TString sdname(sdigitsBranch->GetTitle()) ;
2143 sdname+=":" ;
2144 sdname+=filename ;
46f77f3d 2145
b0bba0af 2146 if(!SDigitizer(sdigitsBranch->GetTitle()) )
2147 PostSDigitizer(sdigitsBranch->GetTitle(),filename) ;
92f521a9 2148 sdigitizerBranch->SetAddress(SDigitizerRef(sdname)) ;
2149 sdigitizerBranch->GetEntry(0) ;
fbf811ec 2150 if(gAlice->TreeS()!=treeS)
2151 treeS->Delete();
b0bba0af 2152}
4ae78bb1 2153
4ae78bb1 2154
2155//____________________________________________________________________________
2156void AliPHOSGetter::ReadPrimaries()
2157{
be28ada9 2158 // a lot simplified.... if 2 files are opened then we have a problem
cb34a1fa 2159
be28ada9 2160 TClonesArray * ar = 0 ;
cb34a1fa 2161 if(! (ar = Primaries()) ) {
2162 PostPrimaries() ;
2163 ar = Primaries() ;
2164 }
2165 ar->Delete() ;
4ae78bb1 2166
9bd3caba 2167 if (TreeK(fHeaderFile)) { // treeK found in header file
2168 if (fDebug)
21cd0c07 2169 Info("ReadPrimaries", "-> TreeK found in %s", fHeaderFile.Data() );
9bd3caba 2170 fNPrimaries = gAlice->GetNtrack() ;
c2cd5471 2171 fAlice = 0 ;
9bd3caba 2172
2173 } else { // treeK not found in header file
21cd0c07 2174 Error("ReadPrimaries", "TreeK not found") ;
7bb289a7 2175 return ;
9bd3caba 2176 }
7bb289a7 2177
cb34a1fa 2178 Int_t index = 0 ;
be28ada9 2179 for (index = 0 ; index < fNPrimaries; index++) {
2180 new ((*ar)[index]) TParticle(*(Primary(index)));
cb34a1fa 2181 }
4ae78bb1 2182}
9bd3caba 2183
4ae78bb1 2184//____________________________________________________________________________
fbf811ec 2185void AliPHOSGetter::Event(const Int_t event, const char* opt)
4ae78bb1 2186{
2187 // Reads the content of all Tree's S, D and R
548f0134 2188
7a9d98f9 2189 if (event >= gAlice->TreeE()->GetEntries() ) {
21cd0c07 2190 Error("Event", "%d not found in TreeE !", event) ;
7a9d98f9 2191 return ;
4ae78bb1 2192 }
5bf7ace9 2193
7bb289a7 2194 TBranch * btb = gAlice->TreeE()->GetBranch("AliPHOSBeamTestEvent") ;
2195 if(btb){
2196 if(!fBTE)
2197 fBTE = new AliPHOSBeamTestEvent() ;
2198 btb->SetAddress(&fBTE) ;
2199 btb->GetEntry(event) ;
2200 }
2201 else{
2202 if(fBTE){
2203 delete fBTE ;
2204 fBTE = 0 ;
2205 }
2206 }
2207
5bf7ace9 2208 Bool_t any = kFALSE ;
2209 if (strstr(opt,"A") ) // do not check the title of the branches
2210 any = kTRUE;
2211
cb34a1fa 2212 gAlice->GetEvent(event) ;
65c0665e 2213
9bd3caba 2214 if( strstr(opt,"R") )
fbf811ec 2215 ReadTreeR(event) ;
b0bba0af 2216
2217 if( strstr(opt,"D") )
fbf811ec 2218 ReadTreeD(event) ;
b0bba0af 2219
9bd3caba 2220 if(strstr(opt,"S") )
fbf811ec 2221 ReadTreeS(event) ;
b0bba0af 2222
9bd3caba 2223 if(strstr(opt,"H") )
fbf811ec 2224 ReadTreeH() ;
9bd3caba 2225
b0bba0af 2226 if( strstr(opt,"Q") )
2227 ReadTreeQA() ;
7bb289a7 2228
c2cd5471 2229 if( strstr(opt,"P") || (strcmp(opt,"")==0) )
9bd3caba 2230 ReadPrimaries() ;
7bb289a7 2231
2232
4ae78bb1 2233}
2234
2235//____________________________________________________________________________
cb34a1fa 2236TObject * AliPHOSGetter::ReturnO(TString what, TString name, TString file) const
4ae78bb1 2237{
2238 // get the object named "what" from the folder
7a9d98f9 2239 // folders are named like //Folders
4ae78bb1 2240
2241 if ( file.IsNull() )
2242 file = fHeaderFile ;
407ae4df 2243 if( name.IsNull() )
2244 name = fBranchTitle ;
7a9d98f9 2245
2246 TFolder * folder = 0 ;
2247 TObject * phosO = 0 ;
2248
cb34a1fa 2249 if ( what.CompareTo("Primaries") == 0 ) {
2250 folder = dynamic_cast<TFolder *>(fPrimariesFolder->FindObject("Primaries")) ;
2251 if (folder)
2252 phosO = dynamic_cast<TObject *>(folder->FindObject("Primaries")) ;
2a657981 2253 else
2254 return 0 ;
cb34a1fa 2255 }
2256 else if ( what.CompareTo("Hits") == 0 ) {
7a9d98f9 2257 folder = dynamic_cast<TFolder *>(fHitsFolder->FindObject("PHOS")) ;
2258 if (folder)
2259 phosO = dynamic_cast<TObject *>(folder->FindObject("Hits")) ;
2260 }
206ce9d6 2261 else if ( what.CompareTo("SDigits") == 0 ) {
407ae4df 2262 if(fToSplit){
2263 file.Remove(file.Last('/')+1,file.Length()-file.Last('/')-1) ;
2264 file.ReplaceAll("/","_") ;
2265 file+="PHOS.SDigits." ;
2266 if(name && (strcmp(name,"Default")!=0)){
2267 file+=name ;
2268 file+="." ;
2269 }
2270 file+="root" ;
2271 }
206ce9d6 2272 TString path = "PHOS/" + file ;
7a9d98f9 2273 folder = dynamic_cast<TFolder *>(fSDigitsFolder->FindObject(path.Data())) ;
2274 if (folder) {
2275 if (name.IsNull())
2276 name = fSDigitsTitle ;
2277 phosO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
4ae78bb1 2278 }
7a9d98f9 2279 }
2280 else if ( what.CompareTo("Digits") == 0 ){
2281 folder = dynamic_cast<TFolder *>(fDigitsFolder->FindObject("PHOS")) ;
2282 if (folder) {
2283 if (name.IsNull())
2284 name = fDigitsTitle ;
2285 phosO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
4ae78bb1 2286 }
7a9d98f9 2287 }
2288 else if ( what.CompareTo("EmcRecPoints") == 0 ) {
2289 folder = dynamic_cast<TFolder *>(fRecoFolder->FindObject("PHOS/EMCARecPoints")) ;
2290 if (folder) {
2291 if (name.IsNull())
2292 name = fRecPointsTitle ;
5bf7ace9 2293 phosO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
4ae78bb1 2294 }
7a9d98f9 2295 }
2296 else if ( what.CompareTo("CpvRecPoints") == 0 ) {
2297 folder = dynamic_cast<TFolder *>(fRecoFolder->FindObject("PHOS/CPVRecPoints")) ;
2298 if (folder) {
2299 if (name.IsNull())
2300 name = fRecPointsTitle ;
2301 phosO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
2302 }
2303 }
2304 else if ( what.CompareTo("TrackSegments") == 0 ) {
2305 folder = dynamic_cast<TFolder *>(fRecoFolder->FindObject("PHOS/TrackSegments")) ;
2306 if (folder) {
2307 if (name.IsNull())
2308 name = fTrackSegmentsTitle ;
2309 phosO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
2310 }
2311 }
2312 else if ( what.CompareTo("RecParticles") == 0 ) {
2313 folder = dynamic_cast<TFolder *>(fRecoFolder->FindObject("PHOS/RecParticles")) ;
2314 if (folder) {
2315 if (name.IsNull())
2316 name = fRecParticlesTitle ;
6ad0e528 2317 phosO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
7a9d98f9 2318 }
2319 }
2320 else if ( what.CompareTo("Alarms") == 0 ){
c4539e40 2321 phosO = dynamic_cast<TFolder *>(fQAFolder->FindObject("PHOS")) ;
4ae78bb1 2322 }
4ae78bb1 2323 if (!phosO) {
b0bba0af 2324 if(fDebug)
21cd0c07 2325 Warning("ReturnO", "Object %s not found in PHOS", what.Data() ) ;
b0bba0af 2326 return 0 ;
4ae78bb1 2327 }
cb34a1fa 2328
4ae78bb1 2329 return phosO ;
2330}
2331
2332//____________________________________________________________________________
2333const TTask * AliPHOSGetter::ReturnT(TString what, TString name) const
2334{
2335 // get the TTask named "what" from the folder
7a9d98f9 2336 // folders are named like //Folders/Tasks/what/PHOS/name
4ae78bb1 2337
7a9d98f9 2338 TString search(what) ;
2339 if ( what.CompareTo("Clusterizer") == 0 )
2340 search = "Reconstructioner" ;
4ae78bb1 2341 else if ( what.CompareTo("TrackSegmentMaker") == 0 )
7a9d98f9 2342 search = "Reconstructioner" ;
4ae78bb1 2343 else if ( what.CompareTo("PID") == 0 )
7a9d98f9 2344 search = "Reconstructioner" ;
eb9763ac 2345 else if ( what.CompareTo("QATasks") == 0 )
7a9d98f9 2346 search = "QA" ;
4ae78bb1 2347
7a9d98f9 2348 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject(search)) ;
4ae78bb1 2349
7a9d98f9 2350 if (!tasks) {
21cd0c07 2351 Error("ReturnT", "Task %s not found !", what.Data() ) ;
7a9d98f9 2352 return 0 ;
4ae78bb1 2353 }
2354
7a9d98f9 2355 TTask * phosT = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
4ae78bb1 2356 if (!phosT) {
21cd0c07 2357 Error("ReturnT", "Task %s/PHOS not found !", what.Data() ) ;
7a9d98f9 2358 return 0 ;
4ae78bb1 2359 }
7a9d98f9 2360
2361 TList * list = phosT->GetListOfTasks() ;
4ae78bb1 2362
2363 if (what.CompareTo("SDigitizer") == 0) {
2364 if ( name.IsNull() )
2365 name = fSDigitsTitle ;
2366 } else if (what.CompareTo("Digitizer") == 0){
2367 if ( name.IsNull() )
2368 name = fDigitsTitle ;
2369 } else if (what.CompareTo("Clusterizer") == 0){
2370 if ( name.IsNull() )
2371 name = fRecPointsTitle ;
92f521a9 2372 name.Append(":clu") ;
4ae78bb1 2373 }
2374 else if (what.CompareTo("TrackSegmentMaker") == 0){
2375 if ( name.IsNull() )
2376 name = fTrackSegmentsTitle ;
92f521a9 2377 name.Append(":tsm") ;
4ae78bb1 2378 }
2379 else if (what.CompareTo("PID") == 0){
2380 if ( name.IsNull() )
2381 name = fRecParticlesTitle ;
b0bba0af 2382 name.Append(":pid") ;
4ae78bb1 2383 }
b0bba0af 2384 else if (what.CompareTo("QATasks") == 0){
eb9763ac 2385 if ( name.IsNull() )
2386 return phosT ;
2387 }
4ae78bb1 2388
7a9d98f9 2389 TIter it(list) ;
b0bba0af 2390 TTask * task = 0 ;
7a9d98f9 2391 while((task = static_cast<TTask *>(it.Next()) )){
b0bba0af 2392 TString taskname(task->GetName()) ;
2393 if(taskname.BeginsWith(name))
2394 return task ;
2395 }
2396
2397 if(fDebug)
21cd0c07 2398 Warning("ReturnT", "-> Task %s/PHOS/%s not found", search.Data(), name.Data() ) ;
b0bba0af 2399 return 0 ;
4ae78bb1 2400}
65549808 2401
2402//____________________________________________________________________________
2403void AliPHOSGetter::RemoveTask(TString opt, TString name) const
2404{
2405 // remove a task from the folder
2406 // path is fTasksFolder/SDigitizer/PHOS/name
b134c32f 2407
65549808 2408 TTask * task = 0 ;
2409 TTask * phos = 0 ;
2410 TList * lofTasks = 0 ;
2411
b134c32f 2412 if (opt == "S") { // SDigitizer
65549808 2413 task = dynamic_cast<TTask*>(fTasksFolder->FindObject("SDigitizer")) ;
2414 if (!task)
2415 return ;
2416 }
b134c32f 2417 else if (opt == "D") { // Digitizer
65549808 2418 task = dynamic_cast<TTask*>(fTasksFolder->FindObject("Digitizer")) ;
2419 if (!task)
2420 return ;
2421 }
b134c32f 2422 else if (opt == "C" || opt == "T" || opt == "P" ) { // Clusterizer, TrackSegmentMaker, PID
2423 task = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
2424 if (!task)
2425 return ;
2426 }
65549808 2427 else {
21cd0c07 2428 Warning("RemoveTask", "Unknown option %s", opt.Data() );
65549808 2429 return ;
2430 }
2431 phos = dynamic_cast<TTask*>(task->GetListOfTasks()->FindObject("PHOS")) ;
2432 if (!phos)
2433 return ;
2434 lofTasks = phos->GetListOfTasks() ;
2435 if (!lofTasks)
2436 return ;
2437 TObject * obj = lofTasks->FindObject(name) ;
2438 if (obj)
2439 lofTasks->Remove(obj) ;
b134c32f 2440
65549808 2441}
2442
2443//____________________________________________________________________________
2444void AliPHOSGetter::RemoveObjects(TString opt, TString name) const
2445{
2446 // remove SDigits from the folder
2447 // path is fSDigitsFolder/fHeaderFileName/name
2448
2449 TFolder * phos = 0 ;
2450 TFolder * phosmain = 0 ;
2451
b134c32f 2452 if (opt == "H") { // Hits
65549808 2453 phos = dynamic_cast<TFolder*>(fHitsFolder->FindObject("PHOS")) ;
2454 if (!phos)
2455 return ;
2456 name = "Hits" ;
2457 }
2458
b134c32f 2459 else if ( opt == "S") { // SDigits
65549808 2460 phosmain = dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("PHOS")) ;
2461 if (!phosmain)
2462 return ;
2463 phos = dynamic_cast<TFolder*>(phosmain->FindObject(fHeaderFile)) ;
2464 if (!phos)
2465 return ;
2466 }
2467
b134c32f 2468 else if (opt == "D") { // Digits
65549808 2469 phos = dynamic_cast<TFolder*>(fDigitsFolder->FindObject("PHOS")) ;
2470 if (!phos)
2471 return ;
2472 }
b134c32f 2473
2474 else if (opt == "RE") { // EMCARecPoints
2475 phos = dynamic_cast<TFolder*>(fRecoFolder->FindObject("PHOS/EMCARecPoints")) ;
2476 if (!phos)
2477 return ;
2478 }
2479
2480 else if (opt == "RC") { // CPVRecPoints
2481 phos = dynamic_cast<TFolder*>(fRecoFolder->FindObject("PHOS/CPVRecPoints")) ;
2482 if (!phos)
2483 return ;
2484 }
2485
2486 else if (opt == "T") { // TrackSegments
2487 phos = dynamic_cast<TFolder*>(fRecoFolder->FindObject("PHOS/TrackSegments")) ;
2488 if (!phos)
2489 return ;
2490 }
2491
2492 else if (opt == "P") { // RecParticles
2493 phos = dynamic_cast<TFolder*>(fRecoFolder->FindObject("PHOS/RecParticles")) ;
2494 if (!phos)
2495 return ;
2496 }
2497
65549808 2498 else {
21cd0c07 2499 Warning("RemoveObjects", "Unknown option %s", opt.Data() ) ;
65549808 2500 return ;
2501 }
2502
2503 TObjArray * ar = dynamic_cast<TObjArray*>(phos->FindObject(name)) ;
2504 if (ar) {
2505 phos->Remove(ar) ;
2506 ar->Delete() ;
2507 delete ar ;
2508 }
2509
2510 if (opt == "S")
2511 phosmain->Remove(phos) ;
2512
2513}
2514
2515//____________________________________________________________________________
2516void AliPHOSGetter::RemoveSDigits() const
2517{
0bc3b8ed 2518 // Clean SDigit array
2519
65549808 2520 TFolder * phos= dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("PHOS")) ;
2521 if (!phos)
2522 return ;
2523
2524 phos->SetOwner() ;
2525 phos->Clear() ;
2526}
fbf811ec 2527
2528//____________________________________________________________________________
0bc3b8ed 2529void AliPHOSGetter::CleanWhiteBoard(void)
2530{
2531 // Delete all PHOS objects from folders
fbf811ec 2532
2533 TFolder * phosmain = 0 ;
2534 TFolder * phos ;
2535 TObjArray * ar ;
2536 TList * lofTasks = 0 ;
2537 TTask * task = 0 ;
2538 TTask * phost = 0 ;
2539
2540 // Hits
2541 phos = dynamic_cast<TFolder*>(fHitsFolder->FindObject("PHOS")) ;
2542 if (phos){
2543 TObjArray * ar = dynamic_cast<TObjArray*>(phos->FindObject("Hits")) ;
2544 if (ar) {
2545 phos->Remove(ar) ;
2546 ar->Delete() ;
2547 delete ar ;
2548 }
2549 }
2550
2551 // SDigits
2552 phosmain = dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("PHOS")) ;
2553 if (phosmain){
2554 phos = dynamic_cast<TFolder*>(phosmain->FindObject(fHeaderFile)) ;
2555 if (phos) {
2556 ar = dynamic_cast<TObjArray*>(phos->FindObject(fSDigitsTitle)) ;
2557 if (ar) {
2558 phos->Remove(ar) ;
2559 ar->Delete() ;
2560 delete ar ;
2561 }
2562 }
2563 phosmain->Remove(phos) ;
2564 }
2565
2566
2567 // Digits
2568 phos = dynamic_cast<TFolder*>(fDigitsFolder->FindObject("PHOS")) ;
2569 if (phos){
2570 ar = dynamic_cast<TObjArray*>(phos->FindObject(fDigitsTitle)) ;
2571 if (ar) {
2572 phos->Remove(ar) ;
2573 ar->Delete() ;
2574 delete ar ;
2575 }
2576 }
2577
2578
2579 // EMCARecPoints
2580 phos = dynamic_cast<TFolder*>(fRecoFolder->FindObject("PHOS/EMCARecPoints")) ;
2581 if (phos){
2582 ar = dynamic_cast<TObjArray*>(phos->FindObject(fRecPointsTitle)) ;
2583 if (ar) {
2584 phos->Remove(ar) ;
2585 ar->Delete() ;
2586 delete ar ;
2587 }
2588 }
2589
2590
2591 // CPVRecPoints
2592 phos = dynamic_cast<TFolder*>(fRecoFolder->FindObject("PHOS/CPVRecPoints")) ;
2593 if (phos){
2594 ar = dynamic_cast<TObjArray*>(phos->FindObject(fRecPointsTitle)) ;
2595 if (ar) {
2596 phos->Remove(ar) ;
2597 ar->Delete() ;
2598 delete ar ;
2599 }
2600 }
2601
2602
2603 // TrackSegments
2604 phos = dynamic_cast<TFolder*>(fRecoFolder->FindObject("PHOS/TrackSegments")) ;
2605 if (phos) {
2606 ar = dynamic_cast<TObjArray*>(phos->FindObject(fTrackSegmentsTitle)) ;
2607 if (ar) {
2608 phos->Remove(ar) ;
2609 ar->Delete() ;
2610 delete ar ;
2611 }
2612 }
2613
2614
2615
2616 // RecParticles
2617 phos = dynamic_cast<TFolder*>(fRecoFolder->FindObject("PHOS/RecParticles")) ;
2618 if (phos){
2619 ar = dynamic_cast<TObjArray*>(phos->FindObject(fRecParticlesTitle)) ;
2620 if (ar) {
2621 phos->Remove(ar) ;
2622 ar->Delete() ;
2623 delete ar ;
2624 }
2625 }
2626
2627
548f0134 2628 //---- Now Tasks -----------
fbf811ec 2629
2630 TObject * obj ;
2631 TString sdname(fSDigitsTitle);
2632
2633 // Digitizer
2634 task = dynamic_cast<TTask*>(fTasksFolder->FindObject("Digitizer")) ;
2635 if (task){
2636 phost = dynamic_cast<TTask*>(task->GetListOfTasks()->FindObject("PHOS")) ;
2637 if (phost){
2638 lofTasks = phost->GetListOfTasks() ;
2639 if (lofTasks){
2640 obj = lofTasks->FindObject(sdname.Data()) ;
2641 if (obj)
2642 lofTasks->Remove(obj) ;
2643 }
2644 }
2645 }
2646
2647
2648 sdname.Append(":") ;
2649 // Clusterizer, TrackSegmentMaker, PID
2650 task = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
2651 if (task){
2652 phost = dynamic_cast<TTask*>(task->GetListOfTasks()->FindObject("PHOS")) ;
2653 if (phost){
2654 lofTasks = phost->GetListOfTasks() ;
2655 TIter next(lofTasks);
2656 while((obj=next())){
2657 TString oname(obj->GetName()) ;
2658 if (oname.BeginsWith(sdname)){
2659 lofTasks->Remove(obj) ;
2660 }
2661 }
2662 }
2663 }
2664
2665
2666 // SDigitizer
2667 sdname.Append(fHeaderFile) ;
2668 task = dynamic_cast<TTask*>(fTasksFolder->FindObject("SDigitizer")) ;
2669 if (task) {
2670 phost = dynamic_cast<TTask*>(task->GetListOfTasks()->FindObject("PHOS")) ;
2671 if (phost){
2672 lofTasks = phost->GetListOfTasks() ;
2673 if (lofTasks){
2674 obj = lofTasks->FindObject(sdname.Data()) ;
2675 if (obj)
2676 lofTasks->Remove(obj) ;
2677 }
2678 }
2679 }
2680
2681}
2682//____________________________________________________________________________
2683void AliPHOSGetter::SetTitle(const char * branchTitle )
2684{
0bc3b8ed 2685 // Set branch titles and add folders with PHOS data
2686
fbf811ec 2687 fBranchTitle = branchTitle ;
2688 fSDigitsTitle = branchTitle ;
2689 fDigitsTitle = branchTitle ;
2690 fRecPointsTitle = branchTitle ;
2691 fRecParticlesTitle = branchTitle ;
2692 fTrackSegmentsTitle = branchTitle ;
2693 if(fToSplit){
2694 //First - extract full path if necessary
2695 TString sFileName(fHeaderFile) ;
2696 Ssiz_t islash = sFileName.Last('/') ;
2697 if(islash<sFileName.Length())
2698 sFileName.Remove(islash+1,sFileName.Length()) ;
2699 else
2700 sFileName="" ;
2701 //Now construct file names
2702 fSDigitsFileName = sFileName ;
2703 fDigitsFileName = sFileName ;
2704 fRecPointsFileName = sFileName ;
2705 fRecParticlesFileName = sFileName ;
2706 fTrackSegmentsFileName = sFileName ;
2707 fSDigitsFileName += "PHOS.SDigits." ;
2708 fDigitsFileName += "PHOS.Digits." ;
2709 fRecPointsFileName += "PHOS.RecData." ;
2710 fTrackSegmentsFileName+= "PHOS.RecData." ;
2711 fRecParticlesFileName += "PHOS.RecData." ;
2712 if((strcmp(fBranchTitle.Data(),"Default")!=0)&&(strcmp(fBranchTitle.Data(),"")!=0)){
2713 fSDigitsFileName += fBranchTitle ;
2714 fSDigitsFileName += "." ;
2715 fDigitsFileName += fBranchTitle ;
2716 fDigitsFileName += "." ;
2717 fRecPointsFileName += fBranchTitle ;
2718 fRecPointsFileName += "." ;
2719 fRecParticlesFileName += fBranchTitle ;
2720 fRecParticlesFileName += "." ;
2721 fTrackSegmentsFileName+= fBranchTitle ;
2722 fTrackSegmentsFileName+= "." ;
2723 }
2724 fSDigitsFileName += "root" ;
2725 fDigitsFileName += "root" ;
2726 fRecPointsFileName += "root" ;
2727 fRecParticlesFileName += "root" ;
2728 fTrackSegmentsFileName+= "root" ;
2729 }else{
407ae4df 2730 fSDigitsFileName = fHeaderFile ;
2731
fbf811ec 2732 fDigitsFileName = "" ;
2733 fRecPointsFileName = "" ;
2734 fRecParticlesFileName = "" ;
2735 fTrackSegmentsFileName = "" ;
2736 }
2737 TFolder * phosFolder ;
2738 phosFolder = dynamic_cast<TFolder*>(fHitsFolder->FindObject("PHOS")) ;
2739 if ( !phosFolder )
2740 phosFolder = fHitsFolder->AddFolder("PHOS", "Hits from PHOS") ;
2741
2742 phosFolder = dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("PHOS")) ;
2743 if ( !phosFolder )
2744 phosFolder = fSDigitsFolder->AddFolder("PHOS", "SDigits from PHOS") ;
fbf811ec 2745
407ae4df 2746 //Make folder for SDigits
2747 fSDigitsFileName.ReplaceAll("/","_") ;
2748 phosFolder->AddFolder(fSDigitsFileName.Data(),"");
fbf811ec 2749
2750 phosFolder = dynamic_cast<TFolder*>(fDigitsFolder->FindObject("PHOS")) ;
2751 if ( !phosFolder )
2752 phosFolder = fDigitsFolder->AddFolder("PHOS", "Digits from PHOS") ;
2753
2754 phosFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("PHOS")) ;
2755 if ( !phosFolder )
2756 phosFolder = fRecoFolder->AddFolder("PHOS", "Reconstructed data from PHOS") ;
2757
fbf811ec 2758}
2759//____________________________________________________________________________
0bc3b8ed 2760void AliPHOSGetter::CloseSplitFiles(void)
2761{
2762 // Close files opened in a split mode
fbf811ec 2763 TFile * file ;
2764 file = static_cast<TFile*>(gROOT->GetFile(fSDigitsFileName.Data() ) ) ;
2765 if(file)
2766 file->Close() ;
2767 file = static_cast<TFile*>(gROOT->GetFile(fDigitsFileName.Data() ) ) ;
2768 if(file)
2769 file->Close() ;
2770 file = static_cast<TFile*>(gROOT->GetFile(fRecPointsFileName.Data() ) ) ;
2771 if(file)
2772 file->Close() ;
2773 file = static_cast<TFile*>(gROOT->GetFile(fTrackSegmentsFileName.Data() ) ) ;
2774 if(file)
2775 file->Close() ;
2776 file = static_cast<TFile*>(gROOT->GetFile(fRecParticlesFileName.Data() ) ) ;
2777 if(file)
2778 file->Close() ;
2779
2780}