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