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