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