]>
Commit | Line | Data |
---|---|---|
3e87ef69 | 1 | // @(#) $Id$ |
b1886074 | 2 | |
3 | // Author: Anders Vestbo <mailto:vestbo@fi.uib.no> | |
3e87ef69 | 4 | //*-- Copyright © ALICE HLT Group |
b1886074 | 5 | |
e06900d5 | 6 | #include "AliL3StandardIncludes.h" |
0309a5ee | 7 | #include <sys/time.h> |
f000f8a5 | 8 | |
e06900d5 | 9 | #include "AliL3Logging.h" |
b1886074 | 10 | #include "AliL3HoughMerger.h" |
11 | #include "AliL3HoughIntMerger.h" | |
12 | #include "AliL3HoughGlobalMerger.h" | |
f80b98cb | 13 | #include "AliL3Histogram.h" |
f000f8a5 | 14 | #include "AliL3Hough.h" |
15 | #include "AliL3HoughTransformer.h" | |
6c97129d | 16 | #include "AliL3HoughClusterTransformer.h" |
636080ea | 17 | #include "AliL3HoughTransformerLUT.h" |
b46b53c1 | 18 | #include "AliL3HoughTransformerVhdl.h" |
f000f8a5 | 19 | #include "AliL3HoughMaxFinder.h" |
3e87ef69 | 20 | #include "AliL3Benchmark.h" |
95a00d93 | 21 | #ifdef use_aliroot |
f80b98cb | 22 | #include "AliL3FileHandler.h" |
95a00d93 | 23 | #else |
24 | #include "AliL3MemHandler.h" | |
25 | #endif | |
d96f6a4a | 26 | #include "AliL3DataHandler.h" |
f80b98cb | 27 | #include "AliL3DigitData.h" |
28 | #include "AliL3HoughEval.h" | |
29 | #include "AliL3Transform.h" | |
f80b98cb | 30 | #include "AliL3TrackArray.h" |
31 | #include "AliL3HoughTrack.h" | |
95a00d93 | 32 | |
e06900d5 | 33 | #if GCCVERSION == 3 |
34 | using namespace std; | |
35 | #endif | |
b1886074 | 36 | |
aa641eb8 | 37 | /** /class AliL3Hough |
38 | //<pre> | |
b1886074 | 39 | //_____________________________________________________________ |
40 | // AliL3Hough | |
41 | // | |
237d3f5c | 42 | // Interface class for the Hough transform |
b1886074 | 43 | // |
237d3f5c | 44 | // Example how to use: |
45 | // | |
46 | // AliL3Hough *hough = new AliL3Hough(path,kTRUE,NumberOfEtaSegments); | |
47 | // hough->ReadData(slice); | |
48 | // hough->Transform(); | |
49 | // hough->FindTrackCandidates(); | |
50 | // | |
51 | // AliL3TrackArray *tracks = hough->GetTracks(patch); | |
aa641eb8 | 52 | //</pre> |
53 | */ | |
f000f8a5 | 54 | |
55 | ClassImp(AliL3Hough) | |
56 | ||
57 | AliL3Hough::AliL3Hough() | |
58 | { | |
b1886074 | 59 | //Constructor |
60 | ||
6dbc57b4 | 61 | fBinary = kFALSE; |
a6008206 | 62 | fAddHistograms = kFALSE; |
6dbc57b4 | 63 | fDoIterative = kFALSE; |
64 | fWriteDigits = kFALSE; | |
65 | fUse8bits = kFALSE; | |
66 | ||
67 | fMemHandler = 0; | |
237d3f5c | 68 | fHoughTransformer = 0; |
6dbc57b4 | 69 | fEval = 0; |
70 | fPeakFinder = 0; | |
71 | fTracks = 0; | |
72 | fMerger = 0; | |
73 | fInterMerger = 0; | |
74 | fGlobalMerger = 0; | |
3e87ef69 | 75 | fBenchmark = 0; |
76 | ||
6dbc57b4 | 77 | fNEtaSegments = 0; |
78 | fNPatches = 0; | |
79 | fVersion = 0; | |
80 | fCurrentSlice = 0; | |
3e87ef69 | 81 | |
6dbc57b4 | 82 | SetTransformerParams(); |
83 | SetThreshold(); | |
636080ea | 84 | SetNSaveIterations(); |
3e87ef69 | 85 | SetPeakThreshold(); |
f000f8a5 | 86 | } |
87 | ||
e06900d5 | 88 | AliL3Hough::AliL3Hough(Char_t *path,Bool_t binary,Int_t n_eta_segments,Bool_t bit8,Int_t tv) |
b46b53c1 | 89 | { |
90 | //Default ctor. | |
91 | ||
92 | fBinary = binary; | |
93 | strcpy(fPath,path); | |
6dbc57b4 | 94 | fNEtaSegments = n_eta_segments; |
b46b53c1 | 95 | fAddHistograms = kFALSE; |
6dbc57b4 | 96 | fDoIterative = kFALSE; |
97 | fWriteDigits = kFALSE; | |
98 | fUse8bits = bit8; | |
99 | fVersion = tv; | |
b46b53c1 | 100 | } |
f000f8a5 | 101 | |
f000f8a5 | 102 | AliL3Hough::~AliL3Hough() |
103 | { | |
237d3f5c | 104 | //dtor |
105 | ||
b1886074 | 106 | CleanUp(); |
107 | if(fMerger) | |
108 | delete fMerger; | |
109 | if(fInterMerger) | |
110 | delete fInterMerger; | |
a6008206 | 111 | if(fPeakFinder) |
112 | delete fPeakFinder; | |
1c404dd5 | 113 | if(fGlobalMerger) |
114 | delete fGlobalMerger; | |
3e87ef69 | 115 | if(fBenchmark) |
116 | delete fBenchmark; | |
f000f8a5 | 117 | } |
118 | ||
b1886074 | 119 | void AliL3Hough::CleanUp() |
f000f8a5 | 120 | { |
b1886074 | 121 | //Cleanup memory |
122 | ||
1c404dd5 | 123 | for(Int_t i=0; i<fNPatches; i++) |
4fc9a6a4 | 124 | { |
b1886074 | 125 | if(fTracks[i]) delete fTracks[i]; |
126 | if(fEval[i]) delete fEval[i]; | |
127 | if(fHoughTransformer[i]) delete fHoughTransformer[i]; | |
128 | if(fMemHandler[i]) delete fMemHandler[i]; | |
4fc9a6a4 | 129 | } |
b1886074 | 130 | |
3e87ef69 | 131 | if(fTracks) delete [] fTracks; |
132 | if(fEval) delete [] fEval; | |
133 | if(fHoughTransformer) delete [] fHoughTransformer; | |
134 | if(fMemHandler) delete [] fMemHandler; | |
135 | ||
f000f8a5 | 136 | } |
137 | ||
e06900d5 | 138 | void AliL3Hough::Init(Char_t *path,Bool_t binary,Int_t n_eta_segments,Bool_t bit8,Int_t tv) |
f000f8a5 | 139 | { |
d96f6a4a | 140 | fBinary = binary; |
141 | strcpy(fPath,path); | |
142 | fNEtaSegments = n_eta_segments; | |
6dbc57b4 | 143 | fWriteDigits = kFALSE; |
144 | fUse8bits = bit8; | |
145 | fVersion = tv; | |
146 | ||
147 | Init(); //do the rest | |
148 | } | |
149 | ||
e06900d5 | 150 | void AliL3Hough::Init(Bool_t doit, Bool_t addhists) |
a4639de2 | 151 | { |
6dbc57b4 | 152 | fDoIterative = doit; |
153 | fAddHistograms = addhists; | |
b46b53c1 | 154 | |
b490510d | 155 | AliL3Transform::Init(fPath,!fBinary); |
26abc209 | 156 | fNPatches = AliL3Transform::GetNPatches(); |
3e87ef69 | 157 | |
237d3f5c | 158 | fHoughTransformer = new AliL3HoughBaseTransformer*[fNPatches]; |
95a00d93 | 159 | fMemHandler = new AliL3MemHandler*[fNPatches]; |
3e87ef69 | 160 | |
1c404dd5 | 161 | fTracks = new AliL3TrackArray*[fNPatches]; |
162 | fEval = new AliL3HoughEval*[fNPatches]; | |
6dbc57b4 | 163 | |
1c404dd5 | 164 | for(Int_t i=0; i<fNPatches; i++) |
f80b98cb | 165 | { |
6dbc57b4 | 166 | switch (fVersion){ //choose Transformer |
b46b53c1 | 167 | case 1: |
636080ea | 168 | fHoughTransformer[i] = new AliL3HoughTransformerLUT(0,i,fNEtaSegments); |
b46b53c1 | 169 | break; |
6c97129d | 170 | case 2: |
171 | fHoughTransformer[i] = new AliL3HoughClusterTransformer(0,i,fNEtaSegments); | |
172 | break; | |
636080ea | 173 | case 3: |
174 | fHoughTransformer[i] = new AliL3HoughTransformerVhdl(0,i,fNEtaSegments,fNSaveIterations); | |
175 | break; | |
b46b53c1 | 176 | default: |
3e87ef69 | 177 | fHoughTransformer[i] = new AliL3HoughTransformer(0,i,fNEtaSegments,kFALSE,kFALSE); |
b46b53c1 | 178 | } |
aa641eb8 | 179 | |
6dbc57b4 | 180 | fHoughTransformer[i]->CreateHistograms(fNBinX,fLowPt,fNBinY,-fPhi,fPhi); |
181 | fHoughTransformer[i]->SetLowerThreshold(fThreshold); | |
aa641eb8 | 182 | |
0309a5ee | 183 | LOG(AliL3Log::kInformational,"AliL3Hough::Init","Version") |
6dbc57b4 | 184 | <<"Initializing Hough transformer version "<<fVersion<<ENDLOG; |
a4639de2 | 185 | |
b1886074 | 186 | fEval[i] = new AliL3HoughEval(); |
187 | fTracks[i] = new AliL3TrackArray("AliL3HoughTrack"); | |
d96f6a4a | 188 | if(fUse8bits) |
189 | fMemHandler[i] = new AliL3DataHandler(); | |
190 | else | |
95a00d93 | 191 | #ifdef use_aliroot |
d96f6a4a | 192 | { |
193 | fMemHandler[i] = new AliL3FileHandler(); | |
194 | if(!fBinary) | |
3bb06991 | 195 | { |
44c7f8de | 196 | Char_t filename[1024]; |
b490510d | 197 | sprintf(filename,"%s/digitfile.root",fPath); |
3bb06991 | 198 | fMemHandler[i]->SetAliInput(filename); |
199 | } | |
d96f6a4a | 200 | } |
95a00d93 | 201 | #else |
202 | fMemHandler[i] = new AliL3MemHandler(); | |
203 | #endif | |
a6008206 | 204 | } |
6dbc57b4 | 205 | |
a4639de2 | 206 | fPeakFinder = new AliL3HoughMaxFinder("KappaPhi",1000); |
1c404dd5 | 207 | fMerger = new AliL3HoughMerger(fNPatches); |
b1886074 | 208 | fInterMerger = new AliL3HoughIntMerger(); |
237d3f5c | 209 | fGlobalMerger = 0; |
3e87ef69 | 210 | fBenchmark = new AliL3Benchmark(); |
211 | ||
212 | } | |
213 | ||
214 | void AliL3Hough::DoBench(Char_t *name) | |
215 | { | |
216 | fBenchmark->Analyze(name); | |
a6008206 | 217 | } |
218 | ||
219 | void AliL3Hough::Process(Int_t minslice,Int_t maxslice) | |
220 | { | |
221 | //Process all slices [minslice,maxslice]. | |
1c404dd5 | 222 | fGlobalMerger = new AliL3HoughGlobalMerger(minslice,maxslice); |
b1886074 | 223 | |
a6008206 | 224 | for(Int_t i=minslice; i<=maxslice; i++) |
225 | { | |
b1886074 | 226 | ReadData(i); |
227 | Transform(); | |
a6008206 | 228 | if(fAddHistograms) |
229 | AddAllHistograms(); | |
230 | FindTrackCandidates(); | |
3e87ef69 | 231 | //Evaluate(); |
232 | //fGlobalMerger->FillTracks(fTracks[0],i); | |
f80b98cb | 233 | } |
4fc9a6a4 | 234 | } |
f80b98cb | 235 | |
e06900d5 | 236 | void AliL3Hough::ReadData(Int_t slice,Int_t eventnr) |
4fc9a6a4 | 237 | { |
b1886074 | 238 | //Read data from files, binary or root. |
3bb06991 | 239 | |
240 | fCurrentSlice = slice; | |
1c404dd5 | 241 | for(Int_t i=0; i<fNPatches; i++) |
f80b98cb | 242 | { |
4fc9a6a4 | 243 | fMemHandler[i]->Free(); |
244 | UInt_t ndigits=0; | |
245 | AliL3DigitRowData *digits =0; | |
246 | Char_t name[256]; | |
3fe49b5b | 247 | fMemHandler[i]->Init(slice,i); |
a6008206 | 248 | if(fBinary)//take input data from binary files |
4fc9a6a4 | 249 | { |
d96f6a4a | 250 | if(fUse8bits) |
251 | sprintf(name,"%sdigits_c8_%d_%d.raw",fPath,slice,i); | |
252 | else | |
253 | sprintf(name,"%sdigits_%d_%d.raw",fPath,slice,i); | |
636080ea | 254 | |
4fc9a6a4 | 255 | fMemHandler[i]->SetBinaryInput(name); |
256 | digits = (AliL3DigitRowData *)fMemHandler[i]->CompBinary2Memory(ndigits); | |
257 | fMemHandler[i]->CloseBinaryInput(); | |
258 | } | |
259 | else //read data from root file | |
260 | { | |
95a00d93 | 261 | #ifdef use_aliroot |
3e87ef69 | 262 | digits=(AliL3DigitRowData *)fMemHandler[i]->AliAltroDigits2Memory(ndigits,eventnr); |
208b54c5 | 263 | fMemHandler[i]->FreeDigitsTree(); |
95a00d93 | 264 | #else |
265 | cerr<<"You cannot read from rootfile now"<<endl; | |
266 | #endif | |
4fc9a6a4 | 267 | } |
aa641eb8 | 268 | |
636080ea | 269 | //set input data and init transformer |
270 | fHoughTransformer[i]->SetInputData(ndigits,digits); | |
271 | fHoughTransformer[i]->Init(slice,i,fNEtaSegments); | |
b1886074 | 272 | } |
273 | } | |
274 | ||
3e87ef69 | 275 | void AliL3Hough::Transform(Int_t *row_range) |
b1886074 | 276 | { |
277 | //Transform all data given to the transformer within the given slice | |
278 | //(after ReadData(slice)) | |
0309a5ee | 279 | |
280 | Double_t initTime,cpuTime; | |
281 | initTime = GetCpuTime(); | |
1c404dd5 | 282 | for(Int_t i=0; i<fNPatches; i++) |
b1886074 | 283 | { |
284 | fHoughTransformer[i]->Reset();//Reset the histograms | |
3e87ef69 | 285 | fBenchmark->Start("Hough Transform"); |
286 | if(!row_range) | |
237d3f5c | 287 | fHoughTransformer[i]->TransformCircle(); |
288 | else | |
3e87ef69 | 289 | fHoughTransformer[i]->TransformCircleC(row_range,1); |
290 | fBenchmark->Stop("Hough Transform"); | |
b1886074 | 291 | } |
0309a5ee | 292 | cpuTime = GetCpuTime() - initTime; |
293 | LOG(AliL3Log::kInformational,"AliL3Hough::Transform()","Timing") | |
294 | <<"Transform done in average per patch of "<<cpuTime*1000/fNPatches<<" ms"<<ENDLOG; | |
b1886074 | 295 | } |
296 | ||
297 | void AliL3Hough::MergePatches() | |
298 | { | |
299 | if(fAddHistograms) //Nothing to merge here | |
300 | return; | |
b1886074 | 301 | fMerger->MergePatches(kTRUE); |
b1886074 | 302 | } |
303 | ||
304 | void AliL3Hough::MergeInternally() | |
305 | { | |
306 | if(fAddHistograms) | |
307 | fInterMerger->FillTracks(fTracks[0]); | |
308 | else | |
309 | fInterMerger->FillTracks(fMerger->GetOutTracks()); | |
310 | ||
311 | fInterMerger->MMerge(); | |
312 | } | |
313 | ||
314 | void AliL3Hough::ProcessSliceIter() | |
315 | { | |
316 | //Process current slice (after ReadData(slice)) iteratively. | |
317 | ||
6c97129d | 318 | if(!fAddHistograms) |
b1886074 | 319 | { |
6c97129d | 320 | for(Int_t i=0; i<fNPatches; i++) |
321 | { | |
322 | ProcessPatchIter(i); | |
323 | fMerger->FillTracks(fTracks[i],i); //Copy tracks to merger | |
324 | } | |
325 | } | |
326 | else | |
327 | { | |
328 | for(Int_t i=0; i<10; i++) | |
329 | { | |
330 | Transform(); | |
331 | AddAllHistograms(); | |
332 | InitEvaluate(); | |
333 | AliL3HoughBaseTransformer *tr = fHoughTransformer[0]; | |
334 | for(Int_t j=0; j<fNEtaSegments; j++) | |
335 | { | |
336 | AliL3Histogram *hist = tr->GetHistogram(j); | |
337 | if(hist->GetNEntries()==0) continue; | |
338 | fPeakFinder->Reset(); | |
339 | fPeakFinder->SetHistogram(hist); | |
340 | fPeakFinder->FindAbsMaxima(); | |
341 | AliL3HoughTrack *track = (AliL3HoughTrack*)fTracks[0]->NextTrack(); | |
342 | track->SetTrackParameters(fPeakFinder->GetXPeak(0),fPeakFinder->GetYPeak(0),fPeakFinder->GetWeight(0)); | |
343 | track->SetEtaIndex(j); | |
344 | track->SetEta(tr->GetEta(j,fCurrentSlice)); | |
345 | for(Int_t k=0; k<fNPatches; k++) | |
346 | { | |
347 | fEval[i]->SetNumOfPadsToLook(2); | |
348 | fEval[i]->SetNumOfRowsToMiss(2); | |
349 | fEval[i]->RemoveFoundTracks(); | |
3e87ef69 | 350 | /* |
6c97129d | 351 | Int_t nrows=0; |
352 | if(!fEval[i]->LookInsideRoad(track,nrows)) | |
353 | { | |
354 | fTracks[0]->Remove(fTracks[0]->GetNTracks()-1); | |
355 | fTracks[0]->Compress(); | |
356 | } | |
3e87ef69 | 357 | */ |
6c97129d | 358 | } |
359 | } | |
360 | ||
361 | } | |
362 | ||
f80b98cb | 363 | } |
4fc9a6a4 | 364 | } |
365 | ||
b1886074 | 366 | void AliL3Hough::ProcessPatchIter(Int_t patch) |
367 | { | |
368 | //Process patch in a iterative way. | |
369 | //transform + peakfinding + evaluation + transform +... | |
370 | ||
6c97129d | 371 | Int_t num_of_tries = 5; |
237d3f5c | 372 | AliL3HoughBaseTransformer *tr = fHoughTransformer[patch]; |
b1886074 | 373 | AliL3TrackArray *tracks = fTracks[patch]; |
374 | tracks->Reset(); | |
375 | AliL3HoughEval *ev = fEval[patch]; | |
376 | ev->InitTransformer(tr); | |
6c97129d | 377 | //ev->RemoveFoundTracks(); |
378 | ev->SetNumOfRowsToMiss(3); | |
b5a207b4 | 379 | ev->SetNumOfPadsToLook(2); |
b1886074 | 380 | AliL3Histogram *hist; |
381 | for(Int_t t=0; t<num_of_tries; t++) | |
382 | { | |
383 | tr->Reset(); | |
384 | tr->TransformCircle(); | |
385 | for(Int_t i=0; i<fNEtaSegments; i++) | |
386 | { | |
387 | hist = tr->GetHistogram(i); | |
388 | if(hist->GetNEntries()==0) continue; | |
6c97129d | 389 | fPeakFinder->Reset(); |
b1886074 | 390 | fPeakFinder->SetHistogram(hist); |
6c97129d | 391 | fPeakFinder->FindAbsMaxima(); |
392 | //fPeakFinder->FindPeak1(); | |
b1886074 | 393 | AliL3HoughTrack *track = (AliL3HoughTrack*)tracks->NextTrack(); |
6c97129d | 394 | track->SetTrackParameters(fPeakFinder->GetXPeak(0),fPeakFinder->GetYPeak(0),fPeakFinder->GetWeight(0)); |
395 | track->SetEtaIndex(i); | |
396 | track->SetEta(tr->GetEta(i,fCurrentSlice)); | |
3e87ef69 | 397 | /* |
6c97129d | 398 | Int_t nrows=0; |
399 | if(!ev->LookInsideRoad(track,nrows)) | |
b1886074 | 400 | { |
401 | tracks->Remove(tracks->GetNTracks()-1); | |
402 | tracks->Compress(); | |
403 | } | |
3e87ef69 | 404 | */ |
b1886074 | 405 | } |
406 | } | |
6c97129d | 407 | fTracks[0]->QSort(); |
b1886074 | 408 | LOG(AliL3Log::kInformational,"AliL3Hough::ProcessPatch","NTracks") |
409 | <<AliL3Log::kDec<<"Found "<<tracks->GetNTracks()<<" tracks in patch "<<patch<<ENDLOG; | |
410 | } | |
411 | ||
a6008206 | 412 | void AliL3Hough::AddAllHistograms() |
4fc9a6a4 | 413 | { |
a6008206 | 414 | //Add the histograms within one etaslice. |
415 | //Resulting histogram are in patch=0. | |
b1886074 | 416 | |
0309a5ee | 417 | Double_t initTime,cpuTime; |
418 | initTime = GetCpuTime(); | |
3e87ef69 | 419 | fBenchmark->Start("Add Histograms"); |
a6008206 | 420 | for(Int_t i=0; i<fNEtaSegments; i++) |
421 | { | |
422 | AliL3Histogram *hist0 = fHoughTransformer[0]->GetHistogram(i); | |
1c404dd5 | 423 | for(Int_t j=1; j<fNPatches; j++) |
a6008206 | 424 | { |
425 | AliL3Histogram *hist = fHoughTransformer[j]->GetHistogram(i); | |
426 | hist0->Add(hist); | |
427 | } | |
428 | } | |
3e87ef69 | 429 | fBenchmark->Stop("Add Histograms"); |
b1886074 | 430 | fAddHistograms = kTRUE; |
0309a5ee | 431 | cpuTime = GetCpuTime() - initTime; |
432 | LOG(AliL3Log::kInformational,"AliL3Hough::AddAllHistograms()","Timing") | |
433 | <<"Adding histograms in "<<cpuTime*1000<<" ms"<<ENDLOG; | |
a6008206 | 434 | } |
435 | ||
436 | void AliL3Hough::FindTrackCandidates() | |
437 | { | |
438 | //Look for peaks in histograms, and find the track candidates | |
439 | ||
a6008206 | 440 | Int_t n_patches; |
441 | if(fAddHistograms) | |
b46b53c1 | 442 | n_patches = 1; //Histograms have been added. |
a6008206 | 443 | else |
1c404dd5 | 444 | n_patches = fNPatches; |
b1886074 | 445 | |
0309a5ee | 446 | Double_t initTime,cpuTime; |
447 | initTime = GetCpuTime(); | |
3e87ef69 | 448 | fBenchmark->Start("Find Maxima"); |
a6008206 | 449 | for(Int_t i=0; i<n_patches; i++) |
450 | { | |
237d3f5c | 451 | AliL3HoughBaseTransformer *tr = fHoughTransformer[i]; |
b1886074 | 452 | fTracks[i]->Reset(); |
6c97129d | 453 | |
a6008206 | 454 | for(Int_t j=0; j<fNEtaSegments; j++) |
455 | { | |
456 | AliL3Histogram *hist = tr->GetHistogram(j); | |
b1886074 | 457 | if(hist->GetNEntries()==0) continue; |
3fe49b5b | 458 | fPeakFinder->Reset(); |
a6008206 | 459 | fPeakFinder->SetHistogram(hist); |
3e87ef69 | 460 | //fPeakFinder->FindPeak1(2,1); |
208b54c5 | 461 | fPeakFinder->FindMaxima(0,0); //Simple maxima finder |
3bb06991 | 462 | //fPeakFinder->FindAbsMaxima(); |
3fe49b5b | 463 | for(Int_t k=0; k<fPeakFinder->GetEntries(); k++) |
a6008206 | 464 | { |
3e87ef69 | 465 | if(fPeakFinder->GetWeight(k) == 0 || fPeakFinder->GetWeight(k) < fPeakThreshold) continue; |
b1886074 | 466 | AliL3HoughTrack *track = (AliL3HoughTrack*)fTracks[i]->NextTrack(); |
3fe49b5b | 467 | track->SetTrackParameters(fPeakFinder->GetXPeak(k),fPeakFinder->GetYPeak(k),fPeakFinder->GetWeight(k)); |
a6008206 | 468 | track->SetEtaIndex(j); |
afd8fed4 | 469 | track->SetEta(tr->GetEta(j,fCurrentSlice)); |
26abc209 | 470 | track->SetRowRange(AliL3Transform::GetFirstRow(0),AliL3Transform::GetLastRow(5)); |
a6008206 | 471 | } |
472 | } | |
b1886074 | 473 | fTracks[i]->QSort(); |
a6008206 | 474 | } |
3e87ef69 | 475 | fBenchmark->Stop("Find Maxima"); |
0309a5ee | 476 | cpuTime = GetCpuTime() - initTime; |
477 | LOG(AliL3Log::kInformational,"AliL3Hough::FindTrackCandidates()","Timing") | |
478 | <<"Maxima finding done in "<<cpuTime*1000<<" ms"<<ENDLOG; | |
a6008206 | 479 | } |
480 | ||
3fe49b5b | 481 | void AliL3Hough::InitEvaluate() |
482 | { | |
483 | //Pass the transformer objects to the AliL3HoughEval objects: | |
484 | //This will provide the evaluation objects with all the necessary | |
208b54c5 | 485 | //data and parameters it needs. |
3fe49b5b | 486 | |
487 | for(Int_t i=0; i<fNPatches; i++) | |
488 | fEval[i]->InitTransformer(fHoughTransformer[i]); | |
489 | } | |
490 | ||
0309a5ee | 491 | Int_t AliL3Hough::Evaluate(Int_t road_width,Int_t nrowstomiss) |
a6008206 | 492 | { |
493 | //Evaluate the tracks, by looking along the road in the raw data. | |
3fe49b5b | 494 | //If track does not cross all padrows - rows2miss, it is removed from the arrray. |
0309a5ee | 495 | //If histograms were not added, the check is done locally in patch, |
496 | //meaning that nrowstomiss is the number of padrows the road can miss with respect | |
497 | //to the number of rows in the patch. | |
498 | //If the histograms were added, the comparison is done globally in the _slice_, | |
499 | //meaing that nrowstomiss is the number of padrows the road can miss with | |
500 | //respect to the total number of padrows in the slice. | |
501 | // | |
502 | //Return value = number of tracks which were removed (only in case of fAddHistograms) | |
a6008206 | 503 | |
b1886074 | 504 | if(!fTracks[0]) |
a6008206 | 505 | { |
b1886074 | 506 | LOG(AliL3Log::kError,"AliL3Hough::Evaluate","Track Array") |
507 | <<"No tracks to work with..."<<ENDLOG; | |
0309a5ee | 508 | return 0; |
a6008206 | 509 | } |
510 | ||
0309a5ee | 511 | Int_t removed_tracks=0; |
512 | AliL3TrackArray *tracks=0; | |
a4639de2 | 513 | |
0309a5ee | 514 | if(fAddHistograms) |
a4639de2 | 515 | { |
0309a5ee | 516 | tracks = fTracks[0]; |
0309a5ee | 517 | for(Int_t i=0; i<tracks->GetNTracks(); i++) |
a6008206 | 518 | { |
a4639de2 | 519 | AliL3Track *track = tracks->GetCheckedTrack(i); |
520 | if(!track) continue; | |
521 | track->SetNHits(0); | |
0309a5ee | 522 | } |
f80b98cb | 523 | } |
f000f8a5 | 524 | |
a4639de2 | 525 | for(Int_t i=0; i<fNPatches; i++) |
526 | EvaluatePatch(i,road_width,nrowstomiss); | |
527 | ||
aa641eb8 | 528 | //Here we check the tracks globally; |
529 | //how many good rows (padrows with signal) | |
530 | //did it cross in the slice | |
531 | if(fAddHistograms) | |
0309a5ee | 532 | { |
533 | for(Int_t j=0; j<tracks->GetNTracks(); j++) | |
534 | { | |
a4639de2 | 535 | AliL3HoughTrack *track = (AliL3HoughTrack*)tracks->GetCheckedTrack(j); |
536 | ||
537 | if(track->GetNHits() < AliL3Transform::GetNRows() - nrowstomiss) | |
0309a5ee | 538 | { |
539 | tracks->Remove(j); | |
540 | removed_tracks++; | |
541 | } | |
542 | } | |
543 | tracks->Compress(); | |
544 | tracks->QSort(); | |
545 | } | |
a4639de2 | 546 | |
547 | return removed_tracks; | |
548 | } | |
549 | ||
550 | void AliL3Hough::EvaluatePatch(Int_t i,Int_t road_width,Int_t nrowstomiss) | |
551 | { | |
552 | //Evaluate patch i. | |
0309a5ee | 553 | |
a4639de2 | 554 | fEval[i]->InitTransformer(fHoughTransformer[i]); |
555 | fEval[i]->SetNumOfPadsToLook(road_width); | |
556 | fEval[i]->SetNumOfRowsToMiss(nrowstomiss); | |
557 | //fEval[i]->RemoveFoundTracks(); | |
0309a5ee | 558 | |
a4639de2 | 559 | AliL3TrackArray *tracks=0; |
560 | ||
561 | if(!fAddHistograms) | |
562 | tracks = fTracks[i]; | |
563 | else | |
564 | tracks = fTracks[0]; | |
565 | ||
566 | Int_t nrows=0; | |
567 | for(Int_t j=0; j<tracks->GetNTracks(); j++) | |
568 | { | |
569 | AliL3HoughTrack *track = (AliL3HoughTrack*)tracks->GetCheckedTrack(j); | |
570 | if(!track) | |
571 | { | |
572 | LOG(AliL3Log::kWarning,"AliL3Hough::EvaluatePatch","Track array") | |
573 | <<"Track object missing!"<<ENDLOG; | |
574 | continue; | |
575 | } | |
576 | nrows=0; | |
3e87ef69 | 577 | Int_t rowrange[2] = {AliL3Transform::GetFirstRow(i),AliL3Transform::GetLastRow(i)}; |
578 | Bool_t result = fEval[i]->LookInsideRoad(track,nrows,rowrange); | |
a4639de2 | 579 | if(fAddHistograms) |
580 | { | |
581 | Int_t pre=track->GetNHits(); | |
582 | track->SetNHits(pre+nrows); | |
583 | } | |
3e87ef69 | 584 | else//the track crossed too few good padrows (padrows with signal) in the patch, so remove it |
585 | { | |
586 | if(result == kFALSE) | |
587 | tracks->Remove(j); | |
588 | } | |
a4639de2 | 589 | } |
590 | ||
591 | tracks->Compress(); | |
a4639de2 | 592 | |
a6008206 | 593 | } |
f80b98cb | 594 | |
44c7f8de | 595 | void AliL3Hough::MergeEtaSlices() |
b1886074 | 596 | { |
44c7f8de | 597 | //Merge tracks found in neighbouring eta slices. |
598 | //Removes the track with the lower weight. | |
599 | ||
3e87ef69 | 600 | fBenchmark->Start("Merge Eta-slices"); |
44c7f8de | 601 | AliL3TrackArray *tracks = fTracks[0]; |
602 | if(!tracks) | |
b1886074 | 603 | { |
44c7f8de | 604 | cerr<<"AliL3Hough::MergeEtaSlices : No tracks "<<endl; |
b1886074 | 605 | return; |
606 | } | |
44c7f8de | 607 | for(Int_t j=0; j<tracks->GetNTracks(); j++) |
b1886074 | 608 | { |
44c7f8de | 609 | AliL3HoughTrack *track1 = (AliL3HoughTrack*)tracks->GetCheckedTrack(j); |
610 | if(!track1) continue; | |
611 | for(Int_t k=j+1; k<tracks->GetNTracks(); k++) | |
612 | { | |
613 | AliL3HoughTrack *track2 = (AliL3HoughTrack*)tracks->GetCheckedTrack(k); | |
614 | if(!track2) continue; | |
615 | if(abs(track1->GetEtaIndex() - track2->GetEtaIndex()) != 1) continue; | |
3e87ef69 | 616 | if(fabs(track1->GetKappa()-track2->GetKappa()) < 0.006 && |
617 | fabs(track1->GetPsi()- track2->GetPsi()) < 0.1) | |
44c7f8de | 618 | { |
3e87ef69 | 619 | //cout<<"Merging track in slices "<<track1->GetEtaIndex()<<" "<<track2->GetEtaIndex()<<endl; |
620 | if(track1->GetWeight() > track2->GetWeight()) | |
621 | tracks->Remove(k); | |
622 | else | |
623 | tracks->Remove(j); | |
44c7f8de | 624 | } |
625 | } | |
b1886074 | 626 | } |
3e87ef69 | 627 | fBenchmark->Stop("Merge Eta-slices"); |
44c7f8de | 628 | tracks->Compress(); |
b1886074 | 629 | } |
630 | ||
3fe49b5b | 631 | void AliL3Hough::WriteTracks(Int_t slice,Char_t *path) |
1c404dd5 | 632 | { |
c2f25cd2 | 633 | |
3e87ef69 | 634 | AliL3MemHandler mem; |
95a00d93 | 635 | Char_t fname[100]; |
b5a207b4 | 636 | if(fAddHistograms) |
637 | { | |
3fe49b5b | 638 | sprintf(fname,"%s/tracks_ho_%d.raw",path,slice); |
3e87ef69 | 639 | mem.SetBinaryOutput(fname); |
640 | mem.TrackArray2Binary(fTracks[0]); | |
641 | mem.CloseBinaryOutput(); | |
b5a207b4 | 642 | } |
643 | else | |
644 | { | |
645 | for(Int_t i=0; i<fNPatches; i++) | |
646 | { | |
3fe49b5b | 647 | sprintf(fname,"%s/tracks_ho_%d_%d.raw",path,slice,i); |
3e87ef69 | 648 | mem.SetBinaryOutput(fname); |
649 | mem.TrackArray2Binary(fTracks[i]); | |
650 | mem.CloseBinaryOutput(); | |
b5a207b4 | 651 | } |
652 | } | |
1c404dd5 | 653 | } |
208b54c5 | 654 | |
a6008206 | 655 | void AliL3Hough::WriteDigits(Char_t *outfile) |
656 | { | |
208b54c5 | 657 | #ifdef use_aliroot |
a6008206 | 658 | //Write the current data to a new rootfile. |
659 | ||
1c404dd5 | 660 | for(Int_t i=0; i<fNPatches; i++) |
a6008206 | 661 | { |
662 | AliL3DigitRowData *tempPt = (AliL3DigitRowData*)fHoughTransformer[i]->GetDataPointer(); | |
663 | fMemHandler[i]->AliDigits2RootFile(tempPt,outfile); | |
664 | } | |
208b54c5 | 665 | #else |
666 | cerr<<"AliL3Hough::WriteDigits : You need to compile with AliROOT!"<<endl; | |
667 | return; | |
668 | #endif | |
4fc9a6a4 | 669 | } |
208b54c5 | 670 | |
0309a5ee | 671 | Double_t AliL3Hough::GetCpuTime() |
672 | { | |
673 | //Return the Cputime in seconds. | |
674 | struct timeval tv; | |
675 | gettimeofday( &tv, NULL ); | |
676 | return tv.tv_sec+(((Double_t)tv.tv_usec)/1000000.); | |
677 | //return (Double_t)(clock()) / CLOCKS_PER_SEC; | |
678 | } | |
60a3d829 | 679 |