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