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