]>
Commit | Line | Data |
---|---|---|
3e87ef69 | 1 | // @(#) $Id$ |
2 | ||
3 | // Author: Anders Vestbo <mailto:vestbo@fi.uib.no> | |
4 | //*-- Copyright © ALICE HLT Group | |
5 | ||
4aa41877 | 6 | #include "AliHLTStandardIncludes.h" |
3e87ef69 | 7 | |
4aa41877 | 8 | #include "AliHLTLogging.h" |
9 | #include "AliHLTHoughTransformerGlobal.h" | |
10 | #include "AliHLTFileHandler.h" | |
11 | #include "AliHLTTransform.h" | |
12 | #include "AliHLTDigitData.h" | |
13 | #include "AliHLTTrack.h" | |
14 | #include "AliHLTHistogram.h" | |
15 | #include "AliHLTTrackArray.h" | |
16 | #include "AliHLTHoughMaxFinder.h" | |
17 | #include "AliHLTHoughTrack.h" | |
18 | #include "AliHLTSpacePointData.h" | |
3e87ef69 | 19 | |
20 | #include <TH2.h> | |
21 | ||
c6747af6 | 22 | #if __GNUC__ >= 3 |
3e87ef69 | 23 | using namespace std; |
24 | #endif | |
25 | ||
26 | //_____________________________________________________________ | |
4aa41877 | 27 | // AliHLTHoughTransformerGlobal |
3e87ef69 | 28 | // |
29 | // Hough transformation class | |
30 | // | |
31 | ||
4aa41877 | 32 | ClassImp(AliHLTHoughTransformerGlobal) |
3e87ef69 | 33 | |
4aa41877 | 34 | AliHLTHoughTransformerGlobal::AliHLTHoughTransformerGlobal() |
3e87ef69 | 35 | { |
c62b480b | 36 | //default ctor |
3e87ef69 | 37 | fPadMin=0; |
38 | fPadMax=0; | |
39 | fNActiveSlice=0; | |
40 | fMemHandler=0; | |
41 | fEvent=0; | |
42 | fPsi=0; | |
43 | fPtMin=0; | |
44 | fTracks=0; | |
45 | fPeakFinder=0; | |
46 | fSeedPadRow=-1; | |
47 | } | |
48 | ||
4aa41877 | 49 | AliHLTHoughTransformerGlobal::AliHLTHoughTransformerGlobal(Char_t *path,Int_t event) |
3e87ef69 | 50 | { |
c62b480b | 51 | //normal ctor |
3e87ef69 | 52 | strcpy(fPath,path); |
53 | fEvent=event; | |
54 | fMemHandler=0; | |
55 | fPadMin=0; | |
56 | fPadMax=0; | |
57 | fPsi=0; | |
58 | fPtMin=0; | |
59 | fNActiveSlice=0; | |
4aa41877 | 60 | fTracks = new AliHLTTrackArray("AliHLTHoughTrack"); |
61 | fPeakFinder = new AliHLTHoughMaxFinder("KappaPhi",1000); | |
3e87ef69 | 62 | } |
63 | ||
4aa41877 | 64 | AliHLTHoughTransformerGlobal::~AliHLTHoughTransformerGlobal() |
3e87ef69 | 65 | { |
c62b480b | 66 | //dtor |
3e87ef69 | 67 | if(fPadMin) |
68 | delete [] fPadMin; | |
69 | if(fPadMax) | |
70 | delete [] fPadMax; | |
71 | if(fTracks) | |
72 | delete fTracks; | |
73 | if(fPeakFinder) | |
74 | delete fPeakFinder; | |
75 | UnloadActiveSlices(); | |
76 | ||
77 | } | |
78 | ||
4aa41877 | 79 | void AliHLTHoughTransformerGlobal::CreateHistograms(Float_t /*ptmin*/,Int_t nxbin,Int_t nybin) |
3e87ef69 | 80 | { |
c62b480b | 81 | //create histograms for HT |
3e87ef69 | 82 | if(fPsi==0) |
83 | { | |
4aa41877 | 84 | cerr<<"AliHLTHoughTransformerGlobal::CreateHistograms : Call DefineRegion first"<<endl; |
3e87ef69 | 85 | exit(5); |
86 | } | |
4aa41877 | 87 | AliHLTHoughTransformer::CreateHistograms(nxbin,fPtMin,nybin,-fPsi,fPsi); |
88 | //AliHLTHoughTransformer::CreateHistograms(fPtMin,ptmax,ptres,nybin,fPsi); | |
3e87ef69 | 89 | } |
90 | ||
4aa41877 | 91 | void AliHLTHoughTransformerGlobal::TransformCircleC() |
3e87ef69 | 92 | { |
c62b480b | 93 | //Hough Transform |
4aa41877 | 94 | AliHLTSeed *clusters = new AliHLTSeed[1000]; |
3e87ef69 | 95 | Int_t nclusters = LoadClusterSeeds(clusters); |
96 | ||
97 | Int_t i=0,sector,row,slice; | |
98 | UInt_t dummy=0; | |
99 | Float_t xyz[3],rpe[3],kappa,psi; | |
100 | ||
101 | for(Int_t sl=GetSlice()-fNActiveSlice; sl<=GetSlice()+fNActiveSlice; sl++) | |
102 | { | |
103 | if(sl < 0 || sl < 18 && GetSlice() >= 18) | |
104 | slice = sl + 18; | |
105 | else if(sl > 35 || sl > 17 && GetSlice() <= 17) | |
106 | slice = sl-18; | |
107 | else | |
108 | slice = sl; | |
109 | cout<<"Transforming in slice "<<slice<<endl; | |
110 | ||
4aa41877 | 111 | AliHLTDigitRowData *rowPt = (AliHLTDigitRowData*)fMemHandler[i++]->GetDataPointer(dummy); |
3e87ef69 | 112 | |
4aa41877 | 113 | for(Int_t padrow=0; padrow<AliHLTTransform::GetNRows(); padrow++) |
3e87ef69 | 114 | { |
115 | if(padrow == fSeedPadRow) continue; | |
4aa41877 | 116 | AliHLTDigitData *digits = (AliHLTDigitData*)rowPt->fDigitData; |
3e87ef69 | 117 | |
118 | for(UInt_t j=0; j<rowPt->fNDigit; j++) | |
119 | { | |
120 | Int_t pad = digits[j].fPad; | |
b2a02bce | 121 | |
3e87ef69 | 122 | if(i==1 && pad < fPadMin[padrow]) |
123 | continue; | |
124 | if(i==fNActiveSlice*2+1 && pad>fPadMax[padrow]) | |
125 | continue; | |
b2a02bce | 126 | |
3e87ef69 | 127 | Int_t time = digits[j].fTime; |
128 | Int_t charge = digits[j].fCharge; | |
129 | ||
130 | if(charge > GetUpperThreshold() || charge < GetLowerThreshold()) | |
131 | continue; | |
132 | ||
4aa41877 | 133 | AliHLTTransform::Slice2Sector(slice,padrow,sector,row); |
134 | AliHLTTransform::Raw2Local(xyz,sector,row,pad,time); | |
3e87ef69 | 135 | |
136 | Rotate(xyz,i-1-fNActiveSlice); | |
137 | ||
4aa41877 | 138 | AliHLTTransform::XYZtoRPhiEta(rpe,xyz); |
3e87ef69 | 139 | rpe[0] = sqrt(xyz[0]*xyz[0] + xyz[1]*xyz[1]); |
140 | ||
c62b480b | 141 | Int_t etaindex = GetEtaIndex(rpe[2]); |
3e87ef69 | 142 | |
4aa41877 | 143 | AliHLTHistogram *hist = GetHistogram(etaindex); |
3e87ef69 | 144 | |
145 | for(Int_t l=0; l<nclusters; l++) | |
146 | { | |
c62b480b | 147 | if(clusters[l].fIndex != etaindex) continue; |
3e87ef69 | 148 | psi = atan( (clusters[l].fRadius*sin(rpe[1])-rpe[0]*sin(clusters[l].fPhi))/ |
149 | (clusters[l].fRadius*cos(rpe[1])-rpe[0]*cos(clusters[l].fPhi)) ); | |
150 | kappa = 2*sin(clusters[l].fPhi-psi)/clusters[l].fRadius; | |
151 | if(fabs(kappa) < 1e-33) | |
152 | continue; | |
b2a02bce | 153 | //hist->Fill(kappa,psi,(int)rint(log((Float_t)charge))); |
154 | hist->Fill(kappa,psi,charge); | |
3e87ef69 | 155 | } |
156 | } | |
4aa41877 | 157 | AliHLTMemHandler::UpdateRowPointer(rowPt); |
3e87ef69 | 158 | } |
159 | } | |
160 | delete [] clusters; | |
161 | } | |
162 | ||
4aa41877 | 163 | void AliHLTHoughTransformerGlobal::TransformCircle() |
3e87ef69 | 164 | { |
c62b480b | 165 | //Hough Transform |
3e87ef69 | 166 | Int_t i=0,sector,row,slice; |
167 | UInt_t dummy=0; | |
168 | Float_t xyz[3],rpe[3],kappa,psi; | |
169 | ||
170 | for(Int_t sl=GetSlice()-fNActiveSlice; sl<=GetSlice()+fNActiveSlice; sl++) | |
171 | { | |
172 | if(sl < 0 || sl < 18 && GetSlice() >= 18) | |
173 | slice = sl + 18; | |
174 | else if(sl > 35 || sl > 17 && GetSlice() <= 17) | |
175 | slice = sl-18; | |
176 | else | |
177 | slice = sl; | |
178 | cout<<"Transforming in slice "<<slice<<endl; | |
179 | ||
4aa41877 | 180 | AliHLTDigitRowData *rowPt = (AliHLTDigitRowData*)fMemHandler[i++]->GetDataPointer(dummy); |
3e87ef69 | 181 | |
4aa41877 | 182 | for(Int_t padrow=0; padrow<AliHLTTransform::GetNRows(); padrow++) |
3e87ef69 | 183 | { |
184 | ||
4aa41877 | 185 | AliHLTDigitData *digits = (AliHLTDigitData*)rowPt->fDigitData; |
3e87ef69 | 186 | |
187 | for(UInt_t j=0; j<rowPt->fNDigit; j++) | |
188 | { | |
189 | Int_t pad = digits[j].fPad; | |
190 | ||
191 | if(i==1 && pad < fPadMin[padrow]) | |
192 | continue; | |
193 | if(i==fNActiveSlice*2+1 && pad>fPadMax[padrow]) | |
194 | continue; | |
195 | ||
196 | Int_t time = digits[j].fTime; | |
197 | Int_t charge = digits[j].fCharge; | |
198 | ||
199 | if(charge > GetUpperThreshold() || charge < GetLowerThreshold()) | |
200 | continue; | |
201 | ||
4aa41877 | 202 | AliHLTTransform::Slice2Sector(slice,padrow,sector,row); |
203 | AliHLTTransform::Raw2Local(xyz,sector,row,pad,time); | |
3e87ef69 | 204 | |
205 | Rotate(xyz,i-1-fNActiveSlice); | |
206 | ||
4aa41877 | 207 | AliHLTTransform::XYZtoRPhiEta(rpe,xyz); |
3e87ef69 | 208 | rpe[0] = sqrt(xyz[0]*xyz[0] + xyz[1]*xyz[1]); |
209 | ||
c62b480b | 210 | Int_t etaindex = GetEtaIndex(rpe[2]); |
3e87ef69 | 211 | |
4aa41877 | 212 | AliHLTHistogram *hist = GetHistogram(etaindex); |
3e87ef69 | 213 | |
214 | for(Int_t b=hist->GetFirstYbin(); b<=hist->GetLastYbin(); b++) | |
215 | { | |
216 | psi = hist->GetBinCenterY(b); | |
217 | kappa = 2*sin(rpe[1] - psi)/rpe[0]; | |
218 | ||
219 | if(fabs(kappa) < 1e-33) | |
220 | continue; | |
221 | ||
b2a02bce | 222 | hist->Fill(kappa,psi,charge); |
223 | //hist->Fill(kappa,psi,(int)rint(log((Float_t)charge))); | |
3e87ef69 | 224 | } |
225 | } | |
4aa41877 | 226 | AliHLTMemHandler::UpdateRowPointer(rowPt); |
3e87ef69 | 227 | } |
228 | } | |
229 | } | |
230 | ||
4aa41877 | 231 | void AliHLTHoughTransformerGlobal::VerifyTracks(AliHLTTrackArray *tracks,Int_t &index) |
3e87ef69 | 232 | { |
c62b480b | 233 | //remove tracks which do not cross the seed padrow |
3e87ef69 | 234 | for(int i=index; i<tracks->GetNTracks(); i++) |
235 | { | |
4aa41877 | 236 | AliHLTHoughTrack *tr = (AliHLTHoughTrack*)tracks->GetCheckedTrack(i); |
3e87ef69 | 237 | if(!tr) continue; |
238 | ||
239 | Float_t angle=0; | |
4aa41877 | 240 | AliHLTTransform::Local2GlobalAngle(&angle,GetSlice()); |
241 | if(!tr->CalculateReferencePoint(angle,AliHLTTransform::Row2X(fSeedPadRow))) | |
3e87ef69 | 242 | { |
243 | tracks->Remove(i); | |
244 | continue; | |
245 | } | |
246 | Int_t sector,row; | |
4aa41877 | 247 | AliHLTTransform::Slice2Sector(GetSlice(),fSeedPadRow,sector,row); |
3e87ef69 | 248 | float xyz[3] = {tr->GetPointX(),tr->GetPointY(),tr->GetPointZ()}; |
4aa41877 | 249 | AliHLTTransform::Global2Raw(xyz,sector,row); |
250 | if(xyz[1]<0 || xyz[1]>=AliHLTTransform::GetNPads(fSeedPadRow) || | |
251 | xyz[2]<0 || xyz[2]>=AliHLTTransform::GetNTimeBins()) | |
3e87ef69 | 252 | tracks->Remove(i); |
253 | } | |
254 | tracks->Compress(); | |
255 | index = tracks->GetNTracks(); | |
256 | } | |
257 | ||
4aa41877 | 258 | void AliHLTHoughTransformerGlobal::FindPeaks(AliHLTHistogram *hist,Float_t eta) |
3e87ef69 | 259 | { |
c62b480b | 260 | //Peak Finder |
3e87ef69 | 261 | fPeakFinder->Reset(); |
262 | fPeakFinder->SetHistogram(hist); | |
263 | fPeakFinder->FindAbsMaxima(); | |
264 | if(fPeakFinder->GetWeight(0) < 1000) | |
265 | return; | |
266 | ||
4aa41877 | 267 | AliHLTHoughTrack *track = (AliHLTHoughTrack*)fTracks->NextTrack(); |
3e87ef69 | 268 | track->SetTrackParameters(fPeakFinder->GetXPeak(0),fPeakFinder->GetYPeak(0),fPeakFinder->GetWeight(0)); |
269 | track->SetEta(eta); | |
4aa41877 | 270 | track->SetRowRange(AliHLTTransform::GetFirstRow(0),AliHLTTransform::GetLastRow(5)); |
3e87ef69 | 271 | } |
272 | ||
4aa41877 | 273 | void AliHLTHoughTransformerGlobal::Rotate(Float_t *xyz,Int_t relslice) |
3e87ef69 | 274 | { |
275 | //Rotate coordinates from one slice to the slice relative to it; | |
276 | //-1 means lower | |
277 | //1 means upper | |
278 | ||
4aa41877 | 279 | Float_t angle = (Float_t)relslice*AliHLTTransform::Deg2Rad(20); |
3e87ef69 | 280 | Float_t x=xyz[0],y=xyz[1]; |
281 | xyz[0] = x*cos(angle) - y*sin(angle); | |
282 | xyz[1] = x*sin(angle) + y*cos(angle); | |
283 | } | |
284 | ||
285 | ||
4aa41877 | 286 | void AliHLTHoughTransformerGlobal::DefineRegion(Float_t minpt,Float_t /*linephi*/,Int_t seedpadrow) |
3e87ef69 | 287 | { |
288 | //Setup the region to be included in the transform | |
289 | //This function should be called only once, since it is the same for all slices. | |
290 | ||
291 | fSeedPadRow=seedpadrow; | |
292 | fPtMin = minpt; | |
293 | ||
4aa41877 | 294 | fPadMin = new Int_t[AliHLTTransform::GetNRows()]; |
295 | fPadMax = new Int_t[AliHLTTransform::GetNRows()]; | |
3e87ef69 | 296 | |
297 | //Phirange of data which should be included in the transform | |
298 | //Here we assume a min pt to define it; fPtMin | |
299 | //Based on pt (kappa) and the two points; origo and middle point, we can get psi angle | |
300 | ||
301 | //Calculate the upper point, the lower point is symmetrical around the x-axis | |
302 | //The track in this calculation has a positive charge, and the kappa sign is the opposite: | |
303 | ||
304 | Float_t xyz[3],phi,phi2; | |
305 | ||
306 | phi = CalculateBorder(xyz,-1); //upward bending track | |
307 | phi2 = CalculateBorder(xyz,1); //downward bending track | |
308 | if(phi2 > phi) | |
309 | phi = phi2; | |
310 | ||
4aa41877 | 311 | cout<<"Phiangle "<<phi*180/AliHLTTransform::Pi()<<" psi "<<fPsi*180/AliHLTTransform::Pi()<<" nslices "<<fNActiveSlice<<endl; |
3e87ef69 | 312 | |
313 | Float_t rotangle = fNActiveSlice*20; | |
314 | ||
315 | //Calculate the LUT for min/max pad for every padrow, and check which slices we need. | |
316 | Int_t pad,sector,row; | |
4aa41877 | 317 | for(Int_t i=0; i<AliHLTTransform::GetNRows(); i++) |
3e87ef69 | 318 | { |
4aa41877 | 319 | AliHLTTransform::Slice2Sector(0,i,sector,row); |
3e87ef69 | 320 | |
321 | //Lower boundary: | |
4aa41877 | 322 | pad = AliHLTTransform::GetNPads(i)-1; |
3e87ef69 | 323 | while(pad >= 0) |
324 | { | |
4aa41877 | 325 | AliHLTTransform::Raw2Local(xyz,sector,row,pad,0); |
326 | if(AliHLTTransform::GetPhi(xyz) > -1.*phi + AliHLTTransform::Deg2Rad(rotangle)) | |
3e87ef69 | 327 | fPadMin[i] = pad; |
328 | else | |
329 | break; | |
330 | pad--; | |
331 | } | |
332 | ||
333 | //Upper boundary | |
334 | pad = 0; | |
4aa41877 | 335 | while(pad < AliHLTTransform::GetNPads(i)) |
3e87ef69 | 336 | { |
4aa41877 | 337 | AliHLTTransform::Raw2Local(xyz,sector,row,pad,0); |
338 | if(AliHLTTransform::GetPhi(xyz) < phi - AliHLTTransform::Deg2Rad(rotangle)) | |
3e87ef69 | 339 | fPadMax[i] = pad; |
340 | else | |
341 | break; | |
342 | pad++; | |
343 | } | |
344 | } | |
345 | ||
346 | cout<<"Padmax "<<fPadMax[155]<<endl; | |
347 | ||
348 | } | |
349 | ||
4aa41877 | 350 | Float_t AliHLTHoughTransformerGlobal::CalculateBorder(Float_t *xyz,Int_t charge) |
3e87ef69 | 351 | { |
c62b480b | 352 | //Define Hough space borders |
4aa41877 | 353 | Double_t lineradius = sqrt(pow(AliHLTTransform::Row2X(fSeedPadRow),2) + pow(AliHLTTransform::GetMaxY(fSeedPadRow),2)); |
3e87ef69 | 354 | |
4aa41877 | 355 | Double_t kappa = -charge*AliHLTTransform::GetBField()*AliHLTTransform::GetBFact()/fPtMin; |
3e87ef69 | 356 | |
357 | //Calculate the psi angle of the track = emission angle with x-axis in origo | |
358 | if( fabs(lineradius*kappa/2) > 1) | |
359 | { | |
4aa41877 | 360 | cerr<<"AliHLTTransformerGlobal::DefineRegion : Angle too big"<<endl; |
3e87ef69 | 361 | exit(5); |
362 | } | |
363 | ||
364 | Int_t nslices=0; | |
4aa41877 | 365 | Float_t psi = AliHLTTransform::Deg2Rad(10) - asin(lineradius*kappa/2); |
3e87ef69 | 366 | if(charge > 0) |
367 | fPsi=psi; | |
368 | ||
b2a02bce | 369 | cout<<"Calculated psi-angle "<<fPsi<<endl; |
370 | ||
4aa41877 | 371 | AliHLTTrack track; |
3e87ef69 | 372 | track.SetFirstPoint(0,0,0); |
373 | track.SetPt(fPtMin); | |
374 | track.SetPsi(psi); | |
375 | track.SetCharge(charge); | |
376 | track.CalculateHelix(); | |
377 | ||
378 | Int_t crossingrow=0; | |
379 | if(charge < 0) | |
4aa41877 | 380 | crossingrow = AliHLTTransform::GetNRows()-1; |
3e87ef69 | 381 | |
382 | Float_t rotangle; | |
383 | ||
384 | redefine: | |
385 | ||
386 | rotangle = nslices*20; | |
387 | ||
388 | if(nslices==0)//here we are in local slice, so we use the appropriate function. a mess of course... | |
389 | { | |
390 | while(!track.GetCrossingPoint(crossingrow,xyz)) | |
391 | { | |
392 | if(crossingrow==0) | |
393 | { | |
4aa41877 | 394 | cerr<<"AliHLTHoughTransformerGlobal::DefineRegion : Error calculating point1 on row "<<crossingrow<<endl; |
3e87ef69 | 395 | exit(5); |
396 | } | |
397 | crossingrow--; | |
398 | } | |
399 | } | |
400 | else | |
401 | { | |
4aa41877 | 402 | while(!track.CalculateReferencePoint(AliHLTTransform::Deg2Rad(rotangle),AliHLTTransform::Row2X(crossingrow))) |
3e87ef69 | 403 | { |
404 | if(crossingrow==0) | |
405 | { | |
4aa41877 | 406 | cerr<<"AliHLTHoughTransformerGlobal::DefineRegion : Error calculating point2 on row "<<crossingrow<<endl; |
3e87ef69 | 407 | exit(5); |
408 | } | |
409 | crossingrow--; | |
410 | } | |
411 | ||
412 | xyz[0] = track.GetPointX(); | |
413 | xyz[1] = track.GetPointY(); | |
414 | xyz[2] = track.GetPointZ(); | |
415 | } | |
416 | ||
417 | Float_t phi = atan2(xyz[1],xyz[0]); | |
418 | ||
419 | //Rotate coordinates back to local coordinates: | |
420 | Rotate(xyz,-1*nslices); | |
421 | ||
422 | Int_t sector,row; | |
4aa41877 | 423 | AliHLTTransform::Slice2Sector(0,crossingrow,sector,row); |
424 | AliHLTTransform::Local2Raw(xyz,sector,row); | |
3e87ef69 | 425 | if(xyz[1] < 0) |
426 | { | |
427 | if(crossingrow>0) | |
428 | { | |
4aa41877 | 429 | cerr<<"AliHLTHoughTransformerGlobal::DefineRegion : Wrong pad, probably a deadzone... "<<xyz[1]<<endl; |
3e87ef69 | 430 | exit(5); |
431 | } | |
432 | else | |
433 | return 0;//here you only want the crossing point with the outer padrow | |
434 | } | |
4aa41877 | 435 | if(xyz[1] >= AliHLTTransform::GetNPads(crossingrow)) //Here the range is even one more slice away |
3e87ef69 | 436 | { |
437 | cerr<<"One more slice with pad "<<xyz[1]<<endl; | |
438 | nslices++; | |
439 | if(charge < 0) | |
4aa41877 | 440 | crossingrow = AliHLTTransform::GetNRows()-1; |
3e87ef69 | 441 | goto redefine; |
442 | } | |
443 | ||
444 | if(nslices > fNActiveSlice) | |
445 | fNActiveSlice = nslices; | |
446 | ||
447 | cout<<"Calculated phi "<<phi<<" and pad "<<xyz[1]<<" on row "<<crossingrow<<endl; | |
448 | return phi; | |
449 | } | |
450 | ||
4aa41877 | 451 | void AliHLTHoughTransformerGlobal::LoadActiveSlices(Bool_t binary) |
3e87ef69 | 452 | { |
c62b480b | 453 | //Load active slices |
3e87ef69 | 454 | if(fMemHandler) |
455 | UnloadActiveSlices(); | |
4aa41877 | 456 | fMemHandler = new AliHLTMemHandler*[(fNActiveSlice*2 + 1)]; |
3e87ef69 | 457 | Char_t filename[1024]; |
458 | UInt_t dummy; | |
459 | Int_t i=0,slice; | |
460 | for(Int_t sl=GetSlice()-fNActiveSlice; sl<=GetSlice()+fNActiveSlice; sl++) | |
461 | { | |
462 | if(sl < 0 || sl < 18 && GetSlice() >= 18) | |
463 | slice = sl + 18; | |
464 | else if(sl > 35 || sl > 17 && GetSlice() <= 17) | |
465 | slice = sl-18; | |
466 | else | |
467 | slice = sl; | |
468 | cout<<"Loading slice "<<slice<<endl; | |
4aa41877 | 469 | fMemHandler[i] = new AliHLTFileHandler(); |
3e87ef69 | 470 | fMemHandler[i]->Init(slice,-1); |
471 | if(binary) | |
472 | { | |
473 | sprintf(filename,"%s/binaries/digits_%d_%d_%d.raw",fPath,fEvent,slice,-1); | |
474 | fMemHandler[i]->SetBinaryInput(filename); | |
475 | fMemHandler[i]->CompBinary2Memory(dummy); | |
476 | fMemHandler[i++]->CloseBinaryInput(); | |
477 | } | |
478 | else | |
479 | { | |
b2a02bce | 480 | sprintf(filename,"%s/digitfile.root",fPath); |
481 | fMemHandler[i]->SetAliInput(filename); | |
3e87ef69 | 482 | fMemHandler[i]->AliAltroDigits2Memory(dummy,fEvent); |
483 | fMemHandler[i++]->CloseAliInput(); | |
484 | } | |
485 | } | |
486 | ||
487 | } | |
488 | ||
4aa41877 | 489 | void AliHLTHoughTransformerGlobal::UnloadActiveSlices() |
3e87ef69 | 490 | { |
c62b480b | 491 | //Unload active slices |
3e87ef69 | 492 | if(!fMemHandler) |
493 | return; | |
494 | for(Int_t i=0; i<=fNActiveSlice*2; i++) | |
495 | { | |
496 | if(!fMemHandler[i]) continue; | |
497 | delete fMemHandler[i]; | |
498 | } | |
499 | delete [] fMemHandler; | |
500 | fMemHandler=0; | |
501 | } | |
502 | ||
4aa41877 | 503 | Int_t AliHLTHoughTransformerGlobal::LoadClusterSeeds(AliHLTSeed *seeds) |
3e87ef69 | 504 | { |
c62b480b | 505 | //Load cluster seeds |
3e87ef69 | 506 | Char_t filename[1024]; |
507 | UInt_t npoints; | |
508 | sprintf(filename,"%s/hough/points_%d_%d_%d.raw",fPath,fEvent,GetSlice(),-1); | |
509 | //sprintf(filename,"../tracker/points_%d_%d_%d.raw",fEvent,GetSlice(),-1); | |
4aa41877 | 510 | AliHLTMemHandler mem; |
3e87ef69 | 511 | if(!mem.SetBinaryInput(filename)) |
512 | { | |
4aa41877 | 513 | cerr<<"AliHLTHoughTransformerGlobal::LoadClusterSeeds : Cannot open file "<<filename<<endl; |
3e87ef69 | 514 | exit(5); |
515 | } | |
4aa41877 | 516 | AliHLTSpacePointData *points = (AliHLTSpacePointData*)mem.Allocate(); |
3e87ef69 | 517 | mem.Binary2Memory(npoints,points); |
518 | mem.CloseBinaryInput(); | |
519 | ||
520 | Int_t counter=0; | |
521 | for(UInt_t i=0; i<npoints; i++) | |
522 | { | |
523 | Int_t lrow = (Int_t)points[i].fPadRow; | |
524 | if(lrow < fSeedPadRow) continue; | |
525 | if(lrow > fSeedPadRow) break; | |
4aa41877 | 526 | if(fabs(points[i].fY) > AliHLTTransform::GetMaxY(lrow)) |
3e87ef69 | 527 | { |
4aa41877 | 528 | cerr<<"AliHLTHoughTransformerGlobal::LoadClusterSeeds : Seeds seems not to be in local coordinates: " |
3e87ef69 | 529 | <<points[i].fY<<endl; |
530 | exit(5); | |
531 | } | |
4aa41877 | 532 | Float_t xyz[3] = {AliHLTTransform::Row2X(lrow),points[i].fY,points[i].fZ}; |
533 | Double_t eta = AliHLTTransform::GetEta(xyz); | |
3e87ef69 | 534 | seeds[counter].fPhi = atan2(xyz[1],xyz[0]); |
535 | seeds[counter].fRadius = sqrt(xyz[0]*xyz[0] + xyz[1]*xyz[1]); | |
536 | seeds[counter].fIndex = GetEtaIndex(eta); | |
537 | seeds[counter++].fEta = eta; | |
538 | } | |
539 | cout<<"Loaded "<<counter<<" cluster seeds on slice "<<GetSlice()<<" padrow "<<fSeedPadRow<<endl; | |
540 | mem.Free(); | |
541 | return counter; | |
542 | } | |
543 | ||
4aa41877 | 544 | void AliHLTHoughTransformerGlobal::DisplayActiveRegion(TH2F *hist,Int_t etaindex) |
3e87ef69 | 545 | { |
546 | //Fill the active region in a histogram | |
547 | ||
548 | Int_t i=0,sector,row,slice; | |
549 | UInt_t dummy=0; | |
550 | Float_t xyz[3]; | |
551 | for(Int_t sl=GetSlice()-fNActiveSlice; sl<=GetSlice()+fNActiveSlice; sl++) | |
552 | { | |
553 | if(sl < 0 || sl < 18 && GetSlice() >= 18) | |
554 | slice = sl + 18; | |
555 | else if(sl > 35 || sl > 17 && GetSlice() <= 17) | |
556 | slice = sl-18; | |
557 | else | |
558 | slice = sl; | |
559 | cout<<"Displaying slice "<<slice<<endl; | |
4aa41877 | 560 | AliHLTDigitRowData *rowPt = (AliHLTDigitRowData*)fMemHandler[i++]->GetDataPointer(dummy); |
561 | for(Int_t padrow=0; padrow<AliHLTTransform::GetNRows(); padrow++) | |
3e87ef69 | 562 | { |
4aa41877 | 563 | AliHLTDigitData *digits = (AliHLTDigitData*)rowPt->fDigitData; |
3e87ef69 | 564 | for(UInt_t j=0; j<rowPt->fNDigit; j++) |
565 | { | |
566 | Int_t pad = digits[j].fPad; | |
567 | if(i==1 && pad < fPadMin[padrow]) | |
568 | continue; | |
569 | if(i==fNActiveSlice*2+1 && pad>fPadMax[padrow]) | |
570 | continue; | |
571 | Int_t time = digits[j].fTime; | |
4aa41877 | 572 | AliHLTTransform::Slice2Sector(slice,padrow,sector,row); |
573 | AliHLTTransform::Raw2Local(xyz,sector,row,pad,time); | |
3e87ef69 | 574 | |
575 | Rotate(xyz,i-1-fNActiveSlice); | |
576 | ||
4aa41877 | 577 | Double_t eta = AliHLTTransform::GetEta(xyz); |
c62b480b | 578 | if(GetEtaIndex(eta) == etaindex) |
3e87ef69 | 579 | hist->Fill(xyz[0],xyz[1]); |
580 | } | |
4aa41877 | 581 | AliHLTMemHandler::UpdateRowPointer(rowPt); |
3e87ef69 | 582 | } |
583 | } | |
584 | } |