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