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