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