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