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