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