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