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" |
2731cd1e |
63 | #include "AliPHOSPpsdRecPoint.h" |
d15a28e7 |
64 | #include "AliPHOSLink.h" |
7b7c1533 |
65 | #include "AliPHOSGetter.h" |
baef0810 |
66 | #include "AliPHOS.h" |
d15a28e7 |
67 | #include "AliRun.h" |
68 | |
69 | ClassImp( AliPHOSTrackSegmentMakerv1) |
70 | |
71 | |
72 | //____________________________________________________________________________ |
2bd5457f |
73 | AliPHOSTrackSegmentMakerv1::AliPHOSTrackSegmentMakerv1() : AliPHOSTrackSegmentMaker() |
d15a28e7 |
74 | { |
7b7c1533 |
75 | // default ctor (to be used mainly by Streamer) |
76 | |
77 | fR0 = 10. ; |
78 | fEmcFirst = 0 ; |
79 | fEmcLast = 0 ; |
80 | fCpvFirst = 0 ; |
81 | fCpvLast = 0 ; |
82 | fPpsdFirst = 0 ; |
83 | fPpsdLast = 0 ; |
84 | fLinkLowArray = 0 ; |
85 | fLinkUpArray = 0 ; |
86 | fHeaderFileName = "" ; |
87 | fRecPointsBranchTitle = "" ; |
88 | fTrackSegmentsBranchTitle = "" ; |
2b60655b |
89 | fTrackSegmentsInRun = 0 ; |
d15a28e7 |
90 | } |
7b7c1533 |
91 | |
9f616d61 |
92 | //____________________________________________________________________________ |
7b7c1533 |
93 | AliPHOSTrackSegmentMakerv1::AliPHOSTrackSegmentMakerv1(const char * headerFile, const char * name) : AliPHOSTrackSegmentMaker(headerFile, name) |
2731cd1e |
94 | { |
95 | // ctor |
2731cd1e |
96 | |
7b7c1533 |
97 | fR0 = 10. ; |
98 | fEmcFirst = 0 ; |
99 | fEmcLast = 0 ; |
100 | fCpvFirst = 0 ; |
101 | fCpvLast = 0 ; |
102 | fPpsdFirst = 0 ; |
103 | fPpsdLast = 0 ; |
104 | |
105 | fHeaderFileName = GetTitle() ; |
106 | fRecPointsBranchTitle = GetName() ; |
107 | fTrackSegmentsBranchTitle = GetName() ; |
2b60655b |
108 | fTrackSegmentsInRun = 0 ; |
109 | |
7b7c1533 |
110 | TString tempo(GetName()) ; |
55ea5766 |
111 | tempo.Append(":") ; |
7b7c1533 |
112 | tempo.Append(Version()) ; |
113 | SetName(tempo.Data()) ; |
b2a60966 |
114 | |
7b7c1533 |
115 | Init() ; |
98cbd830 |
116 | |
2731cd1e |
117 | } |
98cbd830 |
118 | |
2731cd1e |
119 | //____________________________________________________________________________ |
120 | AliPHOSTrackSegmentMakerv1::~AliPHOSTrackSegmentMakerv1() |
121 | { |
122 | // dtor |
123 | if(fLinkLowArray) delete fLinkLowArray ; |
124 | if(fLinkUpArray) delete fLinkUpArray ; |
d15a28e7 |
125 | } |
9f616d61 |
126 | |
d15a28e7 |
127 | //____________________________________________________________________________ |
2731cd1e |
128 | void AliPHOSTrackSegmentMakerv1::FillOneModule() |
9f616d61 |
129 | { |
f035f6ce |
130 | // Finds first and last indexes between which |
131 | // clusters from one PHOS module are |
55ea5766 |
132 | |
133 | TString taskName(GetName()) ; |
134 | taskName.Remove(taskName.Index(Version())-1) ; |
7b7c1533 |
135 | AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ; |
136 | const AliPHOSGeometry * geom = gime->PHOSGeometry() ; |
55ea5766 |
137 | TObjArray * emcRecPoints = gime->EmcRecPoints(taskName) ; |
138 | TObjArray * cpvRecPoints = gime->CpvRecPoints(taskName) ; |
2731cd1e |
139 | |
140 | //First EMC clusters |
7b7c1533 |
141 | Int_t totalEmc = emcRecPoints->GetEntriesFast() ; |
2731cd1e |
142 | for(fEmcFirst = fEmcLast; (fEmcLast < totalEmc) && |
7b7c1533 |
143 | (((AliPHOSRecPoint *) emcRecPoints->At(fEmcLast))->GetPHOSMod() == fModule ); |
2731cd1e |
144 | fEmcLast ++) ; |
145 | |
2731cd1e |
146 | //Now CPV clusters |
7b7c1533 |
147 | Int_t totalCpv = cpvRecPoints->GetEntriesFast() ; |
6ad0bfa0 |
148 | |
7b7c1533 |
149 | if(fModule <= geom->GetNCPVModules()){ // in CPV geometry |
9f616d61 |
150 | |
2731cd1e |
151 | for(fCpvFirst = fCpvLast; (fCpvLast < totalCpv) && |
7b7c1533 |
152 | (((AliPHOSRecPoint *) cpvRecPoints->At(fCpvLast))->GetPHOSMod() == fModule ); |
2731cd1e |
153 | fCpvLast ++) ; |
31aa6d6c |
154 | |
2731cd1e |
155 | fPpsdFirst = fCpvLast ; //To avoid scanning RecPoints between fPpsdFirst and fPpsdLast |
156 | fPpsdLast = fCpvLast ; //and to be ready to switch to mixed geometry |
d15a28e7 |
157 | } |
2731cd1e |
158 | else{ //in PPSD geometry |
159 | fCpvLast = fPpsdLast ; |
160 | //Upper layer first |
161 | for(fCpvFirst = fCpvLast; (fCpvLast < totalCpv) && |
7b7c1533 |
162 | (((AliPHOSPpsdRecPoint *) cpvRecPoints->At(fCpvLast))->GetPHOSMod() == fModule ) && |
163 | (((AliPHOSPpsdRecPoint *) cpvRecPoints->At(fCpvLast))->GetUp()) ; |
2731cd1e |
164 | fCpvLast ++) ; |
165 | |
166 | fPpsdLast= fCpvLast ; |
167 | for(fPpsdFirst = fPpsdLast; (fPpsdLast < totalCpv) && |
7b7c1533 |
168 | (((AliPHOSPpsdRecPoint *) cpvRecPoints->At(fPpsdLast))->GetPHOSMod() == fModule ) && |
169 | (!((AliPHOSPpsdRecPoint *) cpvRecPoints->At(fPpsdLast))->GetUp()) ; |
2731cd1e |
170 | fPpsdLast ++) ; |
d15a28e7 |
171 | } |
2731cd1e |
172 | |
d15a28e7 |
173 | } |
7b7c1533 |
174 | |
d15a28e7 |
175 | //____________________________________________________________________________ |
baef0810 |
176 | Float_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() |
92862013 |
183 | Float_t r = fR0 ; |
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()){ |
192 | if(vecCpv.X() <= vecEmc.X() + fR0 + 2*delta ){ |
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 | //____________________________________________________________________________ |
212 | void 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") ; |
218 | |
219 | TString taskName(GetName()) ; |
55ea5766 |
220 | taskName.Remove(taskName.Index(Version())-1) ; |
7b7c1533 |
221 | |
55ea5766 |
222 | AliPHOSGetter * gime = AliPHOSGetter::GetInstance(GetTitle(), taskName) ; |
7b7c1533 |
223 | if ( gime == 0 ) { |
224 | cerr << "ERROR: AliPHOSTrackSegmentMakerv1::Init -> Could not obtain the Getter object !" << endl ; |
225 | return ; |
226 | } |
227 | |
228 | fLinkLowArray = new TClonesArray("AliPHOSLink", 1000); |
229 | fLinkUpArray = new TClonesArray("AliPHOSLink", 1000); |
230 | |
231 | //add Task to //YSAlice/tasks/Reconstructioner/PHOS |
55ea5766 |
232 | gime->PostTrackSegmentMaker(this) ; |
7b7c1533 |
233 | |
55ea5766 |
234 | // create a folder on the white board //YSAlice/WhiteBoard/RecPoints/PHOS/trackSegmentsName |
235 | gime->PostTrackSegments(taskName) ; |
7b7c1533 |
236 | |
237 | } |
238 | |
d15a28e7 |
239 | //____________________________________________________________________________ |
baef0810 |
240 | void AliPHOSTrackSegmentMakerv1::MakeLinks()const |
d15a28e7 |
241 | { |
f035f6ce |
242 | // Finds distances (links) between all EMC and PPSD clusters, |
243 | // which are not further apart from each other than fR0 |
244 | // and sort them in accordance with this distance |
55ea5766 |
245 | |
246 | TString taskName(GetName()) ; |
247 | taskName.Remove(taskName.Index(Version())-1) ; |
b2a60966 |
248 | |
7b7c1533 |
249 | AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ; |
55ea5766 |
250 | TObjArray * emcRecPoints = gime->EmcRecPoints(taskName) ; |
251 | TObjArray * cpvRecPoints = gime->CpvRecPoints(taskName) ; |
7b7c1533 |
252 | |
2731cd1e |
253 | fLinkUpArray->Clear() ; |
254 | fLinkLowArray->Clear() ; |
255 | |
256 | AliPHOSRecPoint * ppsd ; |
257 | AliPHOSRecPoint * cpv ; |
92862013 |
258 | AliPHOSEmcRecPoint * emcclu ; |
28c3a259 |
259 | |
d15a28e7 |
260 | Int_t iLinkLow = 0 ; |
261 | Int_t iLinkUp = 0 ; |
262 | |
28c3a259 |
263 | Int_t iEmcRP; |
2731cd1e |
264 | for(iEmcRP = fEmcFirst; iEmcRP < fEmcLast; iEmcRP++ ) { |
7b7c1533 |
265 | emcclu = (AliPHOSEmcRecPoint *) emcRecPoints->At(iEmcRP) ; |
2731cd1e |
266 | |
267 | Bool_t toofar ; |
268 | Int_t iPpsd ; |
269 | for(iPpsd = fPpsdFirst; iPpsd < fPpsdLast;iPpsd++ ) { |
d15a28e7 |
270 | |
7b7c1533 |
271 | ppsd = (AliPHOSRecPoint *) cpvRecPoints->At(iPpsd) ; |
2731cd1e |
272 | Float_t r = GetDistanceInPHOSPlane(emcclu, ppsd, toofar) ; |
273 | |
92862013 |
274 | if(toofar) |
d15a28e7 |
275 | break ; |
2731cd1e |
276 | if(r < fR0) |
277 | new ((*fLinkLowArray)[iLinkLow++]) AliPHOSLink(r, iEmcRP, iPpsd) ; |
d15a28e7 |
278 | } |
279 | |
2731cd1e |
280 | Int_t iCpv = 0 ; |
281 | for(iCpv = fCpvFirst; iCpv < fCpvLast;iCpv++ ) { |
28c3a259 |
282 | |
7b7c1533 |
283 | cpv = (AliPHOSRecPoint *) cpvRecPoints->At(iCpv) ; |
2731cd1e |
284 | Float_t r = GetDistanceInPHOSPlane(emcclu, cpv, toofar) ; |
d15a28e7 |
285 | |
92862013 |
286 | if(toofar) |
d15a28e7 |
287 | break ; |
83974468 |
288 | if(r < fR0) { |
2731cd1e |
289 | new ((*fLinkUpArray)[iLinkUp++]) AliPHOSLink(r, iEmcRP, iCpv) ; |
28c3a259 |
290 | } |
d15a28e7 |
291 | } |
28c3a259 |
292 | } |
d15a28e7 |
293 | |
2731cd1e |
294 | fLinkLowArray->Sort() ; //first links with smallest distances |
295 | fLinkUpArray->Sort() ; |
d15a28e7 |
296 | } |
28c3a259 |
297 | |
d15a28e7 |
298 | //____________________________________________________________________________ |
2731cd1e |
299 | void AliPHOSTrackSegmentMakerv1::MakePairs() |
6ad0bfa0 |
300 | { |
f035f6ce |
301 | // Using the previously made list of "links", we found the smallest link - i.e. |
a4e98857 |
302 | // link with the least distance between EMC and CPV and pointing to still |
f035f6ce |
303 | // unassigned RecParticles. We assign these RecPoints to TrackSegment and |
304 | // remove them from the list of "unassigned". |
6ad0bfa0 |
305 | |
55ea5766 |
306 | TString taskName(GetName()) ; |
307 | taskName.Remove(taskName.Index(Version())-1) ; |
308 | |
7b7c1533 |
309 | AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ; |
55ea5766 |
310 | TObjArray * emcRecPoints = gime->EmcRecPoints(taskName) ; |
311 | TObjArray * cpvRecPoints = gime->CpvRecPoints(taskName) ; |
312 | TClonesArray * trackSegments = gime->TrackSegments(taskName) ; |
7b7c1533 |
313 | |
01a599c9 |
314 | //Make arrays to mark clusters already chosen |
2731cd1e |
315 | Int_t * emcExist = 0; |
316 | if(fEmcLast > fEmcFirst) |
317 | emcExist = new Int_t[fEmcLast-fEmcFirst] ; |
318 | |
319 | Int_t index; |
320 | for(index = 0; index <fEmcLast-fEmcFirst; index ++) |
321 | emcExist[index] = 1 ; |
322 | |
323 | Bool_t * cpvExist = 0; |
324 | if(fCpvLast > fCpvFirst) |
325 | cpvExist = new Bool_t[fCpvLast-fCpvFirst] ; |
326 | for(index = 0; index <fCpvLast-fCpvFirst; index ++) |
327 | cpvExist[index] = kTRUE ; |
328 | |
329 | Bool_t * ppsdExist = 0; |
330 | if(fPpsdLast > fPpsdFirst) |
331 | ppsdExist = new Bool_t[fPpsdLast-fPpsdFirst] ; |
332 | for(index = 0; index <fPpsdLast-fPpsdFirst; index ++) |
333 | ppsdExist[index] = kTRUE ; |
334 | |
335 | // Finds the smallest links and makes pairs of CPV and EMC clusters with smallest distance |
336 | TIter nextLow(fLinkLowArray) ; |
337 | TIter nextUp(fLinkUpArray) ; |
d15a28e7 |
338 | |
339 | AliPHOSLink * linkLow ; |
340 | AliPHOSLink * linkUp ; |
341 | |
d15a28e7 |
342 | |
2731cd1e |
343 | AliPHOSRecPoint * nullpointer = 0 ; |
9f616d61 |
344 | |
d15a28e7 |
345 | while ( (linkLow = (AliPHOSLink *)nextLow() ) ){ |
55ea5766 |
346 | |
144a844a |
347 | if( (emcExist[linkLow->GetEmc()-fEmcFirst]> 0) && |
348 | ppsdExist[linkLow->GetPpsd()-fPpsdFirst] ){ // RecPoints not removed yet |
7b7c1533 |
349 | new ((*trackSegments)[fNTrackSegments]) AliPHOSTrackSegment((AliPHOSEmcRecPoint *) emcRecPoints->At(linkLow->GetEmc()), |
2731cd1e |
350 | nullpointer, |
7b7c1533 |
351 | (AliPHOSRecPoint *)cpvRecPoints->At(linkLow->GetPpsd()) ) ; |
2731cd1e |
352 | |
7b7c1533 |
353 | ((AliPHOSTrackSegment* )trackSegments->At(fNTrackSegments))->SetIndexInList(fNTrackSegments); |
28c3a259 |
354 | //replace index of emc to negative and shifted index of TS |
2731cd1e |
355 | emcExist[linkLow->GetEmc()-fEmcFirst] = -2 - fNTrackSegments ; |
356 | //mark ppsd as used |
357 | ppsdExist[linkLow->GetPpsd()-fPpsdFirst] = kFALSE ; |
28c3a259 |
358 | fNTrackSegments++ ; |
6ad0bfa0 |
359 | } |
d15a28e7 |
360 | } |
28c3a259 |
361 | |
2731cd1e |
362 | |
28c3a259 |
363 | while ( (linkUp = (AliPHOSLink *)nextUp() ) ){ |
2731cd1e |
364 | if(emcExist[linkUp->GetEmc()-fEmcFirst] != -1){ //without ppsd Up yet |
d15a28e7 |
365 | |
2731cd1e |
366 | if(cpvExist[linkUp->GetPpsd()-fCpvFirst]){ //CPV still exist |
7956ec10 |
367 | |
2731cd1e |
368 | if(emcExist[linkUp->GetEmc()-fEmcFirst] > 0){ //without ppsd Low => create new TS |
7956ec10 |
369 | |
7b7c1533 |
370 | new ((* trackSegments)[fNTrackSegments]) AliPHOSTrackSegment((AliPHOSEmcRecPoint *) emcRecPoints->At(linkUp->GetEmc()) , |
371 | (AliPHOSRecPoint *)cpvRecPoints->At(linkUp->GetPpsd()), |
2731cd1e |
372 | nullpointer) ; |
7b7c1533 |
373 | ((AliPHOSTrackSegment *) trackSegments->At(fNTrackSegments))->SetIndexInList(fNTrackSegments); |
7956ec10 |
374 | fNTrackSegments++ ; |
375 | } |
376 | else{ // append ppsd Up to existing TS |
7b7c1533 |
377 | ((AliPHOSTrackSegment *)trackSegments->At(-2-emcExist[linkUp->GetEmc()-fEmcFirst]))->SetCpvRecPoint((AliPHOSCpvRecPoint *)cpvRecPoints->At(linkUp->GetPpsd())); |
7956ec10 |
378 | } |
379 | |
2731cd1e |
380 | emcExist[linkUp->GetEmc()-fEmcFirst] = -1 ; //Mark emc that Cpv was found |
381 | //mark CPV recpoint as already used |
382 | cpvExist[linkUp->GetPpsd()-fCpvFirst] = kFALSE ; |
7956ec10 |
383 | } //if ppsdUp still exist |
28c3a259 |
384 | } |
385 | } |
386 | |
2731cd1e |
387 | //look through emc recPoints left without CPV/PPSD |
388 | if(emcExist){ //if there is emc rec point |
389 | Int_t iEmcRP ; |
390 | for(iEmcRP = 0; iEmcRP < fEmcLast-fEmcFirst ; iEmcRP++ ){ |
391 | if(emcExist[iEmcRP] > 0 ){ |
7b7c1533 |
392 | new ((*trackSegments)[fNTrackSegments]) AliPHOSTrackSegment((AliPHOSEmcRecPoint *)emcRecPoints->At(iEmcRP+fEmcFirst), |
2731cd1e |
393 | nullpointer, |
394 | nullpointer ) ; |
7b7c1533 |
395 | ((AliPHOSTrackSegment *) trackSegments->At(fNTrackSegments))->SetIndexInList(fNTrackSegments); |
2731cd1e |
396 | fNTrackSegments++; |
397 | } |
d15a28e7 |
398 | } |
d15a28e7 |
399 | } |
28c3a259 |
400 | |
d15a28e7 |
401 | } |
402 | |
403 | //____________________________________________________________________________ |
2731cd1e |
404 | void AliPHOSTrackSegmentMakerv1::Exec(Option_t * option) |
d15a28e7 |
405 | { |
a4e98857 |
406 | // STEERing method |
28c3a259 |
407 | |
7b7c1533 |
408 | if( strcmp(GetName(), "")== 0 ) |
409 | Init() ; |
6ad0bfa0 |
410 | |
2731cd1e |
411 | if(strstr(option,"tim")) |
b3f97575 |
412 | gBenchmark->Start("PHOSTSMaker"); |
7b7c1533 |
413 | |
414 | if(strstr(option,"print")) { |
415 | Print("") ; |
416 | return ; |
417 | } |
d15a28e7 |
418 | |
7b7c1533 |
419 | //check, if the branch with name of this" already exits? |
55ea5766 |
420 | gAlice->GetEvent(0) ; |
7b7c1533 |
421 | TObjArray * lob = (TObjArray*)gAlice->TreeR()->GetListOfBranches() ; |
422 | TIter next(lob) ; |
423 | TBranch * branch = 0 ; |
424 | Bool_t phostsfound = kFALSE, tracksegmentmakerfound = kFALSE ; |
2731cd1e |
425 | |
7b7c1533 |
426 | TString taskName(GetName()) ; |
55ea5766 |
427 | taskName.Remove(taskName.Index(Version())-1) ; |
7b7c1533 |
428 | |
429 | while ( (branch = (TBranch*)next()) && (!phostsfound || !tracksegmentmakerfound) ) { |
430 | if ( (strcmp(branch->GetName(), "PHOSTS")==0) && (strcmp(branch->GetTitle(), taskName.Data())==0) ) |
431 | phostsfound = kTRUE ; |
432 | |
433 | else if ( (strcmp(branch->GetName(), "AliPHOSTrackSegmentMaker")==0) && (strcmp(branch->GetTitle(), taskName.Data())==0) ) |
434 | tracksegmentmakerfound = kTRUE ; |
435 | } |
436 | |
437 | if ( phostsfound || tracksegmentmakerfound ) { |
438 | cerr << "WARNING: AliPHOSTrackSegmentMakerv1::Exec -> TrackSegments and/or TrackSegmentMaker branch with name " |
439 | << taskName.Data() << " already exits" << endl ; |
440 | return ; |
441 | } |
442 | |
55ea5766 |
443 | AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ; |
444 | const AliPHOSGeometry * geom = gime->PHOSGeometry() ; |
7b7c1533 |
445 | Int_t nevents = (Int_t) gAlice->TreeE()->GetEntries() ; |
446 | Int_t ievent ; |
447 | |
448 | for(ievent = 0; ievent < nevents; ievent++){ |
01a599c9 |
449 | |
55ea5766 |
450 | // if(!ReadRecPoints(ievent)) //reads RecPoints for event ievent |
451 | // continue; |
452 | gime->Event(ievent,"R") ; |
453 | |
454 | //Make some initializations |
455 | fNTrackSegments = 0 ; |
456 | fEmcFirst = 0 ; |
457 | fEmcLast = 0 ; |
458 | fCpvFirst = 0 ; |
459 | fCpvLast = 0 ; |
460 | fPpsdFirst= 0 ; |
461 | fPpsdLast = 0 ; |
462 | gime->TrackSegments(taskName)->Clear() ; |
463 | |
7b7c1533 |
464 | for(fModule = 1; fModule <= geom->GetNModules() ; fModule++ ){ |
2731cd1e |
465 | |
466 | FillOneModule() ; |
467 | |
468 | MakeLinks() ; |
469 | |
470 | MakePairs() ; |
471 | |
472 | } |
28c3a259 |
473 | |
7b7c1533 |
474 | WriteTrackSegments(ievent) ; |
475 | |
2731cd1e |
476 | if(strstr(option,"deb")) |
477 | PrintTrackSegments(option) ; |
7b7c1533 |
478 | |
2731cd1e |
479 | } |
9f616d61 |
480 | |
2731cd1e |
481 | if(strstr(option,"tim")){ |
482 | gBenchmark->Stop("PHOSTSMaker"); |
483 | cout << "AliPHOSTSMaker:" << endl ; |
484 | cout << " took " << gBenchmark->GetCpuTime("PHOSTSMaker") << " seconds for making TS " |
7b7c1533 |
485 | << gBenchmark->GetCpuTime("PHOSTSMaker")/nevents << " seconds per event " << endl ; |
2731cd1e |
486 | cout << endl ; |
487 | } |
7b7c1533 |
488 | |
d15a28e7 |
489 | } |
7b7c1533 |
490 | |
d15a28e7 |
491 | //____________________________________________________________________________ |
baef0810 |
492 | void AliPHOSTrackSegmentMakerv1::Print(Option_t * option)const |
a4e98857 |
493 | { |
baef0810 |
494 | // Print TrackSegmentMaker parameters |
495 | |
7b7c1533 |
496 | if( strcmp(GetName(), "") != 0 ) { |
2731cd1e |
497 | cout << "======== AliPHOSTrackSegmentMakerv1 ========" << endl ; |
498 | cout << "Making Track segments "<< endl ; |
f035f6ce |
499 | cout << " Headers file: " << fHeaderFileName.Data() << endl ; |
500 | cout << " RecPoints branch file name: " << fRecPointsBranchTitle.Data() << endl ; |
7b7c1533 |
501 | cout << " TrackSegments Branch file name: " << fTrackSegmentsBranchTitle.Data() << endl ; |
2731cd1e |
502 | cout << "with parameters: " << endl ; |
f035f6ce |
503 | cout << " Maximal EMC - CPV (PPSD) distance (cm)" << fR0 << endl ; |
2731cd1e |
504 | cout << "============================================" << endl ; |
505 | } |
506 | else |
507 | cout << "AliPHOSTrackSegmentMakerv1 not initialized " << endl ; |
d15a28e7 |
508 | } |
98cbd830 |
509 | //____________________________________________________________________________ |
7b7c1533 |
510 | Bool_t AliPHOSTrackSegmentMakerv1::ReadRecPoints(Int_t event) |
a4e98857 |
511 | { |
7b7c1533 |
512 | // Reads Emc and CPV recPoints |
a4e98857 |
513 | // made previously with Clusterizer. |
f035f6ce |
514 | |
2731cd1e |
515 | |
516 | //Make some initializations |
7b7c1533 |
517 | |
2731cd1e |
518 | fNTrackSegments = 0 ; |
519 | fEmcFirst = 0 ; |
520 | fEmcLast = 0 ; |
521 | fCpvFirst = 0 ; |
522 | fCpvLast = 0 ; |
523 | fPpsdFirst= 0 ; |
524 | fPpsdLast = 0 ; |
525 | |
2731cd1e |
526 | // Get TreeR header from file |
2731cd1e |
527 | if(gAlice->TreeR()==0){ |
7b7c1533 |
528 | cerr << "ERROR: AliPHOSTrackSegmentMakerv1::ReadRecPoints -> There is no Reconstruction Tree" << endl; |
529 | return kFALSE; |
2731cd1e |
530 | } |
98cbd830 |
531 | |
2731cd1e |
532 | |
7b7c1533 |
533 | // Find RecPoints |
534 | TBranch * emcbranch = 0; |
535 | TBranch * cpvbranch = 0; |
536 | TBranch * clusterizerbranch = 0; |
537 | TObjArray * lob = (TObjArray*)gAlice->TreeR()->GetListOfBranches() ; |
538 | TIter next(lob) ; |
539 | TBranch * branch = 0 ; |
540 | Bool_t phosemcfound = kFALSE, phoscpvfound = kFALSE, clusterizerfound = kFALSE ; |
2731cd1e |
541 | |
7b7c1533 |
542 | TString taskName(GetName()) ; |
543 | taskName.ReplaceAll(Version(), "") ; |
98cbd830 |
544 | |
7b7c1533 |
545 | while ( (branch = (TBranch*)next()) && (!phosemcfound || !phoscpvfound || !clusterizerfound) ) { |
546 | if ( (strcmp(branch->GetName(), "PHOSEmcRP")==0) && (strcmp(branch->GetTitle(), taskName.Data())==0) ) { |
547 | phosemcfound = kTRUE ; |
548 | emcbranch = branch ; |
2aca7d46 |
549 | } |
fad3e5b9 |
550 | |
7b7c1533 |
551 | else if ( (strcmp(branch->GetName(), "PHOSCpvRP")==0) && (strcmp(branch->GetTitle(), taskName.Data())==0) ) { |
552 | phoscpvfound = kTRUE ; |
553 | cpvbranch = branch ; |
554 | |
555 | } else if ( (strcmp(branch->GetName(), "AliPHOSClusterizer")==0) && (strcmp(branch->GetTitle(), taskName.Data())==0) ) { |
556 | clusterizerfound = kTRUE ; |
557 | clusterizerbranch = branch ; |
2731cd1e |
558 | } |
98cbd830 |
559 | } |
7b7c1533 |
560 | if ( !phosemcfound || !phoscpvfound || !clusterizerfound ) { |
561 | cerr << "WARNING: AliPHOSTrackSegmentMakerv1::ReadRecPoints -> emc(cpv)RecPoints and/or Clusterizer branch with name " << taskName.Data() |
562 | << " not found" << endl ; |
563 | return kFALSE ; |
564 | } |
98cbd830 |
565 | |
7b7c1533 |
566 | AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ; |
2731cd1e |
567 | |
7b7c1533 |
568 | TObjArray * emcRecPoints = gime->EmcRecPoints() ; |
569 | emcRecPoints->Clear() ; |
570 | emcbranch->SetAddress(&emcRecPoints) ; |
761e34c0 |
571 | |
7b7c1533 |
572 | TObjArray * cpvRecPoints = gime->CpvRecPoints() ; |
573 | cpvRecPoints->Clear() ; |
574 | cpvbranch->SetAddress(&cpvRecPoints) ; |
01a599c9 |
575 | |
576 | TClonesArray * trackSegments = gime->TrackSegments() ; |
577 | trackSegments->Clear() ; |
7b7c1533 |
578 | |
579 | AliPHOSClusterizer * clusterizer = 0 ; |
580 | clusterizerbranch->SetAddress(&clusterizer) ; |
581 | clusterizerbranch->GetEntry(0) ; |
582 | TString clusterizerName( fTrackSegmentsBranchTitle ) ; |
583 | clusterizerName.Append(clusterizer->Version()) ; |
584 | clusterizer = gime->Clusterizer(clusterizerName) ; |
585 | |
586 | emcbranch->GetEntry(0) ; |
587 | cpvbranch->GetEntry(0) ; |
01a599c9 |
588 | |
7b7c1533 |
589 | clusterizerbranch->GetEntry(0) ; |
01a599c9 |
590 | |
591 | printf("ReadRecPoint: EMC=%d, CPV=%d\n",emcRecPoints->GetEntries(),cpvRecPoints->GetEntries()); |
2731cd1e |
592 | |
2731cd1e |
593 | return kTRUE ; |
594 | |
98cbd830 |
595 | } |
7b7c1533 |
596 | |
d15a28e7 |
597 | //____________________________________________________________________________ |
7b7c1533 |
598 | void AliPHOSTrackSegmentMakerv1::WriteTrackSegments(Int_t event) |
a4e98857 |
599 | { |
f035f6ce |
600 | // Writes found TrackSegments to TreeR. Creates branches |
601 | // "PHOSTS" and "AliPHOSTrackSegmentMaker" with the same title. |
602 | // In the former branch found TrackSegments are stored, while |
603 | // in the latter all parameters, with which TS were made. |
604 | // ROOT does not allow overwriting existing branches, therefore |
a4e98857 |
605 | // first we check, if branches with the same title already exist. |
f035f6ce |
606 | // If yes - exits without writing. |
2731cd1e |
607 | |
7b7c1533 |
608 | AliPHOSGetter *gime = AliPHOSGetter::GetInstance() ; |
55ea5766 |
609 | TString taskName(GetName()) ; |
610 | taskName.Remove(taskName.Index(Version())-1) ; |
611 | |
612 | TClonesArray * trackSegments = gime->TrackSegments(taskName) ; |
613 | trackSegments->Expand(trackSegments->GetEntriesFast()) ; |
9f616d61 |
614 | |
2731cd1e |
615 | //Make branch in TreeR for TrackSegments |
616 | char * filename = 0; |
617 | if(gSystem->Getenv("CONFIG_SPLIT_FILE")!=0){ //generating file name |
618 | filename = new char[strlen(gAlice->GetBaseFile())+20] ; |
619 | sprintf(filename,"%s/PHOS.Reco.root",gAlice->GetBaseFile()) ; |
d15a28e7 |
620 | } |
621 | |
2731cd1e |
622 | TDirectory *cwd = gDirectory; |
31aa6d6c |
623 | |
2731cd1e |
624 | //First TS |
625 | Int_t bufferSize = 32000 ; |
7b7c1533 |
626 | TBranch * tsBranch = gAlice->TreeR()->Branch("PHOSTS",&trackSegments,bufferSize); |
55ea5766 |
627 | tsBranch->SetTitle(fTrackSegmentsBranchTitle); |
2731cd1e |
628 | if (filename) { |
629 | tsBranch->SetFile(filename); |
630 | TIter next( tsBranch->GetListOfBranches()); |
761e34c0 |
631 | TBranch * sb ; |
632 | while ((sb=(TBranch*)next())) { |
633 | sb->SetFile(filename); |
2731cd1e |
634 | } |
635 | cwd->cd(); |
636 | } |
98cbd830 |
637 | |
2731cd1e |
638 | //Second -TSMaker |
639 | Int_t splitlevel = 0 ; |
640 | AliPHOSTrackSegmentMakerv1 * ts = this ; |
7b7c1533 |
641 | TBranch * tsMakerBranch = gAlice->TreeR()->Branch("AliPHOSTrackSegmentMaker","AliPHOSTrackSegmentMakerv1", |
2731cd1e |
642 | &ts,bufferSize,splitlevel); |
55ea5766 |
643 | tsMakerBranch->SetTitle(fTrackSegmentsBranchTitle); |
2731cd1e |
644 | if (filename) { |
645 | tsMakerBranch->SetFile(filename); |
646 | TIter next( tsMakerBranch->GetListOfBranches()); |
761e34c0 |
647 | TBranch * sb; |
648 | while ((sb=(TBranch*)next())) { |
649 | sb->SetFile(filename); |
2731cd1e |
650 | } |
651 | cwd->cd(); |
652 | } |
9f616d61 |
653 | |
761e34c0 |
654 | tsBranch->Fill() ; |
655 | tsMakerBranch->Fill() ; |
eec3ac52 |
656 | |
2731cd1e |
657 | gAlice->TreeR()->Write(0,kOverwrite) ; |
658 | |
659 | } |
98cbd830 |
660 | |
98cbd830 |
661 | |
2731cd1e |
662 | //____________________________________________________________________________ |
a4e98857 |
663 | void AliPHOSTrackSegmentMakerv1::PrintTrackSegments(Option_t * option) |
664 | { |
f035f6ce |
665 | // option deb - prints # of found TrackSegments |
666 | // option deb all - prints as well indexed of found RecParticles assigned to the TS |
55ea5766 |
667 | TString taskName(GetName()) ; |
668 | taskName.Remove(taskName.Index(Version())-1) ; |
669 | |
670 | TClonesArray * trackSegments = AliPHOSGetter::GetInstance()->TrackSegments(taskName) ; |
2731cd1e |
671 | |
01a599c9 |
672 | cout << "AliPHOSTrackSegmentMakerv1: event "<<gAlice->GetEvNumber() << endl ; |
7b7c1533 |
673 | cout << " Found " << trackSegments->GetEntriesFast() << " trackSegments " << endl ; |
2731cd1e |
674 | |
2b60655b |
675 | fTrackSegmentsInRun += trackSegments->GetEntriesFast() ; |
676 | |
2731cd1e |
677 | if(strstr(option,"all")) { // printing found TS |
678 | cout << "TrackSegment # " << " EMC RP# " << " CPV RP# " << " PPSD RP#" << endl ; |
679 | |
680 | Int_t index; |
7b7c1533 |
681 | for (index = 0 ; index <trackSegments->GetEntriesFast() ; index++) { |
682 | AliPHOSTrackSegment * ts = (AliPHOSTrackSegment * )trackSegments->At(index) ; |
2731cd1e |
683 | cout<<" "<< setw(4) << ts->GetIndexInList() << " " |
684 | <<setw(4) << ts->GetEmcIndex()<< " " |
685 | <<setw(4) << ts->GetCpvIndex()<< " " |
686 | <<setw(4) << ts->GetPpsdIndex()<< endl ; |
687 | } |
688 | |
689 | cout << "-------------------------------------------------------"<< endl ; |
d15a28e7 |
690 | } |
2731cd1e |
691 | } |