Added a service method (BranchName) and a method that fills the parameters matrix...
[u/mrichter/AliRoot.git] / PHOS / AliPHOSTrackSegmentMakerv1.cxx
CommitLineData
d15a28e7 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 **************************************************************************/
b2a60966 15/* $Id$ */
d15a28e7 16//_________________________________________________________________________
b2a60966 17// Implementation version 1 of algorithm class to construct PHOS track segments
f035f6ce 18// Track segment for PHOS is list of
19// EMC RecPoint + (possibly) CPV RecPoint + (possibly) PPSD RecPoint
a4e98857 20// To find TrackSegments we do the following:
21// for each EMC RecPoints we look at
22// CPV/PPSD RecPoints in the radious fR0.
23// If there is such a CPV RecPoint,
24// we make "Link" it is just indexes of EMC and CPV/PPSD RecPoint and distance
25// between them in the PHOS plane.
26// Then we sort "Links" and starting from the
27// least "Link" pointing to the unassined EMC and CPV RecPoints assing them to
28// new TrackSegment.
29// If there is no CPV/PPSD RecPoint we make TrackSegment
30// consisting from EMC alone. There is no TrackSegments without EMC RecPoint.
f035f6ce 31//
32// In principle this class should be called from AliPHOSReconstructioner, but
a4e98857 33// one can use it as well in standalone mode.
34// Use case:
35// root [0] AliPHOSTrackSegmentMakerv1 * t = new AliPHOSTrackSegmentMaker("galice.root")
36// Warning in <TDatabasePDG::TDatabasePDG>: object already instantiated
37// root [1] t->ExecuteTask()
38// root [2] t->SetMaxEmcPpsdDistance(5)
39// root [3] t->SetTrackSegmentsBranch("max distance 5 cm")
40// root [4] t->ExecuteTask("deb all time")
f035f6ce 41//
b2a60966 42//*-- Author: Dmitri Peressounko (RRC Ki & SUBATECH)
43//
d15a28e7 44
45// --- ROOT system ---
2731cd1e 46#include "TROOT.h"
47#include "TFile.h"
7b7c1533 48#include "TFolder.h"
2731cd1e 49#include "TTree.h"
50#include "TSystem.h"
51#include "TBenchmark.h"
d15a28e7 52// --- Standard library ---
53
de9ec31b 54#include <iostream.h>
2731cd1e 55#include <iomanip.h>
d15a28e7 56
57// --- AliRoot header files ---
58
59#include "AliPHOSTrackSegmentMakerv1.h"
2731cd1e 60#include "AliPHOSClusterizerv1.h"
d15a28e7 61#include "AliPHOSTrackSegment.h"
2aca7d46 62#include "AliPHOSCpvRecPoint.h"
d15a28e7 63#include "AliPHOSLink.h"
7b7c1533 64#include "AliPHOSGetter.h"
baef0810 65#include "AliPHOS.h"
d15a28e7 66#include "AliRun.h"
67
68ClassImp( AliPHOSTrackSegmentMakerv1)
69
70
71//____________________________________________________________________________
2bd5457f 72 AliPHOSTrackSegmentMakerv1::AliPHOSTrackSegmentMakerv1() : AliPHOSTrackSegmentMaker()
d15a28e7 73{
7b7c1533 74 // default ctor (to be used mainly by Streamer)
75
76 fR0 = 10. ;
77 fEmcFirst = 0 ;
78 fEmcLast = 0 ;
79 fCpvFirst = 0 ;
80 fCpvLast = 0 ;
7b7c1533 81 fLinkUpArray = 0 ;
82 fHeaderFileName = "" ;
83 fRecPointsBranchTitle = "" ;
84 fTrackSegmentsBranchTitle = "" ;
2b60655b 85 fTrackSegmentsInRun = 0 ;
d15a28e7 86}
7b7c1533 87
9f616d61 88//____________________________________________________________________________
7b7c1533 89 AliPHOSTrackSegmentMakerv1::AliPHOSTrackSegmentMakerv1(const char * headerFile, const char * name) : AliPHOSTrackSegmentMaker(headerFile, name)
2731cd1e 90{
91 // ctor
2731cd1e 92
7b7c1533 93 fR0 = 10. ;
94 fEmcFirst = 0 ;
95 fEmcLast = 0 ;
96 fCpvFirst = 0 ;
97 fCpvLast = 0 ;
79bf6a2f 98 fLinkUpArray = 0 ;
7b7c1533 99
100 fHeaderFileName = GetTitle() ;
101 fRecPointsBranchTitle = GetName() ;
102 fTrackSegmentsBranchTitle = GetName() ;
2b60655b 103 fTrackSegmentsInRun = 0 ;
104
9688c1dd 105 TString tsmName( GetName()) ;
106 tsmName.Append(":") ;
107 tsmName.Append(Version()) ;
108 SetName(tsmName) ;
109
7b7c1533 110 Init() ;
98cbd830 111
2731cd1e 112}
98cbd830 113
2731cd1e 114//____________________________________________________________________________
115 AliPHOSTrackSegmentMakerv1::~AliPHOSTrackSegmentMakerv1()
116{
117 // dtor
79bf6a2f 118 delete fLinkUpArray ;
d15a28e7 119}
9f616d61 120
d15a28e7 121//____________________________________________________________________________
2731cd1e 122void AliPHOSTrackSegmentMakerv1::FillOneModule()
9f616d61 123{
f035f6ce 124 // Finds first and last indexes between which
125 // clusters from one PHOS module are
55ea5766 126 TString taskName(GetName()) ;
127 taskName.Remove(taskName.Index(Version())-1) ;
7b7c1533 128 AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
55ea5766 129 TObjArray * emcRecPoints = gime->EmcRecPoints(taskName) ;
130 TObjArray * cpvRecPoints = gime->CpvRecPoints(taskName) ;
9688c1dd 131
2731cd1e 132 //First EMC clusters
7b7c1533 133 Int_t totalEmc = emcRecPoints->GetEntriesFast() ;
2731cd1e 134 for(fEmcFirst = fEmcLast; (fEmcLast < totalEmc) &&
29b077b5 135 ((dynamic_cast<AliPHOSRecPoint *>(emcRecPoints->At(fEmcLast)))->GetPHOSMod() == fModule );
2731cd1e 136 fEmcLast ++) ;
137
2731cd1e 138 //Now CPV clusters
7b7c1533 139 Int_t totalCpv = cpvRecPoints->GetEntriesFast() ;
6ad0bfa0 140
2731cd1e 141 for(fCpvFirst = fCpvLast; (fCpvLast < totalCpv) &&
29b077b5 142 ((dynamic_cast<AliPHOSRecPoint *>(cpvRecPoints->At(fCpvLast)))->GetPHOSMod() == fModule );
2731cd1e 143 fCpvLast ++) ;
9688c1dd 144
d15a28e7 145}
7b7c1533 146
d15a28e7 147//____________________________________________________________________________
baef0810 148Float_t AliPHOSTrackSegmentMakerv1::GetDistanceInPHOSPlane(AliPHOSEmcRecPoint * emcClu,AliPHOSRecPoint * cpvClu, Bool_t &toofar)const
d15a28e7 149{
b2a60966 150 // Calculates the distance between the EMC RecPoint and the PPSD RecPoint
a4e98857 151 // Clusters are sorted in "rows" and "columns" of width 1 cm
f035f6ce 152
2731cd1e 153 Float_t delta = 1 ; // Width of the rows in sorting of RecPoints (in cm)
154 // if you change this value, change it as well in xxxRecPoint::Compare()
92862013 155 Float_t r = fR0 ;
d15a28e7 156
157 TVector3 vecEmc ;
2731cd1e 158 TVector3 vecCpv ;
159
160 emcClu->GetLocalPosition(vecEmc) ;
161 cpvClu->GetLocalPosition(vecCpv) ;
162
163 if(emcClu->GetPHOSMod() == cpvClu->GetPHOSMod()){
164 if(vecCpv.X() <= vecEmc.X() + fR0 + 2*delta ){
165
166 vecCpv = vecCpv - vecEmc ;
167 r = vecCpv.Mag() ;
92862013 168 toofar = kFALSE ;
2731cd1e 169
170 } // if xPpsd >= xEmc + ...
171 else
172 toofar = kTRUE ;
d15a28e7 173 }
174 else
92862013 175 toofar = kTRUE ;
7956ec10 176
177 //toofar = kFALSE ;
178
d15a28e7 179
92862013 180 return r ;
d15a28e7 181}
182
7b7c1533 183//____________________________________________________________________________
184void AliPHOSTrackSegmentMakerv1::Init()
185{
186 // Make all memory allocations that are not possible in default constructor
187
188 if ( strcmp(GetTitle(), "") == 0 )
189 SetTitle("galice.root") ;
9688c1dd 190
191 TString branchname = GetName() ;
192 branchname.Remove(branchname.Index(Version())-1) ;
193
194 AliPHOSGetter * gime = AliPHOSGetter::GetInstance(GetTitle(), branchname) ;
7b7c1533 195 if ( gime == 0 ) {
196 cerr << "ERROR: AliPHOSTrackSegmentMakerv1::Init -> Could not obtain the Getter object !" << endl ;
197 return ;
198 }
199
7b7c1533 200 fLinkUpArray = new TClonesArray("AliPHOSLink", 1000);
201
202 //add Task to //YSAlice/tasks/Reconstructioner/PHOS
55ea5766 203 gime->PostTrackSegmentMaker(this) ;
7b7c1533 204
55ea5766 205 // create a folder on the white board //YSAlice/WhiteBoard/RecPoints/PHOS/trackSegmentsName
9688c1dd 206 gime->PostTrackSegments(branchname) ;
7b7c1533 207
208}
209
d15a28e7 210//____________________________________________________________________________
baef0810 211void AliPHOSTrackSegmentMakerv1::MakeLinks()const
d15a28e7 212{
f035f6ce 213 // Finds distances (links) between all EMC and PPSD clusters,
214 // which are not further apart from each other than fR0
215 // and sort them in accordance with this distance
9688c1dd 216
55ea5766 217 TString taskName(GetName()) ;
218 taskName.Remove(taskName.Index(Version())-1) ;
7b7c1533 219 AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
55ea5766 220 TObjArray * emcRecPoints = gime->EmcRecPoints(taskName) ;
221 TObjArray * cpvRecPoints = gime->CpvRecPoints(taskName) ;
7b7c1533 222
2731cd1e 223 fLinkUpArray->Clear() ;
2731cd1e 224
2731cd1e 225 AliPHOSRecPoint * cpv ;
92862013 226 AliPHOSEmcRecPoint * emcclu ;
28c3a259 227
d15a28e7 228 Int_t iLinkUp = 0 ;
229
28c3a259 230 Int_t iEmcRP;
2731cd1e 231 for(iEmcRP = fEmcFirst; iEmcRP < fEmcLast; iEmcRP++ ) {
29b077b5 232 emcclu = dynamic_cast<AliPHOSEmcRecPoint *>(emcRecPoints->At(iEmcRP)) ;
2731cd1e 233
9688c1dd 234 Bool_t toofar ;
2731cd1e 235 Int_t iCpv = 0 ;
236 for(iCpv = fCpvFirst; iCpv < fCpvLast;iCpv++ ) {
28c3a259 237
29b077b5 238 cpv = dynamic_cast<AliPHOSRecPoint *>(cpvRecPoints->At(iCpv)) ;
2731cd1e 239 Float_t r = GetDistanceInPHOSPlane(emcclu, cpv, toofar) ;
d15a28e7 240
92862013 241 if(toofar)
d15a28e7 242 break ;
83974468 243 if(r < fR0) {
2731cd1e 244 new ((*fLinkUpArray)[iLinkUp++]) AliPHOSLink(r, iEmcRP, iCpv) ;
28c3a259 245 }
d15a28e7 246 }
28c3a259 247 }
d15a28e7 248
9688c1dd 249 fLinkUpArray->Sort() ; //first links with smallest distances
d15a28e7 250}
28c3a259 251
d15a28e7 252//____________________________________________________________________________
2731cd1e 253void AliPHOSTrackSegmentMakerv1::MakePairs()
6ad0bfa0 254{
f035f6ce 255 // Using the previously made list of "links", we found the smallest link - i.e.
a4e98857 256 // link with the least distance between EMC and CPV and pointing to still
f035f6ce 257 // unassigned RecParticles. We assign these RecPoints to TrackSegment and
258 // remove them from the list of "unassigned".
6ad0bfa0 259
55ea5766 260 TString taskName(GetName()) ;
261 taskName.Remove(taskName.Index(Version())-1) ;
262
7b7c1533 263 AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
55ea5766 264 TObjArray * emcRecPoints = gime->EmcRecPoints(taskName) ;
265 TObjArray * cpvRecPoints = gime->CpvRecPoints(taskName) ;
266 TClonesArray * trackSegments = gime->TrackSegments(taskName) ;
9688c1dd 267
01a599c9 268 //Make arrays to mark clusters already chosen
2731cd1e 269 Int_t * emcExist = 0;
270 if(fEmcLast > fEmcFirst)
271 emcExist = new Int_t[fEmcLast-fEmcFirst] ;
272
273 Int_t index;
274 for(index = 0; index <fEmcLast-fEmcFirst; index ++)
275 emcExist[index] = 1 ;
276
277 Bool_t * cpvExist = 0;
278 if(fCpvLast > fCpvFirst)
279 cpvExist = new Bool_t[fCpvLast-fCpvFirst] ;
280 for(index = 0; index <fCpvLast-fCpvFirst; index ++)
281 cpvExist[index] = kTRUE ;
282
2731cd1e 283
284 // Finds the smallest links and makes pairs of CPV and EMC clusters with smallest distance
2731cd1e 285 TIter nextUp(fLinkUpArray) ;
d15a28e7 286
d15a28e7 287 AliPHOSLink * linkUp ;
9688c1dd 288
2731cd1e 289 AliPHOSRecPoint * nullpointer = 0 ;
9688c1dd 290
29b077b5 291 while ( (linkUp = static_cast<AliPHOSLink *>(nextUp()) ) ){
9688c1dd 292
2731cd1e 293 if(emcExist[linkUp->GetEmc()-fEmcFirst] != -1){ //without ppsd Up yet
d15a28e7 294
2731cd1e 295 if(cpvExist[linkUp->GetPpsd()-fCpvFirst]){ //CPV still exist
7956ec10 296
9688c1dd 297 new ((* trackSegments)[fNTrackSegments])
29b077b5 298 AliPHOSTrackSegment(dynamic_cast<AliPHOSEmcRecPoint *>(emcRecPoints->At(linkUp->GetEmc())) ,
299 dynamic_cast<AliPHOSRecPoint *>(cpvRecPoints->At(linkUp->GetPpsd()))) ;
300 (dynamic_cast<AliPHOSTrackSegment *>(trackSegments->At(fNTrackSegments)))->SetIndexInList(fNTrackSegments);
9688c1dd 301 fNTrackSegments++ ;
302
2731cd1e 303 emcExist[linkUp->GetEmc()-fEmcFirst] = -1 ; //Mark emc that Cpv was found
304 //mark CPV recpoint as already used
9688c1dd 305 cpvExist[linkUp->GetPpsd()-fCpvFirst] = kFALSE ;
7956ec10 306 } //if ppsdUp still exist
28c3a259 307 }
308 }
309
2731cd1e 310 //look through emc recPoints left without CPV/PPSD
311 if(emcExist){ //if there is emc rec point
312 Int_t iEmcRP ;
313 for(iEmcRP = 0; iEmcRP < fEmcLast-fEmcFirst ; iEmcRP++ ){
314 if(emcExist[iEmcRP] > 0 ){
9688c1dd 315 new ((*trackSegments)[fNTrackSegments])
29b077b5 316 AliPHOSTrackSegment(dynamic_cast<AliPHOSEmcRecPoint *>(emcRecPoints->At(iEmcRP+fEmcFirst)),
9688c1dd 317 nullpointer) ;
29b077b5 318 (dynamic_cast<AliPHOSTrackSegment *>(trackSegments->At(fNTrackSegments)))->SetIndexInList(fNTrackSegments);
2731cd1e 319 fNTrackSegments++;
320 }
d15a28e7 321 }
d15a28e7 322 }
780a31c1 323 delete [] emcExist ;
324 delete [] cpvExist ;
d15a28e7 325}
326
327//____________________________________________________________________________
2731cd1e 328void AliPHOSTrackSegmentMakerv1::Exec(Option_t * option)
d15a28e7 329{
a4e98857 330 // STEERing method
28c3a259 331
7b7c1533 332 if( strcmp(GetName(), "")== 0 )
333 Init() ;
6ad0bfa0 334
2731cd1e 335 if(strstr(option,"tim"))
b3f97575 336 gBenchmark->Start("PHOSTSMaker");
7b7c1533 337
338 if(strstr(option,"print")) {
339 Print("") ;
340 return ;
341 }
d15a28e7 342
55ea5766 343 gAlice->GetEvent(0) ;
9688c1dd 344 //check, if the branch with name of this" already exits?
29b077b5 345 TObjArray * lob = static_cast<TObjArray*>(gAlice->TreeR()->GetListOfBranches()) ;
7b7c1533 346 TIter next(lob) ;
347 TBranch * branch = 0 ;
348 Bool_t phostsfound = kFALSE, tracksegmentmakerfound = kFALSE ;
2731cd1e 349
9688c1dd 350 TString branchname = GetName() ;
351 branchname.Remove(branchname.Index(Version())-1) ;
7b7c1533 352
29b077b5 353 while ( (branch = static_cast<TBranch*>(next())) && (!phostsfound || !tracksegmentmakerfound) ) {
9688c1dd 354 if ( (strcmp(branch->GetName(), "PHOSTS")==0) && (strcmp(branch->GetTitle(), branchname.Data())==0) )
7b7c1533 355 phostsfound = kTRUE ;
356
9688c1dd 357 else if ( (strcmp(branch->GetName(), "AliPHOSTrackSegmentMaker")==0) && (strcmp(branch->GetTitle(), GetName())==0) )
7b7c1533 358 tracksegmentmakerfound = kTRUE ;
359 }
360
361 if ( phostsfound || tracksegmentmakerfound ) {
362 cerr << "WARNING: AliPHOSTrackSegmentMakerv1::Exec -> TrackSegments and/or TrackSegmentMaker branch with name "
9688c1dd 363 << branchname.Data() << " already exits" << endl ;
7b7c1533 364 return ;
365 }
366
9688c1dd 367 AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
55ea5766 368 const AliPHOSGeometry * geom = gime->PHOSGeometry() ;
7b7c1533 369 Int_t nevents = (Int_t) gAlice->TreeE()->GetEntries() ;
370 Int_t ievent ;
371
372 for(ievent = 0; ievent < nevents; ievent++){
01a599c9 373
55ea5766 374 gime->Event(ievent,"R") ;
55ea5766 375 //Make some initializations
376 fNTrackSegments = 0 ;
377 fEmcFirst = 0 ;
378 fEmcLast = 0 ;
379 fCpvFirst = 0 ;
380 fCpvLast = 0 ;
9688c1dd 381 gime->TrackSegments(branchname)->Clear() ;
55ea5766 382
9688c1dd 383 // if(!ReadRecPoints(ievent)) continue; //reads RecPoints for event ievent
384
7b7c1533 385 for(fModule = 1; fModule <= geom->GetNModules() ; fModule++ ){
2731cd1e 386
387 FillOneModule() ;
388
389 MakeLinks() ;
390
391 MakePairs() ;
392
393 }
28c3a259 394
7b7c1533 395 WriteTrackSegments(ievent) ;
396
2731cd1e 397 if(strstr(option,"deb"))
398 PrintTrackSegments(option) ;
94de8339 399
400 //increment the total number of track segments per run
401 fTrackSegmentsInRun += gime->TrackSegments()->GetEntriesFast() ;
7b7c1533 402
2731cd1e 403 }
9f616d61 404
2731cd1e 405 if(strstr(option,"tim")){
406 gBenchmark->Stop("PHOSTSMaker");
407 cout << "AliPHOSTSMaker:" << endl ;
408 cout << " took " << gBenchmark->GetCpuTime("PHOSTSMaker") << " seconds for making TS "
7b7c1533 409 << gBenchmark->GetCpuTime("PHOSTSMaker")/nevents << " seconds per event " << endl ;
2731cd1e 410 cout << endl ;
411 }
7b7c1533 412
d15a28e7 413}
7b7c1533 414
d15a28e7 415//____________________________________________________________________________
baef0810 416void AliPHOSTrackSegmentMakerv1::Print(Option_t * option)const
a4e98857 417{
baef0810 418 // Print TrackSegmentMaker parameters
419
7b7c1533 420 if( strcmp(GetName(), "") != 0 ) {
2731cd1e 421 cout << "======== AliPHOSTrackSegmentMakerv1 ========" << endl ;
422 cout << "Making Track segments "<< endl ;
f035f6ce 423 cout << " Headers file: " << fHeaderFileName.Data() << endl ;
424 cout << " RecPoints branch file name: " << fRecPointsBranchTitle.Data() << endl ;
7b7c1533 425 cout << " TrackSegments Branch file name: " << fTrackSegmentsBranchTitle.Data() << endl ;
2731cd1e 426 cout << "with parameters: " << endl ;
f035f6ce 427 cout << " Maximal EMC - CPV (PPSD) distance (cm)" << fR0 << endl ;
2731cd1e 428 cout << "============================================" << endl ;
429 }
430 else
431 cout << "AliPHOSTrackSegmentMakerv1 not initialized " << endl ;
d15a28e7 432}
7b7c1533 433
d15a28e7 434//____________________________________________________________________________
7b7c1533 435void AliPHOSTrackSegmentMakerv1::WriteTrackSegments(Int_t event)
a4e98857 436{
f035f6ce 437 // Writes found TrackSegments to TreeR. Creates branches
438 // "PHOSTS" and "AliPHOSTrackSegmentMaker" with the same title.
439 // In the former branch found TrackSegments are stored, while
440 // in the latter all parameters, with which TS were made.
441 // ROOT does not allow overwriting existing branches, therefore
a4e98857 442 // first we check, if branches with the same title already exist.
f035f6ce 443 // If yes - exits without writing.
2731cd1e 444
7b7c1533 445 AliPHOSGetter *gime = AliPHOSGetter::GetInstance() ;
55ea5766 446
9688c1dd 447 TString branchName(GetName() ) ;
448 branchName.Remove(branchName.Index(Version())-1) ;
449
450 TClonesArray * trackSegments = gime->TrackSegments(branchName) ;
55ea5766 451 trackSegments->Expand(trackSegments->GetEntriesFast()) ;
9f616d61 452
2731cd1e 453 //Make branch in TreeR for TrackSegments
454 char * filename = 0;
455 if(gSystem->Getenv("CONFIG_SPLIT_FILE")!=0){ //generating file name
456 filename = new char[strlen(gAlice->GetBaseFile())+20] ;
457 sprintf(filename,"%s/PHOS.Reco.root",gAlice->GetBaseFile()) ;
d15a28e7 458 }
459
2731cd1e 460 TDirectory *cwd = gDirectory;
31aa6d6c 461
2731cd1e 462 //First TS
463 Int_t bufferSize = 32000 ;
7b7c1533 464 TBranch * tsBranch = gAlice->TreeR()->Branch("PHOSTS",&trackSegments,bufferSize);
9688c1dd 465 tsBranch->SetTitle(branchName);
2731cd1e 466 if (filename) {
467 tsBranch->SetFile(filename);
468 TIter next( tsBranch->GetListOfBranches());
761e34c0 469 TBranch * sb ;
29b077b5 470 while ((sb=static_cast<TBranch*>(next()))) {
761e34c0 471 sb->SetFile(filename);
2731cd1e 472 }
473 cwd->cd();
474 }
98cbd830 475
2731cd1e 476 //Second -TSMaker
477 Int_t splitlevel = 0 ;
478 AliPHOSTrackSegmentMakerv1 * ts = this ;
7b7c1533 479 TBranch * tsMakerBranch = gAlice->TreeR()->Branch("AliPHOSTrackSegmentMaker","AliPHOSTrackSegmentMakerv1",
2731cd1e 480 &ts,bufferSize,splitlevel);
9688c1dd 481 tsMakerBranch->SetTitle(branchName);
2731cd1e 482 if (filename) {
483 tsMakerBranch->SetFile(filename);
484 TIter next( tsMakerBranch->GetListOfBranches());
761e34c0 485 TBranch * sb;
29b077b5 486 while ((sb=static_cast<TBranch*>(next()))) {
761e34c0 487 sb->SetFile(filename);
2731cd1e 488 }
489 cwd->cd();
490 }
9f616d61 491
761e34c0 492 tsBranch->Fill() ;
493 tsMakerBranch->Fill() ;
eec3ac52 494
2731cd1e 495 gAlice->TreeR()->Write(0,kOverwrite) ;
496
780a31c1 497 delete [] filename ;
2731cd1e 498}
98cbd830 499
98cbd830 500
2731cd1e 501//____________________________________________________________________________
a4e98857 502void AliPHOSTrackSegmentMakerv1::PrintTrackSegments(Option_t * option)
503{
f035f6ce 504 // option deb - prints # of found TrackSegments
505 // option deb all - prints as well indexed of found RecParticles assigned to the TS
55ea5766 506 TString taskName(GetName()) ;
507 taskName.Remove(taskName.Index(Version())-1) ;
508
509 TClonesArray * trackSegments = AliPHOSGetter::GetInstance()->TrackSegments(taskName) ;
9688c1dd 510
2731cd1e 511
01a599c9 512 cout << "AliPHOSTrackSegmentMakerv1: event "<<gAlice->GetEvNumber() << endl ;
7b7c1533 513 cout << " Found " << trackSegments->GetEntriesFast() << " trackSegments " << endl ;
2731cd1e 514
515 if(strstr(option,"all")) { // printing found TS
9688c1dd 516 cout << "TrackSegment # " << " EMC RP# " << " CPV RP# " << endl ;
2731cd1e 517
518 Int_t index;
7b7c1533 519 for (index = 0 ; index <trackSegments->GetEntriesFast() ; index++) {
520 AliPHOSTrackSegment * ts = (AliPHOSTrackSegment * )trackSegments->At(index) ;
2731cd1e 521 cout<<" "<< setw(4) << ts->GetIndexInList() << " "
522 <<setw(4) << ts->GetEmcIndex()<< " "
9688c1dd 523 <<setw(4) << ts->GetCpvIndex()<< " " << endl ;
2731cd1e 524 }
525
526 cout << "-------------------------------------------------------"<< endl ;
d15a28e7 527 }
2731cd1e 528}