Correct log field
[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// ................
38// please->GetEvent(event) ; // reads new event from galice.root
39//
40//*-- Author: Yves Schutz (SUBATECH) & Dmitri Peressounko (RRC KI & SUBATECH)
41//*-- Completely redesigned by Dmitri Peressounko March 2001
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 ---
49
50#include "TFile.h"
51#include "TTree.h"
52#include "TROOT.h"
53#include "TObjString.h"
54#include "TFolder.h"
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"
67#include "AliPHOSClusterizer.h"
68#include "AliPHOSClusterizerv1.h"
69#include "AliPHOSTrackSegmentMaker.h"
70#include "AliPHOSTrackSegmentMakerv1.h"
71#include "AliPHOSTrackSegment.h"
72#include "AliPHOSPID.h"
73#include "AliPHOSPIDv1.h"
74#include "AliPHOSGeometry.h"
75
76ClassImp(AliPHOSGetter)
77
78 AliPHOSGetter * AliPHOSGetter::fgObjGetter = 0 ;
79
80//____________________________________________________________________________
81AliPHOSGetter::AliPHOSGetter(const char* headerFile, const char* branchTitle )
82{
83 //Initialize all lists
84
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
7a9d98f9 95 fModuleFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Run/Configuration/Modules"));
96 fHitsFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/RunMC/Event/Data/Hits"));
97 fSDigitsFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/RunMC/Event/Data/SDigits"));
98 fDigitsFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Run/Event/Data"));
99 fRecoFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Run/Event/RecData"));
100 fQAFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Run/Conditions/QA"));
101 fTasksFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Tasks")) ;
102
b0bba0af 103 if ( fHeaderFile != "aliroot" ) { // to call the getter without a file
518b8b75 104
eb9763ac 105 //open headers file
7a9d98f9 106 TFile * file = static_cast<TFile*>(gROOT->GetFile(fHeaderFile.Data() ) ) ;
4ae78bb1 107
eb9763ac 108 if(file == 0){ //if file was not opened yet, read gAlice
109 if(fHeaderFile.Contains("rfio")) // if we read file using HPSS
110 file = TFile::Open(fHeaderFile.Data(),"update") ;
111 else
112 file = new TFile(fHeaderFile.Data(),"update") ;
113
114 if (!file->IsOpen()) {
115 cerr << "ERROR : AliPHOSGetter::AliPHOSGetter -> Cannot open " << fHeaderFile.Data() << endl ;
116 abort() ;
117 }
118
7a9d98f9 119 gAlice = static_cast<AliRun *>(file->Get("gAlice")) ;
eb9763ac 120
121 if (!gAlice) {
122 cerr << "ERROR : AliPHOSGetter::AliPHOSGetter -> Cannot find gAlice in " << fHeaderFile.Data() << endl ;
123 abort() ;
124 }
7a9d98f9 125 if (!PHOS()) {
126 if (fDebug)
127 cout << "INFO: AliPHOSGetter -> Posting PHOS to Folders" << endl ;
128 AliConfig * conf = AliConfig::Instance() ;
129 conf->Add(static_cast<AliDetector*>(gAlice->GetDetector("PHOS"))) ;
130 conf->Add(static_cast<AliModule*>(gAlice->GetDetector("PHOS"))) ;
131 }
4ae78bb1 132 }
7a9d98f9 133
4ae78bb1 134 }
b0bba0af 135 fDebug=0;
4ae78bb1 136}
4ae78bb1 137//____________________________________________________________________________
81bb1a45 138AliPHOSGetter::~AliPHOSGetter(){
7a9d98f9 139
81bb1a45 140}
7a9d98f9 141
81bb1a45 142//____________________________________________________________________________
4ae78bb1 143void AliPHOSGetter::CreateWhiteBoard() const
144{
7a9d98f9 145
4ae78bb1 146}
147
148//____________________________________________________________________________
149AliPHOSGetter * AliPHOSGetter::GetInstance()
150{
151 // Returns the pointer of the unique instance already defined
152
153 AliPHOSGetter * rv = 0 ;
154 if ( fgObjGetter )
155 rv = fgObjGetter ;
156 else
157 cout << "AliPHOSGetter::GetInstance ERROR: not yet initialized" << endl ;
158
159 return rv ;
160}
161
162//____________________________________________________________________________
163AliPHOSGetter * AliPHOSGetter::GetInstance(const char* headerFile,
164 const char* branchTitle)
165{
166 // Creates and returns the pointer of the unique instance
167 // Must be called only when the environment has changed
168
b0bba0af 169 if ( fgObjGetter )
170 if((fgObjGetter->fBranchTitle.CompareTo(branchTitle) == 0) &&
171 (fgObjGetter->fHeaderFile.CompareTo(headerFile)==0))
172 return fgObjGetter ;
173 else
81bb1a45 174 fgObjGetter->~AliPHOSGetter() ; // delete it if already exists another version
b0bba0af 175
4ae78bb1 176 fgObjGetter = new AliPHOSGetter(headerFile,branchTitle) ;
177
178 // Posts a few item to the white board (folders)
7a9d98f9 179 // fgObjGetter->CreateWhiteBoard() ;
b0bba0af 180
4ae78bb1 181 return fgObjGetter ;
182
183}
184
185//____________________________________________________________________________
7a9d98f9 186const AliPHOS * AliPHOSGetter::PHOS()
4ae78bb1 187{
188 // returns the PHOS object
7a9d98f9 189 AliPHOS * phos = dynamic_cast<AliPHOS*>(fModuleFolder->FindObject("PHOS")) ;
190 if (!phos)
191 if (fDebug)
192 cout << "WARNING: AliPHOSGetter::PHOS -> PHOS module not found in Folders" << endl ;
193 return phos ;
4ae78bb1 194}
195
196//____________________________________________________________________________
7a9d98f9 197const AliPHOSGeometry * AliPHOSGetter::PHOSGeometry()
4ae78bb1 198{
7a9d98f9 199 AliPHOSGeometry * rv = 0 ;
200 if (PHOS() )
201 rv = PHOS()->GetGeometry() ;
202 return rv ;
203}
4ae78bb1 204
205//____________________________________________________________________________
b0bba0af 206Bool_t AliPHOSGetter::PostHits(void) const
207{ //------- Hits ----------------------
dbad285c 208
7a9d98f9 209 // the hierarchy is //Folders/RunMC/Event/Data/PHOS/Hits
b0bba0af 210
7a9d98f9 211 TFolder * phosFolder = dynamic_cast<TFolder*>(fHitsFolder->FindObject("PHOS")) ;
212 if ( !phosFolder ) {
213 if (fDebug) {
214 cout << "WARNING: AliPHOSGetter::Post H -> Folder //" << fHitsFolder << "/PHOS/ not found!" << endl;
215 cout << "INFO: AliPHOSGetter::Post H -> Adding Folder //" << fHitsFolder << "/PHOS/" << endl;
216 }
217 phosFolder = fHitsFolder->AddFolder("PHOS", "Hits from PHOS") ;
b0bba0af 218 }
7a9d98f9 219 TClonesArray *hits= new TClonesArray("AliPHOSHit",1000) ;
220 hits->SetName("Hits") ;
221 phosFolder->Add(hits) ;
222
b0bba0af 223 return kTRUE;
224}
7a9d98f9 225
b0bba0af 226//____________________________________________________________________________
7a9d98f9 227void * AliPHOSGetter::HitsRef(void) const
b0bba0af 228{ //------- Hits ----------------------
4ae78bb1 229
b0bba0af 230
7a9d98f9 231 // the hierarchy is //Folders/RunMC/Event/Data/PHOS/Hits
232 if ( !fHitsFolder ) {
233 cerr << "ERROR: AliPHOSGetter::Post H -> Folder //" << fHitsFolder << " not found!" << endl;
b0bba0af 234 return 0;
235 }
4ae78bb1 236
7a9d98f9 237 TFolder * phosFolder = dynamic_cast<TFolder *>(fHitsFolder->FindObject("PHOS")) ;
238 if ( !phosFolder ) {
239 cerr << "ERROR: AliPHOSGetter::Post HRef -> Folder //" << fHitsFolder << "/PHOS/ not found!" << endl;
240 return 0;
241 }
242
243 TObject * h = phosFolder->FindObject("Hits") ;
244 if(!h) {
245 cerr << "ERROR: AliPHOSGetter::HRef -> " << phosFolder->GetName() << "/Hits not found !" << endl ;
b0bba0af 246 return 0 ;
7a9d98f9 247 }
b0bba0af 248 else
7a9d98f9 249 return static_cast<void *>(phosFolder->GetListOfFolders()->GetObjectRef(h)) ;
b0bba0af 250}
7a9d98f9 251
b0bba0af 252//____________________________________________________________________________
253Bool_t AliPHOSGetter::PostSDigits(const char * name, const char * headerFile) const
254{ //---------- SDigits -------------------------
255
b0bba0af 256
7a9d98f9 257 // the hierarchy is //Folders/RunMC/Event/Data/PHOS/SDigits/headerFile/sdigitsname
b0bba0af 258 // because you can have sdigits from several hit files for mixing
7a9d98f9 259
260 TFolder * phosFolder = dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("PHOS")) ;
261 if ( !phosFolder ) {
262 if (fDebug) {
263 cout << "WARNING: AliPHOSGetter::Post S -> Folder //" << fSDigitsFolder << "/PHOS/ not found!" << endl;
264 cout << "INFO: AliPHOSGetter::Post S -> Adding Folder //" << fHitsFolder << "/PHOS/" << endl;
265 }
266 phosFolder = fSDigitsFolder->AddFolder("PHOS", "SDigits from PHOS") ;
267 }
b0bba0af 268 TString subdir(headerFile) ;
7a9d98f9 269 TFolder * phosSubFolder = dynamic_cast<TFolder*>(phosFolder->FindObject(subdir)) ;
270 if ( !phosSubFolder )
271 phosSubFolder = phosFolder->AddFolder(subdir, "");
272
273 TObject * sd = phosSubFolder->FindObject(name);
b0bba0af 274 if ( sd ) {
275 if (fDebug)
276 cerr <<"INFO: AliPHOSGetter::Post S -> Folder " << subdir
277 << " already exists!" << endl ;
278 }else{
4ae78bb1 279 TClonesArray * sdigits = new TClonesArray("AliPHOSDigit",1000) ;
b0bba0af 280 sdigits->SetName(name) ;
7a9d98f9 281 phosSubFolder->Add(sdigits) ;
b0bba0af 282 }
283
284 return kTRUE;
285}
286//____________________________________________________________________________
7a9d98f9 287void * AliPHOSGetter::SDigitsRef(const char * name, const char * file) const
288{ //------- SDigits ----------------------
b0bba0af 289
7a9d98f9 290 // the hierarchy is //Folders/RunMC/Event/Data/PHOS/SDigits/filename/SDigits
291
292 if ( !fSDigitsFolder ) {
293 cerr << "ERROR: AliPHOSGetter::Post SRef -> Folder //" << fSDigitsFolder << " not found!" << endl;
b0bba0af 294 return 0;
295 }
7a9d98f9 296
297 TFolder * phosFolder = dynamic_cast<TFolder *>(fSDigitsFolder->FindObject("PHOS")) ;
298 if ( !phosFolder ) {
299 cerr << "ERROR: AliPHOSGetter::Post SRef -> Folder //" << fSDigitsFolder << "/PHOS/ not found!" << endl;
300 return 0;
301 }
302
303 TFolder * phosSubFolder = 0 ;
b0bba0af 304 if(file)
7a9d98f9 305 phosSubFolder = dynamic_cast<TFolder *>(phosFolder->FindObject(file)) ;
b0bba0af 306 else
7a9d98f9 307 phosSubFolder = dynamic_cast<TFolder *>(phosFolder->FindObject(fHeaderFile)) ;
308
309 if(!phosSubFolder) {
310 cerr << "ERROR: AliPHOSGetter::Post SRef -> Folder //Folders/RunMC/Event/Data/PHOS/" << file << "not found!" << endl;
311 return 0;
312 }
b0bba0af 313
7a9d98f9 314 TObject * dis = phosSubFolder->FindObject(name) ;
b0bba0af 315 if(!dis)
316 return 0 ;
317 else
7a9d98f9 318 return static_cast<void *>(phosSubFolder->GetListOfFolders()->GetObjectRef(dis)) ;
b0bba0af 319
320}
321
322//____________________________________________________________________________
323Bool_t AliPHOSGetter::PostSDigitizer(AliPHOSSDigitizer * sdigitizer) const
324{ //---------- SDigitizer -------------------------
7a9d98f9 325
326 // the hierarchy is //Folders/Tasks/SDigitizer/PHOS/sdigitsname
327
328
329 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("SDigitizer")) ;
330
331 if ( !sd ) {
332 cerr << "ERROR: AliPHOSGetter::Post Ser -> Task //" << fTasksFolder << "/SDigitizer not found!" << endl;
b0bba0af 333 return kFALSE ;
334 }
7a9d98f9 335 TTask * phos = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("PHOS")) ;
b0bba0af 336 if ( !phos ) {
7a9d98f9 337 if (fDebug) {
338 cout <<"WARNING: AliPHOSGetter::Post Ser ->//" << fTasksFolder << "/SDigitizer/PHOS/ not found!" << endl;
339 cout <<"INFO: AliPHOSGetter::Post Ser -> Adding //" << fTasksFolder << "/SDigitizer/PHOS/" << endl;
340 }
341 phos = new TTask("PHOS", "") ;
342 sd->Add(phos) ;
b0bba0af 343 }
7a9d98f9 344 AliPHOSSDigitizer * phossd = dynamic_cast<AliPHOSSDigitizer *>(phos->GetListOfTasks()->FindObject( sdigitizer->GetName() ));
b0bba0af 345 if (phossd) {
346 if (fDebug)
347 cout << "INFO: AliPHOSGetter::Post Ser -> Task " << sdigitizer->GetName() << " already exists" << endl ;
348 phos->GetListOfTasks()->Remove(phossd) ;
349 }
350 phos->Add(sdigitizer) ;
351 return kTRUE;
352
353}
7a9d98f9 354
b0bba0af 355//____________________________________________________________________________
7a9d98f9 356void * AliPHOSGetter::SDigitizerRef(const char * name) const
b0bba0af 357{
358
7a9d98f9 359 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("SDigitizer")) ;
360 if ( !sd ) {
361 cerr << "ERROR: AliPHOSGetter::Post SerRef -> Task //" << fTasksFolder << "/SDigitizer not found!" << endl;
362 abort();
363 }
4ae78bb1 364
7a9d98f9 365 TTask * phos = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("PHOS")) ;
366 if ( !phos ) {
367 cerr <<"ERROR: AliPHOSGetter::Post SerRef -> //" << fTasksFolder << "/SDigitizer/PHOS not found!" << endl;
368 abort();
369 }
b0bba0af 370
7a9d98f9 371 TTask * task = dynamic_cast<TTask*>(phos->GetListOfTasks()->FindObject(name)) ;
b0bba0af 372
7a9d98f9 373 return static_cast<void *>(phos->GetListOfTasks()->GetObjectRef(task)) ;
b0bba0af 374
375}
376
b0bba0af 377//____________________________________________________________________________
378Bool_t AliPHOSGetter::PostSDigitizer(const char * name, const char * file) const
379{ //---------- SDigitizer -------------------------
380
7a9d98f9 381 // the hierarchy is //Folders/Tasks/SDigitizer/PHOS/sdigitsname
382
383
384 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("SDigitizer")) ;
385 if ( !sd ) {
386 cerr << "ERROR: AliPHOSGetter::Post Ser -> Task //" << fTasksFolder << "/SDigitizer not found!" << endl;
b0bba0af 387 return kFALSE ;
388 }
7a9d98f9 389
390 TTask * phos = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("PHOS")) ;
b0bba0af 391 if ( !phos ) {
7a9d98f9 392 if (fDebug) {
393 cout <<"WARNING: AliPHOSGetter::Post Ser -> //" << fTasksFolder << "/SDigitizer/PHOS/ not found!" << endl;
394 cout <<"INFO: AliPHOSGetter::Post Ser -> Adding //" << fTasksFolder << "/SDigitizer/PHOS" << endl;
395 }
396 phos = new TTask("PHOS", "") ;
397 sd->Add(phos) ;
b0bba0af 398 }
7a9d98f9 399
b0bba0af 400 TString sdname(name) ;
401 sdname.Append(":") ;
402 sdname.Append(file);
7a9d98f9 403 AliPHOSSDigitizer * phossd = dynamic_cast<AliPHOSSDigitizer *>(phos->GetListOfTasks()->FindObject( sdname ));
b0bba0af 404 if (!phossd) {
405 phossd = new AliPHOSSDigitizer() ;
406 //Note, we can not call constructor with parameters: it will call Getter and scrud up everething
407 phossd->SetName(sdname) ;
408 phossd->SetTitle(file) ;
409 phos->Add(phossd) ;
410 }
411 return kTRUE;
412
413}
7a9d98f9 414
b0bba0af 415//____________________________________________________________________________
416Bool_t AliPHOSGetter::PostDigits(const char * name) const
417{ //---------- Digits -------------------------
418
7a9d98f9 419 // the hierarchy is //Folders/Run/Event/Data/PHOS/SDigits/name
420
421 TFolder * phosFolder = dynamic_cast<TFolder*>(fDigitsFolder->FindObject("PHOS")) ;
422
423 if ( !phosFolder ) {
424 if (fDebug) {
425 cout << "WARNING: AliPHOSGetter::Post D -> Folder //" << fDigitsFolder << "/PHOS/ not found!" << endl;
426 cout << "INFO: AliPHOSGetter::Post D -> Adding Folder //" << fDigitsFolder << "/PHOS/" << endl;
427 }
428 phosFolder = fDigitsFolder->AddFolder("PHOS", "Digits from PHOS") ;
b0bba0af 429 }
7a9d98f9 430
431 TObject* dig = phosFolder->FindObject( name ) ;
b0bba0af 432 if ( !dig ) {
433 TClonesArray * digits = new TClonesArray("AliPHOSDigit",1000) ;
434 digits->SetName(name) ;
7a9d98f9 435 phosFolder->Add(digits) ;
b0bba0af 436 }
437 return kTRUE;
438}
7a9d98f9 439
b0bba0af 440//____________________________________________________________________________
7a9d98f9 441void * AliPHOSGetter::DigitsRef(const char * name) const
442{ //------- Digits ----------------------
443
444 // the hierarchy is //Folders/Run/Event/Data/PHOS/Digits/name
b0bba0af 445
7a9d98f9 446 if ( !fDigitsFolder ) {
447 cerr << "ERROR: AliPHOSGetter::Post DRef -> Folder //" << fDigitsFolder << " not found!" << endl;
448 return 0;
449 }
b0bba0af 450
7a9d98f9 451 TFolder * phosFolder = dynamic_cast<TFolder*>(fDigitsFolder->FindObject("PHOS")) ;
452 if ( !phosFolder ) {
453 cerr << "ERROR: AliPHOSGetter::DRef -> Folder //" << fDigitsFolder << "/PHOS/ not found!" << endl;
b0bba0af 454 return 0;
455 }
456
7a9d98f9 457 TObject * d = phosFolder->FindObject(name) ;
b0bba0af 458 if(!d)
459 return 0 ;
460 else
7a9d98f9 461 return static_cast<void *>(phosFolder->GetListOfFolders()->GetObjectRef(d)) ;
b0bba0af 462
463}
464
b0bba0af 465//____________________________________________________________________________
466Bool_t AliPHOSGetter::PostDigitizer(AliPHOSDigitizer * digitizer) const
467{ //---------- Digitizer -------------------------
468
7a9d98f9 469 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("Digitizer")) ;
470
471 if ( !sd ) {
472 cerr << "ERROR: AliPHOSGetter::Post Der -> Task //" << fTasksFolder << "/Digitizer not found!" << endl;
473 return kFALSE ;
b0bba0af 474 }
7a9d98f9 475 TTask * phos = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("PHOS")) ;
b0bba0af 476 if ( !phos ) {
7a9d98f9 477 if (fDebug) {
478 cout <<"WARNING: AliPHOSGetter::Post Der -> //" << fTasksFolder << "/Digitizer/PHOS not found!" << endl;
479 cout <<"INFO: AliPHOSGetter::Post Der -> Adding //" << fTasksFolder << "/Digitizer/PHOS" << endl;
480 }
481 phos = new TTask("PHOS", "") ;
482 sd->Add(phos) ;
483 }
484
485 AliPHOSDigitizer * phosd = dynamic_cast<AliPHOSDigitizer*>(phos->GetListOfTasks()->FindObject(digitizer->GetName())) ;
b0bba0af 486 if (phosd) {
487 phosd->Delete() ;
488 phos->GetListOfTasks()->Remove(phosd) ;
4ae78bb1 489 }
7a9d98f9 490 phos->Add(digitizer) ;
b0bba0af 491 return kTRUE;
7a9d98f9 492}
493
b0bba0af 494//____________________________________________________________________________
495Bool_t AliPHOSGetter::PostDigitizer(const char * name) const
496{ //---------- Digitizer -------------------------
497
7a9d98f9 498 // the hierarchy is //Folders/Tasks/SDigitizer/PHOS/sdigitsname
499
500 TTask * d = dynamic_cast<TTask*>(fTasksFolder->FindObject("Digitizer")) ;
501 if ( !d ) {
502 cerr << "ERROR: AliPHOSGetter::Post Der -> Task //" << fTasksFolder << "/Digitizer not found!" << endl;
503 return kFALSE ;
b0bba0af 504 }
7a9d98f9 505
506 TTask * phos = dynamic_cast<TTask*>(d->GetListOfTasks()->FindObject("PHOS")) ;
b0bba0af 507 if ( !phos ) {
7a9d98f9 508 if (fDebug) {
509 cout <<"WARNING: AliPHOSGetter::Post Der -> //" << fTasksFolder << "/Digitizer/PHOS not found!" << endl;
510 cout <<"INFO: AliPHOSGetter::Post Der -> Adding //" << fTasksFolder << "/Digitizer/PHOS" << endl;
511 }
512 phos = new TTask("PHOS", "") ;
513 d->Add(phos) ;
514}
b0bba0af 515
7a9d98f9 516 AliPHOSDigitizer * phosd = dynamic_cast<AliPHOSDigitizer*>(phos->GetListOfTasks()->FindObject(name)) ;
b0bba0af 517 if (!phosd) {
518 phosd = new AliPHOSDigitizer() ;
519 phosd->SetName(fDigitsTitle) ;
520 phosd->SetTitle(fHeaderFile) ;
521 phos->Add(phosd) ;
522 }
523 return kTRUE;
524}
525
526//____________________________________________________________________________
7a9d98f9 527void * AliPHOSGetter::DigitizerRef(const char * name) const
b0bba0af 528{
7a9d98f9 529 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("Digitizer")) ;
530 if ( !sd ) {
531 cerr << "ERROR: AliPHOSGetter::Post DerRef -> Task //" << fTasksFolder << "/Digitizer not found!" << endl;
532 abort();
533 }
b0bba0af 534
7a9d98f9 535 TTask * phos = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("PHOS")) ;
536 if ( !phos ) {
537 cerr <<"ERROR: AliPHOSGetter::Post DerRef -> //" << fTasksFolder << "/Digitizer/PHOS" << endl;
538 abort();
539 }
b0bba0af 540
7a9d98f9 541 TTask * task = dynamic_cast<TTask*>(phos->GetListOfTasks()->FindObject(name)) ;
b0bba0af 542
7a9d98f9 543 return static_cast<void *>(phos->GetListOfTasks()->GetObjectRef(task)) ;
b0bba0af 544
545}
546
547//____________________________________________________________________________
548Bool_t AliPHOSGetter::PostRecPoints(const char * name) const
549{ // -------------- RecPoints -------------------------------------------
550
7a9d98f9 551 // the hierarchy is //Folders/Run/Event/RecData/PHOS/EMCARecPoints/name
552 // the hierarchy is //Folders/Run/Event/RecData/PHOS/CPVRecPoints/name
553
554 TFolder * phosFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("PHOS")) ;
b0bba0af 555
7a9d98f9 556 if ( !phosFolder ) {
557 if (fDebug) {
558 cout << "WARNING: AliPHOSGetter::Post RPo -> Folder //" << fRecoFolder << "/PHOS/ not found!" << endl;
559 cout << "INFO: AliPHOSGetter::Post Rpo -> Adding Folder //" << fRecoFolder << "/PHOS/" << endl;
560 }
561 phosFolder = fRecoFolder->AddFolder("PHOS", "Reconstructed data from PHOS") ;
562 }
b0bba0af 563
7a9d98f9 564 // EMCA RecPoints
565 TFolder * phosRPoEMCAFolder = dynamic_cast<TFolder*>(phosFolder->FindObject("EMCARecPoints")) ;
566 if ( !phosRPoEMCAFolder ) {
567 if (fDebug) {
568 cout << "WARNING: AliPHOSGetter::Post RPo -> Folder //" << fRecoFolder << "/PHOS/EMCARecPoints/ not found!" << endl;
569 cout << "INFO: AliPHOSGetter::Post Rpo -> Adding Folder //" << fRecoFolder << "/PHOS/EMCARecPoints not found!" << endl;
570 }
571 phosRPoEMCAFolder = phosFolder->AddFolder("EMCARecPoints", "EMCA RecPoints from PHOS") ;
b0bba0af 572 }
7a9d98f9 573
574 TObject * erp = phosFolder->FindObject( name ) ;
b0bba0af 575 if ( !erp ) {
576 TObjArray * emcrp = new TObjArray(100) ;
577 emcrp->SetName(name) ;
7a9d98f9 578 phosRPoEMCAFolder->Add(emcrp) ;
b0bba0af 579 }
580
7a9d98f9 581 // CPV RecPoints
582 TFolder * phosRPoCPVFolder = dynamic_cast<TFolder*>(phosFolder->FindObject("CPVRecPoints")) ;
583 if ( !phosRPoCPVFolder ) {
584 if (fDebug) {
585 cout << "WARNING: AliPHOSGetter::Post RPo -> Folder //" << fRecoFolder << "/PHOS/CPVRecPoints/ not found!" << endl;
586 cout << "INFO: AliPHOSGetter::Post Rpo -> Adding Folder //" << fRecoFolder << "/PHOS/CPVRecPoints/" << endl;
587 }
588 phosRPoCPVFolder = phosFolder->AddFolder("CPVRecPoints", "CPV RecPoints from PHOS") ;
b0bba0af 589 }
7a9d98f9 590
591 TObject * crp = phosRPoCPVFolder->FindObject( name ) ;
b0bba0af 592 if ( !crp ) {
593 TObjArray * cpvrp = new TObjArray(100) ;
594 cpvrp->SetName(name) ;
7a9d98f9 595 phosRPoCPVFolder->Add(cpvrp) ;
b0bba0af 596 }
597 return kTRUE;
598}
599
600//____________________________________________________________________________
7a9d98f9 601void * AliPHOSGetter::EmcRecPointsRef(const char * name) const
b0bba0af 602{ // -------------- RecPoints -------------------------------------------
603
7a9d98f9 604 // the hierarchy is //Folders/Run/Event/RecData/PHOS/EMCARecPoints/name
b0bba0af 605
7a9d98f9 606 if ( !fRecoFolder ) {
607 cerr << "ERROR: AliPHOSGetter::EmcRecPointsRef -> Folder //" << fRecoFolder << " not found!" << endl;
b0bba0af 608 return 0 ;
609 }
610
7a9d98f9 611 TFolder * phosFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("PHOS/EMCARecPoints")) ;
612 if ( !phosFolder ) {
613 cerr << "ERROR: AliPHOSGetter::EmcRecPointsRef -> Folder //" << fRecoFolder << "/PHOS/EMCARecPoints/ not found!" << endl;
614 return 0;
615 }
616
617
618 TObject * erp = phosFolder->FindObject(name ) ;
b0bba0af 619 if ( !erp ) {
620 return 0 ;
621 }
7a9d98f9 622 return static_cast<void *>(phosFolder->GetListOfFolders()->GetObjectRef(erp)) ;
b0bba0af 623
624}
7a9d98f9 625
b0bba0af 626//____________________________________________________________________________
7a9d98f9 627void * AliPHOSGetter::CpvRecPointsRef(const char * name) const
b0bba0af 628{ // -------------- RecPoints -------------------------------------------
629
7a9d98f9 630 // the hierarchy is //Folders/Run/Event/RecData/PHOS/CPVRecPoints/name
b0bba0af 631
7a9d98f9 632 if ( !fRecoFolder ) {
633 cerr << "ERROR: AliPHOSGetter::EmcRecPointsRef -> Folder //" << fRecoFolder << " not found!" << endl;
b0bba0af 634 return 0 ;
635 }
7a9d98f9 636
637 TFolder * phosFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("PHOS/CPVRecPoints")) ;
638 if ( !phosFolder ) {
639 cerr << "ERROR: AliPHOSGetter::CpvRecPointsRef -> Folder //" << fRecoFolder << "/PHOS/CPVRecPoints/" << endl;
640 return 0;
641 }
642
643 TObject * crp = phosFolder->FindObject(name ) ;
b0bba0af 644 if ( !crp ) {
645 return 0 ;
646 }
7a9d98f9 647 return static_cast<void *>(phosFolder->GetListOfFolders()->GetObjectRef(crp)) ;
b0bba0af 648
649}
650
651//____________________________________________________________________________
652Bool_t AliPHOSGetter::PostClusterizer(AliPHOSClusterizer * clu) const
653{ // ------------------ AliPHOSClusterizer ------------------------
654
7a9d98f9 655 // the hierarchy is //Folders/Tasks/Reconstructioner/PHOS/sdigitsname
656
657 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
658
659 if ( !tasks ) {
660 cerr << "ERROR: AliPHOSGetter::Post Rer -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
661 return kFALSE ;
662 }
663
664 TTask * phos = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
b0bba0af 665 if ( !phos ) {
7a9d98f9 666 if (fDebug) {
667 cout <<"WARNING: AliPHOSGetter::Post Rer -> //" << fTasksFolder << "/ReconstructionerPHOS not found!" << endl;
668 cout <<"INFO: AliPHOSGetter::Post Rer -> Adding //" << fTasksFolder << "/Reconstructioner/PHOS" << endl;
4ae78bb1 669 }
7a9d98f9 670 phos = new TTask("PHOS", "") ;
671 tasks->Add(phos) ;
b0bba0af 672 }
7a9d98f9 673
674 AliPHOSClusterizer * phoscl = dynamic_cast<AliPHOSClusterizer*>(phos->GetListOfTasks()->FindObject(clu->GetName())) ;
675 if (phoscl) {
676 if (fDebug)
677 cout << "INFO: AliPHOSGetter::Post Rer -> Task " << clu->GetName() << " already exists" << endl ;
678 phoscl->Delete() ;
679 phos->GetListOfTasks()->Remove(phoscl) ;
680 }
681 phos->Add(clu) ;
682 return kTRUE;
683}
b0bba0af 684
685//____________________________________________________________________________
7a9d98f9 686void * AliPHOSGetter::ClusterizerRef(const char * name) const
b0bba0af 687{ // ------------------ AliPHOSClusterizer ------------------------
4ae78bb1 688
7a9d98f9 689 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
690
691 if ( !tasks ) {
692 cerr << "ERROR: AliPHOSGetter::Post RerRef -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
693 return kFALSE ;
694 }
695
696 TTask * phos = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
b0bba0af 697 if ( !phos ) {
7a9d98f9 698 cerr <<"WARNING: AliPHOSGetter::Post RerRef -> //" << fTasksFolder << "/Reconstructioner/PHOS" << endl;
b0bba0af 699 return 0 ;
7a9d98f9 700 }
701
b0bba0af 702 TList * l = phos->GetListOfTasks() ;
703 TIter it(l) ;
704 TTask * task ;
705 TTask * clu = 0 ;
706 TString cluname(name) ;
707 cluname+=":clu-" ;
7a9d98f9 708 while((task = static_cast<TTask *>(it.Next()) )){
b0bba0af 709 TString taskname(task->GetName()) ;
710 if(taskname.BeginsWith(cluname)){
711 clu = task ;
712 break ;
4ae78bb1 713 }
b0bba0af 714 }
715
716 if(clu)
7a9d98f9 717 return static_cast<void *>(l->GetObjectRef(clu)) ;
b0bba0af 718 else
719 return 0 ;
720}
721
722//____________________________________________________________________________
723Bool_t AliPHOSGetter::PostClusterizer(const char * name) const
724{ // ------------------ AliPHOSClusterizer ------------------------
7a9d98f9 725
726 // the hierarchy is //Folders/Tasks/Reconstructioner/PHOS/sdigitsname
b0bba0af 727
7a9d98f9 728 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
729
730 if ( !tasks ) {
731 cerr << "ERROR: AliPHOSGetter::Post Rer -> Task//" << fTasksFolder << "/Reconstructioner not found!" << endl;
732 return kFALSE ;
733 }
b0bba0af 734
7a9d98f9 735 TTask * phos = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
b0bba0af 736 if ( !phos ) {
7a9d98f9 737 if (fDebug) {
738 cout <<"WARNING: AliPHOSGetter::Post Rer -> //" << fTasksFolder << "/Reconstructioner/PHOS not found!" << endl;
739 cout <<"INFO: AliPHOSGetter::Post Rer -> Adding //" << fTasksFolder << "/Reconstructioner/PHOS" << endl;
740 }
741 phos = new TTask("PHOS", "") ;
742 tasks->Add(phos) ;
b0bba0af 743 }
7a9d98f9 744
b0bba0af 745 AliPHOSClusterizer * phoscl = new AliPHOSClusterizerv1() ;
746 TString clun(name) ;
747 clun+=":clu-v1" ;
748 phoscl->SetName(clun) ;
749 phos->Add(phoscl) ;
750 return kTRUE;
751
752}
7a9d98f9 753
b0bba0af 754//____________________________________________________________________________
755Bool_t AliPHOSGetter::PostTrackSegments(const char * name) const
756{ // ---------------TrackSegments -----------------------------------
757
7a9d98f9 758 // the hierarchy is //Folders/Run/Event/RecData/PHOS/TrackSegments/name
759
760 TFolder * phosFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("PHOS")) ;
761
762 if ( !phosFolder ) {
763 if (fDebug) {
764 cout << "WARNING: AliPHOSGetter::Post TS -> Folder //" << fRecoFolder << "/PHOS/ not found!" << endl;
765 cout << "INFO: AliPHOSGetter::Post TS -> Adding Folder //" << fRecoFolder << "/PHOS" << endl;
766 }
767 phosFolder = fRecoFolder->AddFolder("PHOS", "Reconstructed data from PHOS") ;
768 }
769
770 TFolder * phosTSFolder = dynamic_cast<TFolder*>(phosFolder->FindObject("TrackSegments")) ;
771 if ( !phosTSFolder ) {
772 if (fDebug) {
773 cout << "WARNING: AliPHOSGetter::Post TS -> Folder//" << fRecoFolder << "/PHOS/TrackSegments/ not found!" << endl;
774 cout << "INFO: AliPHOSGetter::Post TS -> Adding Folder //" << fRecoFolder << "/PHOS/TrackSegments/" << endl;
775 }
776 phosTSFolder = phosFolder->AddFolder("TrackSegments", "TrackSegments from PHOS") ;
b0bba0af 777 }
7a9d98f9 778
779 TObject * tss = phosTSFolder->FindObject( name ) ;
b0bba0af 780 if (!tss) {
781 TClonesArray * ts = new TClonesArray("AliPHOSTrackSegment",100) ;
782 ts->SetName(name) ;
7a9d98f9 783 phosTSFolder->Add(ts) ;
b0bba0af 784 }
785 return kTRUE;
786}
787
788//____________________________________________________________________________
7a9d98f9 789void * AliPHOSGetter::TrackSegmentsRef(const char * name) const
b0bba0af 790{ // ---------------TrackSegments -----------------------------------
791
7a9d98f9 792 // the hierarchy is //Folders/Run/Event/RecData/PHOS/TrackSegments/name
793
794 if ( !fRecoFolder ) {
795 cerr << "ERROR: AliPHOSGetter::TrackSegmentsRef -> Folder //" << fRecoFolder << "not found!" << endl;
b0bba0af 796 return 0 ;
797 }
7a9d98f9 798
799 TFolder * phosFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("PHOS/TrackSegments")) ;
800 if ( !phosFolder ) {
801 cerr << "ERROR: AliPHOSGetter::TrackSegmentsRef -> Folder //" << fRecoFolder << "/PHOS/TrackSegments/ not found!" << endl;
802 return 0;
803 }
b0bba0af 804
7a9d98f9 805 TObject * tss = phosFolder->FindObject(name) ;
b0bba0af 806 if (!tss) {
807 return 0 ;
808 }
7a9d98f9 809 return static_cast<void *>(phosFolder->GetListOfFolders()->GetObjectRef(tss)) ;
b0bba0af 810}
811
812//____________________________________________________________________________
813Bool_t AliPHOSGetter::PostTrackSegmentMaker(AliPHOSTrackSegmentMaker * tsmaker) const
814{ //------------Track Segment Maker ------------------------------
815
7a9d98f9 816 // the hierarchy is //Folders/Tasks/Reconstructioner/PHOS/sdigitsname
817
818 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
819
820 if ( !tasks ) {
821 cerr << "ERROR: AliPHOSGetter::Post Ter -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
822 return kFALSE ;
b0bba0af 823 }
7a9d98f9 824
825 TTask * phos = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
b0bba0af 826 if ( !phos ) {
7a9d98f9 827 if (fDebug) {
828 cout <<"WARNING: AliPHOSGetter::Post Rer -> //" << fTasksFolder << "/Reconstructioner/PHOS not found!" << endl;
829 cout <<"INFO: AliPHOSGetter::Post Rer -> Adding //" << fTasksFolder << "/Reconstructioner/PHOS" << endl;
830 }
831 phos = new TTask("PHOS", "") ;
832 tasks->Add(phos) ;
833 }
834
b0bba0af 835 AliPHOSTrackSegmentMaker * phosts =
7a9d98f9 836 dynamic_cast<AliPHOSTrackSegmentMaker*>(phos->GetListOfTasks()->FindObject(tsmaker->GetName())) ;
b0bba0af 837 if (phosts) {
838 phosts->Delete() ;
839 phos->GetListOfTasks()->Remove(phosts) ;
840 }
841 phos->Add(tsmaker) ;
842 return kTRUE;
843
844}
845//____________________________________________________________________________
846Bool_t AliPHOSGetter::PostTrackSegmentMaker(const char * name) const
847{ //------------Track Segment Maker ------------------------------
848
7a9d98f9 849 // the hierarchy is //Folders/Tasks/Reconstructioner/PHOS/sdigitsname
850
b0bba0af 851
7a9d98f9 852 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
853
854 if ( !tasks ) {
855 cerr << "ERROR: AliPHOSGetter::Post Ter -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
856 return kFALSE ;
b0bba0af 857 }
7a9d98f9 858
859 TTask * phos = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
b0bba0af 860 if ( !phos ) {
7a9d98f9 861 if (fDebug) {
862 cout <<"WARNING: AliPHOSGetter::Post Rer -> //" << fTasksFolder << "/Reconstructioner/PHOS not found!" << endl;
863 cout <<"INFO: AliPHOSGetter::Post Rer -> Adding //" << fTasksFolder << "/Reconstructioner/PHOS" << endl;
864 }
865 phos = new TTask("PHOS", "") ;
866 tasks->Add(phos) ;
b0bba0af 867 }
7a9d98f9 868
b0bba0af 869 AliPHOSTrackSegmentMaker * phosts =
7a9d98f9 870 dynamic_cast<AliPHOSTrackSegmentMaker*>(phos->GetListOfTasks()->FindObject(name)) ;
b0bba0af 871 if (!phosts) {
872 phosts = new AliPHOSTrackSegmentMakerv1() ;
873 TString tsn(name);
874 tsn+=":tsm-v1" ;
875 phosts->SetName(tsn) ;
876 phos->Add(phosts) ;
877 }
878 return kTRUE;
879
880}
7a9d98f9 881
b0bba0af 882//____________________________________________________________________________
7a9d98f9 883void * AliPHOSGetter::TSMakerRef(const char * name) const
b0bba0af 884{ //------------Track Segment Maker ------------------------------
885
7a9d98f9 886 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
887
888 if ( !tasks ) {
889 cerr << "ERROR: AliPHOSGetter::Post TerRef -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
890 return kFALSE ;
b0bba0af 891 }
7a9d98f9 892
893 TTask * phos = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
894 if ( !phos ) {
895 cerr <<"WARNING: AliPHOSGetter::Post TerRef -> //" << fTasksFolder << "/Reconstructioner/PHOS not found!" << endl;
b0bba0af 896 return 0 ;
7a9d98f9 897 }
898
b0bba0af 899 TList * l = phos->GetListOfTasks() ;
900 TIter it(l) ;
901 TTask * task ;
902 TTask * tsm = 0 ;
903 TString tsmname(name) ;
904 tsmname+=":tsm-" ;
7a9d98f9 905 while((task = static_cast<TTask *>(it.Next()) )){
b0bba0af 906 TString taskname(task->GetName()) ;
907 if(taskname.BeginsWith(tsmname)){
908 tsm = task ;
909 break ;
4ae78bb1 910 }
b0bba0af 911 }
912
913 if(tsm)
7a9d98f9 914 return static_cast<void *>(l->GetObjectRef(tsm)) ;
b0bba0af 915 else
916 return 0 ;
917
918}
919
920//____________________________________________________________________________
921Bool_t AliPHOSGetter::PostRecParticles(const char * name) const
922{ // -------------------- RecParticles ------------------------
923
7a9d98f9 924 // the hierarchy is //Folders/Run/Event/RecData/PHOS/TrackSegments/name
925
926 TFolder * phosFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("PHOS")) ;
b0bba0af 927
7a9d98f9 928 if ( !phosFolder ) {
929 if (fDebug) {
930 cout << "WARNING: AliPHOSGetter::Post RPa -> Folder //" << fRecoFolder << "/PHOS/ not found!" << endl;
931 cout << "INFO: AliPHOSGetter::Post Rpa -> Adding Folder //" << fRecoFolder << "/PHOS/" << endl;
932 }
933 phosFolder = fRecoFolder->AddFolder("PHOS", "Reconstructed data from PHOS") ;
b0bba0af 934 }
7a9d98f9 935
936 TFolder * phosRPaFolder = dynamic_cast<TFolder*>(phosFolder->FindObject("RecParticles")) ;
937 if ( !phosRPaFolder ) {
938 if (fDebug) {
939 cout << "WARNING: AliPHOSGetter::Post RPa -> Folder //" << fRecoFolder << "/PHOS/RecParticles/ not found!" << endl;
940 cout << "INFO: AliPHOSGetter::Post RPa -> Adding Folder //" << fRecoFolder << "/PHOS/RecParticles/" << endl;
941 }
942 phosRPaFolder = phosFolder->AddFolder("RecParticles", "RecParticles from PHOS") ;
943 }
944
945 TObject * rps = phosRPaFolder->FindObject( name ) ;
b0bba0af 946 if ( !rps ) {
947 TClonesArray * rp = new TClonesArray("AliPHOSRecParticle",100) ;
948 rp->SetName(name) ;
7a9d98f9 949 phosRPaFolder->Add(rp) ;
b0bba0af 950 }
951 return kTRUE;
952}
7a9d98f9 953
b0bba0af 954//____________________________________________________________________________
7a9d98f9 955void * AliPHOSGetter::RecParticlesRef(const char * name) const
b0bba0af 956{ // ---------------TrackSegments -----------------------------------
957
7a9d98f9 958 // the hierarchy is //Folders/Run/Event/RecData/PHOS/TrackSegments/name
959
960 if ( !fRecoFolder ) {
961 cerr << "ERROR: AliPHOSGetter::RecParticlesRef -> Folder//" << fRecoFolder << " not found!" << endl;
b0bba0af 962 return 0 ;
963 }
7a9d98f9 964
965 TFolder * phosFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("PHOS/RecParticles")) ;
966 if ( !phosFolder ) {
967 cerr << "ERROR: AliPHOSGetter::RecParticlesRef -> Folder //" << fRecoFolder << "/PHOS/RecParticles/ not found!" << endl;
968 return 0;
969 }
970
971 TObject * tss = phosFolder->FindObject(name ) ;
b0bba0af 972 if (!tss) {
973 return 0 ;
974 }
7a9d98f9 975 return static_cast<void *>(phosFolder->GetListOfFolders()->GetObjectRef(tss)) ;
b0bba0af 976}
977
978//____________________________________________________________________________
979Bool_t AliPHOSGetter::PostPID(AliPHOSPID * pid) const
7a9d98f9 980{ // ------------AliPHOS PID -----------------------------
981
982 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
983
984 if ( !tasks ) {
985 cerr << "ERROR: AliPHOSGetter::Post Per -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
986 return kFALSE ;
b0bba0af 987 }
7a9d98f9 988
989 TTask * phos = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
b0bba0af 990 if ( !phos ) {
7a9d98f9 991 if (fDebug) {
992 cout <<"WARNING: AliPHOSGetter::Post Per -> //" << fTasksFolder << "/Reconstructioner/PHOS not found!" << endl;
993 cout <<"INFO: AliPHOSGetter::Post Per -> Adding //" << fTasksFolder << "/Reconstructioner/PHOS" << endl;
994 }
995 phos = new TTask("PHOS", "") ;
996 tasks->Add(phos) ;
4ae78bb1 997 }
7a9d98f9 998
999 AliPHOSPID * phospid = dynamic_cast<AliPHOSPID*>(phos->GetListOfTasks()->FindObject(pid->GetName())) ;
b0bba0af 1000 if (phospid) {
1001 if (fDebug)
1002 cout << "INFO: AliPHOSGetter::Post Per -> Task " << pid->GetName()
1003 << " already exists" << endl ;
1004 phos->GetListOfTasks()->Remove(phospid) ;
1005 }
1006
1007 phos->Add(pid) ;
1008 return kTRUE;
1009}
7a9d98f9 1010
b0bba0af 1011//____________________________________________________________________________
1012Bool_t AliPHOSGetter::PostPID(const char * name) const
1013{
7a9d98f9 1014 // the hierarchy is //Folders/Tasks/Reconstructioner/PHOS/sdigitsname
1015
1016 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
1017
1018 if ( !tasks ) {
1019 cerr << "ERROR: AliPHOSGetter::Post Per -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
1020 return kFALSE ;
b0bba0af 1021 }
7a9d98f9 1022
1023 TTask * phos = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
b0bba0af 1024 if ( !phos ) {
7a9d98f9 1025 if (fDebug) {
1026 cout <<"WARNING: AliPHOSGetter::Post Per -> //" << fTasksFolder << "/Reconstructioner/PHOS not found!" << endl;
1027 cout <<"INFO: AliPHOSGetter::Post Per -> Adding //" << fTasksFolder << "/Reconstructioner/PHOS" << endl;
1028 }
1029 phos = new TTask("PHOS", "") ;
1030 tasks->Add(phos) ;
1031 }
4ae78bb1 1032
b0bba0af 1033 TList * l = phos->GetListOfTasks() ;
1034 TIter it(l) ;
1035 TString pidname(name) ;
1036 pidname+=":pid" ;
1037 TTask * task ;
7a9d98f9 1038 while((task = static_cast<TTask *>(it.Next()) )){
b0bba0af 1039 TString taskname(task->GetName()) ;
1040 if(taskname.BeginsWith(pidname))
1041 return kTRUE ;
1042 }
1043
1044 AliPHOSPIDv1 * phospid = new AliPHOSPIDv1() ;
1045 pidname+="-v1" ;
1046 phospid->SetName(pidname) ;
1047 phos->Add(phospid) ;
1048
1049 return kTRUE;
1050}
7a9d98f9 1051
b0bba0af 1052//____________________________________________________________________________
7a9d98f9 1053void * AliPHOSGetter::PIDRef(const char * name) const
b0bba0af 1054{ //------------PID ------------------------------
1055
7a9d98f9 1056 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
1057
1058 if ( !tasks ) {
1059 cerr << "ERROR: AliPHOSGetter::Post PerRef -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
1060 return kFALSE ;
b0bba0af 1061 }
7a9d98f9 1062
1063 TTask * phos = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
1064 if ( !phos ) {
1065 cerr <<"WARNING: AliPHOSGetter::Post PerRef -> //" << fTasksFolder << "/ReconstructionerPHOS not found!" << endl;
b0bba0af 1066 return 0 ;
7a9d98f9 1067 }
1068
b0bba0af 1069 TList * l = phos->GetListOfTasks() ;
1070 TIter it(l) ;
1071 TTask * task ;
1072 TTask * pid = 0 ;
1073 TString pidname(name) ;
1074 pidname+=":pid-" ;
7a9d98f9 1075 while((task = static_cast<TTask *>(it.Next()) )){
b0bba0af 1076 TString taskname(task->GetName()) ;
1077 if(taskname.BeginsWith(pidname)){
1078 pid = task ;
1079 break ;
1080 }
4ae78bb1 1081 }
b0bba0af 1082
1083 if(pid)
7a9d98f9 1084 return static_cast<void *>(l->GetObjectRef(pid)) ;
b0bba0af 1085 else
1086 return 0 ;
1087
1088}
1089
1090//____________________________________________________________________________
7a9d98f9 1091Bool_t AliPHOSGetter::PostQA(void) const
1092{ // ------------------ QA ---------------------------------
1093
1094 // the hierarchy is //Folders/Run/Conditions/QA/PHOS/alarmsName
1095
1096 TFolder * phosFolder = dynamic_cast<TFolder*>(fQAFolder->FindObject("PHOS")) ;
1097 if ( !phosFolder ) {
1098 if (fDebug) {
1099 cout << "WARNING: AliPHOSGetter::Post Q -> Folder //" << fQAFolder << "/PHOS/ not found!" << endl;
1100 cout << "INFO: AliPHOSGetter::Post Q -> Adding Folder //" << fQAFolder << "/PHOS/" << endl;
1101 }
1102 phosFolder = fQAFolder->AddFolder("PHOS", "QA from PHOS") ;
1103 }
1104
b0bba0af 1105 return kTRUE;
4ae78bb1 1106}
1107
1108//____________________________________________________________________________
7a9d98f9 1109void * AliPHOSGetter::AlarmsRef(void) const
1110{ //------- Alarms ----------------------
1111
1112
1113 // the hierarchy is //Folders/Run/Conditions/QA/PHOS
1114 if ( !fQAFolder ) {
1115 cerr << "ERROR: AliPHOSGetter::Post QRef -> Folder //" << fQAFolder << " not found!" << endl;
1116 return 0;
1117 }
1118
1119 TFolder * phosFolder = dynamic_cast<TFolder *>(fQAFolder->FindObject("PHOS")) ;
1120 if ( !phosFolder ) {
1121 cerr << "ERROR: AliPHOSGetter::Post QRef -> Folder //" << fQAFolder << "/PHOS/ not found!" << endl;
1122 return 0;
1123 }
1124
1125 return static_cast<void *>(fQAFolder->GetListOfFolders()->GetObjectRef(phosFolder)) ;
1126}
1127
1128//____________________________________________________________________________
4ae78bb1 1129const TParticle * AliPHOSGetter::Primary(Int_t index) const
1130{
1131 // Return primary particle numbered by <index>
1132
1133 if(index < 0)
1134 return 0 ;
1135
1136 Int_t primaryIndex = index % 10000000 ;
1137 Int_t primaryList = (Int_t ) ((index-primaryIndex)/10000000.) ;
1138
1139 if ( primaryList > 0 ) {
7a9d98f9 1140 if (fDebug) {
1141 cout << " Getter does not support currently Mixing of primary " << endl ;
1142 cout << " can not return primary: " << index<< " (list "<< primaryList<< " primary # " << primaryIndex << " )"<<endl ;
1143 }
4ae78bb1 1144 return 0;
1145 }
1146
1147 return gAlice->Particle(primaryIndex) ;
1148
1149}
1150
1151//____________________________________________________________________________
1152void AliPHOSGetter::ReadTreeD()
1153{
1154 // Read the digit tree gAlice->TreeD()
1155 if(gAlice->TreeD()== 0){
1156 cerr << "ERROR: AliPHOSGetter::ReadTreeD: can not read TreeD " << endl ;
1157 return ;
1158 }
1159
7a9d98f9 1160 TObjArray * lob = static_cast<TObjArray*>(gAlice->TreeD()->GetListOfBranches()) ;
4ae78bb1 1161 TIter next(lob) ;
1162 TBranch * branch = 0 ;
1163 TBranch * digitsbranch = 0 ;
1164 TBranch * digitizerbranch = 0 ;
1165 Bool_t phosfound = kFALSE, digitizerfound = kFALSE ;
1166
7a9d98f9 1167 while ( (branch = static_cast<TBranch*>(next())) && (!phosfound || !digitizerfound) ) {
4ae78bb1 1168 if ( (strcmp(branch->GetName(), "PHOS")==0) && (strcmp(branch->GetTitle(), fDigitsTitle)==0) ) {
1169 digitsbranch = branch ;
1170 phosfound = kTRUE ;
1171 }
1172 else if ( (strcmp(branch->GetName(), "AliPHOSDigitizer")==0) && (strcmp(branch->GetTitle(), fDigitsTitle)==0) ) {
1173 digitizerbranch = branch ;
1174 digitizerfound = kTRUE ;
1175 }
1176 }
1177
1178 if ( !phosfound || !digitizerfound ) {
7a9d98f9 1179 if (fDebug)
1180 cout << "WARNING: AliPHOSGetter::ReadTreeD -> Cannot find Digits and/or Digitizer with name "
1181 << fDigitsTitle << endl ;
4ae78bb1 1182 return ;
1183 }
1184
b0bba0af 1185 //read digits
1186 if(!Digits(fDigitsTitle) )
1187 PostDigits(fDigitsTitle);
1188 digitsbranch->SetAddress(DigitsRef(fDigitsTitle)) ;
1189 digitsbranch->GetEntry(0) ;
4ae78bb1 1190
b0bba0af 1191
1192 // read the Digitizer
1193 if(!Digitizer(fDigitsTitle))
1194 PostDigitizer(fDigitsTitle) ;
1195 digitizerbranch->SetAddress(DigitizerRef(fDigitsTitle)) ;
4ae78bb1 1196 digitizerbranch->GetEntry(0) ;
b0bba0af 1197
4ae78bb1 1198
1199}
1200
1201//____________________________________________________________________________
1202void AliPHOSGetter::ReadTreeH()
1203{
1204 // Read the first entry of PHOS branch in hit tree gAlice->TreeH()
1205
1206 if(gAlice->TreeH()== 0){
1207 cerr << "ERROR: AliPHOSGetter::ReadTreeH: -> Cannot read TreeH " << endl ;
1208 return ;
1209 }
1210
7a9d98f9 1211 TBranch * hitsbranch = static_cast<TBranch*>(gAlice->TreeH()->GetBranch("PHOS")) ;
4ae78bb1 1212 if ( !hitsbranch ) {
7a9d98f9 1213 if (fDebug)
1214 cout << "WARNING: AliPHOSGetter::ReadTreeH -> Cannot find branch PHOS" << endl ;
b0bba0af 1215 return ;
4ae78bb1 1216 }
b0bba0af 1217 if(!Hits())
1218 PostHits() ;
1219
1220 hitsbranch->SetAddress(HitsRef()) ;
1221
1222 hitsbranch->GetEntry(0) ;
1223
4ae78bb1 1224}
1225
1226//____________________________________________________________________________
b0bba0af 1227void AliPHOSGetter::Track(Int_t itrack)
1228{
1229 // Read the first entry of PHOS branch in hit tree gAlice->TreeH()
1230
1231 if(gAlice->TreeH()== 0){
1232 cerr << "ERROR: AliPHOSGetter::ReadTreeH: -> Cannot read TreeH " << endl ;
1233 return ;
1234 }
1235
7a9d98f9 1236 TBranch * hitsbranch = dynamic_cast<TBranch*>(gAlice->TreeH()->GetListOfBranches()->FindObject("PHOS")) ;
b0bba0af 1237 if ( !hitsbranch ) {
7a9d98f9 1238 if (fDebug)
1239 cout << "WARNING: AliPHOSGetter::ReadTreeH -> Cannot find branch PHOS" << endl ;
b0bba0af 1240 return ;
1241 }
1242 if(!Hits())
1243 PostHits() ;
1244 hitsbranch->SetAddress(HitsRef()) ;
1245 hitsbranch->GetEntry(itrack) ;
1246
1247
1248}
1249//____________________________________________________________________________
4ae78bb1 1250void AliPHOSGetter::ReadTreeQA()
1251{
1252 // Read the digit tree gAlice->TreeQA()
1253 // so far only PHOS knows about this Tree
1254
1255 if(PHOS()->TreeQA()== 0){
1256 cerr << "ERROR: AliPHOSGetter::ReadTreeQA: can not read TreeQA " << endl ;
1257 return ;
1258 }
1259
1260 TBranch * qabranch = PHOS()->TreeQA()->GetBranch("PHOS") ;
1261 if (!qabranch) {
7a9d98f9 1262 if (fDebug)
1263 cout << "WARNING: AliPHOSGetter::ReadTreeQA -> Cannot find QA Alarms for PHOS" << endl ;
4ae78bb1 1264 return ;
1265 }
b0bba0af 1266
7a9d98f9 1267 if(!Alarms())
1268 PostQA() ;
1269
1270 qabranch->SetAddress(AlarmsRef()) ;
1271
4ae78bb1 1272 qabranch->GetEntry(0) ;
7a9d98f9 1273
1274// PostQA("PHOS") ;
1275// TFolder * alarmsF = Alarms() ;
1276// alarmsF->Clear() ;
1277// qabranch->SetAddress(&alarmsF) ;
1278// qabranch->GetEntry(0) ;
4ae78bb1 1279
1280}
1281
1282//____________________________________________________________________________
1283void AliPHOSGetter::ReadTreeR()
1284{
1285 // Read the reconstrunction tree gAlice->TreeR()
1286
1287 if(gAlice->TreeR()== 0){
7a9d98f9 1288 cerr << "ERROR: AliPHOSGetter::ReadTreeR: can not read TreeR " << endl ;
b0bba0af 1289 return ;
4ae78bb1 1290 }
b0bba0af 1291
4ae78bb1 1292 // RecPoints
7a9d98f9 1293 TObjArray * lob = static_cast<TObjArray*>(gAlice->TreeR()->GetListOfBranches()) ;
4ae78bb1 1294 TIter next(lob) ;
1295 TBranch * branch = 0 ;
1296 TBranch * emcbranch = 0 ;
1297 TBranch * cpvbranch = 0 ;
1298 TBranch * clusterizerbranch = 0 ;
1299 Bool_t phosemcrpfound = kFALSE, phoscpvrpfound = kFALSE, clusterizerfound = kFALSE ;
1300
7a9d98f9 1301 while ( (branch = static_cast<TBranch*>(next())) && (!phosemcrpfound || !phoscpvrpfound || !clusterizerfound) )
b0bba0af 1302 if(strcmp(branch->GetTitle(), fRecPointsTitle)==0) {
1303 if ( strcmp(branch->GetName(), "PHOSEmcRP")==0) {
1304 emcbranch = branch ;
1305 phosemcrpfound = kTRUE ;
1306 }
1307 else if ( strcmp(branch->GetName(), "PHOSCpvRP")==0) {
1308 cpvbranch = branch ;
1309 phoscpvrpfound = kTRUE ;
1310 }
1311 else if(strcmp(branch->GetName(), "AliPHOSClusterizer")==0){
1312 clusterizerbranch = branch ;
1313 clusterizerfound = kTRUE ;
1314 }
4ae78bb1 1315 }
4ae78bb1 1316
b0bba0af 1317 if ( !phosemcrpfound ) {
7a9d98f9 1318 if (fDebug)
1319 cout << "WARNING: AliPHOSGetter::ReadTreeR -> Cannot find EmcRecPoints with title "
1320 << fRecPointsTitle << endl ;
4ae78bb1 1321 return ;
1322 }
b0bba0af 1323 if ( !phoscpvrpfound ) {
7a9d98f9 1324 if (fDebug)
1325 cout << "WARNING: AliPHOSGetter::ReadTreeR -> Cannot find CpvRecPoints with title "
1326 << fRecPointsTitle << endl ;
b0bba0af 1327 return ;
1328 }
1329 if ( !clusterizerfound ) {
7a9d98f9 1330 if (fDebug)
1331 cout << "WARNING: AliPHOSGetter::ReadTreeR -> Can not find Clusterizer with title "
1332 << fRecPointsTitle << endl ;
b0bba0af 1333 return ;
1334 }
1335
1336 // Read and Post the RecPoints
1337 if(!EmcRecPoints(fRecPointsTitle) )
1338 PostRecPoints(fRecPointsTitle) ;
1339 emcbranch->SetAddress(EmcRecPointsRef(fRecPointsTitle)) ;
1340 emcbranch->GetEntry(0) ;
1341
1342 cpvbranch->SetAddress(CpvRecPointsRef(fRecPointsTitle)) ;
1343 cpvbranch->GetEntry(0) ;
1344
1345 if(!Clusterizer(fRecPointsTitle) )
1346 PostClusterizer(fRecPointsTitle) ;
1347 clusterizerbranch->SetAddress(ClusterizerRef(fRecPointsTitle)) ;
4ae78bb1 1348 clusterizerbranch->GetEntry(0) ;
1349
b0bba0af 1350
1351 //------------------- TrackSegments ---------------------
4ae78bb1 1352 next.Reset() ;
1353 TBranch * tsbranch = 0 ;
1354 TBranch * tsmakerbranch = 0 ;
1355 Bool_t phostsfound = kFALSE, tsmakerfound = kFALSE ;
b0bba0af 1356
7a9d98f9 1357 while ( (branch = static_cast<TBranch*>(next())) && (!phostsfound || !tsmakerfound) )
b0bba0af 1358 if(strcmp(branch->GetTitle(), fTrackSegmentsTitle)==0) {
1359 if ( strcmp(branch->GetName(), "PHOSTS")==0){
1360 tsbranch = branch ;
1361 phostsfound = kTRUE ;
1362 }
1363 else if(strcmp(branch->GetName(), "AliPHOSTrackSegmentMaker")==0) {
1364 tsmakerbranch = branch ;
1365 tsmakerfound = kTRUE ;
1366 }
4ae78bb1 1367 }
b0bba0af 1368
4ae78bb1 1369 if ( !phostsfound || !tsmakerfound ) {
7a9d98f9 1370 if (fDebug)
1371 cout << "WARNING: AliPHOSGetter::ReadTreeR -> Cannot find TrackSegments and/or TrackSegmentMaker with name "
1372 << fTrackSegmentsTitle << endl ;
4ae78bb1 1373 return ;
1374 }
b0bba0af 1375
1376 // Read and Post the TrackSegments
1377 if(!TrackSegments(fTrackSegmentsTitle))
1378 PostTrackSegments(fTrackSegmentsTitle) ;
1379 tsbranch->SetAddress(TrackSegmentsRef(fTrackSegmentsTitle)) ;
1380 tsbranch->GetEntry(0) ;
1381
1382 // Read and Post the TrackSegment Maker
1383 if(!TrackSegmentMaker(fTrackSegmentsTitle))
1384 PostTrackSegmentMaker(fTrackSegmentsTitle) ;
1385 tsmakerbranch->SetAddress(TSMakerRef(fTrackSegmentsTitle)) ;
4ae78bb1 1386 tsmakerbranch->GetEntry(0) ;
b0bba0af 1387
1388
1389 //------------ RecParticles ----------------------------
4ae78bb1 1390 next.Reset() ;
1391 TBranch * rpabranch = 0 ;
1392 TBranch * pidbranch = 0 ;
1393 Bool_t phosrpafound = kFALSE, pidfound = kFALSE ;
1394
7a9d98f9 1395 while ( (branch = static_cast<TBranch*>(next())) && (!phosrpafound || !pidfound) )
b0bba0af 1396 if(strcmp(branch->GetTitle(), fRecParticlesTitle)==0) {
1397 if ( strcmp(branch->GetName(), "PHOSRP")==0) {
1398 rpabranch = branch ;
1399 phosrpafound = kTRUE ;
1400 }
1401 else if (strcmp(branch->GetName(), "AliPHOSPID")==0) {
1402 pidbranch = branch ;
1403 pidfound = kTRUE ;
1404 }
4ae78bb1 1405 }
b0bba0af 1406
4ae78bb1 1407 if ( !phosrpafound || !pidfound ) {
7a9d98f9 1408 if (fDebug)
1409 cout << "WARNING: AliPHOSGetter::ReadTreeR -> Cannot find RecParticles and/or PID with name "
1410 << fRecParticlesTitle << endl ;
4ae78bb1 1411 return ;
1412 }
b0bba0af 1413
1414 // Read and Post the RecParticles
1415 if(!RecParticles(fRecParticlesTitle))
1416 PostRecParticles(fRecParticlesTitle) ;
1417 rpabranch->SetAddress(RecParticlesRef(fRecParticlesTitle)) ;
1418 rpabranch->GetEntry(0) ;
1419
1420 // Read and Post the PID
1421 if(!PID(fRecParticlesTitle))
1422 PostPID(fRecParticlesTitle) ;
1423 pidbranch->SetAddress(PIDRef(fRecParticlesTitle)) ;
4ae78bb1 1424 pidbranch->GetEntry(0) ;
4ae78bb1 1425
4ae78bb1 1426
1427}
1428
1429//____________________________________________________________________________
b0bba0af 1430void AliPHOSGetter::ReadTreeS(Int_t event)
4ae78bb1 1431{
1432 // Read the summable digits tree gAlice->TreeS()
b0bba0af 1433
1434 // loop over all opened files and read their SDigits to the White Board
7a9d98f9 1435 TFolder * phosF = dynamic_cast<TFolder *>(fSDigitsFolder->FindObject("PHOS")) ;
1436 if (!phosF)
1437 phosF = fSDigitsFolder->AddFolder("PHOS", "SDigits from PHOS") ;
b0bba0af 1438 TCollection * folderslist = phosF->GetListOfFolders() ;
1439
1440 //Add current file to list if it is not there yet
1441 if ( (fHeaderFile != "aliroot") && ( !folderslist->Contains(fHeaderFile) ) ){
1442 phosF->AddFolder(fHeaderFile, "");
b0bba0af 1443 }
7a9d98f9 1444
b0bba0af 1445 TIter next(folderslist) ;
1446 TFolder * folder = 0 ;
1447 TFile * file;
1448 TTree * treeS = 0;
7a9d98f9 1449 while ( (folder = static_cast<TFolder*>(next())) ) {
b0bba0af 1450 if(fHeaderFile.CompareTo(folder->GetName()) == 0 )
1451 treeS=gAlice->TreeS() ;
1452 else{
7a9d98f9 1453 cout << " AliPHOSGetter::ReadTreeS 2 " << folder->GetName() << endl ;
1454 file = static_cast<TFile*>(gROOT->GetFile(folder->GetName()));
b0bba0af 1455 file->cd() ;
1456
1457 // Get SDigits Tree header from file
1458 TString treeName("TreeS") ;
1459 treeName += event ;
7a9d98f9 1460 treeS = dynamic_cast<TTree*>(gDirectory->Get(treeName.Data()));
b0bba0af 1461 }
1462 if(treeS==0){
1463 cerr << "ERROR: AliPHOSGetter::ReadTreeS There is no SDigit Tree" << endl;
1464 return ;
1465 }
1466
1467 //set address of the SDigits and SDigitizer
1468 TBranch * sdigitsBranch = 0;
1469 TBranch * sdigitizerBranch = 0;
1470 TBranch * branch = 0 ;
7a9d98f9 1471 TObjArray * lob = static_cast<TObjArray*>(treeS->GetListOfBranches()) ;
b0bba0af 1472 TIter next(lob) ;
1473 Bool_t phosfound = kFALSE, sdigitizerfound = kFALSE ;
1474
7a9d98f9 1475 while ( (branch = static_cast<TBranch*>(next())) && (!phosfound || !sdigitizerfound) ) {
b0bba0af 1476 if ( (strcmp(branch->GetName(), "PHOS")==0) && (strcmp(branch->GetTitle(), fSDigitsTitle)==0) ) {
1477 phosfound = kTRUE ;
1478 sdigitsBranch = branch ;
1479 }
1480
1481 else if ( (strcmp(branch->GetName(), "AliPHOSSDigitizer")==0) && (strcmp(branch->GetTitle(), fSDigitsTitle)==0) ) {
1482 sdigitizerfound = kTRUE ;
1483 sdigitizerBranch = branch ;
1484 }
1485 }
1486 if ( !phosfound || !sdigitizerfound ) {
7a9d98f9 1487 if (fDebug)
1488 cout << "WARNING: AliPHOSDigitizer::ReadSDigits -> Digits and/or Digitizer branch with name " << GetName()
1489 << " not found" << endl ;
b0bba0af 1490 return ;
1491 }
1492
1493 if ( !folder->FindObject(fSDigitsTitle) )
1494 PostSDigits(fSDigitsTitle,folder->GetName()) ;
1495 sdigitsBranch->SetAddress(SDigitsRef(fSDigitsTitle,folder->GetName())) ;
1496 sdigitsBranch->GetEntry(0) ;
1497
1498 TString sdname(fSDigitsTitle) ;
1499 sdname+=":" ;
1500 sdname+=folder->GetName() ;
1501 if(!SDigitizer(sdname) )
1502 PostSDigitizer(fSDigitsTitle,folder->GetName()) ;
1503 sdigitizerBranch->SetAddress(SDigitizerRef(sdname)) ;
1504 sdigitizerBranch->GetEntry(0) ;
1505
1506 }
1507
1508 // After SDigits have been read from all files, return to the first one
1509
1510 next.Reset();
7a9d98f9 1511 folder = static_cast<TFolder*>(next());
b0bba0af 1512 if(folder){
7a9d98f9 1513 file = static_cast<TFile*>(gROOT->GetFile(folder->GetName()));
b0bba0af 1514 file ->cd() ;
4ae78bb1 1515 }
1516
b0bba0af 1517}
1518//____________________________________________________________________________
1519void AliPHOSGetter::ReadTreeS(TTree * treeS, Int_t input)
1520{ // Read the summable digits fron treeS()
1521
7a9d98f9 1522
b0bba0af 1523 TString filename("mergefile") ;
1524 filename+= input ;
7a9d98f9 1525
1526 TFolder * phosFolder = dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("PHOS")) ;
1527 if ( !phosFolder ) {
1528 phosFolder = fSDigitsFolder->AddFolder("PHOS", "SDigits from PHOS") ;
1529 }
1530 TFolder * folder=(TFolder*)phosFolder->FindObject(filename) ;
b0bba0af 1531 //set address of the SDigits and SDigitizer
1532 TBranch * sdigitsBranch = 0;
1533 TBranch * sdigitizerBranch = 0;
1534 TBranch * branch = 0 ;
1535 TObjArray * lob = (TObjArray*)treeS->GetListOfBranches() ;
4ae78bb1 1536 TIter next(lob) ;
4ae78bb1 1537 Bool_t phosfound = kFALSE, sdigitizerfound = kFALSE ;
1538
1539 while ( (branch = (TBranch*)next()) && (!phosfound || !sdigitizerfound) ) {
b0bba0af 1540 if ( strcmp(branch->GetName(), "PHOS")==0) {
4ae78bb1 1541 phosfound = kTRUE ;
b0bba0af 1542 sdigitsBranch = branch ;
4ae78bb1 1543 }
b0bba0af 1544
1545 else if ( strcmp(branch->GetName(), "AliPHOSSDigitizer")==0) {
4ae78bb1 1546 sdigitizerfound = kTRUE ;
b0bba0af 1547 sdigitizerBranch = branch ;
4ae78bb1 1548 }
1549 }
4ae78bb1 1550 if ( !phosfound || !sdigitizerfound ) {
7a9d98f9 1551 if (fDebug)
1552 cout << "WARNING: AliPHOSGetter::ReadTreeS -> Digits and/or Digitizer branch not found" << endl ;
4ae78bb1 1553 return ;
1554 }
4ae78bb1 1555
b0bba0af 1556 if (!folder || !(folder->FindObject(sdigitsBranch->GetTitle()) ) )
1557 PostSDigits(sdigitsBranch->GetTitle(),filename) ;
4ae78bb1 1558
b0bba0af 1559 sdigitsBranch->SetAddress(SDigitsRef(sdigitsBranch->GetTitle(),filename)) ;
1560
1561 TString sdname(sdigitsBranch->GetTitle()) ;
1562 sdname+=":" ;
1563 sdname+=filename ;
1564 if(!SDigitizer(sdigitsBranch->GetTitle()) )
1565 PostSDigitizer(sdigitsBranch->GetTitle(),filename) ;
1566 sdigitizerBranch->SetAddress(SDigitizerRef(sdname)) ;
1567
1568 sdigitsBranch->GetEntry(0) ;
1569 sdigitizerBranch->GetEntry(0) ;
1570
1571}
4ae78bb1 1572
4ae78bb1 1573
1574//____________________________________________________________________________
1575void AliPHOSGetter::ReadPrimaries()
1576{
1577 // Reads specific branches of primaries
1578
1579 fNPrimaries = gAlice->GetNtrack();
1580
1581 // //Check, is it necessary to open new files
1582 // TArrayI* events = fDigitizer->GetCurrentEvents() ;
1583 // TClonesArray * filenames = fDigitizer->GetHeadersFiles() ;
1584// Int_t input ;
1585// for(input = 0; input < filenames->GetEntriesFast(); input++){
1586
1587// TObjString * filename = (TObjString *) filenames->At(input) ;
1588
1589// //Test, if this file already open
1590// TFile *file = (TFile*) gROOT->GetFile( filename->GetString() ) ;
1591// if(file == 0)
1592// file = new TFile( filename->GetString()) ;
1593// file->cd() ;
1594
1595// // Get Kine Tree from file
1596// // char treeName[20];
1597// // sprintf(treeName,"TreeK%d",events->At(input));
1598// // TTree * treeK = (TTree*)gDirectory->Get(treeName);
1599// // if (treeK)
1600// // treeK->SetBranchAddress("Particles", &fParticleBuffer);
1601// // else
1602// // cout << "AliPHOSGetter: cannot find Kine Tree for event:" << events->At(input) << endl;
1603
1604// // // Create the particle stack
1605// // if(!fParticles) fParticles = new TClonesArray("TParticle",1000);
1606// // // Build the pointer list
1607// // if(fParticleMap) { <----
1608// // fParticleMap->Clear();
1609// // fParticleMap->Expand(treeK->GetEntries());
1610// // } else
1611// // fParticleMap = new TObjArray(treeK->GetEntries());
1612
1613// // From gAlice->Particle(i)
1614
1615
1616// // if(!(*fParticleMap)[i]) {
1617// // Int_t nentries = fParticles->GetEntries();
1618
1619// // // algorithmic way of getting entry index
1620// // // (primary particles are filled after secondaries)
1621// // Int_t entry;
1622// // if (i<fHeader.GetNprimary())
1623// // entry = i+fHeader.GetNsecondary();
1624// // else
1625// // entry = i-fHeader.GetNprimary();
1626
1627// // // only check the algorithmic way and give
1628// // // the fatal error if it is wrong
1629// // if (entry != fParticleFileMap[i]) {
1630// // Fatal("Particle",
1631// // "!!!! The algorithmic way is WRONG: !!!\n entry: %d map: %d",
1632// // entry, fParticleFileMap[i]);
1633// // }
1634
1635// // fTreeK->GetEntry(fParticleFileMap[i]);
1636// // new ((*fParticles)[nentries]) TParticle(*fParticleBuffer);
1637// // fParticleMap->AddAt((*fParticles)[nentries],i);
1638// // }
1639// // return (TParticle *) (*fParticleMap)[i];
1640
1641
1642
1643// }
1644
1645
1646// //scan over opened files and read corresponding TreeK##
1647
1648 return ;
1649}
1650//____________________________________________________________________________
cbfb577a 1651void AliPHOSGetter::Event(const Int_t event, const char* opt)
4ae78bb1 1652{
1653 // Reads the content of all Tree's S, D and R
1654
7a9d98f9 1655 if (event >= gAlice->TreeE()->GetEntries() ) {
1656 cerr << "ERROR: AliPHOSGetter::Event -> " << event << " not found in TreeE!" << endl ;
1657 return ;
4ae78bb1 1658 }
4ae78bb1 1659 gAlice->GetEvent(event) ;
dbad285c 1660
b0bba0af 1661 if(strstr(opt,"H") )
1662 ReadTreeH() ;
1663
1664 if(strstr(opt,"S") )
1665 ReadTreeS(event) ;
1666
1667 if( strstr(opt,"D") )
1668 ReadTreeD() ;
1669
1670 if( strstr(opt,"R") )
1671 ReadTreeR() ;
1672
1673 if( strstr(opt,"Q") )
1674 ReadTreeQA() ;
1675
1676 if( strstr(opt,"P") )
1677 ReadPrimaries() ;
1678
4ae78bb1 1679}
1680
1681//____________________________________________________________________________
1682const TObject * AliPHOSGetter::ReturnO(TString what, TString name, TString file) const
1683{
1684 // get the object named "what" from the folder
7a9d98f9 1685 // folders are named like //Folders
4ae78bb1 1686
1687 if ( file.IsNull() )
1688 file = fHeaderFile ;
7a9d98f9 1689
1690 TFolder * folder = 0 ;
1691 TObject * phosO = 0 ;
1692
1693 // if ( name.IsNull() ) {
1694 if ( what.CompareTo("Hits") == 0 ) {
1695 folder = dynamic_cast<TFolder *>(fHitsFolder->FindObject("PHOS")) ;
1696 if (folder)
1697 phosO = dynamic_cast<TObject *>(folder->FindObject("Hits")) ;
1698 }
1699 else if ( what.CompareTo("SDigits") == 0 ) {
1700 TString path = "PHOS/" + file ;
1701 folder = dynamic_cast<TFolder *>(fSDigitsFolder->FindObject(path.Data())) ;
1702 if (folder) {
1703 if (name.IsNull())
1704 name = fSDigitsTitle ;
1705 phosO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
4ae78bb1 1706 }
7a9d98f9 1707 }
1708 else if ( what.CompareTo("Digits") == 0 ){
1709 folder = dynamic_cast<TFolder *>(fDigitsFolder->FindObject("PHOS")) ;
1710 if (folder) {
1711 if (name.IsNull())
1712 name = fDigitsTitle ;
1713 phosO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
4ae78bb1 1714 }
7a9d98f9 1715 }
1716 else if ( what.CompareTo("EmcRecPoints") == 0 ) {
1717 folder = dynamic_cast<TFolder *>(fRecoFolder->FindObject("PHOS/EMCARecPoints")) ;
1718 if (folder) {
1719 if (name.IsNull())
1720 name = fRecPointsTitle ;
1721 phosO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
4ae78bb1 1722 }
7a9d98f9 1723 }
1724 else if ( what.CompareTo("CpvRecPoints") == 0 ) {
1725 folder = dynamic_cast<TFolder *>(fRecoFolder->FindObject("PHOS/CPVRecPoints")) ;
1726 if (folder) {
1727 if (name.IsNull())
1728 name = fRecPointsTitle ;
1729 phosO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1730 }
1731 }
1732 else if ( what.CompareTo("TrackSegments") == 0 ) {
1733 folder = dynamic_cast<TFolder *>(fRecoFolder->FindObject("PHOS/TrackSegments")) ;
1734 if (folder) {
1735 if (name.IsNull())
1736 name = fTrackSegmentsTitle ;
1737 phosO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1738 }
1739 }
1740 else if ( what.CompareTo("RecParticles") == 0 ) {
1741 folder = dynamic_cast<TFolder *>(fRecoFolder->FindObject("PHOS/RecParticles")) ;
1742 if (folder) {
1743 if (name.IsNull())
1744 name = fRecParticlesTitle ;
1745 phosO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1746 }
1747 }
1748 else if ( what.CompareTo("Alarms") == 0 ){
1749 if (name.IsNull() )
1750 phosO = dynamic_cast<TObject *>(fQAFolder->FindObject("PHOS")) ;
1751 else {
1752 folder = dynamic_cast<TFolder *>(fQAFolder->FindObject("PHOS")) ;
1753 if (!folder)
1754 phosO = 0 ;
1755 else
1756 phosO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
4ae78bb1 1757 }
4ae78bb1 1758 }
4ae78bb1 1759 if (!phosO) {
b0bba0af 1760 if(fDebug)
7a9d98f9 1761 cerr << "ERROR : AliPHOSGetter::ReturnO -> Object " << what << " not found in " << folder->GetName() << endl ;
b0bba0af 1762 return 0 ;
4ae78bb1 1763 }
1764 return phosO ;
1765}
1766
1767//____________________________________________________________________________
1768const TTask * AliPHOSGetter::ReturnT(TString what, TString name) const
1769{
1770 // get the TTask named "what" from the folder
7a9d98f9 1771 // folders are named like //Folders/Tasks/what/PHOS/name
4ae78bb1 1772
7a9d98f9 1773 TString search(what) ;
1774 if ( what.CompareTo("Clusterizer") == 0 )
1775 search = "Reconstructioner" ;
4ae78bb1 1776 else if ( what.CompareTo("TrackSegmentMaker") == 0 )
7a9d98f9 1777 search = "Reconstructioner" ;
4ae78bb1 1778 else if ( what.CompareTo("PID") == 0 )
7a9d98f9 1779 search = "Reconstructioner" ;
eb9763ac 1780 else if ( what.CompareTo("QATasks") == 0 )
7a9d98f9 1781 search = "QA" ;
4ae78bb1 1782
7a9d98f9 1783 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject(search)) ;
4ae78bb1 1784
7a9d98f9 1785 if (!tasks) {
1786 cerr << "ERROR: AliPHOSGetter::ReturnT -> Task " << what << " not found!" << endl ;
1787 return 0 ;
4ae78bb1 1788 }
1789
7a9d98f9 1790 TTask * phosT = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
4ae78bb1 1791 if (!phosT) {
7a9d98f9 1792 cerr << "ERROR: AliPHOSGetter::ReturnT -> Task " << what << "/PHOS not found!" << endl ;
1793 return 0 ;
4ae78bb1 1794 }
7a9d98f9 1795
1796 TList * list = phosT->GetListOfTasks() ;
4ae78bb1 1797
1798 if (what.CompareTo("SDigitizer") == 0) {
1799 if ( name.IsNull() )
1800 name = fSDigitsTitle ;
1801 } else if (what.CompareTo("Digitizer") == 0){
1802 if ( name.IsNull() )
1803 name = fDigitsTitle ;
1804 } else if (what.CompareTo("Clusterizer") == 0){
1805 if ( name.IsNull() )
1806 name = fRecPointsTitle ;
b0bba0af 1807 name.Append(":clu") ;
4ae78bb1 1808 }
1809 else if (what.CompareTo("TrackSegmentMaker") == 0){
1810 if ( name.IsNull() )
1811 name = fTrackSegmentsTitle ;
b0bba0af 1812 name.Append(":tsm") ;
4ae78bb1 1813 }
1814 else if (what.CompareTo("PID") == 0){
1815 if ( name.IsNull() )
1816 name = fRecParticlesTitle ;
b0bba0af 1817 name.Append(":pid") ;
4ae78bb1 1818 }
b0bba0af 1819 else if (what.CompareTo("QATasks") == 0){
eb9763ac 1820 if ( name.IsNull() )
1821 return phosT ;
1822 }
4ae78bb1 1823
7a9d98f9 1824 TIter it(list) ;
b0bba0af 1825 TTask * task = 0 ;
7a9d98f9 1826 while((task = static_cast<TTask *>(it.Next()) )){
b0bba0af 1827 TString taskname(task->GetName()) ;
1828 if(taskname.BeginsWith(name))
1829 return task ;
1830 }
1831
1832 if(fDebug)
7a9d98f9 1833 cout << "WARNING: AliPHOSGetter::ReturnT -> Task " << search << "/" << name << " not found!" << endl ;
b0bba0af 1834 return 0 ;
4ae78bb1 1835}