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