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