1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 //_________________________________________________________________________
19 // A singleton. This class should be used on the analysiz stage to get
20 // reconstructed objects: Digits, RecPoints, TrackSegments and RecParticles,
21 // instead of direct reading them from galice.root file. This container
22 // ensures, that one reads Digits, made of these particular digits RecPoints,
23 // made of these particlar RecPoints TrackSegments and RecParticles, what is
24 // not trivial if there are several identical branches, but produced with
25 // different set of parameters.
27 // An example of use (see as well class AliPHOSAnalyser):
28 // AliPHOSIndexToObject * please = AliPHOSIndexToObject::GetInstance("galice.root","RecParticles","") ;
29 // for(Int_t irecp = 0; irecp < please->GimeNRecParticles() ; irecp++)
30 // AliPHOSRecParticle * part = please->GimeRecParticle(1) ;
32 // please->GetEvent(event) ; // reads new event from galice.root
34 //*-- Author: Yves Schutz (SUBATECH) & Dmitri Peressounko (RRC KI & SUBATECH)
35 //*-- Complitely redesigned by Dmitri Peressounko March 2001
36 //////////////////////////////////////////////////////////////////////////////
39 // --- ROOT system ---
44 #include "TObjString.h"
46 // --- Standard library ---
49 // --- AliRoot header files ---
52 #include "AliPHOSIndexToObject.h"
53 #include "AliPHOSDigitizer.h"
54 #include "AliPHOSClusterizer.h"
55 #include "AliPHOSTrackSegmentMaker.h"
56 #include "AliPHOSPID.h"
58 ClassImp(AliPHOSIndexToObject)
60 AliPHOSIndexToObject * AliPHOSIndexToObject::fgObjGetter = 0 ;
62 //____________________________________________________________________________
63 AliPHOSIndexToObject::AliPHOSIndexToObject(char* headerFile,char* branch,char* branchTitle )
68 fDigits = new TClonesArray("AliPHOSDigit",100) ;
69 fEmcRecPoints = new TObjArray(100) ;
70 fCpvRecPoints = new TObjArray(100) ;
71 fTS = new TClonesArray("AliPHOSTrackSegment",100) ;
72 fRecParticles = new TClonesArray("AliPHOSRecParticle",100) ;
73 fPrimaries = new TObjArray(1) ;
81 fHeaderFile = headerFile ;
82 TFile * file = (TFile*) gROOT->GetFile(fHeaderFile.Data() ) ;
85 if(fHeaderFile.Contains("rfio")) // if we read file using HPSS
86 file = TFile::Open(fHeaderFile.Data(),"update") ;
88 file = new TFile(fHeaderFile.Data(),"update") ;
89 gAlice = (AliRun *) file->Get("gAlice") ;
92 fMaxEvent = (Int_t) gAlice->TreeE()->GetEntries() ;
94 char * dummyfile = 0 ;
96 gAlice->GetEvent(fEvent) ;
98 Bool_t isRead = kFALSE;
100 if((strcmp(branch,"PHOSRP")==0) || (strcmp(branch,"PHOSPID")==0)){
101 ReadRecParticles(branchTitle) ; //first read RecPartcles and branche TS from which they are made
102 ReadTS(dummyfile); //read TS from which made RecParticles above
103 ReadRecPoints(dummyfile) ; //RecPoints from which TS above made
104 ReadDigits(dummyfile) ; //digits. from whic RecPoints made
108 if((strcmp(branch,"PHOSTS")==0) || (strcmp(branch,"PHOSTSMaker")==0)){
109 ReadTS(branchTitle); //read TS and branch of RecPoints from which they are made
110 ReadRecPoints(dummyfile) ; //recpoints abd branch of digits
111 ReadDigits(dummyfile) ; //digits and branch of Primaries
112 ReadRecParticles(dummyfile) ; //posiible completion of TS
116 if((strcmp(branch,"PHOSEmcRP")==0)|| (strcmp(branch,"PHOSCpvRP")==0) ||
117 (strcmp(branch,"PHOSClusterizer")==0)){
118 ReadRecPoints(branchTitle) ; //RecPoints and Digits branch filename
119 ReadDigits(dummyfile) ; //digits and primary file name
120 ReadTS(dummyfile); //possible completion of RecPoints
121 ReadRecParticles(dummyfile) ; //possible completion of TS
125 if((strcmp(branch,"PHOS")==0) || (strcmp(branch,"PHOSDigitizer")==0)){
126 ReadDigits(branchTitle) ;
127 ReadRecPoints(dummyfile) ;
129 ReadRecParticles(dummyfile) ;
134 cout << "AliPHOSIndexToObject: wrong branch name specified: " << branch << endl ;
135 cout << " avalilable names are `PHOSRP', `PHOSPID'"<<endl ;
136 cout << " `PHOSTS', `PHOSTSMaker'"<<endl ;
137 cout << " `PHOSEmcRP', `PHOSCpvRP', `PHOSClusterizer'"<< endl ;
138 cout << " `PHOS' and `PHOSDigitizer'"<< endl ;
140 ReadPrimaries() ; // should be called when digits are already read
143 //____________________________________________________________________________
144 AliPHOSIndexToObject * AliPHOSIndexToObject::GetInstance()
146 // Returns the pointer of the unique instance already defined
148 AliPHOSIndexToObject * rv = 0 ;
152 cout << "AliPHOSIndexToObject::GetInstance ERROR: not yet initialized" << endl ;
157 //____________________________________________________________________________
158 AliPHOSIndexToObject * AliPHOSIndexToObject::GetInstance(char* headerFile,char* branch,char* branchTitle)
160 // Creates and returns the pointer of the unique instance
161 // Must be called only when the environment has changed
163 if ( fgObjGetter ) // delete it if already exists
166 fgObjGetter = new AliPHOSIndexToObject(headerFile,branch,branchTitle) ;
172 //____________________________________________________________________________
173 TParticle * AliPHOSIndexToObject::GimePrimary(Int_t index)
177 Int_t primaryList = (Int_t) (TMath::Ceil(index/10000000.) ) - 1 ;
178 Int_t primaryIndex = index - primaryList*10000000 ;
180 if ( primaryList > 0 ) {
181 cout << " IndexToObject does not support currently Mixing of primary " << endl ;
182 cout << " can not return primary: " << index<< " (list "<< primaryList<< " primary # " << primaryIndex << " )"<<endl ;
186 return gAlice->Particle(primaryIndex) ;
190 //____________________________________________________________________________
191 Bool_t AliPHOSIndexToObject::ReadRecParticles(char * branchTitle){
193 if(gAlice->TreeR()==0)
196 if(fPID) // already read
197 branchTitle = fPID->GetRecParticlesBranch() ;
200 if(branchTitle){ // we should read a specific branch
201 TBranch * pidBranch = 0;
202 TBranch * rpBranch = 0;
204 TObjArray * branches = gAlice->TreeR()->GetListOfBranches() ;
206 Bool_t pidNotFound = kTRUE ;
207 Bool_t rpNotFound = kTRUE ;
209 for(ibranch = 0;(ibranch <branches->GetEntries())&&(pidNotFound||rpNotFound);ibranch++){
212 pidBranch=(TBranch *) branches->At(ibranch) ;
213 if( (strcmp(branchTitle,pidBranch->GetTitle())==0 ) &&
214 (strcmp(pidBranch->GetName(),"AliPHOSPID") == 0) )
215 pidNotFound = kFALSE ;
218 rpBranch=(TBranch *) branches->At(ibranch) ;
219 if( (strcmp(branchTitle,rpBranch->GetTitle())==0 ) &&
220 (strcmp(rpBranch->GetName(),"PHOSRP") == 0) )
221 rpNotFound = kFALSE ;
225 if(pidNotFound ||rpNotFound ){
226 cout << "AliPHOSIndexToObject error" << endl ;
227 cout << " Can't find Branch with PID and RecParticles " ;
231 pidBranch->SetAddress(&fPID) ;
232 rpBranch->SetAddress(&fRecParticles) ;
233 gAlice->TreeR()->GetEvent(0) ;
235 else{ //we Should read any branch and print warning if there are other possibilities
236 if(fTSMaker){//if TrackSegments already read, we should read RecParticles Made from it
237 TBranch * pidBranch = 0;
238 TBranch * rpBranch = 0;
240 TObjArray * branches = gAlice->TreeR()->GetListOfBranches() ;
242 Int_t branchRead = 0;
243 Bool_t allNotFound = kTRUE ;
245 Bool_t pidNotFound = kTRUE ;
246 Bool_t rpNotFound = kTRUE ;
248 for(ibranch = branchRead;(ibranch <branches->GetEntries() )&& pidNotFound;ibranch++){
249 pidBranch=(TBranch *) branches->At(ibranch) ;
250 if(strcmp(pidBranch->GetName(),"AliPHOSPID") == 0)
251 pidNotFound = kFALSE ;
253 branchRead = ibranch +1 ;
254 for(ibranch = 0 ;(ibranch <branches->GetEntries() )&& rpNotFound;ibranch++){
255 rpBranch=(TBranch *) branches->At(ibranch) ;
256 if( (strcmp(pidBranch->GetTitle(),rpBranch->GetTitle())==0 ) &&
257 (strcmp(rpBranch->GetName(),"PHOSRP") == 0) )
258 rpNotFound = kFALSE ;
261 if(pidNotFound ||rpNotFound ){
262 cout << "AliPHOSIndexToObject error" << endl ;
263 cout << " Can't find Branch with PID and RecParticles " ;
267 pidBranch->SetAddress(&fPID) ;
268 rpBranch->SetAddress(&fRecParticles) ;
269 gAlice->TreeR()->GetEvent(0) ;
271 if(strcmp(fTSMaker->GetTrackSegmentsBranch(),fPID->GetTrackSegmentsBranch()) == 0)
272 allNotFound = kFALSE ;
275 else{//we read any (first) recparticles
276 TBranch * pidBranch = 0;
277 TBranch * rpBranch = 0;
278 TObjArray * branches = gAlice->TreeR()->GetListOfBranches() ;
280 Bool_t pidNotFound = kTRUE ;
281 Bool_t rpNotFound = kTRUE ;
283 for(ibranch = 0;(ibranch <branches->GetEntries() )&& pidNotFound;ibranch++){
284 pidBranch=(TBranch *) branches->At(ibranch) ;
285 if(strcmp(pidBranch->GetName(),"AliPHOSPID") == 0)
286 pidNotFound = kFALSE ;
288 for(ibranch = 0 ;(ibranch <branches->GetEntries() )&& rpNotFound;ibranch++){
289 rpBranch=(TBranch *) branches->At(ibranch) ;
290 if( (strcmp(pidBranch->GetTitle(),rpBranch->GetTitle())==0 ) &&
291 (strcmp(rpBranch->GetName(),"PHOSRP") == 0) )
292 rpNotFound = kFALSE ;
295 if(pidNotFound ||rpNotFound ){
296 cout << "AliPHOSIndexToObject worning: " << endl ;
297 cout << " Can't find Branch with PID and RecParticles " << endl;
301 pidBranch->SetAddress(&fPID) ;
302 rpBranch->SetAddress(&fRecParticles) ;
303 gAlice->TreeR()->GetEvent(0) ;
309 //____________________________________________________________________________
310 Bool_t AliPHOSIndexToObject::ReadTS(char * branchTitle){
312 if(gAlice->TreeR()==0)
315 if(fPID)//if RecParticles already read, we should read TS from which they are made
316 branchTitle= fPID->GetTrackSegmentsBranch() ;
318 if(branchTitle){ // we should read a specific branch
320 TBranch * tsMakerBranch = 0;
321 TBranch * tsBranch = 0;
323 TObjArray * branches = gAlice->TreeR()->GetListOfBranches() ;
325 Bool_t tsMakerNotFound = kTRUE ;
326 Bool_t tsNotFound = kTRUE ;
328 for(ibranch = 0;(ibranch <branches->GetEntries())&&(tsMakerNotFound||tsNotFound);ibranch++){
330 tsMakerBranch=(TBranch *) branches->At(ibranch) ;
331 if( strcmp(branchTitle,tsMakerBranch->GetTitle())==0 )
332 if( strcmp(tsMakerBranch->GetName(),"AliPHOSTrackSegmentMaker") == 0)
333 tsMakerNotFound = kFALSE ;
336 tsBranch=(TBranch *) branches->At(ibranch) ;
337 if( strcmp(branchTitle,tsBranch->GetTitle())==0 )
338 if( strcmp(tsBranch->GetName(),"PHOSTS") == 0)
339 tsNotFound = kFALSE ;
343 if(tsMakerNotFound ||tsNotFound ){
344 cout << "AliPHOSIndexToObject error" << endl ;
345 cout << " Can't find Branch with TrackSegmentMaker and TrackSegments " ;
346 cout << " Do nothing" <<endl ;
350 tsMakerBranch->SetAddress(&fTSMaker) ;
351 tsBranch->SetAddress(&fTS) ;
352 gAlice->TreeR()->GetEvent(0) ;
356 if(fClusterizer){//Clusterizer aready read,
357 //we should read TrackSegments made from these RecPoints
359 Int_t branchRead = 0 ;
360 TBranch * tsMakerBranch = 0;
361 TBranch * tsBranch = 0;
363 TObjArray * branches = gAlice->TreeR()->GetListOfBranches() ;
365 Bool_t allNotFound = kTRUE ;
367 Bool_t tsMakerNotFound = kTRUE ;
368 Bool_t tsNotFound = kTRUE ;
370 for(ibranch = branchRead;(ibranch <branches->GetEntries())&&(tsMakerNotFound);ibranch++){
371 tsMakerBranch=(TBranch *) branches->At(ibranch) ;
372 if( strcmp(tsMakerBranch->GetName(),"AliPHOSTrackSegmentMaker") == 0)
373 tsMakerNotFound = kFALSE ;
375 branchRead = ibranch++ ;
376 for(ibranch = 0 ;(ibranch <branches->GetEntries())&&(tsNotFound);ibranch++){
377 tsBranch=(TBranch *) branches->At(ibranch) ;
378 if( (strcmp(tsBranch->GetName(),"PHOSTS") == 0) &&
379 (strcmp(tsBranch->GetName(),tsMakerBranch->GetTitle())==0))
380 tsNotFound = kFALSE ;
383 branchRead = ibranch++ ;
385 if(tsMakerNotFound ||tsNotFound ){
386 cout << "AliPHOSIndexToObject error" << endl ;
387 cout << " Can't find Branch with TrackSegmentMaker and TrackSegments " ;
388 cout << " Do nothing" <<endl ;
392 tsMakerBranch->SetAddress(&fTSMaker) ;
393 tsBranch->SetAddress(&fTS) ;
394 gAlice->TreeR()->GetEvent(0) ;
396 if(strcmp(fTSMaker->GetRecPointsBranch(),fClusterizer->GetRecPointsBranch()) == 0)
397 allNotFound = kFALSE ;
401 else{//Neither Title,neither fPID, neither fClusterizer: we read any (first) occurence
402 TBranch * tsMakerBranch = 0;
403 TBranch * tsBranch = 0;
404 TObjArray * branches = gAlice->TreeR()->GetListOfBranches() ;
405 Bool_t tsMakerNotFound = kTRUE ;
406 Bool_t tsNotFound = kTRUE ;
408 for(ibranch = 0;(ibranch <branches->GetEntries())&& tsMakerNotFound;ibranch++){
409 tsMakerBranch=(TBranch *) branches->At(ibranch) ;
410 if( strcmp(tsMakerBranch->GetName(),"AliPHOSTrackSegmentMaker") == 0)
411 tsMakerNotFound = kFALSE ;
413 for(ibranch = 0 ;(ibranch <branches->GetEntries())&&(tsNotFound);ibranch++){
414 tsBranch=(TBranch *) branches->At(ibranch) ;
415 if( (strcmp(tsBranch->GetName(),"PHOSTS") == 0) &&
416 (strcmp(tsBranch->GetName(),tsMakerBranch->GetTitle())==0))
417 tsNotFound = kFALSE ;
419 if(tsMakerNotFound ||tsNotFound ){
420 cout << "AliPHOSIndexToObject error" << endl ;
421 cout << " Can't find Branch with TrackSegmentMaker and TrackSegments " ;
422 cout << " Do nothing" <<endl ;
426 tsMakerBranch->SetAddress(&fTSMaker) ;
427 tsBranch->SetAddress(&fTS) ;
428 gAlice->TreeR()->GetEvent(0) ;
434 //____________________________________________________________________________
435 Bool_t AliPHOSIndexToObject::ReadRecPoints(char * branchTitle){
437 if(gAlice->TreeR() == 0)
440 if(fTSMaker) //if TrackSegment maker already read, read corresponding branches
441 branchTitle = fTSMaker->GetRecPointsBranch() ;
443 if(branchTitle){ // we should read a specific branch
444 TBranch * emcBranch = 0;
445 TBranch * cpvBranch = 0;
446 TBranch * clusterizerBranch = 0;
448 TObjArray * branches = gAlice->TreeR()->GetListOfBranches() ;
450 Bool_t emcNotFound = kTRUE ;
451 Bool_t cpvNotFound = kTRUE ;
452 Bool_t clusterizerNotFound = kTRUE ;
454 for(ibranch = 0;((ibranch < branches->GetEntries())&&(emcNotFound ||cpvNotFound || clusterizerNotFound)) ;ibranch++){
456 emcBranch=(TBranch *) branches->At(ibranch) ;
457 if( (strcmp(emcBranch->GetTitle(),branchTitle) == 0) &&
458 (strcmp(emcBranch->GetName(),"PHOSEmcRP") == 0) )
459 emcNotFound = kFALSE ;
462 cpvBranch=(TBranch *) branches->At(ibranch) ;
463 if( (strcmp(cpvBranch->GetTitle(),branchTitle) == 0) &&
464 (strcmp(cpvBranch->GetName(),"PHOSCpvRP") == 0) )
465 cpvNotFound = kFALSE ;
467 if(clusterizerNotFound){
468 clusterizerBranch = (TBranch *) branches->At(ibranch) ;
469 if( (strcmp(clusterizerBranch->GetTitle(),branchTitle) == 0) &&
470 (strcmp(clusterizerBranch->GetName(),"AliPHOSClusterizer") == 0) )
471 clusterizerNotFound = kFALSE ;
476 if(clusterizerNotFound || emcNotFound || cpvNotFound){
477 cout << "AliPHOSIndexToObject error" << endl ;
478 cout << " Can't find Branch with RecPoints or Clusterizer " << endl ;
482 emcBranch->SetAddress(&fEmcRecPoints) ;
483 cpvBranch->SetAddress(&fCpvRecPoints) ;
484 clusterizerBranch->SetAddress(&fClusterizer) ;
485 gAlice->TreeR()->GetEvent(0) ;
487 else{ //no specific branch
488 if(fDigitizer){//Digitizer aready read,
489 //we should read RecPoints made from these Digits
490 TBranch * emcBranch = 0;
491 TBranch * cpvBranch = 0;
492 TBranch * clusterizerBranch = 0;
494 TObjArray * branches = gAlice->TreeR()->GetListOfBranches() ;
495 Int_t branchRead = 0;
496 Bool_t allNotFound = kTRUE ;
498 Bool_t emcNotFound = kTRUE ;
499 Bool_t cpvNotFound = kTRUE ;
500 Bool_t clusterizerNotFound = kTRUE ;
502 for(ibranch = branchRead;ibranch < branches->GetEntries();ibranch++){
503 emcBranch=(TBranch *) branches->At(ibranch) ;
504 if( strcmp(emcBranch->GetName(),"PHOSEmcRP") == 0)
505 emcNotFound = kFALSE ;
507 branchRead = ibranch + 1 ;
508 for(ibranch = 0 ;ibranch < branches->GetEntries();ibranch++){
509 cpvBranch=(TBranch *) branches->At(ibranch) ;
510 if( (strcmp(cpvBranch->GetTitle(),emcBranch->GetTitle()) == 0) &&
511 (strcmp(cpvBranch->GetName(),"PHOSCpvRP") == 0) )
512 cpvNotFound = kFALSE ;
514 for(ibranch = 0 ;ibranch < branches->GetEntries();ibranch++){
515 clusterizerBranch = (TBranch *) branches->At(ibranch) ;
516 if( (strcmp(clusterizerBranch->GetTitle(),emcBranch->GetTitle()) == 0) &&
517 (strcmp(clusterizerBranch->GetName(),"AliPHOSClusterizer") == 0) )
518 clusterizerNotFound = kFALSE ;
521 if(clusterizerNotFound || emcNotFound || cpvNotFound){
522 cout << "AliPHOSIndexToObject error" << endl ;
523 cout << " Can't find Branch with RecPoints or Clusterizer " << endl ;
527 emcBranch->SetAddress(&fEmcRecPoints) ;
528 cpvBranch->SetAddress(&fCpvRecPoints) ;
529 clusterizerBranch->SetAddress(&fClusterizer) ;
530 gAlice->TreeR()->GetEvent(0) ;
532 if(strcmp(fClusterizer->GetDigitsBranch(),fDigitizer->GetDigitsBranch())== 0)
533 allNotFound = kFALSE ;
536 else{//Neither Title, Neither TSMaker, Neither Digits: we read any (first) RecPoints
537 TBranch * emcBranch = 0;
538 TBranch * cpvBranch = 0;
539 TBranch * clusterizerBranch = 0;
540 TObjArray * branches = gAlice->TreeR()->GetListOfBranches() ;
541 Bool_t emcNotFound = kTRUE ;
542 Bool_t cpvNotFound = kTRUE ;
543 Bool_t clusterizerNotFound = kTRUE ;
545 for(ibranch = 0 ;ibranch < branches->GetEntries();ibranch++){
546 emcBranch=(TBranch *) branches->At(ibranch) ;
547 if( strcmp(emcBranch->GetName(),"PHOSEmcRP") == 0)
548 emcNotFound = kFALSE ;
550 for(ibranch = 0 ;ibranch < branches->GetEntries();ibranch++){
551 cpvBranch=(TBranch *) branches->At(ibranch) ;
552 if( (strcmp(cpvBranch->GetTitle(),emcBranch->GetTitle()) == 0) &&
553 (strcmp(cpvBranch->GetName(),"PHOSCpvRP") == 0) )
554 cpvNotFound = kFALSE ;
556 for(ibranch = 0;ibranch < branches->GetEntries();ibranch++){
557 clusterizerBranch = (TBranch *) branches->At(ibranch) ;
558 if( (strcmp(clusterizerBranch->GetTitle(),emcBranch->GetTitle()) == 0) &&
559 (strcmp(clusterizerBranch->GetName(),"AliPHOSClusterizer") == 0) )
560 clusterizerNotFound = kFALSE ;
563 if(clusterizerNotFound || emcNotFound || cpvNotFound){
564 cout << "AliPHOSIndexToObject error" << endl ;
565 cout << " Can't find Branch with RecPoints or Clusterizer " << endl ;
569 emcBranch->SetAddress(&fEmcRecPoints) ;
570 cpvBranch->SetAddress(&fCpvRecPoints) ;
571 clusterizerBranch->SetAddress(&fClusterizer) ;
572 gAlice->TreeR()->GetEvent(0) ;
578 //____________________________________________________________________________
579 Bool_t AliPHOSIndexToObject::ReadDigits(char * branchTitle){
581 if(gAlice->TreeD()== 0)
586 //if RecPoints are already read, we should read Digits from which they are made
588 branchTitle = fClusterizer->GetDigitsBranch() ;
590 if(branchTitle){ // we should read a specific branch
591 TBranch * digitsBranch = 0;
592 TBranch * digitizerBranch = 0;
594 TObjArray * branches = gAlice->TreeD()->GetListOfBranches() ;
596 Bool_t phosNotFound = kTRUE ;
597 Bool_t digitizerNotFound = kTRUE ;
599 for(ibranch = 0;ibranch <branches->GetEntries();ibranch++){
602 digitsBranch=(TBranch *) branches->At(ibranch) ;
603 if( (strcmp(digitsBranch->GetTitle(),branchTitle)==0 ) &&
604 (strcmp(digitsBranch->GetName(),"PHOS") == 0) )
605 phosNotFound = kFALSE ;
607 if(digitizerNotFound){
608 digitizerBranch = (TBranch *) branches->At(ibranch) ;
609 if( (strcmp(digitizerBranch->GetTitle(),branchTitle) == 0) &&
610 (strcmp(digitizerBranch->GetName(),"AliPHOSDigitizer") == 0) )
611 digitizerNotFound = kFALSE ;
615 if(digitizerNotFound || phosNotFound){
616 cout << "AliPHOSIndexToObject error: " << endl ;
617 cout << " Can't find Branch with Digits or Digitizer "<< endl ; ;
621 digitsBranch->SetAddress(&fDigits) ;
622 digitizerBranch->SetAddress(&fDigitizer) ;
625 else{ //we should read any branch and print warning if there are other possibilities
626 TBranch * digitsBranch = 0;
627 TBranch * digitizerBranch = 0;
629 TObjArray * branches = gAlice->TreeD()->GetListOfBranches() ;
631 Bool_t phosNotFound = kTRUE ;
632 Bool_t digitizerNotFound = kTRUE ;
634 for(ibranch = 0;(ibranch <branches->GetEntries())&& phosNotFound ;ibranch++){
635 digitsBranch=(TBranch *) branches->At(ibranch) ;
636 if(strcmp(digitsBranch->GetName(),"PHOS") == 0)
637 phosNotFound = kFALSE ;
639 for(ibranch = 0;(ibranch <branches->GetEntries())&& digitizerNotFound ;ibranch++){
640 digitizerBranch = (TBranch *) branches->At(ibranch) ;
641 if( (strcmp(digitizerBranch->GetTitle(),digitsBranch->GetTitle()) == 0) &&
642 (strcmp(digitizerBranch->GetName(),"AliPHOSDigitizer") == 0) )
643 digitizerNotFound = kFALSE ;
646 if(digitizerNotFound || phosNotFound){
647 cout << "AliPHOSIndexToObject error: " << endl ;
648 cout << " Can't find Branch with Digits or Digitizer "<< endl ; ;
652 digitsBranch->SetAddress(&fDigits) ;
653 digitizerBranch->SetAddress(&fDigitizer) ;
657 gAlice->TreeD()->GetEvent(0) ;
661 //____________________________________________________________________________
662 Bool_t AliPHOSIndexToObject::ReadPrimaries(){
663 //read specific branches of primaries
665 // //Check, is it necessary to open new files
666 // TArrayI* events = fDigitizer->GetCurrentEvents() ;
667 // TClonesArray * filenames = fDigitizer->GetHeadersFiles() ;
669 // for(input = 0; input < filenames->GetEntriesFast(); input++){
671 // TObjString * filename = (TObjString *) filenames->At(input) ;
673 // //Test, if this file already open
674 // TFile *file = (TFile*) gROOT->GetFile( filename->GetString() ) ;
676 // file = new TFile( filename->GetString()) ;
679 // // Get Kine Tree from file
680 // // char treeName[20];
681 // // sprintf(treeName,"TreeK%d",events->At(input));
682 // // TTree * treeK = (TTree*)gDirectory->Get(treeName);
684 // // treeK->SetBranchAddress("Particles", &fParticleBuffer);
686 // // cout << "AliPHOSIndexToObject: cannot find Kine Tree for event:" << events->At(input) << endl;
688 // // // Create the particle stack
689 // // if(!fParticles) fParticles = new TClonesArray("TParticle",1000);
690 // // // Build the pointer list
691 // // if(fParticleMap) { <----
692 // // fParticleMap->Clear();
693 // // fParticleMap->Expand(treeK->GetEntries());
695 // // fParticleMap = new TObjArray(treeK->GetEntries());
697 // // From gAlice->Particle(i)
700 // // if(!(*fParticleMap)[i]) {
701 // // Int_t nentries = fParticles->GetEntries();
703 // // // algorithmic way of getting entry index
704 // // // (primary particles are filled after secondaries)
706 // // if (i<fHeader.GetNprimary())
707 // // entry = i+fHeader.GetNsecondary();
709 // // entry = i-fHeader.GetNprimary();
711 // // // only check the algorithmic way and give
712 // // // the fatal error if it is wrong
713 // // if (entry != fParticleFileMap[i]) {
714 // // Fatal("Particle",
715 // // "!!!! The algorithmic way is WRONG: !!!\n entry: %d map: %d",
716 // // entry, fParticleFileMap[i]);
719 // // fTreeK->GetEntry(fParticleFileMap[i]);
720 // // new ((*fParticles)[nentries]) TParticle(*fParticleBuffer);
721 // // fParticleMap->AddAt((*fParticles)[nentries],i);
723 // // return (TParticle *) (*fParticleMap)[i];
730 // //scan over opened files and read corresponding TreeK##
734 //____________________________________________________________________________
735 void AliPHOSIndexToObject::GetEvent(Int_t event){
736 if(event == fEvent) // do nothing
739 if(event > fMaxEvent)
743 gAlice->GetEvent(fEvent) ;
745 ReadRecParticles(fPID->GetRecParticlesBranch()) ;
746 ReadTS(fTSMaker->GetTrackSegmentsBranch()) ;
747 ReadRecPoints(fClusterizer->GetRecPointsBranch()) ;
748 ReadDigits(fDigitizer->GetDigitsBranch()) ;