]>
Commit | Line | Data |
---|---|---|
3e87ef69 | 1 | // @(#) $Id$ |
95a00d93 | 2 | |
b1886074 | 3 | // Author: Anders Vestbo <mailto:vestbo@fi.uib.no> |
3e87ef69 | 4 | //*-- Copyright © ALICE HLT Group |
f80b98cb | 5 | |
4aa41877 | 6 | #include "AliHLTStandardIncludes.h" |
e06900d5 | 7 | |
95a00d93 | 8 | #ifdef use_root |
b46b21a5 | 9 | #include <TH1.h> |
162e2e5a | 10 | #include <TFile.h> |
95a00d93 | 11 | #endif |
e06900d5 | 12 | |
4aa41877 | 13 | #include "AliHLTLogging.h" |
14 | #include "AliHLTHoughEval.h" | |
15 | #include "AliHLTMemHandler.h" | |
16 | #include "AliHLTTrackArray.h" | |
17 | #include "AliHLTHoughBaseTransformer.h" | |
18 | #include "AliHLTDigitData.h" | |
19 | #include "AliHLTHoughTrack.h" | |
20 | #include "AliHLTTransform.h" | |
21 | #include "AliHLTHistogram.h" | |
22 | #include "AliHLTHistogram1D.h" | |
4de874d1 | 23 | |
0bd0c1ef | 24 | #if __GNUC__ == 3 |
e06900d5 | 25 | using namespace std; |
26 | #endif | |
27 | ||
4aa41877 | 28 | /** /class AliHLTHoughEval |
0bd0c1ef | 29 | //<pre> |
b1886074 | 30 | //_____________________________________________________________ |
4aa41877 | 31 | // AliHLTHoughEval |
b1886074 | 32 | // |
33 | // Evaluation class for tracklets produced by the Hough transform. | |
0bd0c1ef | 34 | // |
35 | </pre> | |
36 | */ | |
b1886074 | 37 | |
4aa41877 | 38 | ClassImp(AliHLTHoughEval) |
4de874d1 | 39 | |
4aa41877 | 40 | AliHLTHoughEval::AliHLTHoughEval() |
4de874d1 | 41 | { |
c62b480b | 42 | //default ctor |
99e7186b | 43 | fRemoveFoundTracks = kFALSE; |
f80b98cb | 44 | fNumOfPadsToLook = 1; |
99e7186b | 45 | fNumOfRowsToMiss = 1; |
b46b21a5 | 46 | fEtaHistos=0; |
b1886074 | 47 | fRowPointers = 0; |
4de874d1 | 48 | } |
49 | ||
b46b21a5 | 50 | |
4aa41877 | 51 | AliHLTHoughEval::~AliHLTHoughEval() |
4de874d1 | 52 | { |
c62b480b | 53 | //dtor |
b46b21a5 | 54 | fHoughTransformer = 0; |
99e7186b | 55 | if(fRowPointers) |
b1886074 | 56 | { |
57 | for(Int_t i=0; i<fNrows; i++) | |
58 | fRowPointers[i] = 0; | |
59 | delete [] fRowPointers; | |
60 | } | |
4de874d1 | 61 | } |
62 | ||
4aa41877 | 63 | void AliHLTHoughEval::InitTransformer(AliHLTHoughBaseTransformer *transformer) |
b46b21a5 | 64 | { |
c62b480b | 65 | //Init hough transformer |
b46b21a5 | 66 | fHoughTransformer = transformer; |
67 | fSlice = fHoughTransformer->GetSlice(); | |
68 | fPatch = fHoughTransformer->GetPatch(); | |
4aa41877 | 69 | fNrows = AliHLTTransform::GetLastRow(fPatch) - AliHLTTransform::GetFirstRow(fPatch) + 1; |
b46b21a5 | 70 | fNEtaSegments = fHoughTransformer->GetNEtaSegments(); |
71 | fEtaMin = fHoughTransformer->GetEtaMin(); | |
72 | fEtaMax = fHoughTransformer->GetEtaMax(); | |
0bd0c1ef | 73 | fZVertex = fHoughTransformer->GetZVertex(); |
b46b21a5 | 74 | GenerateLUT(); |
75 | } | |
76 | ||
4aa41877 | 77 | void AliHLTHoughEval::GenerateLUT() |
4de874d1 | 78 | { |
b46b21a5 | 79 | //Generate a Look-up table, to limit the access to raw data |
99e7186b | 80 | |
b1886074 | 81 | if(!fRowPointers) |
4aa41877 | 82 | fRowPointers = new AliHLTDigitRowData*[fNrows]; |
99e7186b | 83 | |
4aa41877 | 84 | AliHLTDigitRowData *tempPt = (AliHLTDigitRowData*)fHoughTransformer->GetDataPointer(); |
99e7186b | 85 | if(!tempPt) |
4aa41877 | 86 | printf("\nAliHLTHoughEval::GenerateLUT : Zero data pointer\n"); |
f80b98cb | 87 | |
4aa41877 | 88 | for(Int_t i=AliHLTTransform::GetFirstRow(fPatch); i<=AliHLTTransform::GetLastRow(fPatch); i++) |
f80b98cb | 89 | { |
4aa41877 | 90 | Int_t prow = i - AliHLTTransform::GetFirstRow(fPatch); |
99e7186b | 91 | fRowPointers[prow] = tempPt; |
4aa41877 | 92 | AliHLTMemHandler::UpdateRowPointer(tempPt); |
f80b98cb | 93 | } |
94 | ||
99e7186b | 95 | } |
f80b98cb | 96 | |
4aa41877 | 97 | Bool_t AliHLTHoughEval::LookInsideRoad(AliHLTHoughTrack *track,Int_t &nrowscrossed,Int_t *rowrange,Bool_t remove) |
99e7186b | 98 | { |
99 | //Look at rawdata along the road specified by the track candidates. | |
100 | //If track is good, return true, if not return false. | |
162e2e5a | 101 | |
f80b98cb | 102 | Int_t sector,row; |
99e7186b | 103 | |
0309a5ee | 104 | Int_t nrow=0,npixs=0;//,rows_crossed=0; |
f80b98cb | 105 | Float_t xyz[3]; |
99e7186b | 106 | |
c62b480b | 107 | Int_t totalcharge=0;//total charge along the road |
3e87ef69 | 108 | |
4aa41877 | 109 | //for(Int_t padrow = AliHLTTransform::GetFirstRow(fPatch); padrow <= AliHLTTransform::GetLastRow(fPatch); padrow++) |
3e87ef69 | 110 | for(Int_t padrow = rowrange[0]; padrow<=rowrange[1]; padrow++) |
f80b98cb | 111 | { |
4aa41877 | 112 | Int_t prow = padrow - AliHLTTransform::GetFirstRow(fPatch); |
3e87ef69 | 113 | if(track->IsHelix()) |
f80b98cb | 114 | { |
3e87ef69 | 115 | if(!track->GetCrossingPoint(padrow,xyz)) |
116 | { | |
117 | continue; | |
118 | } | |
119 | } | |
120 | else | |
121 | { | |
122 | track->GetLineCrossingPoint(padrow,xyz); | |
4aa41877 | 123 | xyz[0] += AliHLTTransform::Row2X(track->GetFirstRow()); |
c62b480b | 124 | Float_t r = sqrt(xyz[0]*xyz[0] + xyz[1]*xyz[1]); |
125 | xyz[2] = r*track->GetTgl(); | |
f80b98cb | 126 | } |
127 | ||
4aa41877 | 128 | AliHLTTransform::Slice2Sector(fSlice,padrow,sector,row); |
129 | AliHLTTransform::Local2Raw(xyz,sector,row); | |
6c97129d | 130 | |
f80b98cb | 131 | npixs=0; |
99e7186b | 132 | |
133 | //Get the timebins for this pad | |
4aa41877 | 134 | AliHLTDigitRowData *tempPt = fRowPointers[prow]; |
99e7186b | 135 | if(!tempPt) |
f80b98cb | 136 | { |
4aa41877 | 137 | printf("AliHLTHoughEval::LookInsideRoad : Zero data pointer\n"); |
99e7186b | 138 | continue; |
f80b98cb | 139 | } |
140 | ||
99e7186b | 141 | //Look at both sides of the pad: |
162e2e5a | 142 | for(Int_t p=(Int_t)rint(xyz[1])-fNumOfPadsToLook; p<=(Int_t)rint(xyz[1])+fNumOfPadsToLook; p++) |
99e7186b | 143 | { |
4aa41877 | 144 | AliHLTDigitData *digPt = tempPt->fDigitData; |
99e7186b | 145 | for(UInt_t j=0; j<tempPt->fNDigit; j++) |
146 | { | |
3e87ef69 | 147 | Int_t pad = digPt[j].fPad; |
0309a5ee | 148 | Int_t charge = digPt[j].fCharge; |
149 | if(charge <= fHoughTransformer->GetLowerThreshold()) continue; | |
99e7186b | 150 | if(pad < p) continue; |
151 | if(pad > p) break; | |
152 | UShort_t time = digPt[j].fTime; | |
4aa41877 | 153 | Double_t eta = AliHLTTransform::GetEta(fSlice,padrow,pad,time); |
c62b480b | 154 | Int_t pixelindex = fHoughTransformer->GetEtaIndex(eta); |
155 | if(pixelindex != track->GetEtaIndex()) continue; | |
156 | totalcharge += digPt[j].fCharge; | |
99e7186b | 157 | if(remove) |
3e87ef69 | 158 | digPt[j].fCharge = 0; //Erease the track from image |
99e7186b | 159 | npixs++; |
160 | } | |
161 | } | |
162 | ||
162e2e5a | 163 | if(npixs > 1)//At least 2 digits on this padrow |
f80b98cb | 164 | { |
165 | nrow++; | |
166 | } | |
167 | } | |
99e7186b | 168 | if(remove) |
169 | return kTRUE; | |
170 | ||
c62b480b | 171 | nrowscrossed += nrow; //Update the number of rows crossed. |
0309a5ee | 172 | |
3e87ef69 | 173 | if(nrow >= rowrange[1]-rowrange[0]+1 - fNumOfRowsToMiss)//this was a good track |
f80b98cb | 174 | { |
99e7186b | 175 | if(fRemoveFoundTracks) |
0309a5ee | 176 | { |
177 | Int_t dummy=0; | |
3e87ef69 | 178 | LookInsideRoad(track,dummy,rowrange,kTRUE); |
0309a5ee | 179 | } |
f80b98cb | 180 | return kTRUE; |
181 | } | |
182 | else | |
183 | return kFALSE; | |
184 | } | |
185 | ||
4aa41877 | 186 | void AliHLTHoughEval::FindEta(AliHLTTrackArray *tracks) |
b46b21a5 | 187 | { |
c62b480b | 188 | //Find the corresponding eta slice hough space |
b46b21a5 | 189 | Int_t sector,row; |
190 | Float_t xyz[3]; | |
191 | ||
192 | Int_t ntracks = tracks->GetNTracks(); | |
4aa41877 | 193 | fEtaHistos = new AliHLTHistogram1D*[ntracks]; |
b46b21a5 | 194 | |
195 | Char_t hname[100]; | |
196 | for(Int_t i=0; i<ntracks; i++) | |
197 | { | |
198 | sprintf(hname,"etahist_%d",i); | |
4aa41877 | 199 | fEtaHistos[i] = new AliHLTHistogram1D(hname,hname,100,0,1); |
b46b21a5 | 200 | } |
201 | Double_t etaslice = (fEtaMax - fEtaMin)/fNEtaSegments; | |
202 | ||
203 | for(Int_t ntr=0; ntr<ntracks; ntr++) | |
204 | { | |
4aa41877 | 205 | AliHLTHoughTrack *track = (AliHLTHoughTrack*)tracks->GetCheckedTrack(ntr); |
b46b21a5 | 206 | if(!track) continue; |
4aa41877 | 207 | for(Int_t padrow = AliHLTTransform::GetFirstRow(fPatch); padrow <= AliHLTTransform::GetLastRow(fPatch); padrow++) |
b46b21a5 | 208 | { |
4aa41877 | 209 | Int_t prow = padrow - AliHLTTransform::GetFirstRow(fPatch); |
b46b21a5 | 210 | |
211 | if(!track->GetCrossingPoint(padrow,xyz)) | |
212 | { | |
4aa41877 | 213 | printf("AliHLTHoughEval::LookInsideRoad : Track does not cross line!!\n"); |
b46b21a5 | 214 | continue; |
215 | } | |
216 | ||
4aa41877 | 217 | AliHLTTransform::Slice2Sector(fSlice,padrow,sector,row); |
218 | AliHLTTransform::Local2Raw(xyz,sector,row); | |
b46b21a5 | 219 | |
220 | //Get the timebins for this pad | |
4aa41877 | 221 | AliHLTDigitRowData *tempPt = fRowPointers[prow]; |
b46b21a5 | 222 | if(!tempPt) |
223 | { | |
4aa41877 | 224 | printf("AliHLTHoughEval::LookInsideRoad : Zero data pointer\n"); |
b46b21a5 | 225 | continue; |
226 | } | |
227 | ||
228 | //Look at both sides of the pad: | |
229 | for(Int_t p=(Int_t)rint(xyz[1])-fNumOfPadsToLook; p<=(Int_t)rint(xyz[1])+fNumOfPadsToLook; p++) | |
230 | { | |
4aa41877 | 231 | AliHLTDigitData *digPt = tempPt->fDigitData; |
b46b21a5 | 232 | for(UInt_t j=0; j<tempPt->fNDigit; j++) |
233 | { | |
234 | UChar_t pad = digPt[j].fPad; | |
0309a5ee | 235 | Int_t charge = digPt[j].fCharge; |
236 | if(charge <= fHoughTransformer->GetLowerThreshold()) continue; | |
b46b21a5 | 237 | if(pad < p) continue; |
238 | if(pad > p) break; | |
239 | UShort_t time = digPt[j].fTime; | |
4aa41877 | 240 | Double_t eta = AliHLTTransform::GetEta(fSlice,padrow,pad,time); |
c62b480b | 241 | Int_t pixelindex = (Int_t)(eta/etaslice); |
242 | if(pixelindex > track->GetEtaIndex()+1) continue; | |
243 | if(pixelindex < track->GetEtaIndex()-1) break; | |
b46b21a5 | 244 | fEtaHistos[ntr]->Fill(eta,digPt[j].fCharge); |
245 | } | |
246 | } | |
247 | } | |
248 | } | |
249 | ||
250 | for(Int_t i=0; i<ntracks; i++) | |
251 | { | |
4aa41877 | 252 | AliHLTHistogram1D *hist = fEtaHistos[i]; |
c62b480b | 253 | Int_t maxbin = hist->GetMaximumBin(); |
254 | Double_t maxvalue = hist->GetBinContent(maxbin); | |
4aa41877 | 255 | AliHLTHoughTrack *track = (AliHLTHoughTrack*)tracks->GetCheckedTrack(i); |
b46b21a5 | 256 | if(!track) continue; |
c62b480b | 257 | if(hist->GetBinContent(maxbin-1)<maxvalue && hist->GetBinContent(maxbin+1)<maxvalue) |
b46b21a5 | 258 | { |
c62b480b | 259 | track->SetWeight((Int_t)maxvalue,kTRUE); |
260 | track->SetEta(hist->GetBinCenter(maxbin)); | |
b46b21a5 | 261 | track->SetNHits(track->GetWeight()); |
262 | } | |
263 | else | |
264 | { | |
265 | track->SetWeight(0); | |
266 | tracks->Remove(i); //remove this track, because it was not a peak | |
267 | } | |
268 | } | |
269 | tracks->Compress(); | |
270 | ||
271 | //for(Int_t i=0; i<ntracks; i++) | |
272 | //delete fEtaHistos[i]; | |
273 |