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 |
18 | // Associates EMC and PPSD clusters |
19 | // Unfolds the EMC cluster |
20 | // |
21 | //*-- Author: Dmitri Peressounko (RRC Ki & SUBATECH) |
22 | // |
d15a28e7 |
23 | |
24 | // --- ROOT system --- |
2731cd1e |
25 | #include "TROOT.h" |
26 | #include "TFile.h" |
27 | #include "TTree.h" |
28 | #include "TSystem.h" |
29 | #include "TBenchmark.h" |
d15a28e7 |
30 | // --- Standard library --- |
31 | |
de9ec31b |
32 | #include <iostream.h> |
2731cd1e |
33 | #include <iomanip.h> |
d15a28e7 |
34 | |
35 | // --- AliRoot header files --- |
36 | |
37 | #include "AliPHOSTrackSegmentMakerv1.h" |
2731cd1e |
38 | #include "AliPHOSClusterizerv1.h" |
d15a28e7 |
39 | #include "AliPHOSTrackSegment.h" |
2aca7d46 |
40 | #include "AliPHOSCpvRecPoint.h" |
2731cd1e |
41 | #include "AliPHOSPpsdRecPoint.h" |
d15a28e7 |
42 | #include "AliPHOSLink.h" |
43 | #include "AliPHOSv0.h" |
44 | #include "AliRun.h" |
45 | |
46 | ClassImp( AliPHOSTrackSegmentMakerv1) |
47 | |
48 | |
49 | //____________________________________________________________________________ |
b2a60966 |
50 | AliPHOSTrackSegmentMakerv1::AliPHOSTrackSegmentMakerv1() : AliPHOSTrackSegmentMaker() |
d15a28e7 |
51 | { |
9f616d61 |
52 | // ctor |
2731cd1e |
53 | SetTitle("version 1") ; |
54 | SetName("AliPHOSTrackSegmentMaker") ; |
28c3a259 |
55 | fR0 = 10. ; |
2731cd1e |
56 | fEmcFirst = 0 ; |
57 | fEmcLast = 0 ; |
58 | fCpvFirst = 0 ; |
59 | fCpvLast = 0 ; |
60 | fPpsdFirst= 0 ; |
61 | fPpsdLast = 0 ; |
62 | fLinkLowArray = 0 ; |
63 | fLinkUpArray = 0 ; |
64 | fIsInitialized = kFALSE ; |
d15a28e7 |
65 | } |
9f616d61 |
66 | //____________________________________________________________________________ |
2731cd1e |
67 | AliPHOSTrackSegmentMakerv1:: AliPHOSTrackSegmentMakerv1(const char* headerFile, const char* branchTitle): AliPHOSTrackSegmentMaker() |
68 | { |
69 | // ctor |
70 | SetTitle("version 1") ; |
71 | SetName("AliPHOSTrackSegmentMaker") ; |
72 | fR0 = 10. ; |
73 | fEmcFirst = 0 ; |
74 | fEmcLast = 0 ; |
75 | fCpvFirst = 0 ; |
76 | fCpvLast = 0 ; |
77 | fPpsdFirst= 0 ; |
78 | fPpsdLast = 0 ; |
79 | |
80 | fHeaderFileName = headerFile ; |
81 | fRecPointsBranchTitle = branchTitle ; |
82 | |
83 | TFile * file = (TFile*) gROOT->GetFile(fHeaderFileName.Data() ) ; |
84 | |
85 | if(file == 0){ |
86 | file = new TFile(fHeaderFileName.Data(),"update") ; |
87 | gAlice = (AliRun *) file->Get("gAlice") ; |
88 | } |
89 | |
90 | AliPHOS * phos = (AliPHOS *) gAlice->GetDetector("PHOS") ; |
91 | fGeom = AliPHOSGeometry::GetInstance(phos->GetGeometry()->GetName(),phos->GetGeometry()->GetTitle() ); |
92 | |
93 | fEmcRecPoints = new TObjArray(200) ; |
94 | fCpvRecPoints = new TObjArray(200) ; |
95 | fClusterizer = new AliPHOSClusterizerv1() ; |
96 | |
97 | fTrackSegments = new TClonesArray("AliPHOSTrackSegment",200) ; |
98 | |
99 | fLinkLowArray = new TClonesArray("AliPHOSLink", 1000); |
100 | fLinkUpArray = new TClonesArray("AliPHOSLink", 1000); |
101 | |
102 | fIsInitialized = kTRUE ; |
b2a60966 |
103 | |
2731cd1e |
104 | } |
d15a28e7 |
105 | //____________________________________________________________________________ |
2731cd1e |
106 | void AliPHOSTrackSegmentMakerv1::Init(){ |
9f616d61 |
107 | |
2731cd1e |
108 | if(!fIsInitialized){ |
109 | if(fHeaderFileName.IsNull()) |
110 | fHeaderFileName = "galice.root" ; |
111 | |
112 | |
113 | TFile * file = (TFile*) gROOT->GetFile(fHeaderFileName.Data() ) ; |
114 | |
115 | if(file == 0){ |
116 | file = new TFile(fHeaderFileName.Data(),"update") ; |
117 | gAlice = (AliRun *) file->Get("gAlice") ; |
6ad0bfa0 |
118 | } |
2731cd1e |
119 | |
120 | AliPHOS * phos = (AliPHOS *) gAlice->GetDetector("PHOS") ; |
121 | fGeom = AliPHOSGeometry::GetInstance(phos->GetGeometry()->GetName(),phos->GetGeometry()->GetTitle() ); |
d15a28e7 |
122 | |
9f616d61 |
123 | |
2731cd1e |
124 | fEmcRecPoints = new TObjArray(200) ; |
125 | fCpvRecPoints = new TObjArray(200) ; |
126 | fClusterizer = new AliPHOSClusterizerv1() ; |
98cbd830 |
127 | |
2731cd1e |
128 | |
129 | fTrackSegments = new TClonesArray("AliPHOSTrackSegment",200) ; |
98cbd830 |
130 | |
2731cd1e |
131 | fLinkLowArray = new TClonesArray("AliPHOSLink", 1000); |
132 | fLinkUpArray = new TClonesArray("AliPHOSLink", 1000); |
133 | |
134 | fIsInitialized = kTRUE ; |
d15a28e7 |
135 | } |
2731cd1e |
136 | } |
98cbd830 |
137 | |
2731cd1e |
138 | //____________________________________________________________________________ |
139 | AliPHOSTrackSegmentMakerv1::~AliPHOSTrackSegmentMakerv1() |
140 | { |
141 | // dtor |
142 | if(fLinkLowArray) delete fLinkLowArray ; |
143 | if(fLinkUpArray) delete fLinkUpArray ; |
d15a28e7 |
144 | } |
9f616d61 |
145 | |
d15a28e7 |
146 | //____________________________________________________________________________ |
2731cd1e |
147 | void AliPHOSTrackSegmentMakerv1::FillOneModule() |
9f616d61 |
148 | { |
2731cd1e |
149 | // Finds bounds in which clusters from one PHOS module are |
9f616d61 |
150 | |
2731cd1e |
151 | |
152 | //First EMC clusters |
153 | Int_t totalEmc = fEmcRecPoints->GetEntriesFast() ; |
154 | for(fEmcFirst = fEmcLast; (fEmcLast < totalEmc) && |
155 | (((AliPHOSRecPoint *) fEmcRecPoints->At(fEmcLast))->GetPHOSMod() == fModule ); |
156 | fEmcLast ++) ; |
157 | |
6ad0bfa0 |
158 | |
2731cd1e |
159 | //Now CPV clusters |
160 | Int_t totalCpv = fCpvRecPoints->GetEntriesFast() ; |
6ad0bfa0 |
161 | |
2731cd1e |
162 | if(fModule <= fGeom->GetNCPVModules()){ // in CPV geometry |
9f616d61 |
163 | |
2731cd1e |
164 | for(fCpvFirst = fCpvLast; (fCpvLast < totalCpv) && |
165 | (((AliPHOSRecPoint *) fCpvRecPoints->At(fCpvLast))->GetPHOSMod() == fModule ); |
166 | fCpvLast ++) ; |
31aa6d6c |
167 | |
2731cd1e |
168 | fPpsdFirst = fCpvLast ; //To avoid scanning RecPoints between fPpsdFirst and fPpsdLast |
169 | fPpsdLast = fCpvLast ; //and to be ready to switch to mixed geometry |
d15a28e7 |
170 | } |
2731cd1e |
171 | else{ //in PPSD geometry |
172 | fCpvLast = fPpsdLast ; |
173 | //Upper layer first |
174 | for(fCpvFirst = fCpvLast; (fCpvLast < totalCpv) && |
175 | (((AliPHOSPpsdRecPoint *) fCpvRecPoints->At(fCpvLast))->GetPHOSMod() == fModule ) && |
176 | (((AliPHOSPpsdRecPoint *) fCpvRecPoints->At(fCpvLast))->GetUp()) ; |
177 | fCpvLast ++) ; |
178 | |
179 | fPpsdLast= fCpvLast ; |
180 | for(fPpsdFirst = fPpsdLast; (fPpsdLast < totalCpv) && |
181 | (((AliPHOSPpsdRecPoint *) fCpvRecPoints->At(fPpsdLast))->GetPHOSMod() == fModule ) && |
182 | (!((AliPHOSPpsdRecPoint *) fCpvRecPoints->At(fPpsdLast))->GetUp()) ; |
183 | fPpsdLast ++) ; |
d15a28e7 |
184 | } |
2731cd1e |
185 | |
d15a28e7 |
186 | } |
187 | //____________________________________________________________________________ |
2731cd1e |
188 | Float_t AliPHOSTrackSegmentMakerv1::GetDistanceInPHOSPlane(AliPHOSEmcRecPoint * emcClu,AliPHOSRecPoint * cpvClu, Bool_t &toofar) |
d15a28e7 |
189 | { |
b2a60966 |
190 | // Calculates the distance between the EMC RecPoint and the PPSD RecPoint |
2731cd1e |
191 | //clusters are sorted in "rows" and "columns" of width 1 cm |
192 | Float_t delta = 1 ; // Width of the rows in sorting of RecPoints (in cm) |
193 | // if you change this value, change it as well in xxxRecPoint::Compare() |
92862013 |
194 | Float_t r = fR0 ; |
d15a28e7 |
195 | |
196 | TVector3 vecEmc ; |
2731cd1e |
197 | TVector3 vecCpv ; |
198 | |
199 | emcClu->GetLocalPosition(vecEmc) ; |
200 | cpvClu->GetLocalPosition(vecCpv) ; |
201 | |
202 | if(emcClu->GetPHOSMod() == cpvClu->GetPHOSMod()){ |
203 | if(vecCpv.X() <= vecEmc.X() + fR0 + 2*delta ){ |
204 | |
205 | vecCpv = vecCpv - vecEmc ; |
206 | r = vecCpv.Mag() ; |
92862013 |
207 | toofar = kFALSE ; |
2731cd1e |
208 | |
209 | } // if xPpsd >= xEmc + ... |
210 | else |
211 | toofar = kTRUE ; |
d15a28e7 |
212 | } |
213 | else |
92862013 |
214 | toofar = kTRUE ; |
7956ec10 |
215 | |
216 | //toofar = kFALSE ; |
217 | |
d15a28e7 |
218 | |
92862013 |
219 | return r ; |
d15a28e7 |
220 | } |
221 | |
222 | //____________________________________________________________________________ |
2731cd1e |
223 | void AliPHOSTrackSegmentMakerv1::MakeLinks() |
d15a28e7 |
224 | { |
b2a60966 |
225 | // Finds distances (links) between all EMC and PPSD clusters, which are not further apart from each other than fR0 |
226 | |
2731cd1e |
227 | fLinkUpArray->Clear() ; |
228 | fLinkLowArray->Clear() ; |
229 | |
230 | AliPHOSRecPoint * ppsd ; |
231 | AliPHOSRecPoint * cpv ; |
92862013 |
232 | AliPHOSEmcRecPoint * emcclu ; |
28c3a259 |
233 | |
d15a28e7 |
234 | Int_t iLinkLow = 0 ; |
235 | Int_t iLinkUp = 0 ; |
236 | |
28c3a259 |
237 | Int_t iEmcRP; |
2731cd1e |
238 | for(iEmcRP = fEmcFirst; iEmcRP < fEmcLast; iEmcRP++ ) { |
239 | emcclu = (AliPHOSEmcRecPoint *) fEmcRecPoints->At(iEmcRP) ; |
240 | |
241 | Bool_t toofar ; |
242 | Int_t iPpsd ; |
243 | for(iPpsd = fPpsdFirst; iPpsd < fPpsdLast;iPpsd++ ) { |
d15a28e7 |
244 | |
2731cd1e |
245 | ppsd = (AliPHOSRecPoint *) fCpvRecPoints->At(iPpsd) ; |
246 | Float_t r = GetDistanceInPHOSPlane(emcclu, ppsd, toofar) ; |
247 | |
92862013 |
248 | if(toofar) |
d15a28e7 |
249 | break ; |
2731cd1e |
250 | if(r < fR0) |
251 | new ((*fLinkLowArray)[iLinkLow++]) AliPHOSLink(r, iEmcRP, iPpsd) ; |
d15a28e7 |
252 | } |
253 | |
2731cd1e |
254 | Int_t iCpv = 0 ; |
255 | for(iCpv = fCpvFirst; iCpv < fCpvLast;iCpv++ ) { |
28c3a259 |
256 | |
2731cd1e |
257 | cpv = (AliPHOSRecPoint *) fCpvRecPoints->At(iCpv) ; |
258 | Float_t r = GetDistanceInPHOSPlane(emcclu, cpv, toofar) ; |
d15a28e7 |
259 | |
92862013 |
260 | if(toofar) |
d15a28e7 |
261 | break ; |
83974468 |
262 | if(r < fR0) { |
2731cd1e |
263 | new ((*fLinkUpArray)[iLinkUp++]) AliPHOSLink(r, iEmcRP, iCpv) ; |
28c3a259 |
264 | } |
d15a28e7 |
265 | } |
28c3a259 |
266 | } |
d15a28e7 |
267 | |
2731cd1e |
268 | fLinkLowArray->Sort() ; //first links with smallest distances |
269 | fLinkUpArray->Sort() ; |
d15a28e7 |
270 | } |
28c3a259 |
271 | |
d15a28e7 |
272 | //____________________________________________________________________________ |
2731cd1e |
273 | void AliPHOSTrackSegmentMakerv1::MakePairs() |
6ad0bfa0 |
274 | { |
6ad0bfa0 |
275 | |
2731cd1e |
276 | //Make arrays to mark clusters already chousen |
277 | Int_t * emcExist = 0; |
278 | if(fEmcLast > fEmcFirst) |
279 | emcExist = new Int_t[fEmcLast-fEmcFirst] ; |
280 | |
281 | Int_t index; |
282 | for(index = 0; index <fEmcLast-fEmcFirst; index ++) |
283 | emcExist[index] = 1 ; |
284 | |
285 | Bool_t * cpvExist = 0; |
286 | if(fCpvLast > fCpvFirst) |
287 | cpvExist = new Bool_t[fCpvLast-fCpvFirst] ; |
288 | for(index = 0; index <fCpvLast-fCpvFirst; index ++) |
289 | cpvExist[index] = kTRUE ; |
290 | |
291 | Bool_t * ppsdExist = 0; |
292 | if(fPpsdLast > fPpsdFirst) |
293 | ppsdExist = new Bool_t[fPpsdLast-fPpsdFirst] ; |
294 | for(index = 0; index <fPpsdLast-fPpsdFirst; index ++) |
295 | ppsdExist[index] = kTRUE ; |
296 | |
297 | // Finds the smallest links and makes pairs of CPV and EMC clusters with smallest distance |
298 | TIter nextLow(fLinkLowArray) ; |
299 | TIter nextUp(fLinkUpArray) ; |
d15a28e7 |
300 | |
301 | AliPHOSLink * linkLow ; |
302 | AliPHOSLink * linkUp ; |
303 | |
d15a28e7 |
304 | |
2731cd1e |
305 | AliPHOSRecPoint * nullpointer = 0 ; |
9f616d61 |
306 | |
d15a28e7 |
307 | while ( (linkLow = (AliPHOSLink *)nextLow() ) ){ |
28c3a259 |
308 | |
2731cd1e |
309 | if( (emcExist[linkLow->GetEmc()-fEmcFirst]> 0) && ppsdExist[linkLow->GetPpsd()-fPpsdFirst] ){ // RecPoints not removed yet |
310 | new ((*fTrackSegments)[fNTrackSegments]) AliPHOSTrackSegment((AliPHOSEmcRecPoint *) fEmcRecPoints->At(linkLow->GetEmc()), |
311 | nullpointer, |
312 | (AliPHOSPpsdRecPoint *)fCpvRecPoints->At(linkLow->GetPpsd()) ) ; |
313 | |
314 | ((AliPHOSTrackSegment* )fTrackSegments->At(fNTrackSegments))->SetIndexInList(fNTrackSegments); |
28c3a259 |
315 | //replace index of emc to negative and shifted index of TS |
2731cd1e |
316 | emcExist[linkLow->GetEmc()-fEmcFirst] = -2 - fNTrackSegments ; |
317 | //mark ppsd as used |
318 | ppsdExist[linkLow->GetPpsd()-fPpsdFirst] = kFALSE ; |
28c3a259 |
319 | fNTrackSegments++ ; |
6ad0bfa0 |
320 | } |
d15a28e7 |
321 | } |
28c3a259 |
322 | |
2731cd1e |
323 | |
28c3a259 |
324 | while ( (linkUp = (AliPHOSLink *)nextUp() ) ){ |
2731cd1e |
325 | if(emcExist[linkUp->GetEmc()-fEmcFirst] != -1){ //without ppsd Up yet |
d15a28e7 |
326 | |
2731cd1e |
327 | if(cpvExist[linkUp->GetPpsd()-fCpvFirst]){ //CPV still exist |
7956ec10 |
328 | |
2731cd1e |
329 | if(emcExist[linkUp->GetEmc()-fEmcFirst] > 0){ //without ppsd Low => create new TS |
7956ec10 |
330 | |
2731cd1e |
331 | new ((* fTrackSegments)[fNTrackSegments]) AliPHOSTrackSegment((AliPHOSEmcRecPoint *) fEmcRecPoints->At(linkUp->GetEmc()) , |
332 | (AliPHOSPpsdRecPoint *)fCpvRecPoints->At(linkUp->GetPpsd()), |
333 | nullpointer) ; |
334 | ((AliPHOSTrackSegment *) fTrackSegments->At(fNTrackSegments))->SetIndexInList(fNTrackSegments); |
7956ec10 |
335 | fNTrackSegments++ ; |
336 | } |
337 | else{ // append ppsd Up to existing TS |
2731cd1e |
338 | ((AliPHOSTrackSegment *)fTrackSegments->At(-2-emcExist[linkUp->GetEmc()-fEmcFirst]))->SetCpvRecPoint((AliPHOSCpvRecPoint *)fCpvRecPoints->At(linkUp->GetPpsd())); |
7956ec10 |
339 | } |
340 | |
2731cd1e |
341 | emcExist[linkUp->GetEmc()-fEmcFirst] = -1 ; //Mark emc that Cpv was found |
342 | //mark CPV recpoint as already used |
343 | cpvExist[linkUp->GetPpsd()-fCpvFirst] = kFALSE ; |
7956ec10 |
344 | } //if ppsdUp still exist |
28c3a259 |
345 | } |
346 | } |
347 | |
2731cd1e |
348 | //look through emc recPoints left without CPV/PPSD |
349 | if(emcExist){ //if there is emc rec point |
350 | Int_t iEmcRP ; |
351 | for(iEmcRP = 0; iEmcRP < fEmcLast-fEmcFirst ; iEmcRP++ ){ |
352 | if(emcExist[iEmcRP] > 0 ){ |
353 | new ((*fTrackSegments)[fNTrackSegments]) AliPHOSTrackSegment((AliPHOSEmcRecPoint *)fEmcRecPoints->At(iEmcRP+fEmcFirst), |
354 | nullpointer, |
355 | nullpointer ) ; |
356 | ((AliPHOSTrackSegment *) fTrackSegments->At(fNTrackSegments))->SetIndexInList(fNTrackSegments); |
357 | fNTrackSegments++; |
358 | } |
d15a28e7 |
359 | } |
d15a28e7 |
360 | } |
28c3a259 |
361 | |
d15a28e7 |
362 | } |
363 | |
364 | //____________________________________________________________________________ |
2731cd1e |
365 | void AliPHOSTrackSegmentMakerv1::Exec(Option_t * option) |
d15a28e7 |
366 | { |
b2a60966 |
367 | // Makes the track segments out of the list of EMC and PPSD Recpoints and stores them in a list |
28c3a259 |
368 | |
2731cd1e |
369 | if(! fIsInitialized) Init() ; |
6ad0bfa0 |
370 | |
2731cd1e |
371 | if(strstr(option,"tim")) |
372 | gBenchmark->Start("PHOSTSMaker"); |
d15a28e7 |
373 | |
2731cd1e |
374 | Int_t nEvents = (Int_t) gAlice->TreeE()->GetEntries() ; |
375 | |
376 | for(fEvent = 0;fEvent< nEvents; fEvent++){ |
377 | if(!ReadRecPoints()) //reads RecPoints for event fEvent |
378 | return; |
98cbd830 |
379 | |
2731cd1e |
380 | for(fModule = 1; fModule <= fGeom->GetNModules() ; fModule++ ){ |
381 | |
382 | FillOneModule() ; |
383 | |
384 | MakeLinks() ; |
385 | |
386 | MakePairs() ; |
387 | |
388 | } |
28c3a259 |
389 | |
2731cd1e |
390 | WriteTrackSegments() ; |
391 | if(strstr(option,"deb")) |
392 | PrintTrackSegments(option) ; |
393 | } |
9f616d61 |
394 | |
2731cd1e |
395 | if(strstr(option,"tim")){ |
396 | gBenchmark->Stop("PHOSTSMaker"); |
397 | cout << "AliPHOSTSMaker:" << endl ; |
398 | cout << " took " << gBenchmark->GetCpuTime("PHOSTSMaker") << " seconds for making TS " |
399 | << gBenchmark->GetCpuTime("PHOSTSMaker")/nEvents << " seconds per event " << endl ; |
400 | cout << endl ; |
401 | } |
9f616d61 |
402 | |
9f616d61 |
403 | |
d15a28e7 |
404 | } |
d15a28e7 |
405 | //____________________________________________________________________________ |
2731cd1e |
406 | void AliPHOSTrackSegmentMakerv1::Print(Option_t * option)const { |
407 | if(fIsInitialized){ |
408 | cout << "======== AliPHOSTrackSegmentMakerv1 ========" << endl ; |
409 | cout << "Making Track segments "<< endl ; |
410 | cout << " Headers file: " << fHeaderFileName.Data() << endl ; |
411 | cout << " RecPoints branch file name: " <<fRecPointsBranchTitle.Data() << endl ; |
412 | cout << " TrackSegments Branch file name: " << fTSBranchTitle.Data() << endl ; |
413 | cout << "with parameters: " << endl ; |
414 | cout << " Maximal EMC - CPV (PPSD) distance " << fR0 << endl ; |
415 | cout << "============================================" << endl ; |
416 | } |
417 | else |
418 | cout << "AliPHOSTrackSegmentMakerv1 not initialized " << endl ; |
d15a28e7 |
419 | } |
98cbd830 |
420 | //____________________________________________________________________________ |
2731cd1e |
421 | Bool_t AliPHOSTrackSegmentMakerv1::ReadRecPoints(){ |
422 | |
423 | //Make some initializations |
424 | fEmcRecPoints->Clear() ; |
425 | fCpvRecPoints->Clear() ; |
426 | fTrackSegments->Clear() ; |
427 | fNTrackSegments = 0 ; |
428 | fEmcFirst = 0 ; |
429 | fEmcLast = 0 ; |
430 | fCpvFirst = 0 ; |
431 | fCpvLast = 0 ; |
432 | fPpsdFirst= 0 ; |
433 | fPpsdLast = 0 ; |
434 | |
435 | |
436 | gAlice->GetEvent(fEvent) ; |
437 | |
438 | // Get TreeR header from file |
439 | char treeName[20]; |
440 | sprintf(treeName,"TreeR%d",fEvent); |
441 | |
442 | if(gAlice->TreeR()==0){ |
443 | cout << "Error in AliPHOSTrackSegmentMakerv1 : no "<<treeName << endl ; |
444 | cout << " Do nothing " << endl ; |
445 | return kFALSE ; |
446 | } |
98cbd830 |
447 | |
2731cd1e |
448 | char * emcBranchName = new char[30]; |
449 | // sprintf(emcBranchName,"PHOSEmcRP%d",fEvent); |
450 | sprintf(emcBranchName,"PHOSEmcRP"); |
451 | char * cpvBranchName = new char[30]; |
452 | // sprintf(cpvBranchName,"PHOSCpvRP%d",fEvent); |
453 | sprintf(cpvBranchName,"PHOSCpvRP"); |
454 | char * cluBranchName = new char[30]; |
455 | // sprintf(cluBranchName,"AliPHOSClusterizer%d",fEvent); |
456 | sprintf(cluBranchName,"AliPHOSClusterizer"); |
457 | |
458 | TBranch * emcBranch = 0; |
459 | TBranch * cpvBranch = 0; |
460 | TBranch * clusterizerBranch = 0; |
461 | |
462 | TObjArray * branches = gAlice->TreeR()->GetListOfBranches() ; |
463 | Int_t ibranch; |
464 | Bool_t emcNotFound = kTRUE ; |
465 | Bool_t cpvNotFound = kTRUE ; |
466 | Bool_t clusterizerNotFound = kTRUE ; |
467 | |
468 | for(ibranch = 0;ibranch <branches->GetEntries();ibranch++){ |
98cbd830 |
469 | |
2731cd1e |
470 | if(emcNotFound){ |
471 | emcBranch=(TBranch *) branches->At(ibranch) ; |
472 | if( fRecPointsBranchTitle.CompareTo(emcBranch->GetTitle())==0 ) |
473 | if( strcmp(emcBranch->GetName(),emcBranchName) == 0) { |
474 | emcNotFound = kFALSE ; |
475 | } |
2aca7d46 |
476 | } |
fad3e5b9 |
477 | |
2731cd1e |
478 | if(cpvNotFound){ |
479 | cpvBranch=(TBranch *) branches->At(ibranch) ; |
480 | if( fRecPointsBranchTitle.CompareTo(cpvBranch->GetTitle())==0 ) |
481 | if( strcmp(cpvBranch->GetName(),cpvBranchName) == 0) |
482 | cpvNotFound = kFALSE ; |
483 | } |
69183710 |
484 | |
2731cd1e |
485 | if(clusterizerNotFound){ |
486 | clusterizerBranch = (TBranch *) branches->At(ibranch) ; |
487 | if( fRecPointsBranchTitle.CompareTo(clusterizerBranch->GetTitle()) == 0) |
488 | if( strcmp(clusterizerBranch->GetName(),cluBranchName) == 0) |
489 | clusterizerNotFound = kFALSE ; |
490 | } |
fad3e5b9 |
491 | |
98cbd830 |
492 | } |
493 | |
2731cd1e |
494 | if(clusterizerNotFound || emcNotFound || cpvNotFound){ |
495 | cout << "AliPHOSTrackSegmentMakerv1: " << endl ; |
496 | cout << " Can't find Branch with RecPoints or Clusterizer " ; |
497 | cout << " Do nothing" <<endl ; |
498 | return kFALSE ; |
499 | } |
500 | |
501 | emcBranch->SetAddress(&fEmcRecPoints) ; |
502 | cpvBranch->SetAddress(&fCpvRecPoints) ; |
503 | clusterizerBranch->SetAddress(&fClusterizer) ; |
504 | |
505 | gAlice->TreeR()->GetEvent(0) ; |
506 | |
507 | delete emcBranchName; |
508 | delete cpvBranchName; |
509 | delete cluBranchName; |
510 | |
511 | return kTRUE ; |
512 | |
98cbd830 |
513 | } |
d15a28e7 |
514 | //____________________________________________________________________________ |
2731cd1e |
515 | void AliPHOSTrackSegmentMakerv1::WriteTrackSegments(){ |
98cbd830 |
516 | |
2731cd1e |
517 | char treeName[20]; |
518 | sprintf(treeName,"TreeR%d",fEvent); |
519 | |
520 | |
521 | //First, check, if branches already exist |
522 | TBranch * tsMakerBranch = 0; |
523 | TBranch * tsBranch = 0; |
524 | |
525 | TObjArray * branches = gAlice->TreeR()->GetListOfBranches() ; |
526 | Int_t ibranch; |
527 | Bool_t tsMakerNotFound = kTRUE ; |
528 | Bool_t tsNotFound = kTRUE ; |
529 | |
530 | for(ibranch = 0;(ibranch <branches->GetEntries())&&(tsMakerNotFound||tsNotFound);ibranch++){ |
531 | if(tsMakerNotFound){ |
532 | tsMakerBranch=(TBranch *) branches->At(ibranch) ; |
533 | if( (strcmp(tsMakerBranch->GetName(),"AliPHOSTrackSegmentMaker") == 0) && |
534 | (fTSBranchTitle.CompareTo( tsMakerBranch->GetTitle())==0 )) |
535 | tsMakerNotFound = kFALSE ; |
536 | } |
537 | if(tsNotFound){ |
538 | tsBranch=(TBranch *) branches->At(ibranch) ; |
539 | if( (strcmp(tsBranch->GetName(),"PHOSTS") == 0) && |
540 | (fTSBranchTitle.CompareTo( tsBranch->GetTitle())==0 )) |
541 | tsNotFound = kFALSE ; |
542 | } |
543 | } |
9f616d61 |
544 | |
2731cd1e |
545 | if(!(tsMakerNotFound && tsNotFound )){ |
546 | cout << "AliPHOSTrackSegmentMakerv1 error:"<< endl ; |
547 | cout << " Branches PHOSTS and AliPHOSTrackSegementMaker " << endl ; |
548 | cout << " with title '"<<fTSBranchTitle.Data() << "' already exist " << endl ; |
549 | cout << " can not overwrite " << endl ; |
d15a28e7 |
550 | return ; |
31aa6d6c |
551 | } |
98cbd830 |
552 | |
2731cd1e |
553 | //Make branch in TreeR for TrackSegments |
554 | char * filename = 0; |
555 | if(gSystem->Getenv("CONFIG_SPLIT_FILE")!=0){ //generating file name |
556 | filename = new char[strlen(gAlice->GetBaseFile())+20] ; |
557 | sprintf(filename,"%s/PHOS.Reco.root",gAlice->GetBaseFile()) ; |
d15a28e7 |
558 | } |
559 | |
2731cd1e |
560 | TDirectory *cwd = gDirectory; |
31aa6d6c |
561 | |
2731cd1e |
562 | //First TS |
563 | Int_t bufferSize = 32000 ; |
564 | tsBranch = gAlice->TreeR()->Branch("PHOSTS",&fTrackSegments,bufferSize); |
565 | tsBranch->SetTitle(fTSBranchTitle.Data()); |
566 | if (filename) { |
567 | tsBranch->SetFile(filename); |
568 | TIter next( tsBranch->GetListOfBranches()); |
569 | while ((tsBranch=(TBranch*)next())) { |
570 | tsBranch->SetFile(filename); |
571 | } |
572 | cwd->cd(); |
573 | } |
98cbd830 |
574 | |
2731cd1e |
575 | //Second -TSMaker |
576 | Int_t splitlevel = 0 ; |
577 | AliPHOSTrackSegmentMakerv1 * ts = this ; |
578 | tsMakerBranch = gAlice->TreeR()->Branch("AliPHOSTrackSegmentMaker","AliPHOSTrackSegmentMakerv1", |
579 | &ts,bufferSize,splitlevel); |
580 | tsMakerBranch->SetTitle(fTSBranchTitle.Data()); |
581 | if (filename) { |
582 | tsMakerBranch->SetFile(filename); |
583 | TIter next( tsMakerBranch->GetListOfBranches()); |
584 | while ((tsMakerBranch=(TBranch*)next())) { |
585 | tsMakerBranch->SetFile(filename); |
586 | } |
587 | cwd->cd(); |
588 | } |
9f616d61 |
589 | |
2731cd1e |
590 | gAlice->TreeR()->Fill() ; |
591 | gAlice->TreeR()->Write(0,kOverwrite) ; |
592 | |
593 | } |
98cbd830 |
594 | |
98cbd830 |
595 | |
2731cd1e |
596 | //____________________________________________________________________________ |
597 | void AliPHOSTrackSegmentMakerv1::PrintTrackSegments(Option_t * option){ |
598 | |
599 | cout << "AliPHOSTrackSegmentMakerv1: " << endl ; |
600 | cout << " Found " << fTrackSegments->GetEntriesFast() << " trackSegments " << endl ; |
601 | |
602 | if(strstr(option,"all")) { // printing found TS |
603 | cout << "TrackSegment # " << " EMC RP# " << " CPV RP# " << " PPSD RP#" << endl ; |
604 | |
605 | Int_t index; |
606 | for (index = 0 ; index <fTrackSegments->GetEntriesFast() ; index++) { |
607 | AliPHOSTrackSegment * ts = (AliPHOSTrackSegment * )fTrackSegments->At(index) ; |
608 | cout<<" "<< setw(4) << ts->GetIndexInList() << " " |
609 | <<setw(4) << ts->GetEmcIndex()<< " " |
610 | <<setw(4) << ts->GetCpvIndex()<< " " |
611 | <<setw(4) << ts->GetPpsdIndex()<< endl ; |
612 | } |
613 | |
614 | cout << "-------------------------------------------------------"<< endl ; |
d15a28e7 |
615 | } |
2731cd1e |
616 | } |
617 | //____________________________________________________________________________ |
618 | void AliPHOSTrackSegmentMakerv1::SetRecPointsBranch(const char * title){ |
619 | //set the title of RecPoints |
620 | fRecPointsBranchTitle = title ; |
621 | |
622 | } |
623 | //____________________________________________________________________________ |
624 | void AliPHOSTrackSegmentMakerv1::SetTrackSegmentsBranch(const char * title){ |
98cbd830 |
625 | |
2731cd1e |
626 | fTSBranchTitle = title ; |
d15a28e7 |
627 | } |