]>
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 | |
e06900d5 | 6 | #include "AliL3StandardIncludes.h" |
7 | ||
95a00d93 | 8 | #ifdef use_root |
b46b21a5 | 9 | #include <TH1.h> |
162e2e5a | 10 | #include <TFile.h> |
95a00d93 | 11 | #endif |
e06900d5 | 12 | |
162e2e5a | 13 | #include "AliL3Logging.h" |
99e7186b | 14 | #include "AliL3HoughEval.h" |
e06900d5 | 15 | #include "AliL3MemHandler.h" |
16 | #include "AliL3TrackArray.h" | |
237d3f5c | 17 | #include "AliL3HoughBaseTransformer.h" |
99e7186b | 18 | #include "AliL3DigitData.h" |
4de874d1 | 19 | #include "AliL3HoughTrack.h" |
99e7186b | 20 | #include "AliL3Transform.h" |
21 | #include "AliL3Histogram.h" | |
b46b21a5 | 22 | #include "AliL3Histogram1D.h" |
4de874d1 | 23 | |
0bd0c1ef | 24 | #if __GNUC__ == 3 |
e06900d5 | 25 | using namespace std; |
26 | #endif | |
27 | ||
0bd0c1ef | 28 | /** /class AliL3HoughEval |
29 | //<pre> | |
b1886074 | 30 | //_____________________________________________________________ |
31 | // AliL3HoughEval | |
32 | // | |
33 | // Evaluation class for tracklets produced by the Hough transform. | |
0bd0c1ef | 34 | // |
35 | </pre> | |
36 | */ | |
b1886074 | 37 | |
4de874d1 | 38 | ClassImp(AliL3HoughEval) |
39 | ||
4de874d1 | 40 | AliL3HoughEval::AliL3HoughEval() |
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 | |
4de874d1 | 51 | AliL3HoughEval::~AliL3HoughEval() |
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 | ||
237d3f5c | 63 | void AliL3HoughEval::InitTransformer(AliL3HoughBaseTransformer *transformer) |
b46b21a5 | 64 | { |
c62b480b | 65 | //Init hough transformer |
b46b21a5 | 66 | fHoughTransformer = transformer; |
67 | fSlice = fHoughTransformer->GetSlice(); | |
68 | fPatch = fHoughTransformer->GetPatch(); | |
26abc209 | 69 | fNrows = AliL3Transform::GetLastRow(fPatch) - AliL3Transform::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 | ||
99e7186b | 77 | void AliL3HoughEval::GenerateLUT() |
4de874d1 | 78 | { |
b46b21a5 | 79 | //Generate a Look-up table, to limit the access to raw data |
99e7186b | 80 | |
b1886074 | 81 | if(!fRowPointers) |
82 | fRowPointers = new AliL3DigitRowData*[fNrows]; | |
99e7186b | 83 | |
84 | AliL3DigitRowData *tempPt = (AliL3DigitRowData*)fHoughTransformer->GetDataPointer(); | |
85 | if(!tempPt) | |
b46b21a5 | 86 | printf("\nAliL3HoughEval::GenerateLUT : Zero data pointer\n"); |
f80b98cb | 87 | |
26abc209 | 88 | for(Int_t i=AliL3Transform::GetFirstRow(fPatch); i<=AliL3Transform::GetLastRow(fPatch); i++) |
f80b98cb | 89 | { |
26abc209 | 90 | Int_t prow = i - AliL3Transform::GetFirstRow(fPatch); |
99e7186b | 91 | fRowPointers[prow] = tempPt; |
b46b21a5 | 92 | AliL3MemHandler::UpdateRowPointer(tempPt); |
f80b98cb | 93 | } |
94 | ||
99e7186b | 95 | } |
f80b98cb | 96 | |
c62b480b | 97 | Bool_t AliL3HoughEval::LookInsideRoad(AliL3HoughTrack *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 | |
109 | //for(Int_t padrow = AliL3Transform::GetFirstRow(fPatch); padrow <= AliL3Transform::GetLastRow(fPatch); padrow++) | |
110 | for(Int_t padrow = rowrange[0]; padrow<=rowrange[1]; padrow++) | |
f80b98cb | 111 | { |
26abc209 | 112 | Int_t prow = padrow - AliL3Transform::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); | |
123 | xyz[0] += AliL3Transform::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 | ||
4ab9f8f0 | 128 | AliL3Transform::Slice2Sector(fSlice,padrow,sector,row); |
129 | AliL3Transform::Local2Raw(xyz,sector,row); | |
6c97129d | 130 | |
f80b98cb | 131 | npixs=0; |
99e7186b | 132 | |
133 | //Get the timebins for this pad | |
134 | AliL3DigitRowData *tempPt = fRowPointers[prow]; | |
135 | if(!tempPt) | |
f80b98cb | 136 | { |
99e7186b | 137 | printf("AliL3HoughEval::LookInsideRoad : Zero data pointer\n"); |
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 | { |
144 | AliL3DigitData *digPt = tempPt->fDigitData; | |
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; | |
868b6166 | 153 | Double_t eta = AliL3Transform::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 | ||
b46b21a5 | 186 | void AliL3HoughEval::FindEta(AliL3TrackArray *tracks) |
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(); | |
193 | fEtaHistos = new AliL3Histogram1D*[ntracks]; | |
194 | ||
195 | Char_t hname[100]; | |
196 | for(Int_t i=0; i<ntracks; i++) | |
197 | { | |
198 | sprintf(hname,"etahist_%d",i); | |
199 | fEtaHistos[i] = new AliL3Histogram1D(hname,hname,100,0,1); | |
200 | } | |
201 | Double_t etaslice = (fEtaMax - fEtaMin)/fNEtaSegments; | |
202 | ||
203 | for(Int_t ntr=0; ntr<ntracks; ntr++) | |
204 | { | |
205 | AliL3HoughTrack *track = (AliL3HoughTrack*)tracks->GetCheckedTrack(ntr); | |
206 | if(!track) continue; | |
26abc209 | 207 | for(Int_t padrow = AliL3Transform::GetFirstRow(fPatch); padrow <= AliL3Transform::GetLastRow(fPatch); padrow++) |
b46b21a5 | 208 | { |
26abc209 | 209 | Int_t prow = padrow - AliL3Transform::GetFirstRow(fPatch); |
b46b21a5 | 210 | |
211 | if(!track->GetCrossingPoint(padrow,xyz)) | |
212 | { | |
213 | printf("AliL3HoughEval::LookInsideRoad : Track does not cross line!!\n"); | |
214 | continue; | |
215 | } | |
216 | ||
4ab9f8f0 | 217 | AliL3Transform::Slice2Sector(fSlice,padrow,sector,row); |
218 | AliL3Transform::Local2Raw(xyz,sector,row); | |
b46b21a5 | 219 | |
220 | //Get the timebins for this pad | |
221 | AliL3DigitRowData *tempPt = fRowPointers[prow]; | |
222 | if(!tempPt) | |
223 | { | |
224 | printf("AliL3HoughEval::LookInsideRoad : Zero data pointer\n"); | |
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 | { | |
231 | AliL3DigitData *digPt = tempPt->fDigitData; | |
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; | |
868b6166 | 240 | Double_t eta = AliL3Transform::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 | { | |
252 | AliL3Histogram1D *hist = fEtaHistos[i]; | |
c62b480b | 253 | Int_t maxbin = hist->GetMaximumBin(); |
254 | Double_t maxvalue = hist->GetBinContent(maxbin); | |
b46b21a5 | 255 | AliL3HoughTrack *track = (AliL3HoughTrack*)tracks->GetCheckedTrack(i); |
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 |