]>
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 | |
4aa41877 | 6 | #include "AliHLTStandardIncludes.h" |
0309a5ee | 7 | #include <sys/time.h> |
f000f8a5 | 8 | |
4aa41877 | 9 | #include "AliHLTLogging.h" |
10 | #include "AliHLTHoughMerger.h" | |
11 | #include "AliHLTHoughIntMerger.h" | |
12 | #include "AliHLTHoughGlobalMerger.h" | |
13 | #include "AliHLTHistogram.h" | |
14 | #include "AliHLTHough.h" | |
15 | #include "AliHLTHoughTransformer.h" | |
ea194d40 | 16 | #ifdef HAVE_ALIHLTHOUGHCLUSTERTRANSFORMER |
4aa41877 | 17 | #include "AliHLTHoughClusterTransformer.h" |
ea194d40 | 18 | #endif //HAVE_ALIHLTHOUGHCLUSTERTRANSFORMER |
4aa41877 | 19 | #include "AliHLTHoughTransformerLUT.h" |
20 | #include "AliHLTHoughTransformerVhdl.h" | |
21 | #include "AliHLTHoughTransformerRow.h" | |
22 | #include "AliHLTHoughMaxFinder.h" | |
23 | #include "AliHLTBenchmark.h" | |
95a00d93 | 24 | #ifdef use_aliroot |
4aa41877 | 25 | #include "AliHLTFileHandler.h" |
95a00d93 | 26 | #else |
4aa41877 | 27 | #include "AliHLTMemHandler.h" |
95a00d93 | 28 | #endif |
4aa41877 | 29 | #include "AliHLTDataHandler.h" |
30 | #include "AliHLTDigitData.h" | |
31 | #include "AliHLTHoughEval.h" | |
32 | #include "AliHLTTransform.h" | |
33 | #include "AliHLTTrackArray.h" | |
34 | #include "AliHLTHoughTrack.h" | |
35 | #include "AliHLTDDLDataFileHandler.h" | |
36 | #include "AliHLTHoughKalmanTrack.h" | |
95a00d93 | 37 | |
a8ffd46b | 38 | #include "TThread.h" |
39 | ||
c6747af6 | 40 | #if __GNUC__ >= 3 |
e06900d5 | 41 | using namespace std; |
42 | #endif | |
b1886074 | 43 | |
4aa41877 | 44 | /** /class AliHLTHough |
aa641eb8 | 45 | //<pre> |
b1886074 | 46 | //_____________________________________________________________ |
4aa41877 | 47 | // AliHLTHough |
b1886074 | 48 | // |
237d3f5c | 49 | // Interface class for the Hough transform |
b1886074 | 50 | // |
237d3f5c | 51 | // Example how to use: |
52 | // | |
4aa41877 | 53 | // AliHLTHough *hough = new AliHLTHough(path,kTRUE,NumberOfEtaSegments); |
237d3f5c | 54 | // hough->ReadData(slice); |
55 | // hough->Transform(); | |
56 | // hough->FindTrackCandidates(); | |
57 | // | |
4aa41877 | 58 | // AliHLTTrackArray *tracks = hough->GetTracks(patch); |
0bd0c1ef | 59 | // |
aa641eb8 | 60 | //</pre> |
61 | */ | |
f000f8a5 | 62 | |
4aa41877 | 63 | ClassImp(AliHLTHough) |
f000f8a5 | 64 | |
4aa41877 | 65 | AliHLTHough::AliHLTHough() |
f000f8a5 | 66 | { |
b1886074 | 67 | //Constructor |
68 | ||
6dbc57b4 | 69 | fBinary = kFALSE; |
a6008206 | 70 | fAddHistograms = kFALSE; |
6dbc57b4 | 71 | fDoIterative = kFALSE; |
72 | fWriteDigits = kFALSE; | |
73 | fUse8bits = kFALSE; | |
74 | ||
75 | fMemHandler = 0; | |
237d3f5c | 76 | fHoughTransformer = 0; |
6dbc57b4 | 77 | fEval = 0; |
78 | fPeakFinder = 0; | |
79 | fTracks = 0; | |
b2a02bce | 80 | fGlobalTracks = 0; |
6dbc57b4 | 81 | fMerger = 0; |
82 | fInterMerger = 0; | |
83 | fGlobalMerger = 0; | |
3e87ef69 | 84 | fBenchmark = 0; |
85 | ||
6dbc57b4 | 86 | fNEtaSegments = 0; |
87 | fNPatches = 0; | |
a8ffd46b | 88 | fLastPatch =-1; |
6dbc57b4 | 89 | fVersion = 0; |
90 | fCurrentSlice = 0; | |
b2a02bce | 91 | fEvent = 0; |
5a31e9df | 92 | |
0bd0c1ef | 93 | fKappaSpread = 6; |
94 | fPeakRatio = 0.5; | |
95 | fInputFile = 0; | |
96 | fInputPtr = 0; | |
a109e73e | 97 | fRawEvent = 0; |
5a31e9df | 98 | |
6dbc57b4 | 99 | SetTransformerParams(); |
100 | SetThreshold(); | |
636080ea | 101 | SetNSaveIterations(); |
3e87ef69 | 102 | SetPeakThreshold(); |
1f1942b8 | 103 | #ifdef use_aliroot |
104 | //just be sure that index is empty for new event | |
4aa41877 | 105 | AliHLTFileHandler::CleanStaticIndex(); |
de3c3890 | 106 | #ifdef use_newio |
107 | fRunLoader = 0; | |
108 | #endif | |
1f1942b8 | 109 | #endif |
a8ffd46b | 110 | fThread = 0; |
f000f8a5 | 111 | } |
112 | ||
4aa41877 | 113 | AliHLTHough::AliHLTHough(Char_t *path,Bool_t binary,Int_t netasegments,Bool_t bit8,Int_t tv,Char_t *infile,Char_t *ptr) |
b46b53c1 | 114 | { |
917e711b | 115 | //Normal constructor |
b46b53c1 | 116 | fBinary = binary; |
117 | strcpy(fPath,path); | |
917e711b | 118 | fNEtaSegments = netasegments; |
b46b53c1 | 119 | fAddHistograms = kFALSE; |
6dbc57b4 | 120 | fDoIterative = kFALSE; |
121 | fWriteDigits = kFALSE; | |
122 | fUse8bits = bit8; | |
123 | fVersion = tv; | |
5a31e9df | 124 | fKappaSpread=6; |
125 | fPeakRatio=0.5; | |
0bd0c1ef | 126 | if(!fBinary) { |
127 | if(infile) { | |
128 | fInputFile = infile; | |
129 | fInputPtr = 0; | |
130 | } | |
131 | else { | |
132 | fInputFile = 0; | |
133 | fInputPtr = ptr; | |
134 | } | |
135 | } | |
136 | else { | |
b2a02bce | 137 | fInputFile = 0; |
0bd0c1ef | 138 | fInputPtr = 0; |
139 | } | |
1f1942b8 | 140 | #ifdef use_aliroot |
141 | //just be sure that index is empty for new event | |
4aa41877 | 142 | AliHLTFileHandler::CleanStaticIndex(); |
de3c3890 | 143 | #ifdef use_newio |
144 | fRunLoader = 0; | |
145 | #endif | |
1f1942b8 | 146 | #endif |
a8ffd46b | 147 | fThread = 0; |
b46b53c1 | 148 | } |
f000f8a5 | 149 | |
4aa41877 | 150 | AliHLTHough::~AliHLTHough() |
f000f8a5 | 151 | { |
237d3f5c | 152 | //dtor |
153 | ||
b1886074 | 154 | CleanUp(); |
155 | if(fMerger) | |
156 | delete fMerger; | |
1f1942b8 | 157 | //cout << "Cleaned class merger " << endl; |
b1886074 | 158 | if(fInterMerger) |
159 | delete fInterMerger; | |
1f1942b8 | 160 | //cout << "Cleaned class inter " << endl; |
a6008206 | 161 | if(fPeakFinder) |
162 | delete fPeakFinder; | |
1f1942b8 | 163 | //cout << "Cleaned class peak " << endl; |
1c404dd5 | 164 | if(fGlobalMerger) |
165 | delete fGlobalMerger; | |
1f1942b8 | 166 | //cout << "Cleaned class global " << endl; |
3e87ef69 | 167 | if(fBenchmark) |
168 | delete fBenchmark; | |
1f1942b8 | 169 | //cout << "Cleaned class bench " << endl; |
b2a02bce | 170 | if(fGlobalTracks) |
171 | delete fGlobalTracks; | |
1f1942b8 | 172 | //cout << "Cleaned class globaltracks " << endl; |
a8ffd46b | 173 | if(fThread) { |
174 | // fThread->Delete(); | |
175 | delete fThread; | |
176 | fThread = 0; | |
177 | } | |
f000f8a5 | 178 | } |
179 | ||
4aa41877 | 180 | void AliHLTHough::CleanUp() |
f000f8a5 | 181 | { |
b1886074 | 182 | //Cleanup memory |
183 | ||
1c404dd5 | 184 | for(Int_t i=0; i<fNPatches; i++) |
4fc9a6a4 | 185 | { |
b1886074 | 186 | if(fTracks[i]) delete fTracks[i]; |
1f1942b8 | 187 | //cout << "Cleaned tracks " << i << endl; |
b1886074 | 188 | if(fEval[i]) delete fEval[i]; |
1f1942b8 | 189 | //cout << "Cleaned eval " << i << endl; |
b1886074 | 190 | if(fHoughTransformer[i]) delete fHoughTransformer[i]; |
1f1942b8 | 191 | //cout << "Cleaned traf " << i << endl; |
b1886074 | 192 | if(fMemHandler[i]) delete fMemHandler[i]; |
1f1942b8 | 193 | //cout << "Cleaned mem " << i << endl; |
4fc9a6a4 | 194 | } |
b1886074 | 195 | |
3e87ef69 | 196 | if(fTracks) delete [] fTracks; |
1f1942b8 | 197 | //cout << "Cleaned class tracks " << endl; |
3e87ef69 | 198 | if(fEval) delete [] fEval; |
1f1942b8 | 199 | //cout << "Cleaned class eval " << endl; |
3e87ef69 | 200 | if(fHoughTransformer) delete [] fHoughTransformer; |
1f1942b8 | 201 | //cout << "Cleaned cleass trafo " << endl; |
3e87ef69 | 202 | if(fMemHandler) delete [] fMemHandler; |
1f1942b8 | 203 | //cout << "Cleaned class mem " << endl; |
f000f8a5 | 204 | } |
205 | ||
4aa41877 | 206 | void AliHLTHough::Init(Int_t netasegments,Int_t tv,AliRawEvent *rawevent,Float_t zvertex) |
a109e73e | 207 | { |
208 | //Normal constructor | |
209 | fNEtaSegments = netasegments; | |
210 | fVersion = tv; | |
211 | fRawEvent = rawevent; | |
212 | fZVertex = zvertex; | |
213 | ||
214 | Init(); | |
215 | } | |
216 | ||
4aa41877 | 217 | void AliHLTHough::Init(Char_t *path,Bool_t binary,Int_t netasegments,Bool_t bit8,Int_t tv,Char_t *infile,Char_t *ptr,Float_t zvertex) |
f000f8a5 | 218 | { |
4aa41877 | 219 | //Normal init of the AliHLTHough |
d96f6a4a | 220 | fBinary = binary; |
221 | strcpy(fPath,path); | |
917e711b | 222 | fNEtaSegments = netasegments; |
6dbc57b4 | 223 | fWriteDigits = kFALSE; |
224 | fUse8bits = bit8; | |
225 | fVersion = tv; | |
0bd0c1ef | 226 | if(!fBinary) { |
227 | if(infile) { | |
228 | fInputFile = infile; | |
229 | fInputPtr = 0; | |
230 | } | |
231 | else { | |
232 | fInputFile = 0; | |
233 | fInputPtr = ptr; | |
234 | } | |
235 | } | |
236 | else { | |
b2a02bce | 237 | fInputFile = 0; |
0bd0c1ef | 238 | fInputPtr = 0; |
239 | } | |
240 | fZVertex = zvertex; | |
6dbc57b4 | 241 | |
242 | Init(); //do the rest | |
243 | } | |
244 | ||
4aa41877 | 245 | void AliHLTHough::Init(Bool_t doit, Bool_t addhists) |
a4639de2 | 246 | { |
917e711b | 247 | // Init |
6dbc57b4 | 248 | fDoIterative = doit; |
249 | fAddHistograms = addhists; | |
b46b53c1 | 250 | |
4aa41877 | 251 | fNPatches = AliHLTTransform::GetNPatches(); |
252 | fHoughTransformer = new AliHLTHoughBaseTransformer*[fNPatches]; | |
253 | fMemHandler = new AliHLTMemHandler*[fNPatches]; | |
3e87ef69 | 254 | |
4aa41877 | 255 | fTracks = new AliHLTTrackArray*[fNPatches]; |
256 | fEval = new AliHLTHoughEval*[fNPatches]; | |
b2a02bce | 257 | |
4aa41877 | 258 | fGlobalTracks = new AliHLTTrackArray("AliHLTHoughTrack"); |
b2a02bce | 259 | |
4aa41877 | 260 | AliHLTHoughBaseTransformer *lasttransformer = 0; |
a8ffd46b | 261 | |
1c404dd5 | 262 | for(Int_t i=0; i<fNPatches; i++) |
f80b98cb | 263 | { |
6dbc57b4 | 264 | switch (fVersion){ //choose Transformer |
b46b53c1 | 265 | case 1: |
4aa41877 | 266 | fHoughTransformer[i] = new AliHLTHoughTransformerLUT(0,i,fNEtaSegments); |
b46b53c1 | 267 | break; |
6c97129d | 268 | case 2: |
ea194d40 | 269 | #ifdef HAVE_ALIHLTHOUGHCLUSTERTRANSFORMER |
4aa41877 | 270 | fHoughTransformer[i] = new AliHLTHoughClusterTransformer(0,i,fNEtaSegments); |
ea194d40 | 271 | #endif //HAVE_ALIHLTHOUGHCLUSTERTRANSFORMER |
6c97129d | 272 | break; |
636080ea | 273 | case 3: |
4aa41877 | 274 | fHoughTransformer[i] = new AliHLTHoughTransformerVhdl(0,i,fNEtaSegments,fNSaveIterations); |
636080ea | 275 | break; |
5a31e9df | 276 | case 4: |
4aa41877 | 277 | fHoughTransformer[i] = new AliHLTHoughTransformerRow(0,i,fNEtaSegments,kFALSE,fZVertex); |
5a31e9df | 278 | break; |
b46b53c1 | 279 | default: |
4aa41877 | 280 | fHoughTransformer[i] = new AliHLTHoughTransformer(0,i,fNEtaSegments,kFALSE,kFALSE); |
b46b53c1 | 281 | } |
aa641eb8 | 282 | |
a8ffd46b | 283 | fHoughTransformer[i]->SetLastTransformer(lasttransformer); |
284 | lasttransformer = fHoughTransformer[i]; | |
de3c3890 | 285 | // fHoughTransformer[i]->CreateHistograms(fNBinX[i],fLowPt[i],fNBinY[i],-fPhi[i],fPhi[i]); |
286 | fHoughTransformer[i]->CreateHistograms(fNBinX[i],-fLowPt[i],fLowPt[i],fNBinY[i],-fPhi[i],fPhi[i]); | |
b2a02bce | 287 | //fHoughTransformer[i]->CreateHistograms(fLowPt[i],fUpperPt[i],fPtRes[i],fNBinY[i],fPhi[i]); |
1f1942b8 | 288 | |
b2a02bce | 289 | fHoughTransformer[i]->SetLowerThreshold(fThreshold[i]); |
290 | fHoughTransformer[i]->SetUpperThreshold(100); | |
291 | ||
4aa41877 | 292 | LOG(AliHLTLog::kInformational,"AliHLTHough::Init","Version") |
6dbc57b4 | 293 | <<"Initializing Hough transformer version "<<fVersion<<ENDLOG; |
a4639de2 | 294 | |
4aa41877 | 295 | fEval[i] = new AliHLTHoughEval(); |
296 | fTracks[i] = new AliHLTTrackArray("AliHLTHoughTrack"); | |
d96f6a4a | 297 | if(fUse8bits) |
4aa41877 | 298 | fMemHandler[i] = new AliHLTDataHandler(); |
d96f6a4a | 299 | else |
95a00d93 | 300 | #ifdef use_aliroot |
d96f6a4a | 301 | { |
a109e73e | 302 | if(!fRawEvent) { |
303 | if(!fInputFile) { | |
304 | if(!fInputPtr) { | |
305 | /* In case of reading digits file */ | |
4aa41877 | 306 | fMemHandler[i] = new AliHLTFileHandler(kTRUE); //use static index |
a109e73e | 307 | if(!fBinary) { |
de3c3890 | 308 | #if use_newio |
a109e73e | 309 | if(!fRunLoader) { |
de3c3890 | 310 | #endif |
a109e73e | 311 | Char_t filename[1024]; |
312 | sprintf(filename,"%s/digitfile.root",fPath); | |
313 | fMemHandler[i]->SetAliInput(filename); | |
de3c3890 | 314 | #if use_newio |
a109e73e | 315 | } |
316 | else { | |
317 | fMemHandler[i]->SetAliInput(fRunLoader); | |
318 | } | |
de3c3890 | 319 | #endif |
a109e73e | 320 | } |
321 | } | |
322 | else { | |
323 | /* In case of reading from DATE */ | |
4aa41877 | 324 | fMemHandler[i] = new AliHLTDDLDataFileHandler(); |
a109e73e | 325 | fMemHandler[i]->SetReaderInput(fInputPtr,-1); |
0bd0c1ef | 326 | } |
327 | } | |
328 | else { | |
a109e73e | 329 | /* In case of reading rawdata from ROOT file */ |
4aa41877 | 330 | fMemHandler[i] = new AliHLTDDLDataFileHandler(); |
a109e73e | 331 | fMemHandler[i]->SetReaderInput(fInputFile); |
3bb06991 | 332 | } |
b2a02bce | 333 | } |
334 | else { | |
a109e73e | 335 | /* In case of reading rawdata using AliRawEvent */ |
4aa41877 | 336 | fMemHandler[i] = new AliHLTDDLDataFileHandler(); |
a109e73e | 337 | fMemHandler[i]->SetReaderInput(fRawEvent); |
b2a02bce | 338 | } |
d96f6a4a | 339 | } |
95a00d93 | 340 | #else |
4aa41877 | 341 | fMemHandler[i] = new AliHLTMemHandler(); |
95a00d93 | 342 | #endif |
a6008206 | 343 | } |
6dbc57b4 | 344 | |
4aa41877 | 345 | fPeakFinder = new AliHLTHoughMaxFinder("KappaPhi",50000); |
7e4eb453 | 346 | if(fVersion!=4) { |
4aa41877 | 347 | fMerger = new AliHLTHoughMerger(fNPatches); |
348 | fInterMerger = new AliHLTHoughIntMerger(); | |
7e4eb453 | 349 | } |
350 | else { | |
351 | fMerger = 0; | |
352 | fInterMerger = 0; | |
353 | } | |
237d3f5c | 354 | fGlobalMerger = 0; |
4aa41877 | 355 | fBenchmark = new AliHLTBenchmark(); |
b2a02bce | 356 | } |
357 | ||
4aa41877 | 358 | void AliHLTHough::SetTransformerParams(Float_t ptres,Float_t ptmin,Float_t ptmax,Int_t ny,Int_t patch) |
b2a02bce | 359 | { |
917e711b | 360 | // Setup the parameters for the Hough Transformer |
8da9b1eb | 361 | // This includes the bin size and limits for |
362 | // the parameter space histograms | |
363 | ||
b2a02bce | 364 | Int_t mrow; |
365 | Float_t psi=0; | |
366 | if(patch==-1) | |
367 | mrow = 80; | |
368 | else | |
4aa41877 | 369 | mrow = AliHLTTransform::GetLastRow(patch); |
b2a02bce | 370 | if(ptmin) |
371 | { | |
4aa41877 | 372 | Double_t lineradius = sqrt(pow(AliHLTTransform::Row2X(mrow),2) + pow(AliHLTTransform::GetMaxY(mrow),2)); |
373 | Double_t kappa = -1*AliHLTTransform::GetBField()*AliHLTTransform::GetBFact()/ptmin; | |
374 | psi = AliHLTTransform::Deg2Rad(10) - asin(lineradius*kappa/2); | |
b2a02bce | 375 | cout<<"Calculated psi range "<<psi<<" in patch "<<patch<<endl; |
376 | } | |
377 | ||
378 | if(patch==-1) | |
379 | { | |
380 | Int_t i=0; | |
381 | while(i < 6) | |
382 | { | |
383 | fPtRes[i] = ptres; | |
384 | fLowPt[i] = ptmin; | |
385 | fUpperPt[i] = ptmax; | |
386 | fNBinY[i] = ny; | |
387 | fPhi[i] = psi; | |
388 | fNBinX[i]=0; | |
389 | i++; | |
390 | } | |
391 | return; | |
392 | } | |
393 | ||
394 | fPtRes[patch] = ptres; | |
395 | fLowPt[patch] = ptmin; | |
396 | fUpperPt[patch] = ptmax; | |
397 | fNBinY[patch] = ny; | |
398 | fPhi[patch] = psi; | |
399 | } | |
de3c3890 | 400 | /* |
4aa41877 | 401 | void AliHLTHough::SetTransformerParams(Int_t nx,Int_t ny,Float_t ptmin,Int_t patch) |
b2a02bce | 402 | { |
917e711b | 403 | // Setup the parameters for the Hough Transformer |
b2a02bce | 404 | |
405 | Int_t mrow=80; | |
4aa41877 | 406 | Double_t lineradius = sqrt(pow(AliHLTTransform::Row2X(mrow),2) + pow(AliHLTTransform::GetMaxY(mrow),2)); |
407 | Double_t kappa = -1*AliHLTTransform::GetBField()*AliHLTTransform::GetBFact()/ptmin; | |
408 | Double_t psi = AliHLTTransform::Deg2Rad(10) - asin(lineradius*kappa/2); | |
b2a02bce | 409 | cout<<"Calculated psi range "<<psi<<" in patch "<<patch<<endl; |
410 | ||
411 | Int_t i=0; | |
412 | while(i < 6) | |
413 | { | |
414 | fLowPt[i] = ptmin; | |
415 | fNBinY[i] = ny; | |
416 | fNBinX[i] = nx; | |
417 | fPhi[i] = psi; | |
418 | i++; | |
419 | } | |
420 | } | |
de3c3890 | 421 | */ |
4aa41877 | 422 | void AliHLTHough::SetTransformerParams(Int_t nx,Int_t ny,Float_t ptmin,Int_t /*patch*/) |
de3c3890 | 423 | { |
917e711b | 424 | // Setup the parameters for the Hough Transformer |
de3c3890 | 425 | |
4aa41877 | 426 | Double_t lineradius = 1.0/(AliHLTHoughTransformerRow::GetBeta1()*sqrt(1.0+tan(AliHLTTransform::Pi()*10/180)*tan(AliHLTTransform::Pi()*10/180))); |
427 | Double_t alpha1 = AliHLTHoughTransformerRow::GetBeta1()*tan(AliHLTTransform::Pi()*10/180); | |
428 | Double_t kappa = 1*AliHLTTransform::GetBField()*AliHLTTransform::GetBFact()/(ptmin*0.9); | |
429 | Double_t psi = AliHLTTransform::Deg2Rad(10) - asin(lineradius*kappa/2); | |
0fdf7509 | 430 | // cout<<"Calculated psi range "<<psi<<" in patch "<<patch<<endl; |
4aa41877 | 431 | Double_t alpha2 = alpha1 - (AliHLTHoughTransformerRow::GetBeta1()-AliHLTHoughTransformerRow::GetBeta2())*tan(psi); |
0fdf7509 | 432 | // cout<<"Calculated alphas range "<<alpha1<<" "<<alpha2<<" in patch "<<patch<<endl; |
de3c3890 | 433 | |
434 | Int_t i=0; | |
435 | while(i < 6) | |
436 | { | |
1e75562a | 437 | fLowPt[i] = 1.1*alpha1; |
438 | fNBinY[i] = ny; | |
439 | fNBinX[i] = nx; | |
440 | fPhi[i] = alpha2; | |
441 | i++; | |
442 | } | |
443 | } | |
444 | ||
4aa41877 | 445 | void AliHLTHough::CalcTransformerParams(Float_t ptmin) |
1e75562a | 446 | { |
447 | // Setup the parameters for the Row Hough Transformer | |
448 | // Automatically adjusts the number of bins in X and Y in a way | |
449 | // that the size of the hough bin is 2x (in X) and 2.5 (in Y) the | |
450 | // size of the tpc pads | |
451 | ||
4aa41877 | 452 | Double_t lineradius = 1.0/(AliHLTHoughTransformerRow::GetBeta1()*sqrt(1.0+tan(AliHLTTransform::Pi()*10/180)*tan(AliHLTTransform::Pi()*10/180))); |
453 | Double_t alpha1 = AliHLTHoughTransformerRow::GetBeta1()*tan(AliHLTTransform::Pi()*10/180); | |
454 | Double_t kappa = 1*AliHLTTransform::GetBField()*AliHLTTransform::GetBFact()/(ptmin*0.9); | |
455 | Double_t psi = AliHLTTransform::Deg2Rad(10) - asin(lineradius*kappa/2); | |
1e75562a | 456 | // cout<<"Calculated psi range "<<psi<<endl; |
4aa41877 | 457 | Double_t alpha2 = alpha1 - (AliHLTHoughTransformerRow::GetBeta1()-AliHLTHoughTransformerRow::GetBeta2())*tan(psi); |
1e75562a | 458 | alpha1 *= 1.1; |
459 | // cout<<"Calculated alphas range "<<alpha1<<" "<<alpha2<<endl; | |
460 | ||
4aa41877 | 461 | Double_t sizex = 2.0*AliHLTTransform::GetPadPitchWidthLow()*AliHLTHoughTransformerRow::GetBeta1()*AliHLTHoughTransformerRow::GetBeta1(); |
462 | Double_t sizey = 2.5*AliHLTTransform::GetPadPitchWidthUp()*AliHLTHoughTransformerRow::GetBeta2()*AliHLTHoughTransformerRow::GetBeta2(); | |
1e75562a | 463 | |
464 | Int_t nx = 2*(Int_t)(alpha1/sizex)+1; | |
465 | Int_t ny = 2*(Int_t)(alpha2/sizey)+1; | |
466 | // cout<<"Calculated number of bins "<<nx<<" "<<ny<<endl; | |
467 | ||
468 | Int_t i=0; | |
469 | while(i < 6) | |
470 | { | |
471 | fLowPt[i] = alpha1; | |
de3c3890 | 472 | fNBinY[i] = ny; |
473 | fNBinX[i] = nx; | |
1e75562a | 474 | fPhi[i] = alpha2; |
de3c3890 | 475 | i++; |
476 | } | |
477 | } | |
b2a02bce | 478 | |
4aa41877 | 479 | void AliHLTHough::SetTransformerParams(Int_t nx,Int_t ny,Float_t lpt,Float_t phi) |
b2a02bce | 480 | { |
481 | Int_t i=0; | |
482 | while(i < 6) | |
483 | { | |
484 | fLowPt[i] = lpt; | |
485 | fNBinY[i] = ny; | |
486 | fNBinX[i] = nx; | |
487 | fPhi[i] = phi; | |
488 | i++; | |
489 | } | |
490 | } | |
491 | ||
4aa41877 | 492 | void AliHLTHough::SetThreshold(Int_t t3,Int_t patch) |
b2a02bce | 493 | { |
917e711b | 494 | // Set digits threshold |
b2a02bce | 495 | if(patch==-1) |
496 | { | |
497 | Int_t i=0; | |
498 | while(i < 6) | |
499 | fThreshold[i++]=t3; | |
500 | return; | |
501 | } | |
502 | fThreshold[patch]=t3; | |
503 | } | |
3e87ef69 | 504 | |
4aa41877 | 505 | void AliHLTHough::SetPeakThreshold(Int_t threshold,Int_t patch) |
b2a02bce | 506 | { |
917e711b | 507 | // Set Peak Finder threshold |
b2a02bce | 508 | if(patch==-1) |
509 | { | |
510 | Int_t i=0; | |
511 | while(i < 6) | |
512 | fPeakThreshold[i++]=threshold; | |
513 | return; | |
514 | } | |
515 | fPeakThreshold[patch]=threshold; | |
3e87ef69 | 516 | } |
517 | ||
4aa41877 | 518 | void AliHLTHough::DoBench(Char_t *name) |
3e87ef69 | 519 | { |
520 | fBenchmark->Analyze(name); | |
a6008206 | 521 | } |
522 | ||
4aa41877 | 523 | void AliHLTHough::Process(Int_t minslice,Int_t maxslice) |
a6008206 | 524 | { |
525 | //Process all slices [minslice,maxslice]. | |
4aa41877 | 526 | fGlobalMerger = new AliHLTHoughGlobalMerger(minslice,maxslice); |
b1886074 | 527 | |
a6008206 | 528 | for(Int_t i=minslice; i<=maxslice; i++) |
529 | { | |
b1886074 | 530 | ReadData(i); |
531 | Transform(); | |
0bd0c1ef | 532 | if(fAddHistograms) { |
533 | if(fVersion != 4) | |
534 | AddAllHistograms(); | |
535 | else | |
536 | AddAllHistogramsRows(); | |
537 | } | |
a6008206 | 538 | FindTrackCandidates(); |
3e87ef69 | 539 | //Evaluate(); |
540 | //fGlobalMerger->FillTracks(fTracks[0],i); | |
f80b98cb | 541 | } |
4fc9a6a4 | 542 | } |
f80b98cb | 543 | |
4aa41877 | 544 | void AliHLTHough::ReadData(Int_t slice,Int_t eventnr) |
4fc9a6a4 | 545 | { |
b1886074 | 546 | //Read data from files, binary or root. |
3bb06991 | 547 | |
1f1942b8 | 548 | #ifdef use_aliroot |
549 | if(fEvent!=eventnr) //just be sure that index is empty for new event | |
4aa41877 | 550 | AliHLTFileHandler::CleanStaticIndex(); |
1f1942b8 | 551 | #endif |
3bb06991 | 552 | fCurrentSlice = slice; |
1f1942b8 | 553 | |
1c404dd5 | 554 | for(Int_t i=0; i<fNPatches; i++) |
f80b98cb | 555 | { |
4fc9a6a4 | 556 | fMemHandler[i]->Free(); |
557 | UInt_t ndigits=0; | |
4aa41877 | 558 | AliHLTDigitRowData *digits =0; |
4fc9a6a4 | 559 | Char_t name[256]; |
3fe49b5b | 560 | fMemHandler[i]->Init(slice,i); |
a6008206 | 561 | if(fBinary)//take input data from binary files |
4fc9a6a4 | 562 | { |
d96f6a4a | 563 | if(fUse8bits) |
b2a02bce | 564 | sprintf(name,"%s/binaries/digits_c8_%d_%d_%d.raw",fPath,eventnr,slice,i); |
d96f6a4a | 565 | else |
b2a02bce | 566 | sprintf(name,"%s/binaries/digits_%d_%d_%d.raw",fPath,eventnr,slice,i); |
636080ea | 567 | |
4fc9a6a4 | 568 | fMemHandler[i]->SetBinaryInput(name); |
4aa41877 | 569 | digits = (AliHLTDigitRowData *)fMemHandler[i]->CompBinary2Memory(ndigits); |
4fc9a6a4 | 570 | fMemHandler[i]->CloseBinaryInput(); |
571 | } | |
572 | else //read data from root file | |
573 | { | |
95a00d93 | 574 | #ifdef use_aliroot |
5a31e9df | 575 | if(fEvent!=eventnr) |
576 | fMemHandler[i]->FreeDigitsTree();//or else the new event is not loaded | |
4aa41877 | 577 | digits=(AliHLTDigitRowData *)fMemHandler[i]->AliAltroDigits2Memory(ndigits,eventnr); |
95a00d93 | 578 | #else |
579 | cerr<<"You cannot read from rootfile now"<<endl; | |
580 | #endif | |
4fc9a6a4 | 581 | } |
aa641eb8 | 582 | |
a8ffd46b | 583 | //Set the pointer to the TPCRawStream in case of fast raw data reading |
584 | fHoughTransformer[i]->SetTPCRawStream(fMemHandler[i]->GetTPCRawStream()); | |
585 | ||
636080ea | 586 | //set input data and init transformer |
587 | fHoughTransformer[i]->SetInputData(ndigits,digits); | |
588 | fHoughTransformer[i]->Init(slice,i,fNEtaSegments); | |
b1886074 | 589 | } |
5a31e9df | 590 | |
591 | fEvent=eventnr; | |
b1886074 | 592 | } |
593 | ||
4aa41877 | 594 | void AliHLTHough::Transform(Int_t *rowrange) |
b1886074 | 595 | { |
596 | //Transform all data given to the transformer within the given slice | |
597 | //(after ReadData(slice)) | |
0309a5ee | 598 | |
599 | Double_t initTime,cpuTime; | |
600 | initTime = GetCpuTime(); | |
a8ffd46b | 601 | Int_t patchorder[6] = {5,2,0,1,3,4}; //The order in which patches are processed |
602 | // Int_t patchorder[6] = {0,1,2,3,4,5}; //The order in which patches are processed | |
603 | // Int_t patchorder[6] = {5,4,3,2,1,0}; //The order in which patches are processed | |
604 | // Int_t patchorder[6] = {5,2,4,3,1,0}; //The order in which patches are processed | |
605 | fLastPatch=-1; | |
1c404dd5 | 606 | for(Int_t i=0; i<fNPatches; i++) |
b1886074 | 607 | { |
0bd0c1ef | 608 | // In case of Row transformer reset the arrays only once |
a8ffd46b | 609 | if((fVersion != 4) || (i == 0)) { |
610 | fBenchmark->Start("Hough Reset"); | |
611 | fHoughTransformer[0]->Reset();//Reset the histograms | |
612 | fBenchmark->Stop("Hough Reset"); | |
613 | } | |
3e87ef69 | 614 | fBenchmark->Start("Hough Transform"); |
a8ffd46b | 615 | PrepareForNextPatch(patchorder[i]); |
616 | if(!rowrange) { | |
617 | char buf[256]; | |
618 | sprintf(buf,"Patch %d",patchorder[i]); | |
619 | fBenchmark->Start(buf); | |
620 | fHoughTransformer[patchorder[i]]->SetLastPatch(fLastPatch); | |
621 | fHoughTransformer[patchorder[i]]->TransformCircle(); | |
622 | fBenchmark->Stop(buf); | |
623 | } | |
237d3f5c | 624 | else |
917e711b | 625 | fHoughTransformer[i]->TransformCircleC(rowrange,1); |
3e87ef69 | 626 | fBenchmark->Stop("Hough Transform"); |
a8ffd46b | 627 | fLastPatch=patchorder[i]; |
b1886074 | 628 | } |
0309a5ee | 629 | cpuTime = GetCpuTime() - initTime; |
4aa41877 | 630 | LOG(AliHLTLog::kInformational,"AliHLTHough::Transform()","Timing") |
0309a5ee | 631 | <<"Transform done in average per patch of "<<cpuTime*1000/fNPatches<<" ms"<<ENDLOG; |
b1886074 | 632 | } |
633 | ||
4aa41877 | 634 | void AliHLTHough::MergePatches() |
b1886074 | 635 | { |
917e711b | 636 | // Merge patches if they are not summed |
b1886074 | 637 | if(fAddHistograms) //Nothing to merge here |
638 | return; | |
b1886074 | 639 | fMerger->MergePatches(kTRUE); |
b1886074 | 640 | } |
641 | ||
4aa41877 | 642 | void AliHLTHough::MergeInternally() |
b1886074 | 643 | { |
917e711b | 644 | // Merge patches internally |
b1886074 | 645 | if(fAddHistograms) |
646 | fInterMerger->FillTracks(fTracks[0]); | |
647 | else | |
648 | fInterMerger->FillTracks(fMerger->GetOutTracks()); | |
649 | ||
650 | fInterMerger->MMerge(); | |
651 | } | |
652 | ||
4aa41877 | 653 | void AliHLTHough::ProcessSliceIter() |
b1886074 | 654 | { |
655 | //Process current slice (after ReadData(slice)) iteratively. | |
656 | ||
6c97129d | 657 | if(!fAddHistograms) |
b1886074 | 658 | { |
6c97129d | 659 | for(Int_t i=0; i<fNPatches; i++) |
660 | { | |
661 | ProcessPatchIter(i); | |
662 | fMerger->FillTracks(fTracks[i],i); //Copy tracks to merger | |
663 | } | |
664 | } | |
665 | else | |
666 | { | |
667 | for(Int_t i=0; i<10; i++) | |
668 | { | |
669 | Transform(); | |
670 | AddAllHistograms(); | |
671 | InitEvaluate(); | |
4aa41877 | 672 | AliHLTHoughBaseTransformer *tr = fHoughTransformer[0]; |
6c97129d | 673 | for(Int_t j=0; j<fNEtaSegments; j++) |
674 | { | |
4aa41877 | 675 | AliHLTHistogram *hist = tr->GetHistogram(j); |
6c97129d | 676 | if(hist->GetNEntries()==0) continue; |
677 | fPeakFinder->Reset(); | |
678 | fPeakFinder->SetHistogram(hist); | |
679 | fPeakFinder->FindAbsMaxima(); | |
4aa41877 | 680 | AliHLTHoughTrack *track = (AliHLTHoughTrack*)fTracks[0]->NextTrack(); |
6c97129d | 681 | track->SetTrackParameters(fPeakFinder->GetXPeak(0),fPeakFinder->GetYPeak(0),fPeakFinder->GetWeight(0)); |
682 | track->SetEtaIndex(j); | |
683 | track->SetEta(tr->GetEta(j,fCurrentSlice)); | |
684 | for(Int_t k=0; k<fNPatches; k++) | |
685 | { | |
686 | fEval[i]->SetNumOfPadsToLook(2); | |
687 | fEval[i]->SetNumOfRowsToMiss(2); | |
688 | fEval[i]->RemoveFoundTracks(); | |
3e87ef69 | 689 | /* |
6c97129d | 690 | Int_t nrows=0; |
691 | if(!fEval[i]->LookInsideRoad(track,nrows)) | |
692 | { | |
693 | fTracks[0]->Remove(fTracks[0]->GetNTracks()-1); | |
694 | fTracks[0]->Compress(); | |
695 | } | |
3e87ef69 | 696 | */ |
6c97129d | 697 | } |
698 | } | |
699 | ||
700 | } | |
701 | ||
f80b98cb | 702 | } |
4fc9a6a4 | 703 | } |
704 | ||
4aa41877 | 705 | void AliHLTHough::ProcessPatchIter(Int_t patch) |
b1886074 | 706 | { |
707 | //Process patch in a iterative way. | |
708 | //transform + peakfinding + evaluation + transform +... | |
709 | ||
917e711b | 710 | Int_t numoftries = 5; |
4aa41877 | 711 | AliHLTHoughBaseTransformer *tr = fHoughTransformer[patch]; |
712 | AliHLTTrackArray *tracks = fTracks[patch]; | |
b1886074 | 713 | tracks->Reset(); |
4aa41877 | 714 | AliHLTHoughEval *ev = fEval[patch]; |
b1886074 | 715 | ev->InitTransformer(tr); |
6c97129d | 716 | //ev->RemoveFoundTracks(); |
717 | ev->SetNumOfRowsToMiss(3); | |
b5a207b4 | 718 | ev->SetNumOfPadsToLook(2); |
4aa41877 | 719 | AliHLTHistogram *hist; |
917e711b | 720 | for(Int_t t=0; t<numoftries; t++) |
b1886074 | 721 | { |
722 | tr->Reset(); | |
723 | tr->TransformCircle(); | |
724 | for(Int_t i=0; i<fNEtaSegments; i++) | |
725 | { | |
726 | hist = tr->GetHistogram(i); | |
727 | if(hist->GetNEntries()==0) continue; | |
6c97129d | 728 | fPeakFinder->Reset(); |
b1886074 | 729 | fPeakFinder->SetHistogram(hist); |
6c97129d | 730 | fPeakFinder->FindAbsMaxima(); |
731 | //fPeakFinder->FindPeak1(); | |
4aa41877 | 732 | AliHLTHoughTrack *track = (AliHLTHoughTrack*)tracks->NextTrack(); |
6c97129d | 733 | track->SetTrackParameters(fPeakFinder->GetXPeak(0),fPeakFinder->GetYPeak(0),fPeakFinder->GetWeight(0)); |
734 | track->SetEtaIndex(i); | |
735 | track->SetEta(tr->GetEta(i,fCurrentSlice)); | |
3e87ef69 | 736 | /* |
6c97129d | 737 | Int_t nrows=0; |
738 | if(!ev->LookInsideRoad(track,nrows)) | |
b1886074 | 739 | { |
740 | tracks->Remove(tracks->GetNTracks()-1); | |
741 | tracks->Compress(); | |
742 | } | |
3e87ef69 | 743 | */ |
b1886074 | 744 | } |
745 | } | |
6c97129d | 746 | fTracks[0]->QSort(); |
4aa41877 | 747 | LOG(AliHLTLog::kInformational,"AliHLTHough::ProcessPatch","NTracks") |
748 | <<AliHLTLog::kDec<<"Found "<<tracks->GetNTracks()<<" tracks in patch "<<patch<<ENDLOG; | |
b1886074 | 749 | } |
750 | ||
4aa41877 | 751 | void AliHLTHough::AddAllHistograms() |
4fc9a6a4 | 752 | { |
a6008206 | 753 | //Add the histograms within one etaslice. |
754 | //Resulting histogram are in patch=0. | |
b1886074 | 755 | |
0309a5ee | 756 | Double_t initTime,cpuTime; |
757 | initTime = GetCpuTime(); | |
3e87ef69 | 758 | fBenchmark->Start("Add Histograms"); |
a6008206 | 759 | for(Int_t i=0; i<fNEtaSegments; i++) |
760 | { | |
4aa41877 | 761 | AliHLTHistogram *hist0 = fHoughTransformer[0]->GetHistogram(i); |
1c404dd5 | 762 | for(Int_t j=1; j<fNPatches; j++) |
a6008206 | 763 | { |
4aa41877 | 764 | AliHLTHistogram *hist = fHoughTransformer[j]->GetHistogram(i); |
a6008206 | 765 | hist0->Add(hist); |
766 | } | |
767 | } | |
3e87ef69 | 768 | fBenchmark->Stop("Add Histograms"); |
b1886074 | 769 | fAddHistograms = kTRUE; |
0309a5ee | 770 | cpuTime = GetCpuTime() - initTime; |
4aa41877 | 771 | LOG(AliHLTLog::kInformational,"AliHLTHough::AddAllHistograms()","Timing") |
0309a5ee | 772 | <<"Adding histograms in "<<cpuTime*1000<<" ms"<<ENDLOG; |
a6008206 | 773 | } |
774 | ||
4aa41877 | 775 | void AliHLTHough::AddAllHistogramsRows() |
0bd0c1ef | 776 | { |
777 | //Add the histograms within one etaslice. | |
778 | //Resulting histogram are in patch=0. | |
779 | ||
780 | Double_t initTime,cpuTime; | |
781 | initTime = GetCpuTime(); | |
782 | fBenchmark->Start("Add HistogramsRows"); | |
783 | ||
4aa41877 | 784 | UChar_t lastpatchlastrow = AliHLTTransform::GetLastRowOnDDL(fLastPatch)+1; |
a8ffd46b | 785 | |
4aa41877 | 786 | UChar_t *tracklastrow = ((AliHLTHoughTransformerRow *)fHoughTransformer[0])->GetTrackLastRow(); |
de3c3890 | 787 | |
0bd0c1ef | 788 | for(Int_t i=0; i<fNEtaSegments; i++) |
789 | { | |
4aa41877 | 790 | UChar_t *gapcount = ((AliHLTHoughTransformerRow *)fHoughTransformer[0])->GetGapCount(i); |
791 | UChar_t *currentrowcount = ((AliHLTHoughTransformerRow *)fHoughTransformer[0])->GetCurrentRowCount(i); | |
0bd0c1ef | 792 | |
4aa41877 | 793 | AliHLTHistogram *hist = fHoughTransformer[0]->GetHistogram(i); |
0bd0c1ef | 794 | Int_t xmin = hist->GetFirstXbin(); |
795 | Int_t xmax = hist->GetLastXbin(); | |
796 | Int_t ymin = hist->GetFirstYbin(); | |
797 | Int_t ymax = hist->GetLastYbin(); | |
a8ffd46b | 798 | Int_t nxbins = hist->GetNbinsX()+2; |
0bd0c1ef | 799 | |
800 | for(Int_t ybin=ymin; ybin<=ymax; ybin++) | |
801 | { | |
802 | for(Int_t xbin=xmin; xbin<=xmax; xbin++) | |
803 | { | |
a8ffd46b | 804 | Int_t bin = xbin + ybin*nxbins; //Int_t bin = hist->GetBin(xbin,ybin); |
805 | if(gapcount[bin] < MAX_N_GAPS) { | |
806 | if(tracklastrow[bin] > lastpatchlastrow) { | |
807 | if(lastpatchlastrow > currentrowcount[bin]) | |
808 | gapcount[bin] += (lastpatchlastrow-currentrowcount[bin]-1); | |
809 | } | |
810 | else { | |
811 | if(tracklastrow[bin] > currentrowcount[bin]) | |
812 | gapcount[bin] += (tracklastrow[bin]-currentrowcount[bin]-1); | |
813 | } | |
814 | if(gapcount[bin] < MAX_N_GAPS) | |
815 | hist->AddBinContent(bin,(159-gapcount[bin])); | |
816 | } | |
0bd0c1ef | 817 | } |
818 | } | |
819 | } | |
820 | ||
821 | fBenchmark->Stop("Add HistogramsRows"); | |
822 | fAddHistograms = kTRUE; | |
823 | cpuTime = GetCpuTime() - initTime; | |
4aa41877 | 824 | LOG(AliHLTLog::kInformational,"AliHLTHough::AddAllHistogramsRows()","Timing") |
0bd0c1ef | 825 | <<"Adding histograms in "<<cpuTime*1000<<" ms"<<ENDLOG; |
826 | } | |
827 | ||
4aa41877 | 828 | void AliHLTHough::PrepareForNextPatch(Int_t nextpatch) |
a8ffd46b | 829 | { |
8da9b1eb | 830 | // Prepare the parameter space for the processing of |
831 | // the next read patch. According to the already | |
832 | // accumulated number of gaps in parameter space | |
833 | // bins, the routine updates the dynamic | |
834 | // pointers used in order to jump rapidly during the | |
835 | // filling of the parameter space. | |
836 | ||
a8ffd46b | 837 | char buf[256]; |
838 | sprintf(buf,"Prepare For Patch %d",nextpatch); | |
839 | fBenchmark->Start(buf); | |
840 | ||
841 | UChar_t lastpatchlastrow; | |
842 | if(fLastPatch == -1) | |
843 | lastpatchlastrow = 0; | |
844 | else | |
4aa41877 | 845 | lastpatchlastrow = AliHLTTransform::GetLastRowOnDDL(fLastPatch)+1; |
a8ffd46b | 846 | UChar_t nextpatchfirstrow; |
847 | if(nextpatch==0) | |
848 | nextpatchfirstrow = 0; | |
849 | else | |
4aa41877 | 850 | nextpatchfirstrow = AliHLTTransform::GetFirstRowOnDDL(nextpatch)-1; |
a8ffd46b | 851 | |
4aa41877 | 852 | UChar_t *trackfirstrow = ((AliHLTHoughTransformerRow *)fHoughTransformer[0])->GetTrackFirstRow(); |
853 | UChar_t *tracklastrow = ((AliHLTHoughTransformerRow *)fHoughTransformer[0])->GetTrackLastRow(); | |
a8ffd46b | 854 | |
855 | for(Int_t i=0; i<fNEtaSegments; i++) | |
856 | { | |
4aa41877 | 857 | UChar_t *gapcount = ((AliHLTHoughTransformerRow *)fHoughTransformer[0])->GetGapCount(i); |
858 | UChar_t *currentrowcount = ((AliHLTHoughTransformerRow *)fHoughTransformer[0])->GetCurrentRowCount(i); | |
859 | UChar_t *prevbin = ((AliHLTHoughTransformerRow *)fHoughTransformer[0])->GetPrevBin(i); | |
860 | UChar_t *nextbin = ((AliHLTHoughTransformerRow *)fHoughTransformer[0])->GetNextBin(i); | |
861 | UChar_t *nextrow = ((AliHLTHoughTransformerRow *)fHoughTransformer[0])->GetNextRow(i); | |
a8ffd46b | 862 | |
4aa41877 | 863 | AliHLTHistogram *hist = fHoughTransformer[0]->GetHistogram(i); |
a8ffd46b | 864 | Int_t xmin = hist->GetFirstXbin(); |
865 | Int_t xmax = hist->GetLastXbin(); | |
866 | Int_t ymin = hist->GetFirstYbin(); | |
867 | Int_t ymax = hist->GetLastYbin(); | |
868 | Int_t nxbins = hist->GetNbinsX()+2; | |
869 | ||
b2b60653 | 870 | if(fLastPatch != -1) { |
871 | UChar_t lastyvalue = 0; | |
872 | Int_t endybin = ymin - 1; | |
873 | for(Int_t ybin=nextrow[ymin]; ybin<=ymax; ybin = nextrow[++ybin]) | |
874 | { | |
875 | UChar_t lastxvalue = 0; | |
876 | UChar_t maxvalue = 0; | |
877 | Int_t endxbin = xmin - 1; | |
878 | for(Int_t xbin=xmin; xbin<=xmax; xbin++) | |
879 | { | |
880 | Int_t bin = xbin + ybin*nxbins; | |
881 | UChar_t value = 0; | |
882 | if(gapcount[bin] < MAX_N_GAPS) { | |
883 | if(tracklastrow[bin] > lastpatchlastrow) { | |
884 | if(lastpatchlastrow > currentrowcount[bin]) | |
885 | gapcount[bin] += (lastpatchlastrow-currentrowcount[bin]-1); | |
886 | } | |
887 | else { | |
888 | if(tracklastrow[bin] > currentrowcount[bin]) | |
889 | gapcount[bin] += (tracklastrow[bin]-currentrowcount[bin]-1); | |
890 | } | |
891 | if(gapcount[bin] < MAX_N_GAPS) { | |
892 | value = 1; | |
893 | maxvalue = 1; | |
894 | if(trackfirstrow[bin] < nextpatchfirstrow) | |
895 | currentrowcount[bin] = nextpatchfirstrow; | |
896 | else | |
897 | currentrowcount[bin] = trackfirstrow[bin]; | |
898 | } | |
a8ffd46b | 899 | } |
a8ffd46b | 900 | if(value > 0) |
901 | { | |
902 | nextbin[xbin + ybin*nxbins] = (UChar_t)xbin; | |
903 | prevbin[xbin + ybin*nxbins] = (UChar_t)xbin; | |
904 | if(value > lastxvalue) | |
905 | { | |
906 | UChar_t *tempnextbin = nextbin + endxbin + 1 + ybin*nxbins; | |
907 | memset(tempnextbin,(UChar_t)xbin,xbin-endxbin-1); | |
908 | } | |
909 | endxbin = xbin; | |
910 | } | |
911 | else | |
912 | { | |
913 | prevbin[xbin + ybin*nxbins] = (UChar_t)endxbin; | |
914 | } | |
915 | lastxvalue = value; | |
916 | } | |
a8ffd46b | 917 | UChar_t *tempnextbin = nextbin + endxbin + 1 + ybin*nxbins; |
918 | memset(tempnextbin,(UChar_t)(xmax+1),xmax-endxbin); | |
919 | if(maxvalue > 0) | |
920 | { | |
921 | nextrow[ybin] = (UChar_t)ybin; | |
922 | if(maxvalue > lastyvalue) | |
923 | { | |
924 | UChar_t *tempnextrow = nextrow + endybin + 1; | |
925 | memset(tempnextrow,(UChar_t)ybin,ybin-endybin-1); | |
926 | } | |
927 | endybin = ybin; | |
928 | } | |
929 | lastyvalue = maxvalue; | |
930 | } | |
b2b60653 | 931 | UChar_t *tempnextrow = nextrow + endybin + 1; |
1e75562a | 932 | memset(tempnextrow,(UChar_t)(ymax+1),ymax-endybin+1); |
b2b60653 | 933 | } |
934 | else { | |
935 | UChar_t lastyvalue = 0; | |
936 | Int_t endybin = ymin - 1; | |
937 | for(Int_t ybin=ymin; ybin<=ymax; ybin++) | |
938 | { | |
939 | UChar_t maxvalue = 0; | |
940 | for(Int_t xbin=xmin; xbin<=xmax; xbin++) | |
941 | { | |
942 | Int_t bin = xbin + ybin*nxbins; | |
943 | if(gapcount[bin] < MAX_N_GAPS) { | |
944 | maxvalue = 1; | |
945 | if(trackfirstrow[bin] < nextpatchfirstrow) | |
946 | currentrowcount[bin] = nextpatchfirstrow; | |
947 | else | |
948 | currentrowcount[bin] = trackfirstrow[bin]; | |
949 | } | |
950 | } | |
951 | if(maxvalue > 0) | |
952 | { | |
953 | nextrow[ybin] = (UChar_t)ybin; | |
954 | if(maxvalue > lastyvalue) | |
955 | { | |
956 | UChar_t *tempnextrow = nextrow + endybin + 1; | |
957 | memset(tempnextrow,(UChar_t)ybin,ybin-endybin-1); | |
958 | } | |
959 | endybin = ybin; | |
960 | } | |
961 | lastyvalue = maxvalue; | |
962 | } | |
a8ffd46b | 963 | UChar_t *tempnextrow = nextrow + endybin + 1; |
1e75562a | 964 | memset(tempnextrow,(UChar_t)(ymax+1),ymax-endybin+1); |
a8ffd46b | 965 | } |
966 | } | |
967 | ||
968 | fBenchmark->Stop(buf); | |
969 | } | |
970 | ||
4aa41877 | 971 | void AliHLTHough::AddTracks() |
b2a02bce | 972 | { |
917e711b | 973 | // Add current slice slice tracks to the global list of found tracks |
b2a02bce | 974 | if(!fTracks[0]) |
975 | { | |
4aa41877 | 976 | cerr<<"AliHLTHough::AddTracks : No tracks"<<endl; |
b2a02bce | 977 | return; |
978 | } | |
4aa41877 | 979 | AliHLTTrackArray *tracks = fTracks[0]; |
b2a02bce | 980 | for(Int_t i=0; i<tracks->GetNTracks(); i++) |
981 | { | |
4aa41877 | 982 | AliHLTTrack *track = tracks->GetCheckedTrack(i); |
b2a02bce | 983 | if(!track) continue; |
984 | if(track->GetNHits()!=1) cerr<<"NHITS "<<track->GetNHits()<<endl; | |
985 | UInt_t *ids = track->GetHitNumbers(); | |
986 | ids[0] = (fCurrentSlice&0x7f)<<25; | |
987 | } | |
988 | ||
989 | fGlobalTracks->AddTracks(fTracks[0],0,fCurrentSlice); | |
990 | } | |
991 | ||
4aa41877 | 992 | void AliHLTHough::FindTrackCandidatesRow() |
a6008206 | 993 | { |
4aa41877 | 994 | // Find AliHLTHoughTransformerRow track candidates |
de3c3890 | 995 | if(fVersion != 4) { |
4aa41877 | 996 | LOG(AliHLTLog::kError,"AliHLTHough::FindTrackCandidatesRow()","") |
de3c3890 | 997 | <<"Incompatible Peak Finder version!"<<ENDLOG; |
998 | return; | |
999 | } | |
1000 | ||
a6008206 | 1001 | //Look for peaks in histograms, and find the track candidates |
917e711b | 1002 | Int_t npatches; |
de3c3890 | 1003 | if(fAddHistograms) |
917e711b | 1004 | npatches = 1; //Histograms have been added. |
de3c3890 | 1005 | else |
917e711b | 1006 | npatches = fNPatches; |
de3c3890 | 1007 | |
1008 | Double_t initTime,cpuTime; | |
1009 | initTime = GetCpuTime(); | |
1010 | fBenchmark->Start("Find Maxima"); | |
917e711b | 1011 | for(Int_t i=0; i<npatches; i++) |
de3c3890 | 1012 | { |
4aa41877 | 1013 | AliHLTHoughBaseTransformer *tr = fHoughTransformer[i]; |
1014 | AliHLTHistogram *h = tr->GetHistogram(0); | |
1015 | Float_t deltax = h->GetBinWidthX()*AliHLTHoughTransformerRow::GetDAlpha(); | |
1016 | Float_t deltay = h->GetBinWidthY()*AliHLTHoughTransformerRow::GetDAlpha(); | |
1017 | Float_t deltaeta = (tr->GetEtaMax()-tr->GetEtaMin())/tr->GetNEtaSegments()*AliHLTHoughTransformerRow::GetDEta(); | |
f644512a | 1018 | Float_t zvertex = tr->GetZVertex(); |
de3c3890 | 1019 | fTracks[i]->Reset(); |
1020 | fPeakFinder->Reset(); | |
1021 | ||
1022 | for(Int_t j=0; j<fNEtaSegments; j++) | |
1023 | { | |
4aa41877 | 1024 | AliHLTHistogram *hist = tr->GetHistogram(j); |
de3c3890 | 1025 | if(hist->GetNEntries()==0) continue; |
1026 | fPeakFinder->SetHistogram(hist); | |
1027 | fPeakFinder->SetEtaSlice(j); | |
4aa41877 | 1028 | fPeakFinder->SetTrackLUTs(((AliHLTHoughTransformerRow *)tr)->GetTrackNRows(),((AliHLTHoughTransformerRow *)tr)->GetTrackFirstRow(),((AliHLTHoughTransformerRow *)tr)->GetTrackLastRow(),((AliHLTHoughTransformerRow *)tr)->GetNextRow(j)); |
de3c3890 | 1029 | #ifdef do_mc |
4aa41877 | 1030 | LOG(AliHLTLog::kInformational,"AliHLTHough::FindTrackCandidates()","") |
de3c3890 | 1031 | <<"Starting "<<j<<" etaslice"<<ENDLOG; |
1032 | #endif | |
1033 | fPeakFinder->SetThreshold(fPeakThreshold[i]); | |
1034 | fPeakFinder->FindAdaptedRowPeaks(1,0,0);//Maxima finder for HoughTransformerRow | |
de3c3890 | 1035 | } |
a6008206 | 1036 | |
de3c3890 | 1037 | for(Int_t k=0; k<fPeakFinder->GetEntries(); k++) |
1038 | { | |
b2b60653 | 1039 | // if(fPeakFinder->GetWeight(k) < 0) continue; |
4aa41877 | 1040 | AliHLTHoughTrack *track = (AliHLTHoughTrack*)fTracks[i]->NextTrack(); |
f644512a | 1041 | Double_t starteta = tr->GetEta(fPeakFinder->GetStartEta(k),fCurrentSlice); |
1042 | Double_t endeta = tr->GetEta(fPeakFinder->GetEndEta(k),fCurrentSlice); | |
1043 | Double_t eta = (starteta+endeta)/2.0; | |
1044 | track->SetTrackParametersRow(fPeakFinder->GetXPeak(k),fPeakFinder->GetYPeak(k),eta,fPeakFinder->GetWeight(k)); | |
1045 | track->SetPterr(deltax); track->SetPsierr(deltay); track->SetTglerr(deltaeta); | |
de3c3890 | 1046 | track->SetBinXY(fPeakFinder->GetXPeak(k),fPeakFinder->GetYPeak(k),fPeakFinder->GetXPeakSize(k),fPeakFinder->GetYPeakSize(k)); |
f644512a | 1047 | track->SetZ0(zvertex); |
de3c3890 | 1048 | Int_t etaindex = (fPeakFinder->GetStartEta(k)+fPeakFinder->GetEndEta(k))/2; |
1049 | track->SetEtaIndex(etaindex); | |
f644512a | 1050 | Int_t rows[2]; |
4aa41877 | 1051 | ((AliHLTHoughTransformerRow *)tr)->GetTrackLength(fPeakFinder->GetXPeak(k),fPeakFinder->GetYPeak(k),rows); |
f644512a | 1052 | track->SetRowRange(rows[0],rows[1]); |
de3c3890 | 1053 | track->SetSector(fCurrentSlice); |
1054 | track->SetSlice(fCurrentSlice); | |
1055 | #ifdef do_mc | |
1056 | Int_t label = tr->GetTrackID(etaindex,fPeakFinder->GetXPeak(k),fPeakFinder->GetYPeak(k)); | |
1057 | track->SetMCid(label); | |
de3c3890 | 1058 | #endif |
1059 | } | |
4aa41877 | 1060 | LOG(AliHLTLog::kInformational,"AliHLTHough::FindTrackCandidates()","") |
a8ffd46b | 1061 | <<"Found "<<fTracks[i]->GetNTracks()<<" tracks in slice "<<fCurrentSlice<<ENDLOG; |
de3c3890 | 1062 | fTracks[i]->QSort(); |
1063 | } | |
1064 | fBenchmark->Stop("Find Maxima"); | |
1065 | cpuTime = GetCpuTime() - initTime; | |
4aa41877 | 1066 | LOG(AliHLTLog::kInformational,"AliHLTHough::FindTrackCandidates()","Timing") |
de3c3890 | 1067 | <<"Maxima finding done in "<<cpuTime*1000<<" ms"<<ENDLOG; |
1068 | } | |
1069 | ||
4aa41877 | 1070 | void AliHLTHough::FindTrackCandidates() |
de3c3890 | 1071 | { |
4aa41877 | 1072 | // Find AliHLTHoughTransformer track candidates |
de3c3890 | 1073 | if(fVersion == 4) { |
4aa41877 | 1074 | LOG(AliHLTLog::kError,"AliHLTHough::FindTrackCandidatesRow()","") |
de3c3890 | 1075 | <<"Incompatible Peak Finder version!"<<ENDLOG; |
1076 | return; | |
1077 | } | |
1078 | ||
917e711b | 1079 | Int_t npatches; |
a6008206 | 1080 | if(fAddHistograms) |
917e711b | 1081 | npatches = 1; //Histograms have been added. |
a6008206 | 1082 | else |
917e711b | 1083 | npatches = fNPatches; |
b1886074 | 1084 | |
0309a5ee | 1085 | Double_t initTime,cpuTime; |
1086 | initTime = GetCpuTime(); | |
3e87ef69 | 1087 | fBenchmark->Start("Find Maxima"); |
917e711b | 1088 | for(Int_t i=0; i<npatches; i++) |
a6008206 | 1089 | { |
4aa41877 | 1090 | AliHLTHoughBaseTransformer *tr = fHoughTransformer[i]; |
b1886074 | 1091 | fTracks[i]->Reset(); |
6c97129d | 1092 | |
a6008206 | 1093 | for(Int_t j=0; j<fNEtaSegments; j++) |
1094 | { | |
4aa41877 | 1095 | AliHLTHistogram *hist = tr->GetHistogram(j); |
b1886074 | 1096 | if(hist->GetNEntries()==0) continue; |
3fe49b5b | 1097 | fPeakFinder->Reset(); |
a6008206 | 1098 | fPeakFinder->SetHistogram(hist); |
de3c3890 | 1099 | #ifdef do_mc |
1100 | cout<<"Starting "<<j<<" etaslice"<<endl; | |
1101 | #endif | |
b2a02bce | 1102 | fPeakFinder->SetThreshold(fPeakThreshold[i]); |
de3c3890 | 1103 | fPeakFinder->FindAdaptedPeaks(fKappaSpread,fPeakRatio); |
b2a02bce | 1104 | |
3fe49b5b | 1105 | for(Int_t k=0; k<fPeakFinder->GetEntries(); k++) |
a6008206 | 1106 | { |
4aa41877 | 1107 | AliHLTHoughTrack *track = (AliHLTHoughTrack*)fTracks[i]->NextTrack(); |
3fe49b5b | 1108 | track->SetTrackParameters(fPeakFinder->GetXPeak(k),fPeakFinder->GetYPeak(k),fPeakFinder->GetWeight(k)); |
a6008206 | 1109 | track->SetEtaIndex(j); |
afd8fed4 | 1110 | track->SetEta(tr->GetEta(j,fCurrentSlice)); |
4aa41877 | 1111 | track->SetRowRange(AliHLTTransform::GetFirstRow(0),AliHLTTransform::GetLastRow(5)); |
a6008206 | 1112 | } |
1113 | } | |
b2a02bce | 1114 | cout<<"Found "<<fTracks[i]->GetNTracks()<<" tracks in patch "<<i<<endl; |
b1886074 | 1115 | fTracks[i]->QSort(); |
a6008206 | 1116 | } |
3e87ef69 | 1117 | fBenchmark->Stop("Find Maxima"); |
0309a5ee | 1118 | cpuTime = GetCpuTime() - initTime; |
4aa41877 | 1119 | LOG(AliHLTLog::kInformational,"AliHLTHough::FindTrackCandidates()","Timing") |
0309a5ee | 1120 | <<"Maxima finding done in "<<cpuTime*1000<<" ms"<<ENDLOG; |
a6008206 | 1121 | } |
1122 | ||
4aa41877 | 1123 | void AliHLTHough::InitEvaluate() |
3fe49b5b | 1124 | { |
4aa41877 | 1125 | //Pass the transformer objects to the AliHLTHoughEval objects: |
3fe49b5b | 1126 | //This will provide the evaluation objects with all the necessary |
208b54c5 | 1127 | //data and parameters it needs. |
3fe49b5b | 1128 | |
1129 | for(Int_t i=0; i<fNPatches; i++) | |
1130 | fEval[i]->InitTransformer(fHoughTransformer[i]); | |
1131 | } | |
1132 | ||
4aa41877 | 1133 | Int_t AliHLTHough::Evaluate(Int_t roadwidth,Int_t nrowstomiss) |
a6008206 | 1134 | { |
1135 | //Evaluate the tracks, by looking along the road in the raw data. | |
3fe49b5b | 1136 | //If track does not cross all padrows - rows2miss, it is removed from the arrray. |
0309a5ee | 1137 | //If histograms were not added, the check is done locally in patch, |
1138 | //meaning that nrowstomiss is the number of padrows the road can miss with respect | |
1139 | //to the number of rows in the patch. | |
1140 | //If the histograms were added, the comparison is done globally in the _slice_, | |
1141 | //meaing that nrowstomiss is the number of padrows the road can miss with | |
1142 | //respect to the total number of padrows in the slice. | |
1143 | // | |
1144 | //Return value = number of tracks which were removed (only in case of fAddHistograms) | |
a6008206 | 1145 | |
b1886074 | 1146 | if(!fTracks[0]) |
a6008206 | 1147 | { |
4aa41877 | 1148 | LOG(AliHLTLog::kError,"AliHLTHough::Evaluate","Track Array") |
b1886074 | 1149 | <<"No tracks to work with..."<<ENDLOG; |
0309a5ee | 1150 | return 0; |
a6008206 | 1151 | } |
1152 | ||
917e711b | 1153 | Int_t removedtracks=0; |
4aa41877 | 1154 | AliHLTTrackArray *tracks=0; |
a4639de2 | 1155 | |
0309a5ee | 1156 | if(fAddHistograms) |
a4639de2 | 1157 | { |
0309a5ee | 1158 | tracks = fTracks[0]; |
0309a5ee | 1159 | for(Int_t i=0; i<tracks->GetNTracks(); i++) |
a6008206 | 1160 | { |
4aa41877 | 1161 | AliHLTTrack *track = tracks->GetCheckedTrack(i); |
a4639de2 | 1162 | if(!track) continue; |
1163 | track->SetNHits(0); | |
0309a5ee | 1164 | } |
f80b98cb | 1165 | } |
f000f8a5 | 1166 | |
a4639de2 | 1167 | for(Int_t i=0; i<fNPatches; i++) |
917e711b | 1168 | EvaluatePatch(i,roadwidth,nrowstomiss); |
a4639de2 | 1169 | |
aa641eb8 | 1170 | //Here we check the tracks globally; |
1171 | //how many good rows (padrows with signal) | |
1172 | //did it cross in the slice | |
1173 | if(fAddHistograms) | |
0309a5ee | 1174 | { |
1175 | for(Int_t j=0; j<tracks->GetNTracks(); j++) | |
1176 | { | |
4aa41877 | 1177 | AliHLTHoughTrack *track = (AliHLTHoughTrack*)tracks->GetCheckedTrack(j); |
a4639de2 | 1178 | |
4aa41877 | 1179 | if(track->GetNHits() < AliHLTTransform::GetNRows() - nrowstomiss) |
0309a5ee | 1180 | { |
1181 | tracks->Remove(j); | |
917e711b | 1182 | removedtracks++; |
0309a5ee | 1183 | } |
1184 | } | |
1185 | tracks->Compress(); | |
1186 | tracks->QSort(); | |
1187 | } | |
a4639de2 | 1188 | |
917e711b | 1189 | return removedtracks; |
a4639de2 | 1190 | } |
1191 | ||
4aa41877 | 1192 | void AliHLTHough::EvaluatePatch(Int_t i,Int_t roadwidth,Int_t nrowstomiss) |
a4639de2 | 1193 | { |
1194 | //Evaluate patch i. | |
0309a5ee | 1195 | |
a4639de2 | 1196 | fEval[i]->InitTransformer(fHoughTransformer[i]); |
917e711b | 1197 | fEval[i]->SetNumOfPadsToLook(roadwidth); |
a4639de2 | 1198 | fEval[i]->SetNumOfRowsToMiss(nrowstomiss); |
1199 | //fEval[i]->RemoveFoundTracks(); | |
0309a5ee | 1200 | |
4aa41877 | 1201 | AliHLTTrackArray *tracks=0; |
a4639de2 | 1202 | |
1203 | if(!fAddHistograms) | |
1204 | tracks = fTracks[i]; | |
1205 | else | |
1206 | tracks = fTracks[0]; | |
1207 | ||
1208 | Int_t nrows=0; | |
1209 | for(Int_t j=0; j<tracks->GetNTracks(); j++) | |
1210 | { | |
4aa41877 | 1211 | AliHLTHoughTrack *track = (AliHLTHoughTrack*)tracks->GetCheckedTrack(j); |
a4639de2 | 1212 | if(!track) |
1213 | { | |
4aa41877 | 1214 | LOG(AliHLTLog::kWarning,"AliHLTHough::EvaluatePatch","Track array") |
a4639de2 | 1215 | <<"Track object missing!"<<ENDLOG; |
1216 | continue; | |
1217 | } | |
1218 | nrows=0; | |
4aa41877 | 1219 | Int_t rowrange[2] = {AliHLTTransform::GetFirstRow(i),AliHLTTransform::GetLastRow(i)}; |
3e87ef69 | 1220 | Bool_t result = fEval[i]->LookInsideRoad(track,nrows,rowrange); |
a4639de2 | 1221 | if(fAddHistograms) |
1222 | { | |
1223 | Int_t pre=track->GetNHits(); | |
1224 | track->SetNHits(pre+nrows); | |
1225 | } | |
3e87ef69 | 1226 | else//the track crossed too few good padrows (padrows with signal) in the patch, so remove it |
1227 | { | |
1228 | if(result == kFALSE) | |
1229 | tracks->Remove(j); | |
1230 | } | |
a4639de2 | 1231 | } |
1232 | ||
1233 | tracks->Compress(); | |
a4639de2 | 1234 | |
a6008206 | 1235 | } |
f80b98cb | 1236 | |
4aa41877 | 1237 | void AliHLTHough::MergeEtaSlices() |
b1886074 | 1238 | { |
44c7f8de | 1239 | //Merge tracks found in neighbouring eta slices. |
1240 | //Removes the track with the lower weight. | |
1241 | ||
3e87ef69 | 1242 | fBenchmark->Start("Merge Eta-slices"); |
4aa41877 | 1243 | AliHLTTrackArray *tracks = fTracks[0]; |
44c7f8de | 1244 | if(!tracks) |
b1886074 | 1245 | { |
4aa41877 | 1246 | cerr<<"AliHLTHough::MergeEtaSlices : No tracks "<<endl; |
b1886074 | 1247 | return; |
1248 | } | |
44c7f8de | 1249 | for(Int_t j=0; j<tracks->GetNTracks(); j++) |
b1886074 | 1250 | { |
4aa41877 | 1251 | AliHLTHoughTrack *track1 = (AliHLTHoughTrack*)tracks->GetCheckedTrack(j); |
44c7f8de | 1252 | if(!track1) continue; |
1253 | for(Int_t k=j+1; k<tracks->GetNTracks(); k++) | |
1254 | { | |
4aa41877 | 1255 | AliHLTHoughTrack *track2 = (AliHLTHoughTrack*)tracks->GetCheckedTrack(k); |
44c7f8de | 1256 | if(!track2) continue; |
1257 | if(abs(track1->GetEtaIndex() - track2->GetEtaIndex()) != 1) continue; | |
3e87ef69 | 1258 | if(fabs(track1->GetKappa()-track2->GetKappa()) < 0.006 && |
1259 | fabs(track1->GetPsi()- track2->GetPsi()) < 0.1) | |
44c7f8de | 1260 | { |
3e87ef69 | 1261 | //cout<<"Merging track in slices "<<track1->GetEtaIndex()<<" "<<track2->GetEtaIndex()<<endl; |
1262 | if(track1->GetWeight() > track2->GetWeight()) | |
1263 | tracks->Remove(k); | |
1264 | else | |
1265 | tracks->Remove(j); | |
44c7f8de | 1266 | } |
1267 | } | |
b1886074 | 1268 | } |
3e87ef69 | 1269 | fBenchmark->Stop("Merge Eta-slices"); |
44c7f8de | 1270 | tracks->Compress(); |
b1886074 | 1271 | } |
1272 | ||
4aa41877 | 1273 | void AliHLTHough::WriteTracks(Char_t *path) |
b2a02bce | 1274 | { |
917e711b | 1275 | // Write found tracks into file |
4aa41877 | 1276 | //cout<<"AliHLTHough::WriteTracks : Sorting the tracsk"<<endl; |
b2a02bce | 1277 | //fGlobalTracks->QSort(); |
1278 | ||
1279 | Char_t filename[1024]; | |
1280 | sprintf(filename,"%s/tracks_%d.raw",path,fEvent); | |
4aa41877 | 1281 | AliHLTMemHandler mem; |
b2a02bce | 1282 | mem.SetBinaryOutput(filename); |
1283 | mem.TrackArray2Binary(fGlobalTracks); | |
1284 | mem.CloseBinaryOutput(); | |
1285 | fGlobalTracks->Reset(); | |
1286 | } | |
1287 | ||
4aa41877 | 1288 | void AliHLTHough::WriteTracks(Int_t slice,Char_t *path) |
1c404dd5 | 1289 | { |
917e711b | 1290 | // Write found tracks slice by slice into file |
c2f25cd2 | 1291 | |
4aa41877 | 1292 | AliHLTMemHandler mem; |
95a00d93 | 1293 | Char_t fname[100]; |
b5a207b4 | 1294 | if(fAddHistograms) |
1295 | { | |
b2a02bce | 1296 | sprintf(fname,"%s/tracks_ho_%d_%d.raw",path,fEvent,slice); |
3e87ef69 | 1297 | mem.SetBinaryOutput(fname); |
1298 | mem.TrackArray2Binary(fTracks[0]); | |
1299 | mem.CloseBinaryOutput(); | |
b5a207b4 | 1300 | } |
1301 | else | |
1302 | { | |
1303 | for(Int_t i=0; i<fNPatches; i++) | |
1304 | { | |
b2a02bce | 1305 | sprintf(fname,"%s/tracks_ho_%d_%d_%d.raw",path,fEvent,slice,i); |
3e87ef69 | 1306 | mem.SetBinaryOutput(fname); |
1307 | mem.TrackArray2Binary(fTracks[i]); | |
1308 | mem.CloseBinaryOutput(); | |
b5a207b4 | 1309 | } |
1310 | } | |
1c404dd5 | 1311 | } |
208b54c5 | 1312 | |
a109e73e | 1313 | #ifdef use_aliroot |
af885e0f | 1314 | Int_t AliHLTHough::FillESD(AliESDEvent *esd) |
a109e73e | 1315 | { |
8da9b1eb | 1316 | // Fill the found hough transform tracks |
1317 | // into the ESD. The tracks are stored as | |
1318 | // AliESDHLTtrack objects. | |
1319 | ||
aa468ace | 1320 | // No TPC PID so far,assuming pions |
1321 | Double_t prob[AliPID::kSPECIES]; | |
1322 | for(Int_t i=0;i<AliPID::kSPECIES;i++) { | |
1323 | if(i==AliPID::kPion) prob[i]=1.0; | |
1324 | else prob[i]=0.1; | |
1325 | } | |
1326 | ||
a109e73e | 1327 | if(!fGlobalTracks) return 0; |
1328 | Int_t nglobaltracks = 0; | |
1329 | for(Int_t i=0; i<fGlobalTracks->GetNTracks(); i++) | |
1330 | { | |
4aa41877 | 1331 | AliHLTHoughTrack *tpt = (AliHLTHoughTrack *)fGlobalTracks->GetCheckedTrack(i); |
a109e73e | 1332 | if(!tpt) continue; |
1333 | ||
f644512a | 1334 | if(tpt->GetWeight()<0) continue; |
4aa41877 | 1335 | AliHLTHoughKalmanTrack *tpctrack = new AliHLTHoughKalmanTrack(*tpt); |
f644512a | 1336 | if(!tpctrack) continue; |
1337 | AliESDtrack *esdtrack2 = new AliESDtrack() ; | |
1338 | esdtrack2->UpdateTrackParams(tpctrack,AliESDtrack::kTPCin); | |
aa468ace | 1339 | esdtrack2->SetESDpid(prob); |
f644512a | 1340 | esd->AddTrack(esdtrack2); |
a109e73e | 1341 | nglobaltracks++; |
f644512a | 1342 | delete esdtrack2; |
1343 | delete tpctrack; | |
a109e73e | 1344 | } |
1345 | return nglobaltracks; | |
1346 | } | |
1347 | #endif | |
1348 | ||
4aa41877 | 1349 | void AliHLTHough::WriteDigits(Char_t *outfile) |
a6008206 | 1350 | { |
1351 | //Write the current data to a new rootfile. | |
917e711b | 1352 | #ifdef use_aliroot |
a6008206 | 1353 | |
1c404dd5 | 1354 | for(Int_t i=0; i<fNPatches; i++) |
a6008206 | 1355 | { |
4aa41877 | 1356 | AliHLTDigitRowData *tempPt = (AliHLTDigitRowData*)fHoughTransformer[i]->GetDataPointer(); |
a6008206 | 1357 | fMemHandler[i]->AliDigits2RootFile(tempPt,outfile); |
1358 | } | |
208b54c5 | 1359 | #else |
4aa41877 | 1360 | cerr<<"AliHLTHough::WriteDigits : You need to compile with AliROOT!"<<endl; |
208b54c5 | 1361 | return; |
1362 | #endif | |
4fc9a6a4 | 1363 | } |
208b54c5 | 1364 | |
4aa41877 | 1365 | Double_t AliHLTHough::GetCpuTime() |
0309a5ee | 1366 | { |
1367 | //Return the Cputime in seconds. | |
1368 | struct timeval tv; | |
1369 | gettimeofday( &tv, NULL ); | |
1370 | return tv.tv_sec+(((Double_t)tv.tv_usec)/1000000.); | |
0309a5ee | 1371 | } |
60a3d829 | 1372 | |
4aa41877 | 1373 | void *AliHLTHough::ProcessInThread(void *args) |
a8ffd46b | 1374 | { |
8da9b1eb | 1375 | // Called in case Hough transform tracking |
1376 | // is executed in a thread | |
1377 | ||
4aa41877 | 1378 | AliHLTHough *instance = (AliHLTHough *)args; |
a8ffd46b | 1379 | Int_t minslice = instance->GetMinSlice(); |
1380 | Int_t maxslice = instance->GetMaxSlice(); | |
1381 | for(Int_t i=minslice; i<=maxslice; i++) | |
1382 | { | |
1383 | instance->ReadData(i,0); | |
1384 | instance->Transform(); | |
1385 | instance->AddAllHistogramsRows(); | |
1386 | instance->FindTrackCandidatesRow(); | |
1387 | instance->AddTracks(); | |
1388 | } | |
1389 | return (void *)0; | |
1390 | } | |
1391 | ||
4aa41877 | 1392 | void AliHLTHough::StartProcessInThread(Int_t minslice,Int_t maxslice) |
a8ffd46b | 1393 | { |
8da9b1eb | 1394 | // Starts the Hough transform tracking as a |
1395 | // separate thread. Takes as parameters the | |
1396 | // range of TPC slices (sectors) to be reconstructed | |
1397 | ||
a8ffd46b | 1398 | if(!fThread) { |
1399 | char buf[255]; | |
1400 | sprintf(buf,"houghtrans_%d_%d",minslice,maxslice); | |
1401 | SetMinMaxSlices(minslice,maxslice); | |
1402 | // fThread = new TThread(buf,(void (*) (void *))&ProcessInThread,(void *)this); | |
1403 | fThread = new TThread(buf,&ProcessInThread,(void *)this); | |
1404 | fThread->Run(); | |
1405 | } | |
1406 | return; | |
1407 | } | |
1408 | ||
4aa41877 | 1409 | Int_t AliHLTHough::WaitForThreadFinish() |
a8ffd46b | 1410 | { |
8da9b1eb | 1411 | // Routine is used in case we run the |
1412 | // Hough transform tracking in several | |
1413 | // threads and want to sync them before | |
1414 | // writing the results to the ESD | |
1415 | ||
5b83f0b3 | 1416 | #if ROOT_VERSION_CODE < 262403 |
a8ffd46b | 1417 | return TThread::Join(fThread->GetId()); |
5b83f0b3 | 1418 | #else |
1419 | return fThread->Join(fThread->GetId()); | |
1420 | #endif | |
a8ffd46b | 1421 | } |