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