]>
Commit | Line | Data |
---|---|---|
3e87ef69 | 1 | // @(#) $Id$ |
735e167e | 2 | |
029912b7 | 3 | // Author: Anders Vestbo <mailto:vestbo@fi.uib.no> |
3e87ef69 | 4 | //*-- Copyright © ALICE HLT Group |
735e167e | 5 | |
4994a25d | 6 | #include "AliL3StandardIncludes.h" |
735e167e | 7 | |
3e87ef69 | 8 | #include "AliL3Logging.h" |
735e167e | 9 | #include "AliL3Modeller.h" |
10 | #include "AliL3MemHandler.h" | |
11 | #include "AliL3TrackArray.h" | |
12 | #include "AliL3ModelTrack.h" | |
13 | #include "AliL3DigitData.h" | |
14 | #include "AliL3Transform.h" | |
3e87ef69 | 15 | #include "AliL3SpacePointData.h" |
16 | ||
17 | #ifdef use_aliroot | |
18 | #include "AliL3FileHandler.h" | |
19 | #endif | |
735e167e | 20 | |
0bd0c1ef | 21 | #if __GNUC__ == 3 |
4994a25d | 22 | using namespace std; |
23 | #endif | |
24 | ||
4a838220 | 25 | //_____________________________________________________________ |
26 | // AliL3Modeller | |
27 | // | |
28 | // Class for modeling TPC data. | |
29 | // | |
30 | // This performs the cluster finding, based on track parameters. | |
31 | // Basically it propagates the tracks to all padrows, and looks | |
32 | // for a corresponding cluster. For the moment only cog is calculated, | |
33 | // and no deconvolution is done. | |
735e167e | 34 | |
35 | ClassImp(AliL3Modeller) | |
36 | ||
37 | AliL3Modeller::AliL3Modeller() | |
38 | { | |
39 | fMemHandler=0; | |
40 | fTracks=0; | |
3e87ef69 | 41 | fRow=0; |
4a838220 | 42 | fTrackThreshold=0; |
2357bb38 | 43 | SetOverlap(); |
44 | SetTrackThreshold(); | |
f64c4364 | 45 | SetSearchRange(); |
3e87ef69 | 46 | SetMaxClusterRange(0,0); |
47 | fDebug=kFALSE; | |
735e167e | 48 | } |
49 | ||
50 | ||
51 | AliL3Modeller::~AliL3Modeller() | |
52 | { | |
53 | if(fMemHandler) | |
54 | delete fMemHandler; | |
55 | if(fTracks) | |
56 | delete fTracks; | |
3e87ef69 | 57 | if(fRow) |
58 | delete [] fRow; | |
735e167e | 59 | } |
60 | ||
4994a25d | 61 | void AliL3Modeller::Init(Int_t slice,Int_t patch,Char_t *trackdata,Char_t *path,Bool_t houghtracks,Bool_t binary) |
735e167e | 62 | { |
63 | fSlice = slice; | |
64 | fPatch = patch; | |
3e87ef69 | 65 | fHoughTracks=houghtracks; |
2357bb38 | 66 | |
be6ddb10 | 67 | sprintf(fPath,"%s",path); |
029912b7 | 68 | |
735e167e | 69 | fTracks = new AliL3TrackArray("AliL3ModelTrack"); |
92a876e2 | 70 | |
71 | Char_t fname[100]; | |
735e167e | 72 | AliL3MemHandler *file = new AliL3MemHandler(); |
3e87ef69 | 73 | if(!houghtracks) |
74 | sprintf(fname,"%s/tracks_tr_%d_0.raw",trackdata,fSlice); //output tracks from the tracker (no merging) | |
75 | else | |
76 | sprintf(fname,"%s/tracks_ho_%d.raw",trackdata,fSlice); | |
77 | //sprintf(fname,"%s/tracks_ho_%d_%d.raw",trackdata,fSlice,fPatch); | |
92a876e2 | 78 | if(!file->SetBinaryInput(fname)) |
735e167e | 79 | { |
92a876e2 | 80 | cerr<<"AliL3Modeller::Init : Error opening trackfile: "<<fname<<endl; |
735e167e | 81 | return; |
82 | } | |
83 | file->Binary2TrackArray(fTracks); | |
84 | file->CloseBinaryInput(); | |
85 | delete file; | |
86 | ||
4a838220 | 87 | if(!houghtracks) |
88 | fTracks->QSort(); | |
89 | ||
735e167e | 90 | for(Int_t i=0; i<fTracks->GetNTracks(); i++) |
91 | { | |
92 | AliL3ModelTrack *track = (AliL3ModelTrack*)fTracks->GetCheckedTrack(i); | |
93 | if(!track) continue; | |
94 | track->Init(fSlice,fPatch); | |
4a838220 | 95 | |
96 | //Only if the tracks has been merged across sector boundaries: | |
97 | //if(!houghtracks) | |
98 | //track->Rotate(fSlice,kTRUE); //!!!!!!!!!!!!!!!!!!! | |
99 | ||
735e167e | 100 | track->CalculateHelix(); |
101 | } | |
102 | ||
3e87ef69 | 103 | Int_t ntimes = AliL3Transform::GetNTimeBins()+1; |
104 | Int_t npads = AliL3Transform::GetNPads(AliL3Transform::GetLastRow(fPatch))+1;//Max num of pads. | |
105 | Int_t bounds = ntimes*npads; | |
106 | fRow = new Digit[bounds]; | |
107 | ||
108 | ||
8487f697 | 109 | UInt_t ndigits=0; |
110 | AliL3DigitRowData *digits=0; | |
111 | #ifdef use_aliroot | |
112 | fMemHandler = new AliL3FileHandler(); | |
2357bb38 | 113 | fMemHandler->Init(slice,patch); |
8487f697 | 114 | if(binary == kFALSE) |
115 | { | |
2357bb38 | 116 | sprintf(fname,"%s/digitfile.root",fPath); |
8487f697 | 117 | fMemHandler->SetAliInput(fname); |
3e87ef69 | 118 | digits = fMemHandler->AliAltroDigits2Memory(ndigits); |
8487f697 | 119 | } |
2357bb38 | 120 | else |
121 | { | |
122 | sprintf(fname,"%sdigits_%d_%d.raw",fPath,fSlice,fPatch); | |
123 | if(!fMemHandler->SetBinaryInput(fname)) | |
124 | { | |
125 | cerr<<"AliL3Modeller::Init : Error opening file "<<fname<<endl; | |
126 | return; | |
127 | } | |
128 | digits=(AliL3DigitRowData*)fMemHandler->CompBinary2Memory(ndigits); | |
129 | } | |
8487f697 | 130 | #else |
735e167e | 131 | fMemHandler = new AliL3MemHandler(); |
2357bb38 | 132 | fMemHandler->Init(slice,patch); |
8487f697 | 133 | if(binary == kFALSE) |
735e167e | 134 | { |
8487f697 | 135 | cerr<<"AliL3Modeller::Init : Compile with AliROOT if you want rootfile as input"<<endl; |
735e167e | 136 | return; |
137 | } | |
8487f697 | 138 | else |
139 | { | |
140 | sprintf(fname,"%sdigits_%d_%d.raw",fPath,fSlice,fPatch); | |
141 | if(!fMemHandler->SetBinaryInput(fname)) | |
142 | { | |
143 | cerr<<"AliL3Modeller::Init : Error opening file "<<fname<<endl; | |
144 | return; | |
145 | } | |
146 | } | |
147 | digits=(AliL3DigitRowData*)fMemHandler->CompBinary2Memory(ndigits); | |
148 | #endif | |
735e167e | 149 | |
150 | SetInputData(digits); | |
151 | } | |
152 | ||
029912b7 | 153 | void AliL3Modeller::FindClusters() |
735e167e | 154 | { |
3e87ef69 | 155 | if(fDebug) |
156 | cout<<"AliL3Modeller::FindClusters : Processing slice "<<fSlice<<" patch "<<fPatch<<endl; | |
735e167e | 157 | if(!fTracks) |
158 | { | |
159 | cerr<<"AliL3Modeller::Process : No tracks"<<endl; | |
160 | return; | |
161 | } | |
162 | if(!fRowData) | |
163 | { | |
164 | cerr<<"AliL3Modeller::Process : No data "<<endl; | |
165 | return; | |
166 | } | |
167 | ||
168 | AliL3DigitRowData *rowPt = fRowData; | |
169 | AliL3DigitData *digPt=0; | |
170 | ||
3e87ef69 | 171 | Int_t pad,time; |
735e167e | 172 | Short_t charge; |
173 | Cluster cluster; | |
3e87ef69 | 174 | ClusterRegion region[200]; |
175 | ||
4a838220 | 176 | for(Int_t i=AliL3Transform::GetFirstRow(fPatch); i<=AliL3Transform::GetLastRow(fPatch); i++) |
735e167e | 177 | { |
3e87ef69 | 178 | if(i != (Int_t)rowPt->fRow) |
179 | { | |
180 | cerr<<"AliL3Modeller::FindClusters : Mismatching rownumbering "<<i<<" "<<rowPt->fRow<<endl; | |
181 | return; | |
182 | } | |
8487f697 | 183 | fCurrentPadRow = i; |
3e87ef69 | 184 | memset((void*)fRow,0,(AliL3Transform::GetNTimeBins()+1)*(AliL3Transform::GetNPads(i)+1)*sizeof(Digit)); |
735e167e | 185 | digPt = (AliL3DigitData*)rowPt->fDigitData; |
2357bb38 | 186 | //cout<<"Loading row "<<i<<" with "<<(Int_t)rowPt->fNDigit<<" digits"<<endl; |
735e167e | 187 | for(UInt_t j=0; j<rowPt->fNDigit; j++) |
188 | { | |
189 | pad = digPt[j].fPad; | |
190 | time = digPt[j].fTime; | |
191 | charge = digPt[j].fCharge; | |
3e87ef69 | 192 | fRow[(AliL3Transform::GetNTimeBins()+1)*pad + time].fCharge = charge; |
193 | fRow[(AliL3Transform::GetNTimeBins()+1)*pad + time].fUsed = kFALSE; | |
029912b7 | 194 | //cout<<"Row "<<i<<" pad "<<pad<<" time "<<time<<" charge "<<charge<<endl; |
735e167e | 195 | } |
196 | ||
197 | for(Int_t k=0; k<fTracks->GetNTracks(); k++) | |
198 | { | |
199 | AliL3ModelTrack *track = (AliL3ModelTrack*)fTracks->GetCheckedTrack(k); | |
200 | if(!track) continue; | |
029912b7 | 201 | |
3e87ef69 | 202 | if(track->GetPadHit(i)<0 || track->GetTimeHit(i)<0 || track->GetNOverlaps(i)>0)//track->GetOverlap(i)>=0) |
95a00d93 | 203 | { |
3e87ef69 | 204 | //cout<<"Track "<<k<<" is empty on row "<<i<<" "<<track->GetPadHit(i)<<" "<<track->GetTimeHit(i)<<endl; |
205 | track->SetCluster(i,0,0,0,0,0,0); //The track has left the patch, or it is overlapping | |
95a00d93 | 206 | continue; |
207 | } | |
735e167e | 208 | |
3e87ef69 | 209 | Int_t minpad,mintime,maxpad,maxtime; |
210 | minpad = mintime = 999; | |
211 | maxpad = maxtime = 0; | |
212 | ||
213 | memset(&cluster,0,sizeof(Cluster)); | |
214 | LocateCluster(track,region,minpad,maxpad);//,mintime,maxtime); | |
215 | if(maxpad - minpad + 1 > fMaxPads || // maxtime - mintime + 1 > fMaxTimebins || | |
216 | maxpad - minpad < 1) // || maxtime - mintime < 1) | |
fe1c53fa | 217 | { |
3e87ef69 | 218 | //cout<<"Cluster not found on row "<<i<<" maxpad "<<maxpad<<" minpad "<<minpad<<" maxtime "<<maxtime<<" mintime "<<mintime |
219 | // <<" padhit "<<track->GetPadHit(i)<<" timehit "<<track->GetTimeHit(i)<<endl; | |
220 | ||
221 | track->SetCluster(i,0,0,0,0,0,0); | |
fe1c53fa | 222 | continue; |
223 | } | |
735e167e | 224 | |
4a838220 | 225 | Int_t npads=0; |
3e87ef69 | 226 | for(pad=minpad; pad<=maxpad; pad++) |
735e167e | 227 | { |
3e87ef69 | 228 | Int_t ntimes=0; |
229 | for(time=region[pad].mintime; time<=region[pad].maxtime; time++) | |
735e167e | 230 | { |
3e87ef69 | 231 | charge = fRow[(AliL3Transform::GetNTimeBins()+1)*pad+time].fCharge; |
232 | if(!charge) continue; | |
233 | if(fRow[(AliL3Transform::GetNTimeBins()+1)*pad+time].fUsed == kTRUE) | |
234 | continue; | |
235 | ntimes++; | |
2357bb38 | 236 | |
237 | //Update the cluster parameters with this timebin | |
735e167e | 238 | cluster.fTime += time*charge; |
239 | cluster.fPad += pad*charge; | |
240 | cluster.fCharge += charge; | |
241 | cluster.fSigmaY2 += pad*pad*charge; | |
242 | cluster.fSigmaZ2 += time*time*charge; | |
3e87ef69 | 243 | fRow[(AliL3Transform::GetNTimeBins()+1)*pad+time].fUsed = kTRUE; |
735e167e | 244 | } |
3e87ef69 | 245 | if(ntimes) |
246 | npads++; | |
735e167e | 247 | } |
3e87ef69 | 248 | FillCluster(track,&cluster,i,npads); |
735e167e | 249 | } |
3e87ef69 | 250 | FillZeros(rowPt); |
735e167e | 251 | fMemHandler->UpdateRowPointer(rowPt); |
735e167e | 252 | } |
f64c4364 | 253 | //cout<<"done processing"<<endl; |
029912b7 | 254 | |
3e87ef69 | 255 | |
029912b7 | 256 | //Debug: |
257 | for(Int_t i=0; i<fTracks->GetNTracks(); i++) | |
258 | { | |
259 | AliL3ModelTrack *track = (AliL3ModelTrack*)fTracks->GetCheckedTrack(i); | |
260 | if(!track) continue; | |
4a838220 | 261 | if(track->GetNClusters() != AliL3Transform::GetNRows(fPatch)) |
262 | cerr<<endl<<"Mismatching hitcounts; nclusters: "<<track->GetNClusters()<<" nrows "<<AliL3Transform::GetNRows(fPatch)<<endl<<endl; | |
029912b7 | 263 | } |
264 | ||
265 | } | |
266 | ||
3e87ef69 | 267 | |
268 | void AliL3Modeller::LocateCluster(AliL3ModelTrack *track,ClusterRegion *region,Int_t &padmin,Int_t &padmax) | |
fe1c53fa | 269 | { |
3e87ef69 | 270 | //Set the cluster range |
271 | //This method searches for _all_ nonzeros timebins which are neigbours. | |
272 | //This makes it rather impractical when dealing with high occupancy, | |
273 | //because then you might have very large "cluster" areas from low | |
274 | //pt electrons/noise. | |
275 | ||
276 | Int_t row=fCurrentPadRow,charge,prtmin=0,prtmax=999; | |
277 | Int_t hitpad = (Int_t)rint(track->GetPadHit(row)); | |
278 | Int_t hittime = (Int_t)rint(track->GetTimeHit(row)); | |
279 | Int_t tmin = hittime; | |
280 | Int_t tmax = tmin; | |
281 | ||
282 | Int_t clustercharge=0; | |
283 | Int_t pad=hitpad; | |
284 | Bool_t pm = kTRUE; | |
285 | Int_t npads=0,middlemax=tmax,middlemin=tmin; | |
fe1c53fa | 286 | while(1) |
287 | { | |
3e87ef69 | 288 | Bool_t padpr=kFALSE; |
289 | Int_t time = hittime; | |
290 | Bool_t tm = kTRUE; | |
291 | if(pad < 0) | |
292 | { | |
293 | padmin = 0; | |
294 | pad = hitpad+1; | |
295 | pm = kFALSE; | |
296 | prtmin = middlemin; | |
297 | prtmax = middlemax; | |
298 | continue; | |
299 | } | |
300 | else if(pad >= AliL3Transform::GetNPads(row)) | |
301 | { | |
302 | padmax = AliL3Transform::GetNPads(row)-1; | |
303 | break; | |
304 | } | |
305 | ||
306 | tmin = 999; | |
307 | tmax = 0; | |
308 | //if(row==0) | |
309 | //cout<<"Starting to look in pad "<<pad<<" time "<<time<<endl; | |
fe1c53fa | 310 | while(1) |
311 | { | |
3e87ef69 | 312 | if(time < 0) |
fe1c53fa | 313 | { |
3e87ef69 | 314 | time = hittime+1; |
315 | tm = kFALSE; | |
316 | } | |
317 | else if(time >= AliL3Transform::GetNTimeBins()) | |
318 | { | |
319 | //timemax = AliL3Transform::GetNTimeBins()-1; | |
320 | break; | |
321 | } | |
322 | charge = fRow[(AliL3Transform::GetNTimeBins()+1)*pad+time].fCharge; | |
323 | //if(row==0) | |
324 | //cout<<"charge "<<charge<<" at pad "<<pad<<" time "<<time<<endl; | |
325 | if(charge>0) | |
326 | { | |
327 | clustercharge+=charge; | |
328 | padpr = kTRUE; | |
329 | if(time < tmin) | |
330 | tmin = time; | |
331 | if(time > tmax) | |
332 | tmax = time; | |
333 | if(tm) | |
334 | time--; | |
335 | else | |
336 | time++; | |
337 | } | |
338 | else | |
339 | { | |
340 | if(tm) | |
fe1c53fa | 341 | { |
3e87ef69 | 342 | //if(abs(time - hittime) < fTimeSearch && padpr == kFALSE)//Keep looking |
343 | if(time > prtmin && npads!=0) | |
fe1c53fa | 344 | time--; |
345 | else | |
3e87ef69 | 346 | { |
347 | time = hittime+1; | |
348 | tm=kFALSE; | |
349 | } | |
fe1c53fa | 350 | } |
3e87ef69 | 351 | //else if(abs(time-hittime) < fTimeSearch && padpr == kFALSE)//Keep looking |
352 | else if(time < prtmax && npads != 0) | |
353 | time++; | |
fe1c53fa | 354 | else |
355 | break; | |
356 | } | |
fe1c53fa | 357 | } |
3e87ef69 | 358 | if(npads==0) |
359 | { | |
360 | middlemax = tmax; | |
361 | middlemin = tmin; | |
362 | } | |
363 | // if(row==0) | |
364 | //cout<<"tmax "<<tmax<<" tmin "<<tmin<<" prtmin "<<prtmin<<" ptrmax "<<prtmax<<endl; | |
fe1c53fa | 365 | |
3e87ef69 | 366 | if(padpr && tmax >= prtmin && tmin <= prtmax)//Sequence is overlapping with the previous |
bd53cfb7 | 367 | { |
3e87ef69 | 368 | //if(row==0) |
369 | //cout<<"Incrementing pad "<<endl; | |
bd53cfb7 | 370 | npads++; |
3e87ef69 | 371 | |
372 | region[pad].mintime=tmin; | |
373 | region[pad].maxtime=tmax; | |
374 | ||
375 | /* | |
376 | if(tmin < timemin) | |
377 | timemin=tmin; | |
378 | if(tmax > timemax) | |
379 | timemax=tmax; | |
380 | */ | |
381 | if(pad < padmin) | |
382 | padmin = pad; | |
383 | if(pad > padmax) | |
384 | padmax = pad; | |
385 | if(pm) | |
386 | pad--; | |
387 | else | |
388 | pad++; | |
389 | ||
390 | prtmin = tmin; | |
391 | prtmax = tmax; | |
bd53cfb7 | 392 | } |
fe1c53fa | 393 | else |
394 | { | |
3e87ef69 | 395 | if(pm) |
fe1c53fa | 396 | { |
3e87ef69 | 397 | if(abs(pad-hitpad)<fPadSearch && clustercharge == 0) |
fe1c53fa | 398 | pad--; |
399 | else | |
3e87ef69 | 400 | { |
401 | //if(row==0) | |
402 | //cout<<"Setting new pad "<<hitpad+1<<endl; | |
403 | pad = hitpad+1; | |
404 | pm = kFALSE; | |
405 | prtmin = middlemin; | |
406 | prtmax = middlemax; | |
407 | continue; | |
408 | } | |
fe1c53fa | 409 | } |
3e87ef69 | 410 | else |
fe1c53fa | 411 | { |
3e87ef69 | 412 | if(abs(pad-hitpad)<fPadSearch && clustercharge==0) |
413 | pad++; | |
414 | else | |
415 | break; | |
fe1c53fa | 416 | } |
fe1c53fa | 417 | } |
fe1c53fa | 418 | } |
419 | ||
fe1c53fa | 420 | } |
421 | ||
3e87ef69 | 422 | |
4a838220 | 423 | void AliL3Modeller::FillCluster(AliL3ModelTrack *track,Cluster *cluster,Int_t row,Int_t npads) |
029912b7 | 424 | { |
425 | if(cluster->fCharge==0) | |
426 | { | |
4a838220 | 427 | track->SetCluster(row,0,0,0,0,0,0); |
029912b7 | 428 | return; |
429 | } | |
430 | Float_t fcharge = (Float_t)cluster->fCharge; | |
431 | Float_t fpad = ((Float_t)cluster->fPad/fcharge); | |
432 | Float_t ftime = ((Float_t)cluster->fTime/fcharge); | |
433 | Float_t sigmaY2,sigmaZ2; | |
434 | CalcClusterWidth(cluster,sigmaY2,sigmaZ2); | |
4a838220 | 435 | track->SetCluster(row,fpad,ftime,fcharge,sigmaY2,sigmaZ2,npads); |
3e87ef69 | 436 | #ifdef do_mc |
437 | Int_t trackID[3]; | |
438 | GetTrackID((Int_t)rint(fpad),(Int_t)rint(ftime),trackID); | |
439 | track->SetClusterLabel(row,trackID); | |
440 | #endif | |
735e167e | 441 | } |
442 | ||
3e87ef69 | 443 | |
444 | ||
445 | void AliL3Modeller::FillZeros(AliL3DigitRowData *rowPt,Bool_t reversesign) | |
95a00d93 | 446 | { |
447 | //Fill zero where data has been used. | |
3e87ef69 | 448 | |
95a00d93 | 449 | AliL3DigitData *digPt = (AliL3DigitData*)rowPt->fDigitData; |
450 | for(UInt_t j=0; j<rowPt->fNDigit; j++) | |
451 | { | |
452 | Int_t pad = digPt[j].fPad; | |
453 | Int_t time = digPt[j].fTime; | |
3e87ef69 | 454 | if(fRow[(AliL3Transform::GetNTimeBins()+1)*pad+time].fUsed==kTRUE) |
455 | { | |
456 | if(reversesign) | |
457 | { | |
458 | if(digPt[j].fCharge < 1024) | |
459 | digPt[j].fCharge += 1024; | |
460 | } | |
461 | else | |
462 | digPt[j].fCharge = 0; | |
463 | } | |
95a00d93 | 464 | } |
465 | } | |
466 | ||
be6ddb10 | 467 | void AliL3Modeller::WriteRemaining() |
95a00d93 | 468 | { |
469 | //Write remaining (nonzero) digits to file. | |
470 | ||
95a00d93 | 471 | AliL3DigitRowData *rowPt; |
472 | rowPt = (AliL3DigitRowData*)fRowData; | |
473 | Int_t digitcount=0; | |
de3c3890 | 474 | Int_t *ndigits=new Int_t[(AliL3Transform::GetNRows(fPatch))]; |
4a838220 | 475 | for(Int_t i=AliL3Transform::GetFirstRow(fPatch); i<=AliL3Transform::GetLastRow(fPatch); i++) |
95a00d93 | 476 | { |
477 | AliL3DigitData *digPt = (AliL3DigitData*)rowPt->fDigitData; | |
4a838220 | 478 | ndigits[(i-AliL3Transform::GetFirstRow(fPatch))]=0; |
95a00d93 | 479 | for(UInt_t j=0; j<rowPt->fNDigit; j++) |
480 | { | |
481 | if(digPt[j].fCharge==0) continue; | |
482 | digitcount++; | |
4a838220 | 483 | ndigits[(i-AliL3Transform::GetFirstRow(fPatch))]++; |
95a00d93 | 484 | } |
4a838220 | 485 | //cout<<"Difference "<<(int)ndigits[(i-AliL3Transform::GetFirstRow(fPatch))]<<" "<<(int)rowPt->fNDigit<<endl; |
95a00d93 | 486 | fMemHandler->UpdateRowPointer(rowPt); |
487 | } | |
488 | ||
4a838220 | 489 | Int_t size = digitcount*sizeof(AliL3DigitData) + AliL3Transform::GetNRows(fPatch)*sizeof(AliL3DigitRowData); |
95a00d93 | 490 | Byte_t *data = new Byte_t[size]; |
491 | memset(data,0,size); | |
492 | AliL3DigitRowData *tempPt = (AliL3DigitRowData*)data; | |
493 | rowPt = (AliL3DigitRowData*)fRowData; | |
494 | ||
4a838220 | 495 | for(Int_t i=AliL3Transform::GetFirstRow(fPatch); i<=AliL3Transform::GetLastRow(fPatch); i++) |
95a00d93 | 496 | { |
497 | Int_t localcount=0; | |
498 | tempPt->fRow = i; | |
4a838220 | 499 | tempPt->fNDigit = ndigits[(i-AliL3Transform::GetFirstRow(fPatch))]; |
95a00d93 | 500 | AliL3DigitData *digPt = (AliL3DigitData*)rowPt->fDigitData; |
501 | for(UInt_t j=0; j<rowPt->fNDigit; j++) | |
502 | { | |
503 | if(digPt[j].fCharge==0) continue; | |
4a838220 | 504 | if(localcount >= ndigits[(i-AliL3Transform::GetFirstRow(fPatch))]) |
95a00d93 | 505 | { |
506 | cerr<<"AliL3Modeller::WriteRemaining : Digitarray out of range!!"<<endl; | |
507 | return; | |
508 | } | |
509 | tempPt->fDigitData[localcount].fCharge = digPt[j].fCharge; | |
510 | tempPt->fDigitData[localcount].fPad = digPt[j].fPad; | |
511 | tempPt->fDigitData[localcount].fTime = digPt[j].fTime; | |
4a838220 | 512 | |
95a00d93 | 513 | localcount++; |
514 | } | |
4a838220 | 515 | if(ndigits[(i-AliL3Transform::GetFirstRow(fPatch))] != localcount) |
95a00d93 | 516 | { |
517 | cerr<<"AliL3Modeller::WriteRemaining : Mismatch in digitcount"<<endl; | |
518 | return; | |
519 | } | |
520 | fMemHandler->UpdateRowPointer(rowPt); | |
521 | Byte_t *tmp = (Byte_t*)tempPt; | |
4a838220 | 522 | Int_t size = sizeof(AliL3DigitRowData) + ndigits[(i-AliL3Transform::GetFirstRow(fPatch))]*sizeof(AliL3DigitData); |
95a00d93 | 523 | tmp += size; |
524 | tempPt = (AliL3DigitRowData*)tmp; | |
525 | } | |
526 | ||
be6ddb10 | 527 | Char_t fname[100]; |
95a00d93 | 528 | AliL3MemHandler *mem = new AliL3MemHandler(); |
2357bb38 | 529 | sprintf(fname,"%s/comp/remains_%d_%d.raw",fPath,fSlice,fPatch); |
3e87ef69 | 530 | mem->Init(fSlice,fPatch); |
be6ddb10 | 531 | mem->SetBinaryOutput(fname); |
4a838220 | 532 | mem->Memory2CompBinary((UInt_t)AliL3Transform::GetNRows(fPatch),(AliL3DigitRowData*)data); |
95a00d93 | 533 | mem->CloseBinaryOutput(); |
534 | delete mem; | |
029912b7 | 535 | delete [] data; |
62bb4b3d | 536 | delete [] ndigits; |
95a00d93 | 537 | } |
538 | ||
3e87ef69 | 539 | void AliL3Modeller::RemoveBadTracks() |
540 | { | |
541 | //Remove tracsk which should not be included in the compression scheme. | |
542 | ||
543 | for(Int_t i=0; i<fTracks->GetNTracks(); i++) | |
544 | { | |
545 | AliL3ModelTrack *track = (AliL3ModelTrack*)fTracks->GetCheckedTrack(i); | |
546 | if(!track) continue; | |
547 | ||
548 | if(track->GetPt() < 0.08) | |
549 | { | |
550 | fTracks->Remove(i); | |
551 | continue; | |
552 | } | |
553 | ||
554 | if(!fHoughTracks) | |
555 | if(track->GetNHits() < fTrackThreshold) | |
556 | fTracks->Remove(i); | |
557 | } | |
558 | fTracks->Compress(); | |
559 | ||
560 | } | |
95a00d93 | 561 | |
735e167e | 562 | void AliL3Modeller::CalculateCrossingPoints() |
563 | { | |
3e87ef69 | 564 | if(fDebug) |
565 | cout<<"Calculating crossing points on "<<fTracks->GetNTracks()<<" tracks"<<endl; | |
735e167e | 566 | if(!fTracks) |
567 | { | |
568 | cerr<<"AliL3Modeller::CalculateCrossingPoints(): No tracks"<<endl; | |
569 | return; | |
570 | } | |
571 | Float_t hit[3]; | |
029912b7 | 572 | |
029912b7 | 573 | Int_t sector,row; |
4a838220 | 574 | for(Int_t i=AliL3Transform::GetLastRow(fPatch); i>=AliL3Transform::GetFirstRow(fPatch); i--) |
735e167e | 575 | { |
576 | for(Int_t j=0; j<fTracks->GetNTracks(); j++) | |
577 | { | |
578 | AliL3ModelTrack *track = (AliL3ModelTrack*)fTracks->GetCheckedTrack(j); | |
579 | if(!track) continue; | |
4a838220 | 580 | |
95a00d93 | 581 | if(!track->GetCrossingPoint(i,hit)) |
735e167e | 582 | { |
f64c4364 | 583 | //cerr<<"AliL3Modeller::CalculateCrossingPoints : Track "<<j<<" does not intersect row "<<i<<" :"<<endl<< |
3e87ef69 | 584 | // " pt "<<track->GetPt()<< |
585 | // " tgl "<<track->GetTgl()<<" psi "<<track->GetPsi()<<" charge "<<track->GetCharge()<<endl; | |
586 | //fTracks->Remove(j); | |
587 | track->SetPadHit(i,-1); | |
588 | track->SetTimeHit(i,-1); | |
735e167e | 589 | continue; |
590 | } | |
2357bb38 | 591 | //cout<<"X "<<hit[0]<<" Y "<<hit[1]<<" Z "<<hit[2]<<" tgl "<<track->GetTgl()<<endl; |
95a00d93 | 592 | |
4a838220 | 593 | AliL3Transform::Slice2Sector(fSlice,i,sector,row); |
594 | AliL3Transform::Local2Raw(hit,sector,row); | |
2357bb38 | 595 | //cout<<"Pad "<<hit[1]<<" time "<<hit[2]<<" in sector "<<sector<<" row "<<row<<endl; |
4a838220 | 596 | if(hit[1]<0 || hit[1]>AliL3Transform::GetNPads(i) || |
597 | hit[2]<0 || hit[2]>AliL3Transform::GetNTimeBins()) | |
95a00d93 | 598 | {//Track is leaving the patch, so flag the track hits (<0) |
599 | track->SetPadHit(i,-1); | |
600 | track->SetTimeHit(i,-1); | |
601 | continue; | |
602 | } | |
3e87ef69 | 603 | |
735e167e | 604 | track->SetPadHit(i,hit[1]); |
605 | track->SetTimeHit(i,hit[2]); | |
3e87ef69 | 606 | track->CalculateClusterWidths(i); |
607 | ||
608 | Double_t beta = track->GetCrossingAngle(i); | |
609 | track->SetCrossingAngleLUT(i,beta); | |
95a00d93 | 610 | |
735e167e | 611 | //if(hit[1]<0 || hit[2]>445) |
95a00d93 | 612 | //if(hit[2]<0 || hit[2]>445) |
613 | //cout<<"pad "<<hit[1]<<" time "<<hit[2]<<" pt "<<track->GetPt()<<" psi "<<track->GetPsi()<<" tgl "<<track->GetTgl()<<" firstpoint "<<track->GetFirstPointX()<<" "<<track->GetFirstPointY()<<" "<<track->GetFirstPointZ()<<endl; | |
735e167e | 614 | //cout<<"Crossing pad "<<hit[1]<<" time "<<hit[2]<<endl; |
615 | } | |
616 | } | |
617 | fTracks->Compress(); | |
3e87ef69 | 618 | if(fDebug) |
619 | cout<<"And there are "<<fTracks->GetNTracks()<<" tracks remaining"<<endl; | |
735e167e | 620 | } |
621 | ||
3e87ef69 | 622 | void AliL3Modeller::CheckForOverlaps(Float_t dangle,Int_t *rowrange) |
735e167e | 623 | { |
624 | //Flag the tracks that overlap | |
625 | ||
3e87ef69 | 626 | if(fDebug) |
627 | cout<<"Checking for overlaps on "<<fTracks->GetNTracks()<<endl; | |
2357bb38 | 628 | Int_t counter=0; |
3e87ef69 | 629 | |
630 | for(Int_t k=AliL3Transform::GetFirstRow(fPatch); k<=AliL3Transform::GetLastRow(fPatch); k++) | |
735e167e | 631 | { |
3e87ef69 | 632 | if(rowrange) |
735e167e | 633 | { |
3e87ef69 | 634 | if(k < rowrange[0]) continue; |
635 | if(k > rowrange[1]) break; | |
636 | } | |
637 | for(Int_t i=0; i<fTracks->GetNTracks(); i++) | |
638 | { | |
639 | AliL3ModelTrack *track1 = (AliL3ModelTrack*)fTracks->GetCheckedTrack(i); | |
640 | if(!track1) continue; | |
641 | if(track1->GetPadHit(k)<0 || track1->GetTimeHit(k)<0) continue; | |
642 | ||
643 | for(Int_t j=i+1; j<fTracks->GetNTracks(); j++) | |
735e167e | 644 | { |
3e87ef69 | 645 | AliL3ModelTrack *track2 = (AliL3ModelTrack*)fTracks->GetCheckedTrack(j); |
646 | if(!track2) continue; | |
647 | if(track2->GetPadHit(k)<0 || track2->GetTimeHit(k)<0) continue; | |
2357bb38 | 648 | |
649 | if(abs((Int_t)rint(track1->GetPadHit(k))-(Int_t)rint(track2->GetPadHit(k))) <= fPadOverlap && | |
650 | abs((Int_t)rint(track1->GetTimeHit(k))-(Int_t)rint(track2->GetTimeHit(k))) <= fTimeOverlap) | |
735e167e | 651 | { |
3e87ef69 | 652 | if(dangle>0 && fabs(track1->GetCrossingAngleLUT(k) - track2->GetCrossingAngleLUT(k)) < dangle) |
653 | fTracks->Remove(j); | |
654 | ||
655 | //cout<<"row "<<k<<" "<<i<<" "<<j<<" "<<track1->GetPadHit(k)<<" "<<track2->GetPadHit(k)<<" "<<fabs(track1->GetCrossingAngleLUT(k) - track2->GetCrossingAngleLUT(k))<<endl; | |
656 | ||
657 | else | |
658 | track1->SetOverlap(k,j); | |
2357bb38 | 659 | counter++; |
735e167e | 660 | } |
661 | } | |
662 | } | |
663 | } | |
3e87ef69 | 664 | fTracks->Compress(); |
665 | if(fDebug) | |
666 | cout<<"and there are "<<fTracks->GetNTracks()<<" track left"<<endl; | |
f64c4364 | 667 | //cout<<"found "<<counter<<" done"<<endl; |
735e167e | 668 | } |
669 | ||
670 | ||
671 | void AliL3Modeller::CalcClusterWidth(Cluster *cl,Float_t &sigmaY2,Float_t &sigmaZ2) | |
672 | { | |
673 | ||
674 | Float_t padw,timew; | |
4a838220 | 675 | |
676 | padw = AliL3Transform::GetPadPitchWidth(fPatch); | |
677 | ||
735e167e | 678 | Float_t charge = (Float_t)cl->fCharge; |
679 | Float_t pad = (Float_t)cl->fPad/charge; | |
680 | Float_t time = (Float_t)cl->fTime/charge; | |
681 | Float_t s2 = (Float_t)cl->fSigmaY2/charge - pad*pad; | |
4a838220 | 682 | |
683 | //Save the sigmas in pad and time: | |
684 | ||
685 | sigmaY2 = (s2);// + 1./12);//*padw*padw; | |
686 | ||
687 | /*Constants added by offline | |
688 | if(s2 != 0) | |
735e167e | 689 | { |
4a838220 | 690 | sigmaY2 = sigmaY2*0.108; |
691 | if(fPatch<3) | |
692 | sigmaY2 = sigmaY2*2.07; | |
735e167e | 693 | } |
4a838220 | 694 | */ |
695 | ||
735e167e | 696 | s2 = (Float_t)cl->fSigmaZ2/charge - time*time; |
4a838220 | 697 | timew = AliL3Transform::GetZWidth(); |
698 | sigmaZ2 = (s2);// +1./12);//*timew*timew; | |
699 | ||
700 | ||
701 | ||
3e87ef69 | 702 | /* |
703 | Constants added by offline | |
4a838220 | 704 | if(s2 != 0) |
735e167e | 705 | { |
4a838220 | 706 | sigmaZ2 = sigmaZ2*0.169; |
707 | if(fPatch < 3) | |
708 | sigmaZ2 = sigmaZ2*1.77; | |
735e167e | 709 | } |
4a838220 | 710 | */ |
735e167e | 711 | } |
f64c4364 | 712 | |
3e87ef69 | 713 | void AliL3Modeller::GetTrackID(Int_t pad,Int_t time,Int_t *trackID) |
714 | { | |
715 | #ifdef do_mc | |
716 | AliL3DigitRowData *rowPt = (AliL3DigitRowData*)fRowData; | |
717 | ||
718 | trackID[0]=trackID[1]=trackID[2]=-2; | |
719 | ||
720 | for(Int_t i=AliL3Transform::GetFirstRow(fPatch); i<=AliL3Transform::GetLastRow(fPatch); i++) | |
721 | { | |
722 | if(rowPt->fRow < (UInt_t)fCurrentPadRow) | |
723 | { | |
724 | AliL3MemHandler::UpdateRowPointer(rowPt); | |
725 | continue; | |
726 | } | |
727 | AliL3DigitData *digPt = (AliL3DigitData*)rowPt->fDigitData; | |
728 | for(UInt_t j=0; j<rowPt->fNDigit; j++) | |
729 | { | |
730 | Int_t cpad = digPt[j].fPad; | |
731 | Int_t ctime = digPt[j].fTime; | |
732 | if(cpad != pad) continue; | |
733 | if(ctime != time) continue; | |
734 | //if(cpad != pad && ctime != ctime) continue; | |
735 | //cout<<"Reading row "<<fCurrentRow<<" pad "<<cpad<<" time "<<ctime<<" trackID "<<digPt[j].fTrackID[0]<<endl; | |
736 | trackID[0] = digPt[j].fTrackID[0]; | |
737 | trackID[1] = digPt[j].fTrackID[1]; | |
738 | trackID[2] = digPt[j].fTrackID[2]; | |
739 | break; | |
740 | //cout<<"Reading trackID "<<trackID[0]<<endl; | |
741 | } | |
742 | break; | |
743 | } | |
744 | #endif | |
745 | return; | |
746 | } | |
747 |