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