]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PHOS/AliPHOSIndexToObject.cxx
the temporary YSAlice folders structure and PHOS folders are created also in default...
[u/mrichter/AliRoot.git] / PHOS / AliPHOSIndexToObject.cxx
CommitLineData
83974468 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
f251ddb2 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
83974468 24//_________________________________________________________________________
a4e98857 25// A singleton. This class should be used in the analysis stage to get
f035f6ce 26// reconstructed objects: Digits, RecPoints, TrackSegments and RecParticles,
a4e98857 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
f035f6ce 31// different set of parameters.
32//
a4e98857 33// An example of how to use (see also class AliPHOSAnalyser):
f035f6ce 34// AliPHOSIndexToObject * please = AliPHOSIndexToObject::GetInstance("galice.root","RecParticles","") ;
35// for(Int_t irecp = 0; irecp < please->GimeNRecParticles() ; irecp++)
36// AliPHOSRecParticle * part = please->GimeRecParticle(1) ;
37// ................
38// please->GetEvent(event) ; // reads new event from galice.root
83974468 39//
3e3852a0 40//*-- Author: Yves Schutz (SUBATECH) & Dmitri Peressounko (RRC KI & SUBATECH)
f035f6ce 41//*-- Complitely redesigned by Dmitri Peressounko March 2001
83974468 42//////////////////////////////////////////////////////////////////////////////
43
ed4205d8 44
83974468 45// --- ROOT system ---
46
3e3852a0 47#include "TFile.h"
94de3818 48#include "TTree.h"
3e3852a0 49#include "TROOT.h"
50#include "TObjString.h"
94de3818 51
83974468 52// --- Standard library ---
3e3852a0 53#include <iostream.h>
83974468 54
55// --- AliRoot header files ---
56
3e3852a0 57#include "AliRun.h"
83974468 58#include "AliPHOSIndexToObject.h"
3e3852a0 59#include "AliPHOSDigitizer.h"
6633daf0 60#include "AliPHOSSDigitizer.h"
3e3852a0 61#include "AliPHOSClusterizer.h"
6633daf0 62#include "AliPHOSClusterizerv1.h"
3e3852a0 63#include "AliPHOSTrackSegmentMaker.h"
6633daf0 64#include "AliPHOSTrackSegmentMakerv1.h"
65#include "AliPHOSTrackSegment.h"
3e3852a0 66#include "AliPHOSPID.h"
6633daf0 67#include "AliPHOSPIDv1.h"
83974468 68
69ClassImp(AliPHOSIndexToObject)
70
88714635 71 AliPHOSIndexToObject * AliPHOSIndexToObject::fgObjGetter = 0 ;
83974468 72
73//____________________________________________________________________________
6633daf0 74AliPHOSIndexToObject::AliPHOSIndexToObject(const char* headerFile,const char* branch,const char* branchTitle )
83974468 75{
a4e98857 76 //Initialize all lists
3e3852a0 77 fEvent = 0 ;
78
6633daf0 79 fSDigits = new TClonesArray("AliPHOSDigit",100) ;
80 fDigits = new TClonesArray("AliPHOSDigit",100) ;
3e3852a0 81 fEmcRecPoints = new TObjArray(100) ;
82 fCpvRecPoints = new TObjArray(100) ;
83 fTS = new TClonesArray("AliPHOSTrackSegment",100) ;
84 fRecParticles = new TClonesArray("AliPHOSRecParticle",100) ;
85 fPrimaries = new TObjArray(1) ;
86
6633daf0 87 fSDigitizer = 0 ;
3e3852a0 88 fDigitizer = 0 ;
89 fClusterizer = 0 ;
90 fTSMaker = 0 ;
91 fPID = 0 ;
92
93 //open headers file
94 fHeaderFile = headerFile ;
95 TFile * file = (TFile*) gROOT->GetFile(fHeaderFile.Data() ) ;
96
97 if(file == 0){
f035f6ce 98 if(fHeaderFile.Contains("rfio")) // if we read file using HPSS
99 file = TFile::Open(fHeaderFile.Data(),"update") ;
100 else
101 file = new TFile(fHeaderFile.Data(),"update") ;
3e3852a0 102 gAlice = (AliRun *) file->Get("gAlice") ;
103 }
104
105 fMaxEvent = (Int_t) gAlice->TreeE()->GetEntries() ;
106
6633daf0 107 DefineBranchTitles(branch,branchTitle) ;
3e3852a0 108
6633daf0 109 //Now read all data from trees
110 fEvent = -1 ;
111 GetEvent(0) ;
3e3852a0 112
6633daf0 113}
114//____________________________________________________________________________
a4e98857 115void AliPHOSIndexToObject:: DefineBranchTitles(const char* startBranch,const char* branchTitle)
116{
117 // Points to the branches of all reconstructed objects with the specified names
f251ddb2 118
6633daf0 119 gAlice->GetEvent(0) ;
a4e98857 120 // Read all reconstruction classes to extract titles of
121 // branches, constituing "reconstruction branch"
6633daf0 122 AliPHOSPID * pids[50]; // here AliPHOSPID's will be stored
123 Int_t ipids = 0 ;
124 AliPHOSTrackSegmentMaker * tsms[50] ;
125 Int_t itsms = 0 ;
126 AliPHOSClusterizer * clus[50] ;
127 Int_t iclus = 0 ;
128 AliPHOSDigitizer * digs[50];
129 Int_t idigs = 0 ;
130 AliPHOSSDigitizer * sdigs[50];
131 Int_t isdigs = 0 ;
3e3852a0 132
6633daf0 133 //read TreeR
134 TObjArray * branches = gAlice->TreeR()->GetListOfBranches() ;
135 Int_t ibranch;
136 TBranch * branch ;
137 for(ibranch = 0;ibranch <branches->GetEntries();ibranch++){
138 branch=(TBranch *) branches->At(ibranch) ;
139 if( (strcmp(branch->GetName(),"AliPHOSPID") == 0) ){
140 pids[ipids] = new AliPHOSPIDv1() ;
141 branch->SetAddress(& (pids[ipids])) ;
f251ddb2 142 branch->GetEntry(0) ;
6633daf0 143 ipids++ ;
144 }
145 if( (strcmp(branch->GetName(),"AliPHOSTrackSegmentMaker") == 0) ){
146 tsms[itsms] = new AliPHOSTrackSegmentMakerv1() ;
147 branch->SetAddress(&(tsms[itsms])) ;
f251ddb2 148 branch->GetEntry(0) ;
6633daf0 149 itsms++ ;
150 }
151 if( (strcmp(branch->GetName(),"AliPHOSClusterizer") == 0) ){
152 clus[iclus] = new AliPHOSClusterizerv1() ;
153 branch->SetAddress(&(clus[iclus])) ;
f251ddb2 154 branch->GetEntry(0) ;
6633daf0 155 iclus++ ;
156 }
3e3852a0 157 }
f251ddb2 158// gAlice->TreeR()->GetEvent(0) ;
3e3852a0 159
3e3852a0 160
6633daf0 161 //read TreeD
162 branches = gAlice->TreeD()->GetListOfBranches() ;
163 for(ibranch = 0;ibranch <branches->GetEntries();ibranch++){
164 branch=(TBranch *) branches->At(ibranch) ;
165 if( (strcmp(branch->GetName(),"AliPHOSDigitizer") == 0) ){
166 digs[idigs] = new AliPHOSDigitizer() ;
167 branch->SetAddress(&(digs[idigs])) ;
f251ddb2 168 branch->GetEntry(0) ;
6633daf0 169 idigs++ ;
170 }
3e3852a0 171 }
f251ddb2 172// gAlice->TreeD()->GetEvent(0) ;
3e3852a0 173
6633daf0 174 //read TreeS
175 branches = gAlice->TreeS()->GetListOfBranches() ;
176 for(ibranch = 0;ibranch <branches->GetEntries();ibranch++){
177 branch=(TBranch *) branches->At(ibranch) ;
f251ddb2 178 gAlice->TreeS()->GetBranch(branch->GetName())->GetEntry(0) ; // YK
6633daf0 179 if( (strcmp(branch->GetName(),"AliPHOSSDigitizer") == 0) ){
180 sdigs[isdigs] = new AliPHOSSDigitizer() ;
181 branch->SetAddress(&(sdigs[isdigs])) ;
f251ddb2 182 branch->GetEntry(0) ;
6633daf0 183 isdigs++ ;
184 }
185 }
f251ddb2 186// gAlice->TreeS()->GetEvent(0) ;
6633daf0 187
a4e98857 188 // now choose among read Reconstruction classes those,
189 // which constituite "reconstruction branch"
6633daf0 190 Bool_t pidDefined = kFALSE ;
191 Bool_t tsmDefined = kFALSE ;
192 Bool_t cluDefined = kFALSE ;
193 Bool_t digDefined = kFALSE ;
194 Bool_t sdigDefined = kFALSE ;
195
196 Int_t index ;
a4e98857 197 // First, go from the end (RecParticles) to the beginning(SDigits)
6633daf0 198 if((strcmp(startBranch,"PHOSRP") == 0)||(strcmp(startBranch,"AliPHOSPID") == 0)){
199 fRPTitle = branchTitle ;
200 for(index = 0; index < ipids ; index++){
201 if(fRPTitle.CompareTo(((AliPHOSPID*)pids[index])->GetRecParticlesBranch())== 0){
202 pidDefined = kTRUE ;
203 fTSTitle =((AliPHOSPID*)pids[index])->GetTrackSegmentsBranch() ;
204 }
205 }
206 }
207 if((strcmp(startBranch,"PHOSTS") == 0)||(strcmp(startBranch,"AliPHOSTrackSegmentMaker") == 0)|| pidDefined ) {
208 if(!pidDefined)
209 fTSTitle = branchTitle ;
210 for(index = 0; index < itsms ; index++)
211 if(fTSTitle.CompareTo(((AliPHOSTrackSegmentMaker*)tsms[index])->GetTrackSegmentsBranch())== 0){
212 tsmDefined = kTRUE ;
213 fRecPointsTitle =((AliPHOSTrackSegmentMaker*)tsms[index])->GetRecPointsBranch() ;
214 }
215 }
216 if((strcmp(startBranch,"PHOSEmcRP") == 0) ||
217 (strcmp(startBranch,"PHOSCpvRP") == 0) ||
218 (strcmp(startBranch,"AliPHOSClusterizer") == 0) || tsmDefined ) {
219 if(!tsmDefined)
220 fRecPointsTitle = branchTitle ;
221 for(index = 0; index < iclus ; index++)
222 if(fRecPointsTitle.CompareTo(((AliPHOSClusterizer*)clus[index])->GetRecPointsBranch())== 0){
223 cluDefined = kTRUE ;
224 fDigitsTitle =((AliPHOSClusterizer*)clus[index])->GetDigitsBranch() ;
225 }
226 }
227 if((strcmp(startBranch,"PHOS") == 0) || (strcmp(startBranch,"AliPHOSDigitizer") == 0) ||cluDefined ) {
228 if(!cluDefined)
229 fDigitsTitle = branchTitle ;
f251ddb2 230 for(index = 0; index < idigs ; index++) {
6633daf0 231 if(fDigitsTitle.CompareTo(((AliPHOSDigitizer*)digs[index])->GetDigitsBranch())== 0){
232 digDefined = kTRUE ;
233 fSDigitsTitle =((AliPHOSDigitizer*)digs[index])->GetSDigitsBranch() ;
234 }
f251ddb2 235 }
6633daf0 236 }
237 for(index = 0; index < idigs ; index++)
238 if(fSDigitsTitle.CompareTo(((AliPHOSSDigitizer*)sdigs[index])->GetSDigitsBranch())== 0)
239 sdigDefined = kTRUE ;
240
241 if(!sdigDefined){
242 cout << "Can not define titles of branches " << endl ;
243 cout << endl ;
3e3852a0 244 }
83974468 245
a4e98857 246 // Now we go in the inverse direction: from sdigits to recparticles - for the
247 // case, if we started decending not from RecParticles, but e.g. from digits
6633daf0 248
249 if( !cluDefined ) {
250 for(index = 0; index < iclus ; index++)
251 if(fDigitsTitle.CompareTo(((AliPHOSClusterizer*)clus[index])->GetDigitsBranch())== 0){
252 cluDefined = kTRUE ;
253 fRecPointsTitle =((AliPHOSClusterizer*)clus[index])->GetRecPointsBranch() ;
254 }
255 }
256 if(! tsmDefined ) {
257 for(index = 0; index < itsms ; index++)
258 if(fRecPointsTitle.CompareTo(((AliPHOSTrackSegmentMaker*)tsms[index])->GetRecPointsBranch())== 0){
259 tsmDefined = kTRUE ;
260 fTSTitle =((AliPHOSTrackSegmentMaker*)tsms[index])->GetTrackSegmentsBranch() ;
261 }
262 }
263 if(!pidDefined){
264 for(index = 0; index < ipids ; index++)
265 if(fTSTitle.CompareTo(((AliPHOSPID*)pids[index])->GetTrackSegmentsBranch())== 0){
266 pidDefined = kTRUE ;
267 fRPTitle = ((AliPHOSPID*)pids[index])->GetRecParticlesBranch() ;
268 }
269 }
270
271 //delete created objects
272 for(index = 0; index < ipids ; index++)
273 delete pids[index] ;
274 for(index = 0; index < itsms ; index++)
275 delete tsms[index] ;
276 for(index = 0; index < iclus ; index++)
277 delete clus[index] ;
278 for(index = 0; index < idigs ; index++)
279 delete digs[index] ;
280 for(index = 0; index < isdigs ; index++)
281 delete sdigs[index] ;
282
83974468 283}
83974468 284//____________________________________________________________________________
285AliPHOSIndexToObject * AliPHOSIndexToObject::GetInstance()
286{
287 // Returns the pointer of the unique instance already defined
288
289 AliPHOSIndexToObject * rv = 0 ;
88714635 290 if ( fgObjGetter )
291 rv = fgObjGetter ;
83974468 292 else
293 cout << "AliPHOSIndexToObject::GetInstance ERROR: not yet initialized" << endl ;
3e3852a0 294
83974468 295 return rv ;
296}
297
298//____________________________________________________________________________
6633daf0 299AliPHOSIndexToObject * AliPHOSIndexToObject::GetInstance(const char* headerFile,
300 const char* branch,
301 const char* branchTitle)
83974468 302{
303 // Creates and returns the pointer of the unique instance
3e3852a0 304 // Must be called only when the environment has changed
83974468 305
6633daf0 306 if(strcmp(branch,"PHOSRP") && strcmp(branch,"AliPHOSPID") &&
307 strcmp(branch,"PHOSTS") && strcmp(branch,"AliPHOSTrackSegmentMaker") &&
308 strcmp(branch,"PHOSEmcRP") && strcmp(branch,"PHOSCpvRP") && strcmp(branch,"AliPHOSClusterizer") &&
309 strcmp(branch,"PHOS") && strcmp(branch,"AliPHOSDigitizer") ){
310
311 cout << "AliPHOSIndexToObject: wrong branch name specified: " << branch << endl ;
312 cout << " avalilable names are `PHOSRP', `AliPHOSPID'"<<endl ;
313 cout << " `PHOSTS', `AliPHOSTrackSegmentMaker'"<<endl ;
314 cout << " `PHOSEmcRP', `PHOSCpvRP', `AliPHOSClusterizer'"<< endl ;
315 cout << " `PHOS' and `AliPHOSDigitizer'"<< endl ;
316 return 0 ;
317 }
318
319
88714635 320 if ( fgObjGetter ) // delete it if already exists
321 delete fgObjGetter ;
83974468 322
3e3852a0 323 fgObjGetter = new AliPHOSIndexToObject(headerFile,branch,branchTitle) ;
83974468 324
88714635 325 return fgObjGetter ;
83974468 326
327}
328
329//____________________________________________________________________________
f251ddb2 330TParticle * AliPHOSIndexToObject::GimePrimary(Int_t index) const
83974468 331{
f251ddb2 332 // Return primary particle numbered by <index>
333
6633daf0 334 if(index < 0)
335 return 0 ;
3e3852a0 336
6633daf0 337 Int_t primaryIndex = index % 10000000 ;
338 Int_t primaryList = (Int_t ) ((index-primaryIndex)/10000000.) ;
3e3852a0 339
340 if ( primaryList > 0 ) {
341 cout << " IndexToObject does not support currently Mixing of primary " << endl ;
342 cout << " can not return primary: " << index<< " (list "<< primaryList<< " primary # " << primaryIndex << " )"<<endl ;
343 return 0;
344 }
345
346 return gAlice->Particle(primaryIndex) ;
83974468 347
348}
83974468 349
3e3852a0 350//____________________________________________________________________________
f251ddb2 351void AliPHOSIndexToObject::ReadTreeD()
352{
353 // Read the digit tree gAlice->TreeD()
6633daf0 354 if(gAlice->TreeD()== 0){
355 cout << "AliPHOSIndexToObject : can not read TreeD " << endl;
356 return ;
357 }
358
359 TBranch * digitsBranch = 0;
360 TBranch * digitizerBranch = 0;
361
362 TObjArray * branches = gAlice->TreeD()->GetListOfBranches() ;
363 Int_t ibranch;
364 Bool_t phosNotFound = kTRUE ;
365 Bool_t digitizerNotFound = kTRUE ;
366
367 for(ibranch = 0;ibranch <branches->GetEntries();ibranch++){
3e3852a0 368
6633daf0 369 if(phosNotFound){
370 digitsBranch=(TBranch *) branches->At(ibranch) ;
371 if( (strcmp(digitsBranch->GetTitle(),fDigitsTitle)==0 ) &&
372 (strcmp(digitsBranch->GetName(),"PHOS") == 0) )
373 phosNotFound = kFALSE ;
3e3852a0 374 }
6633daf0 375 if(digitizerNotFound){
376 digitizerBranch = (TBranch *) branches->At(ibranch) ;
377 if( (strcmp(digitizerBranch->GetTitle(),fDigitsTitle) == 0) &&
378 (strcmp(digitizerBranch->GetName(),"AliPHOSDigitizer") == 0) )
379 digitizerNotFound = kFALSE ;
380 }
3e3852a0 381 }
3e3852a0 382
6633daf0 383 if(digitizerNotFound || phosNotFound){
384 cout << "AliPHOSIndexToObject error: " << endl ;
385 cout << " Can't find Branch with Digits or Digitizer "<< endl ; ;
386 return ;
3e3852a0 387 }
6633daf0 388
f251ddb2 389 digitsBranch ->SetAddress(&fDigits) ;
6633daf0 390 digitizerBranch->SetAddress(&fDigitizer) ;
f251ddb2 391 digitsBranch ->GetEntry(0) ;
392 digitizerBranch->GetEntry(0) ;
6633daf0 393
f251ddb2 394// gAlice->TreeD()->GetEvent(0) ; // YK 29.05.2001
6633daf0 395
83974468 396}
83974468 397//____________________________________________________________________________
a4e98857 398void AliPHOSIndexToObject::ReadTreeS()
399{
f251ddb2 400 // Read the summable digits tree gAlice->TreeS()
401
6633daf0 402 if(gAlice->TreeS()== 0){
403 cout << "AliPHOSIndexToObject: can not read TreeS " << endl ;
404 return ;
3e3852a0 405 }
6633daf0 406
407 TBranch * sdigitsBranch = 0;
408 TBranch * sdigitizerBranch = 0;
409
410 TObjArray * branches = gAlice->TreeS()->GetListOfBranches() ;
411 Int_t ibranch;
412 Bool_t phosNotFound = kTRUE ;
413 Bool_t sdigitizerNotFound = kTRUE ;
414
415 for(ibranch = 0;ibranch <branches->GetEntries();ibranch++){
3e3852a0 416
6633daf0 417 if(phosNotFound){
418 sdigitsBranch=(TBranch *) branches->At(ibranch) ;
419 if( (strcmp(sdigitsBranch->GetTitle(),fSDigitsTitle)==0 ) &&
420 (strcmp(sdigitsBranch->GetName(),"PHOS") == 0) )
421 phosNotFound = kFALSE ;
3e3852a0 422 }
6633daf0 423 if(sdigitizerNotFound){
424 sdigitizerBranch = (TBranch *) branches->At(ibranch) ;
425 if( (strcmp(sdigitizerBranch->GetTitle(),fSDigitsTitle) == 0) &&
426 (strcmp(sdigitizerBranch->GetName(),"AliPHOSSDigitizer") == 0) )
427 sdigitizerNotFound = kFALSE ;
428 }
3e3852a0 429 }
6633daf0 430
431 if(sdigitizerNotFound || phosNotFound){
432 cout << "AliPHOSIndexToObject error: " << endl ;
433 cout << " Can't find Branch with SDigits or SDigitizer "<< endl ; ;
434 return ;
435 }
436
f251ddb2 437 sdigitsBranch ->SetAddress(&fSDigits) ;
6633daf0 438 sdigitizerBranch->SetAddress(&fSDigitizer) ;
f251ddb2 439 sdigitsBranch ->GetEvent(0) ;
440 sdigitizerBranch->GetEvent(0) ;
6633daf0 441
f251ddb2 442// gAlice->TreeS()->GetEvent(0) ; // YK 29.05.2001
6633daf0 443
83974468 444}
83974468 445//____________________________________________________________________________
a4e98857 446void AliPHOSIndexToObject::ReadTreeR()
447{
f251ddb2 448 // Read the reconstrunction tree gAlice->TreeR()
449
6633daf0 450 if(gAlice->TreeR()== 0){
451 cout << "AliPHOSIndexToObject: can not read TreeR " << endl ;
452 return ;
453 }
3e3852a0 454
6633daf0 455 TBranch * pidBranch = 0;
456 TBranch * rpBranch = 0;
457 TBranch * tsMakerBranch = 0;
458 TBranch * tsBranch = 0;
459 TBranch * emcBranch = 0;
460 TBranch * cpvBranch = 0;
461 TBranch * clusterizerBranch = 0;
462
463 TObjArray * branches = gAlice->TreeR()->GetListOfBranches() ;
464 Int_t ibranch;
465 Bool_t pidNotFound = kTRUE ;
466 Bool_t rpNotFound = kTRUE ;
467 Bool_t tsMakerNotFound = kTRUE ;
468 Bool_t tsNotFound = kTRUE ;
469 Bool_t emcNotFound = kTRUE ;
470 Bool_t cpvNotFound = kTRUE ;
471 Bool_t clusterizerNotFound = kTRUE ;
472
473 for(ibranch = 0;ibranch <branches->GetEntries();ibranch++){
3e3852a0 474
6633daf0 475 if(pidNotFound){
476 pidBranch=(TBranch *) branches->At(ibranch) ;
477 if( (fRPTitle.CompareTo(pidBranch->GetTitle())==0 ) &&
478 (strcmp(pidBranch->GetName(),"AliPHOSPID") == 0) )
479 pidNotFound = kFALSE ;
3e3852a0 480 }
6633daf0 481 if(rpNotFound){
482 rpBranch=(TBranch *) branches->At(ibranch) ;
483 if( (fRPTitle.CompareTo(rpBranch->GetTitle())==0 ) &&
484 (strcmp(rpBranch->GetName(),"PHOSRP") == 0) )
485 rpNotFound = kFALSE ;
3e3852a0 486 }
6633daf0 487 if(tsMakerNotFound){
488 tsMakerBranch=(TBranch *) branches->At(ibranch) ;
489 if( fTSTitle.CompareTo(tsMakerBranch->GetTitle())==0 )
490 if( strcmp(tsMakerBranch->GetName(),"AliPHOSTrackSegmentMaker") == 0)
491 tsMakerNotFound = kFALSE ;
3e3852a0 492 }
6633daf0 493 if(tsNotFound){
494 tsBranch=(TBranch *) branches->At(ibranch) ;
495 if( fTSTitle.CompareTo(tsBranch->GetTitle())==0 )
496 if( strcmp(tsBranch->GetName(),"PHOSTS") == 0)
497 tsNotFound = kFALSE ;
498 }
499 if(emcNotFound){
500 emcBranch=(TBranch *) branches->At(ibranch) ;
501 if( (fRecPointsTitle.CompareTo(emcBranch->GetTitle()) == 0) &&
502 (strcmp(emcBranch->GetName(),"PHOSEmcRP") == 0) )
503 emcNotFound = kFALSE ;
504 }
505 if(cpvNotFound){
506 cpvBranch=(TBranch *) branches->At(ibranch) ;
507 if( (fRecPointsTitle.CompareTo(cpvBranch->GetTitle()) == 0) &&
508 (strcmp(cpvBranch->GetName(),"PHOSCpvRP") == 0) )
509 cpvNotFound = kFALSE ;
510 }
511 if(clusterizerNotFound){
512 clusterizerBranch = (TBranch *) branches->At(ibranch) ;
513 if( (fRecPointsTitle.CompareTo(clusterizerBranch->GetTitle()) == 0) &&
514 (strcmp(clusterizerBranch->GetName(),"AliPHOSClusterizer") == 0) )
515 clusterizerNotFound = kFALSE ;
3e3852a0 516 }
517 }
518
6633daf0 519 if(pidNotFound ||rpNotFound ){
520 cout << "AliPHOSIndexToObject error" << endl ;
521 cout << " Can't find Branch with PID and RecParticles " ;
522 return ;
523 }
524 if(tsMakerNotFound ||tsNotFound ){
525 cout << "AliPHOSIndexToObject error" << endl ;
526 cout << " Can't find Branch with TrackSegmentMaker and TrackSegments " ;
527 cout << " Do nothing" <<endl ;
528 return ;
529 }
530 if(clusterizerNotFound || emcNotFound || cpvNotFound){
531 cout << "AliPHOSIndexToObject error" << endl ;
532 cout << " Can't find Branch with RecPoints or Clusterizer " << endl ;
533 return ;
534 }
f035f6ce 535
f251ddb2 536 // YK 29.05.2001 : Read branch instead of tree
537 emcBranch ->SetAddress(&fEmcRecPoints) ;
538 cpvBranch ->SetAddress(&fCpvRecPoints) ;
6633daf0 539 clusterizerBranch->SetAddress(&fClusterizer) ;
f251ddb2 540 emcBranch ->GetEntry(0) ;
541 cpvBranch ->GetEntry(0) ;
542 clusterizerBranch->GetEntry(0) ;
543
544 tsMakerBranch ->SetAddress(&fTSMaker) ;
545 tsBranch ->SetAddress(&fTS) ;
546 tsMakerBranch ->GetEntry(0) ;
547 tsBranch ->GetEntry(0) ;
3e3852a0 548
f251ddb2 549 pidBranch ->SetAddress(&fPID) ;
550 rpBranch ->SetAddress(&fRecParticles) ;
551 pidBranch ->GetEntry(0) ;
552 rpBranch ->GetEntry(0) ;
83974468 553
f251ddb2 554// gAlice->TreeR()->GetEvent(0) ; // YK 29.05.2001
f035f6ce 555
3e3852a0 556}
557//____________________________________________________________________________
a4e98857 558void AliPHOSIndexToObject::ReadPrimaries()
559{
560 // Reads specific branches of primaries
6633daf0 561
562 fNPrimaries = gAlice->GetNtrack();
563
564 // //Check, is it necessary to open new files
565 // TArrayI* events = fDigitizer->GetCurrentEvents() ;
566 // TClonesArray * filenames = fDigitizer->GetHeadersFiles() ;
3e3852a0 567// Int_t input ;
568// for(input = 0; input < filenames->GetEntriesFast(); input++){
569
570// TObjString * filename = (TObjString *) filenames->At(input) ;
571
572// //Test, if this file already open
573// TFile *file = (TFile*) gROOT->GetFile( filename->GetString() ) ;
574// if(file == 0)
575// file = new TFile( filename->GetString()) ;
576// file->cd() ;
577
578// // Get Kine Tree from file
579// // char treeName[20];
580// // sprintf(treeName,"TreeK%d",events->At(input));
581// // TTree * treeK = (TTree*)gDirectory->Get(treeName);
582// // if (treeK)
583// // treeK->SetBranchAddress("Particles", &fParticleBuffer);
584// // else
585// // cout << "AliPHOSIndexToObject: cannot find Kine Tree for event:" << events->At(input) << endl;
586
587// // // Create the particle stack
588// // if(!fParticles) fParticles = new TClonesArray("TParticle",1000);
589// // // Build the pointer list
590// // if(fParticleMap) { <----
591// // fParticleMap->Clear();
592// // fParticleMap->Expand(treeK->GetEntries());
593// // } else
594// // fParticleMap = new TObjArray(treeK->GetEntries());
595
596// // From gAlice->Particle(i)
597
598
599// // if(!(*fParticleMap)[i]) {
600// // Int_t nentries = fParticles->GetEntries();
601
602// // // algorithmic way of getting entry index
603// // // (primary particles are filled after secondaries)
604// // Int_t entry;
605// // if (i<fHeader.GetNprimary())
606// // entry = i+fHeader.GetNsecondary();
607// // else
608// // entry = i-fHeader.GetNprimary();
609
610// // // only check the algorithmic way and give
611// // // the fatal error if it is wrong
612// // if (entry != fParticleFileMap[i]) {
613// // Fatal("Particle",
614// // "!!!! The algorithmic way is WRONG: !!!\n entry: %d map: %d",
615// // entry, fParticleFileMap[i]);
616// // }
617
618// // fTreeK->GetEntry(fParticleFileMap[i]);
619// // new ((*fParticles)[nentries]) TParticle(*fParticleBuffer);
620// // fParticleMap->AddAt((*fParticles)[nentries],i);
621// // }
622// // return (TParticle *) (*fParticleMap)[i];
623
624
625
626// }
627
628
629// //scan over opened files and read corresponding TreeK##
630
6633daf0 631 return ;
3e3852a0 632}
633//____________________________________________________________________________
a4e98857 634void AliPHOSIndexToObject::GetEvent(Int_t event)
635{
636 // Reads the content of all Tree's S, D and R
f251ddb2 637
3e3852a0 638 if(event == fEvent) // do nothing
639 return ;
640
6633daf0 641 if(event > fMaxEvent){
642 cout << "There is no such event " << event << " total # of events " << fMaxEvent << endl ;
f035f6ce 643 return ;
6633daf0 644 }
f035f6ce 645
3e3852a0 646 fEvent = event ;
647 gAlice->GetEvent(fEvent) ;
83974468 648
6633daf0 649 ReadTreeS() ;
650 ReadTreeD() ;
651 ReadTreeR() ;
3e3852a0 652 ReadPrimaries() ;
6633daf0 653
654
655
83974468 656}
3e3852a0 657