4 |
*/ |
*/ |
5 |
#include <TrkLevel2.h> |
#include <TrkLevel2.h> |
6 |
#include <iostream> |
#include <iostream> |
7 |
|
#include <math.h> |
8 |
using namespace std; |
using namespace std; |
9 |
//...................................... |
//...................................... |
10 |
// F77 routines |
// F77 routines |
12 |
extern "C" { |
extern "C" { |
13 |
void dotrack_(int*, double*, double*, double*, double*, int*); |
void dotrack_(int*, double*, double*, double*, double*, int*); |
14 |
void dotrack2_(int*, double*, double*, double*, double*,double*, double*, double*,int*); |
void dotrack2_(int*, double*, double*, double*, double*,double*, double*, double*,int*); |
15 |
int readb_(const char*); |
// int readb_(const char*); |
16 |
|
int readb_(); |
17 |
|
void mini2_(int*,int*,int*); |
18 |
|
void guess_(); |
19 |
} |
} |
20 |
//-------------------------------------- |
//-------------------------------------- |
21 |
// |
// |
25 |
seqno = -1; |
seqno = -1; |
26 |
image = -1; |
image = -1; |
27 |
chi2 = 0; |
chi2 = 0; |
28 |
|
nstep = 0; |
29 |
for(int it1=0;it1<5;it1++){ |
for(int it1=0;it1<5;it1++){ |
30 |
al[it1] = 0; |
al[it1] = 0; |
31 |
for(int it2=0;it2<5;it2++) |
for(int it2=0;it2<5;it2++)coval[it1][it2] = 0; |
|
coval[it1][it2] = 0; |
|
32 |
}; |
}; |
33 |
for(int ip=0;ip<6;ip++){ |
for(int ip=0;ip<6;ip++){ |
34 |
xgood[ip] = 0; |
xgood[ip] = 0; |
35 |
ygood[ip] = 0; |
ygood[ip] = 0; |
36 |
xm[ip] = 0; |
xm[ip] = 0; |
37 |
ym[ip] = 0; |
ym[ip] = 0; |
38 |
zm[ip] = 0; |
zm[ip] = 0; |
39 |
resx[ip] = 0; |
resx[ip] = 0; |
40 |
resy[ip] = 0; |
resy[ip] = 0; |
41 |
xv[ip] = 0; |
xv[ip] = 0; |
42 |
yv[ip] = 0; |
yv[ip] = 0; |
43 |
zv[ip] = 0; |
zv[ip] = 0; |
44 |
axv[ip] = 0; |
axv[ip] = 0; |
45 |
ayv[ip] = 0; |
ayv[ip] = 0; |
46 |
dedx_x[ip] = 0; |
dedx_x[ip] = 0; |
47 |
dedx_y[ip] = 0; |
dedx_y[ip] = 0; |
48 |
}; |
// clx[ip] = 0; |
49 |
|
// cly[ip] = 0; |
50 |
|
}; |
51 |
|
clx = new TRefArray(6,0); |
52 |
|
cly = new TRefArray(6,0); |
53 |
}; |
}; |
54 |
//-------------------------------------- |
//-------------------------------------- |
55 |
// |
// |
59 |
seqno = t.seqno; |
seqno = t.seqno; |
60 |
image = t.image; |
image = t.image; |
61 |
chi2 = t.chi2; |
chi2 = t.chi2; |
62 |
|
nstep = t.nstep; |
63 |
for(int it1=0;it1<5;it1++){ |
for(int it1=0;it1<5;it1++){ |
64 |
al[it1] = t.al[it1]; |
al[it1] = t.al[it1]; |
65 |
for(int it2=0;it2<5;it2++) |
for(int it2=0;it2<5;it2++)coval[it1][it2] = t.coval[it1][it2]; |
|
coval[it1][it2] = t.coval[it1][it2]; |
|
66 |
}; |
}; |
67 |
for(int ip=0;ip<6;ip++){ |
for(int ip=0;ip<6;ip++){ |
68 |
xgood[ip] = t.xgood[ip]; |
xgood[ip] = t.xgood[ip]; |
69 |
ygood[ip] = t.ygood[ip]; |
ygood[ip] = t.ygood[ip]; |
70 |
xm[ip] = t.xm[ip]; |
xm[ip] = t.xm[ip]; |
71 |
ym[ip] = t.ym[ip]; |
ym[ip] = t.ym[ip]; |
72 |
zm[ip] = t.zm[ip]; |
zm[ip] = t.zm[ip]; |
73 |
resx[ip] = t.resx[ip]; |
resx[ip] = t.resx[ip]; |
74 |
resy[ip] = t.resy[ip]; |
resy[ip] = t.resy[ip]; |
75 |
xv[ip] = t.xv[ip]; |
xv[ip] = t.xv[ip]; |
76 |
yv[ip] = t.yv[ip]; |
yv[ip] = t.yv[ip]; |
77 |
zv[ip] = t.zv[ip]; |
zv[ip] = t.zv[ip]; |
78 |
axv[ip] = t.axv[ip]; |
axv[ip] = t.axv[ip]; |
79 |
ayv[ip] = t.ayv[ip]; |
ayv[ip] = t.ayv[ip]; |
80 |
dedx_x[ip] = t.dedx_x[ip]; |
dedx_x[ip] = t.dedx_x[ip]; |
81 |
dedx_y[ip] = t.dedx_y[ip]; |
dedx_y[ip] = t.dedx_y[ip]; |
82 |
}; |
// clx[ip] = 0;//<<<<pointer |
83 |
|
// cly[ip] = 0;//<<<<pointer |
84 |
|
}; |
85 |
|
clx = new TRefArray(*(t.clx)); |
86 |
|
cly = new TRefArray(*(t.cly)); |
87 |
|
|
88 |
}; |
}; |
89 |
//-------------------------------------- |
//-------------------------------------- |
90 |
// |
// |
200 |
//-------------------------------------- |
//-------------------------------------- |
201 |
void TrkTrack::Dump(){ |
void TrkTrack::Dump(){ |
202 |
cout << endl << "========== Track " ; |
cout << endl << "========== Track " ; |
203 |
|
cout << endl << "seq. n. : "<< seqno; |
204 |
|
cout << endl << "image n. : "<< image; |
205 |
cout << endl << "al : "; for(int i=0; i<5; i++)cout << al[i] << " "; |
cout << endl << "al : "; for(int i=0; i<5; i++)cout << al[i] << " "; |
206 |
cout << endl << "chi^2 : "<< chi2; |
cout << endl << "chi^2 : "<< chi2; |
207 |
|
cout << endl << "n.step : "<< nstep; |
208 |
cout << endl << "xgood : "; for(int i=0; i<6; i++)cout << xgood[i] ; |
cout << endl << "xgood : "; for(int i=0; i<6; i++)cout << xgood[i] ; |
209 |
cout << endl << "ygood : "; for(int i=0; i<6; i++)cout << ygood[i] ; |
cout << endl << "ygood : "; for(int i=0; i<6; i++)cout << ygood[i] ; |
210 |
cout << endl << "xm : "; for(int i=0; i<6; i++)cout << xm[i] << " "; |
cout << endl << "xm : "; for(int i=0; i<6; i++)cout << xm[i] << " "; |
211 |
cout << endl << "ym : "; for(int i=0; i<6; i++)cout << ym[i] << " "; |
cout << endl << "ym : "; for(int i=0; i<6; i++)cout << ym[i] << " "; |
212 |
cout << endl << "zm : "; for(int i=0; i<6; i++)cout << zm[i] << " "; |
cout << endl << "zm : "; for(int i=0; i<6; i++)cout << zm[i] << " "; |
213 |
|
cout << endl << "xv : "; for(int i=0; i<6; i++)cout << xv[i] << " "; |
214 |
|
cout << endl << "yv : "; for(int i=0; i<6; i++)cout << yv[i] << " "; |
215 |
|
cout << endl << "zv : "; for(int i=0; i<6; i++)cout << zv[i] << " "; |
216 |
|
cout << endl << "resx : "; for(int i=0; i<6; i++)cout << resx[i] << " "; |
217 |
|
cout << endl << "resy : "; for(int i=0; i<6; i++)cout << resy[i] << " "; |
218 |
|
cout << endl << "coval : "; for(int i=0; i<5; i++)cout << coval[0][i]<<" "; |
219 |
|
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[1][i]<<" "; |
220 |
|
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[2][i]<<" "; |
221 |
|
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[3][i]<<" "; |
222 |
|
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[4][i]<<" "; |
223 |
cout << endl << "dedx_x : "; for(int i=0; i<6; i++)cout << dedx_x[i] << " "; |
cout << endl << "dedx_x : "; for(int i=0; i<6; i++)cout << dedx_x[i] << " "; |
224 |
cout << endl << "dedx_y : "; for(int i=0; i<6; i++)cout << dedx_y[i] << " "; |
cout << endl << "dedx_y : "; for(int i=0; i<6; i++)cout << dedx_y[i] << " "; |
225 |
|
cout << endl; |
226 |
|
} |
227 |
|
/** |
228 |
|
* Set the TrkTrack position measurements |
229 |
|
*/ |
230 |
|
void TrkTrack::SetMeasure(double *xmeas, double *ymeas, double *zmeas){ |
231 |
|
for(int i=0; i<6; i++) xm[i]=*xmeas++; |
232 |
|
for(int i=0; i<6; i++) ym[i]=*ymeas++; |
233 |
|
for(int i=0; i<6; i++) zm[i]=*zmeas++; |
234 |
|
} |
235 |
|
/** |
236 |
|
* Set the TrkTrack position resolution |
237 |
|
*/ |
238 |
|
void TrkTrack::SetResolution(double *rx, double *ry){ |
239 |
|
for(int i=0; i<6; i++) resx[i]=*rx++; |
240 |
|
for(int i=0; i<6; i++) resy[i]=*ry++; |
241 |
|
} |
242 |
|
/** |
243 |
|
* Set the TrkTrack good measurement |
244 |
|
*/ |
245 |
|
void TrkTrack::SetGood(int *xg, int *yg){ |
246 |
|
for(int i=0; i<6; i++) xgood[i]=*xg++; |
247 |
|
for(int i=0; i<6; i++) ygood[i]=*yg++; |
248 |
|
} |
249 |
|
|
250 |
|
/** |
251 |
|
* Load the magnetic field |
252 |
|
*/ |
253 |
|
void TrkTrack::LoadField(TString path){ |
254 |
|
|
255 |
|
strcpy(path_.path,path.Data()); |
256 |
|
path_.pathlen = path.Length(); |
257 |
|
path_.error = 0; |
258 |
|
readb_(); |
259 |
|
|
260 |
|
}; |
261 |
|
|
262 |
|
/** |
263 |
|
* Method to fill minimization-routine common |
264 |
|
*/ |
265 |
|
void TrkTrack::FillMiniStruct(cMini2track& track){ |
266 |
|
|
267 |
|
for(int i=0; i<6; i++){ |
268 |
|
|
269 |
|
track.xgood[i]=xgood[i]; |
270 |
|
track.ygood[i]=ygood[i]; |
271 |
|
|
272 |
|
track.xm[i]=xm[i]; |
273 |
|
track.ym[i]=ym[i]; |
274 |
|
track.zm[i]=zm[i]; |
275 |
|
|
276 |
|
// --- temporaneo ---------------------------- |
277 |
|
// andrebbe inserita la dimensione del sensore |
278 |
|
float segment = 100.; |
279 |
|
track.xm_a[i]=xm[i]; |
280 |
|
track.xm_b[i]=xm[i]; |
281 |
|
track.ym_a[i]=ym[i]; |
282 |
|
track.ym_b[i]=ym[i]; |
283 |
|
if( xgood[i] && !ygood[i] ){ |
284 |
|
track.ym_a[i] = track.ym_a[i]+segment; |
285 |
|
track.ym_b[i] = track.ym_b[i]-segment; |
286 |
|
}else if( !xgood[i] && ygood[i]){ |
287 |
|
track.xm_a[i] = track.xm_a[i]+segment; |
288 |
|
track.xm_b[i] = track.xm_b[i]-segment; |
289 |
|
} |
290 |
|
// --- temporaneo ---------------------------- |
291 |
|
|
292 |
|
track.resx[i]=resx[i]; |
293 |
|
track.resy[i]=resy[i]; |
294 |
|
} |
295 |
|
|
296 |
|
for(int i=0; i<5; i++) track.al[i]=al[i]; |
297 |
|
track.zini = 23.5; |
298 |
|
// ZINI = 23.5 !!! it should be the same parameter in all codes |
299 |
|
|
300 |
|
} |
301 |
|
/** |
302 |
|
* Method to set values from minimization-routine common |
303 |
|
*/ |
304 |
|
void TrkTrack::SetFromMiniStruct(cMini2track *track){ |
305 |
|
|
306 |
|
for(int i=0; i<5; i++) { |
307 |
|
al[i]=track->al[i]; |
308 |
|
for(int j=0; j<5; j++) coval[i][j]=track->cov[i][j]; |
309 |
|
} |
310 |
|
chi2 = track->chi2; |
311 |
|
nstep = track->nstep; |
312 |
|
for(int i=0; i<6; i++){ |
313 |
|
xv[i] = track->xv[i]; |
314 |
|
yv[i] = track->yv[i]; |
315 |
|
zv[i] = track->zv[i]; |
316 |
|
xm[i] = track->xm[i]; |
317 |
|
ym[i] = track->ym[i]; |
318 |
|
zm[i] = track->zm[i]; |
319 |
|
axv[i] = track->axv[i]; |
320 |
|
ayv[i] = track->ayv[i]; |
321 |
|
} |
322 |
|
|
323 |
|
|
324 |
|
} |
325 |
|
/** |
326 |
|
* Tracking method. It calls F77 mini routine. |
327 |
|
*/ |
328 |
|
void TrkTrack::Fit(double pfixed, int& fail, int iprint){ |
329 |
|
|
330 |
|
float al_ini[] = {0.,0.,0.,0.,0.}; |
331 |
|
|
332 |
|
extern cMini2track track_; |
333 |
|
fail = 0; |
334 |
|
FillMiniStruct(track_); |
335 |
|
|
336 |
|
// if fit variables have been reset, evaluate the initial guess |
337 |
|
if(al[0]==-9999.&&al[1]==-9999.&&al[2]==-9999.&&al[3]==-9999.&&al[4]==-9999.)guess_(); |
338 |
|
|
339 |
|
// --------------------- free momentum |
340 |
|
if(pfixed==0.) { |
341 |
|
track_.pfixed=0.; |
342 |
|
} |
343 |
|
// --------------------- fixed momentum |
344 |
|
if(pfixed!=0.) { |
345 |
|
al[4]=1./pfixed; |
346 |
|
track_.pfixed=pfixed; |
347 |
|
} |
348 |
|
|
349 |
|
// store temporarily the initial guess |
350 |
|
for(int i=0; i<5; i++) al_ini[i]=track_.al[i]; |
351 |
|
|
352 |
|
// ------------------------------------------ |
353 |
|
// call mini routine |
354 |
|
int istep=0; |
355 |
|
int ifail=0; |
356 |
|
mini2_(&istep,&ifail, &iprint); |
357 |
|
if(ifail!=0) { |
358 |
|
if(iprint)cout << "ERROR: ifail= " << ifail << endl; |
359 |
|
fail = 1; |
360 |
|
} |
361 |
|
// ------------------------------------------ |
362 |
|
|
363 |
|
SetFromMiniStruct(&track_); |
364 |
|
// cout << endl << "eta ===> " << track_.al[4] << endl; |
365 |
|
|
366 |
|
// for(int i=0; i<5; i++) al[i]=track_.al[i]; |
367 |
|
// chi2=track_.chi2; |
368 |
|
// nstep=track_.nstep; |
369 |
|
// for(int i=0; i<6; i++) xv[i]=track_.xv[i]; |
370 |
|
// for(int i=0; i<6; i++) yv[i]=track_.yv[i]; |
371 |
|
// for(int i=0; i<6; i++) zv[i]=track_.zv[i]; |
372 |
|
// for(int i=0; i<6; i++) axv[i]=track_.axv[i]; |
373 |
|
// for(int i=0; i<6; i++) ayv[i]=track_.ayv[i]; |
374 |
|
// for(int i=0; i<5; i++) { |
375 |
|
// for(int j=0; j<5; j++) coval[i][j]=track_.cov[i][j]; |
376 |
|
// } |
377 |
|
|
378 |
|
if(fail){ |
379 |
|
if(iprint)cout << " >>>> fit failed >>>> drawing initial par"<<endl; |
380 |
|
for(int i=0; i<5; i++) al[i]=al_ini[i]; |
381 |
|
} |
382 |
|
|
383 |
|
}; |
384 |
|
/* |
385 |
|
* Reset the fit parameters |
386 |
|
*/ |
387 |
|
void TrkTrack::FitReset(){ |
388 |
|
for(int i=0; i<5; i++) al[i]=-9999.; |
389 |
|
chi2=0.; |
390 |
|
nstep=0; |
391 |
|
for(int i=0; i<6; i++) xv[i]=0.; |
392 |
|
for(int i=0; i<6; i++) yv[i]=0.; |
393 |
|
for(int i=0; i<6; i++) zv[i]=0.; |
394 |
|
for(int i=0; i<6; i++) axv[i]=0.; |
395 |
|
for(int i=0; i<6; i++) ayv[i]=0.; |
396 |
|
for(int i=0; i<5; i++) { |
397 |
|
for(int j=0; j<5; j++) coval[i][j]=0.; |
398 |
|
} |
399 |
} |
} |
400 |
|
|
401 |
|
//-------------------------------------- |
402 |
|
// |
403 |
|
// |
404 |
|
//-------------------------------------- |
405 |
|
void TrkTrack::Clear(){ |
406 |
|
seqno = -1; |
407 |
|
image = -1; |
408 |
|
chi2 = 0; |
409 |
|
nstep = 0; |
410 |
|
for(int it1=0;it1<5;it1++){ |
411 |
|
al[it1] = 0; |
412 |
|
for(int it2=0;it2<5;it2++)coval[it1][it2] = 0; |
413 |
|
}; |
414 |
|
for(int ip=0;ip<6;ip++){ |
415 |
|
xgood[ip] = 0; |
416 |
|
ygood[ip] = 0; |
417 |
|
xm[ip] = 0; |
418 |
|
ym[ip] = 0; |
419 |
|
zm[ip] = 0; |
420 |
|
resx[ip] = 0; |
421 |
|
resy[ip] = 0; |
422 |
|
xv[ip] = 0; |
423 |
|
yv[ip] = 0; |
424 |
|
zv[ip] = 0; |
425 |
|
axv[ip] = 0; |
426 |
|
ayv[ip] = 0; |
427 |
|
dedx_x[ip] = 0; |
428 |
|
dedx_y[ip] = 0; |
429 |
|
// clx[ip] = 0; |
430 |
|
// cly[ip] = 0; |
431 |
|
}; |
432 |
|
clx->Clear(); |
433 |
|
cly->Clear(); |
434 |
|
}; |
435 |
|
//-------------------------------------- |
436 |
|
// |
437 |
|
// |
438 |
|
//-------------------------------------- |
439 |
|
void TrkTrack::Delete(){ |
440 |
|
Clear(); |
441 |
|
clx->Delete(); |
442 |
|
cly->Delete(); |
443 |
|
}; |
444 |
|
//-------------------------------------- |
445 |
|
// |
446 |
|
// |
447 |
|
//-------------------------------------- |
448 |
|
|
449 |
//-------------------------------------- |
//-------------------------------------- |
450 |
// |
// |
451 |
// |
// |
455 |
coord[0] = 0; |
coord[0] = 0; |
456 |
coord[1] = 0; |
coord[1] = 0; |
457 |
sgnl = 0; |
sgnl = 0; |
458 |
|
cls = 0; |
459 |
}; |
}; |
460 |
//-------------------------------------- |
//-------------------------------------- |
461 |
// |
// |
466 |
coord[0] = s.coord[0]; |
coord[0] = s.coord[0]; |
467 |
coord[1] = s.coord[1]; |
coord[1] = s.coord[1]; |
468 |
sgnl = s.sgnl; |
sgnl = s.sgnl; |
469 |
|
// cls = 0;//<<<<pointer |
470 |
|
cls = TRef(s.cls); |
471 |
}; |
}; |
472 |
//-------------------------------------- |
//-------------------------------------- |
473 |
// |
// |
485 |
// |
// |
486 |
//-------------------------------------- |
//-------------------------------------- |
487 |
TrkLevel2::TrkLevel2(){ |
TrkLevel2::TrkLevel2(){ |
488 |
good2 = -1; |
// good2 = -1; |
489 |
for(Int_t i=0; i<12 ; i++){ |
for(Int_t i=0; i<12 ; i++){ |
490 |
crc[i] = -1; |
// crc[i] = -1; |
491 |
}; |
good[i] = -1; |
492 |
|
}; |
493 |
Track = new TClonesArray("TrkTrack"); |
Track = new TClonesArray("TrkTrack"); |
494 |
SingletX = new TClonesArray("TrkSinglet"); |
SingletX = new TClonesArray("TrkSinglet"); |
495 |
SingletY = new TClonesArray("TrkSinglet"); |
SingletY = new TClonesArray("TrkSinglet"); |
496 |
// Track = 0; |
|
497 |
// Singlet = 0; |
// PhysicalTrack = new TClonesArray("TrkTrack"); |
498 |
// SingletY = 0; |
//sostituire con TRefArray... appena ho capito come si usa |
499 |
} |
} |
500 |
//-------------------------------------- |
//-------------------------------------- |
501 |
// |
// |
502 |
// |
// |
503 |
//-------------------------------------- |
//-------------------------------------- |
504 |
void TrkLevel2::Dump(){ |
void TrkLevel2::Dump(){ |
505 |
|
|
506 |
TClonesArray &t = *Track; |
TClonesArray &t = *Track; |
507 |
TClonesArray &sx = *SingletX; |
TClonesArray &sx = *SingletX; |
508 |
TClonesArray &sy = *SingletY; |
TClonesArray &sy = *SingletY; |
509 |
|
// |
510 |
cout << endl << endl << "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"; |
cout << endl << endl << "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"; |
511 |
cout << endl << "good2 : " << good2; |
cout << endl << "good : "; for(int i=0; i<12; i++) cout << good[i]<<" "; |
|
cout << endl << "crc : "; for(int i=0; i<12; i++) cout << crc[i]; |
|
512 |
cout << endl << "ntrk() : " << this->ntrk() ; |
cout << endl << "ntrk() : " << this->ntrk() ; |
513 |
cout << endl << "nclsx() : " << this->nclsx(); |
cout << endl << "nclsx() : " << this->nclsx(); |
514 |
cout << endl << "nclsy() : " << this->nclsy(); |
cout << endl << "nclsy() : " << this->nclsy(); |
523 |
/** |
/** |
524 |
* Fills a TrkLevel2 object with values from a struct cTrkLevel2 (to get data from F77 common). |
* Fills a TrkLevel2 object with values from a struct cTrkLevel2 (to get data from F77 common). |
525 |
*/ |
*/ |
526 |
void TrkLevel2::FillCommonVar(cTrkLevel2 *l2){ |
void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2){ |
527 |
// |
|
528 |
// Track = new TClonesArray("TrkTrack"); |
// temporary objects: |
|
// SingletX = new TClonesArray("TrkSinglet"); |
|
|
// SingletY = new TClonesArray("TrkSinglet"); |
|
|
// temporary objects: |
|
529 |
TrkSinglet* t_singlet = new TrkSinglet(); |
TrkSinglet* t_singlet = new TrkSinglet(); |
530 |
TrkTrack* t_track = new TrkTrack(); |
TrkTrack* t_track = new TrkTrack(); |
531 |
// general variables |
|
532 |
good2 = l2->good2; |
// **** general variables **** |
533 |
|
// good2 = l2->good2; |
534 |
for(Int_t i=0; i<12 ; i++){ |
for(Int_t i=0; i<12 ; i++){ |
535 |
crc[i] = l2->crc[i]; |
// crc[i] = l2->crc[i]; |
536 |
}; |
good[i] = l2->good[i]; |
537 |
// *** TRACKS *** |
}; |
538 |
|
// *** TRACKS *** |
539 |
TClonesArray &t = *Track; |
TClonesArray &t = *Track; |
540 |
for(int i=0; i<l2->ntrk; i++){ |
for(int i=0; i<l2->ntrk; i++){ |
541 |
t_track->seqno = i; |
t_track->seqno = i;// NBNBNBNB deve sempre essere = i |
542 |
t_track->image = l2->image[i]-1; |
t_track->image = l2->image[i]-1; |
543 |
// cout << "track "<<i<<t_track->seqno << t_track->image<<endl; |
// cout << "track "<<i<<t_track->seqno << t_track->image<<endl; |
544 |
t_track->chi2 = l2->chi2_nt[i]; |
t_track->chi2 = l2->chi2_nt[i]; |
545 |
for(int it1=0;it1<5;it1++){ |
t_track->nstep = l2->nstep_nt[i]; |
546 |
t_track->al[it1] = l2->al_nt[i][it1]; |
for(int it1=0;it1<5;it1++){ |
547 |
for(int it2=0;it2<5;it2++) |
t_track->al[it1] = l2->al_nt[i][it1]; |
548 |
t_track->coval[it1][it2] = l2->coval[i][it2][it1]; |
for(int it2=0;it2<5;it2++) |
549 |
}; |
t_track->coval[it1][it2] = l2->coval[i][it2][it1]; |
550 |
for(int ip=0;ip<6;ip++){ |
}; |
551 |
t_track->xgood[ip] = l2->xgood_nt[i][ip]; |
for(int ip=0;ip<6;ip++){ |
552 |
t_track->ygood[ip] = l2->ygood_nt[i][ip]; |
t_track->xgood[ip] = l2->xgood_nt[i][ip]; |
553 |
t_track->xm[ip] = l2->xm_nt[i][ip]; |
t_track->ygood[ip] = l2->ygood_nt[i][ip]; |
554 |
t_track->ym[ip] = l2->ym_nt[i][ip]; |
t_track->xm[ip] = l2->xm_nt[i][ip]; |
555 |
t_track->zm[ip] = l2->zm_nt[i][ip]; |
t_track->ym[ip] = l2->ym_nt[i][ip]; |
556 |
t_track->resx[ip] = l2->resx_nt[i][ip]; |
t_track->zm[ip] = l2->zm_nt[i][ip]; |
557 |
t_track->resy[ip] = l2->resy_nt[i][ip]; |
t_track->resx[ip] = l2->resx_nt[i][ip]; |
558 |
t_track->xv[ip] = l2->xv_nt[i][ip]; |
t_track->resy[ip] = l2->resy_nt[i][ip]; |
559 |
t_track->yv[ip] = l2->yv_nt[i][ip]; |
t_track->xv[ip] = l2->xv_nt[i][ip]; |
560 |
t_track->zv[ip] = l2->zv_nt[i][ip]; |
t_track->yv[ip] = l2->yv_nt[i][ip]; |
561 |
t_track->axv[ip] = l2->axv_nt[i][ip]; |
t_track->zv[ip] = l2->zv_nt[i][ip]; |
562 |
t_track->ayv[ip] = l2->ayv_nt[i][ip]; |
t_track->axv[ip] = l2->axv_nt[i][ip]; |
563 |
t_track->dedx_x[ip] = l2->dedx_x[i][ip]; |
t_track->ayv[ip] = l2->ayv_nt[i][ip]; |
564 |
t_track->dedx_y[ip] = l2->dedx_y[i][ip]; |
t_track->dedx_x[ip] = l2->dedx_x[i][ip]; |
565 |
}; |
t_track->dedx_y[ip] = l2->dedx_y[i][ip]; |
566 |
new(t[i]) TrkTrack(*t_track); |
// t_track->clx[ip] = 0; |
567 |
t_track->Clear(); |
// t_track->cly[ip] = 0; |
568 |
|
}; |
569 |
|
new(t[i]) TrkTrack(*t_track); |
570 |
|
t_track->Clear(); |
571 |
}; |
}; |
572 |
// *** SINGLETS *** |
// *** SINGLETS *** |
573 |
TClonesArray &sx = *SingletX; |
TClonesArray &sx = *SingletX; |
574 |
for(int i=0; i<l2->nclsx; i++){ |
for(int i=0; i<l2->nclsx; i++){ |
575 |
t_singlet->plane = l2->planex[i]; |
t_singlet->plane = l2->planex[i]; |
576 |
t_singlet->coord[0] = l2->xs[i][0]; |
t_singlet->coord[0] = l2->xs[i][0]; |
577 |
t_singlet->coord[1] = l2->xs[i][1]; |
t_singlet->coord[1] = l2->xs[i][1]; |
578 |
t_singlet->sgnl = l2->signlxs[i]; |
t_singlet->sgnl = l2->signlxs[i]; |
579 |
new(sx[i]) TrkSinglet(*t_singlet); |
// t_singlet->cls = 0; |
580 |
t_singlet->Clear(); |
new(sx[i]) TrkSinglet(*t_singlet); |
581 |
|
t_singlet->Clear(); |
582 |
} |
} |
583 |
TClonesArray &sy = *SingletY; |
TClonesArray &sy = *SingletY; |
584 |
for(int i=0; i<l2->nclsy; i++){ |
for(int i=0; i<l2->nclsy; i++){ |
585 |
t_singlet->plane = l2->planey[i]; |
t_singlet->plane = l2->planey[i]; |
586 |
t_singlet->coord[0] = l2->ys[i][0]; |
t_singlet->coord[0] = l2->ys[i][0]; |
587 |
t_singlet->coord[1] = l2->ys[i][1]; |
t_singlet->coord[1] = l2->ys[i][1]; |
588 |
t_singlet->sgnl = l2->signlys[i]; |
t_singlet->sgnl = l2->signlys[i]; |
589 |
new(sy[i]) TrkSinglet(*t_singlet); |
// t_singlet->cls = 0; |
590 |
t_singlet->Clear(); |
new(sy[i]) TrkSinglet(*t_singlet); |
591 |
|
t_singlet->Clear(); |
592 |
}; |
}; |
593 |
|
|
594 |
|
delete t_track; |
595 |
|
delete t_singlet; |
596 |
} |
} |
597 |
//-------------------------------------- |
//-------------------------------------- |
598 |
// |
// |
599 |
// |
// |
600 |
//-------------------------------------- |
//-------------------------------------- |
601 |
void TrkLevel2::Clear(){ |
/** |
602 |
good2 = -1; |
* Fills a TrkLevel2 object with values from a struct cTrkLevel2 (to get data from F77 common). |
603 |
|
* Ref to Level1 data (clusters) is also set. |
604 |
|
*/ |
605 |
|
void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2, TrkLevel1 *l1){ |
606 |
|
|
607 |
|
// temporary objects: |
608 |
|
TrkSinglet* t_singlet = new TrkSinglet(); |
609 |
|
TrkTrack* t_track = new TrkTrack(); |
610 |
|
// general variables |
611 |
|
// good2 = l2->good2; |
612 |
|
for(Int_t i=0; i<12 ; i++){ |
613 |
|
// crc[i] = l2->crc[i]; |
614 |
|
good[i] = l2->good[i]; |
615 |
|
}; |
616 |
|
// *** TRACKS *** |
617 |
|
TClonesArray &t = *Track; |
618 |
|
for(int i=0; i<l2->ntrk; i++){ |
619 |
|
t_track->seqno = i;// NBNBNBNB deve sempre essere = i |
620 |
|
t_track->image = l2->image[i]-1; |
621 |
|
// cout << "track "<<i<<t_track->seqno << t_track->image<<endl; |
622 |
|
t_track->chi2 = l2->chi2_nt[i]; |
623 |
|
t_track->nstep = l2->nstep_nt[i]; |
624 |
|
for(int it1=0;it1<5;it1++){ |
625 |
|
t_track->al[it1] = l2->al_nt[i][it1]; |
626 |
|
for(int it2=0;it2<5;it2++) |
627 |
|
t_track->coval[it1][it2] = l2->coval[i][it2][it1]; |
628 |
|
}; |
629 |
|
for(int ip=0;ip<6;ip++){ |
630 |
|
t_track->xgood[ip] = l2->xgood_nt[i][ip]; |
631 |
|
t_track->ygood[ip] = l2->ygood_nt[i][ip]; |
632 |
|
t_track->xm[ip] = l2->xm_nt[i][ip]; |
633 |
|
t_track->ym[ip] = l2->ym_nt[i][ip]; |
634 |
|
t_track->zm[ip] = l2->zm_nt[i][ip]; |
635 |
|
t_track->resx[ip] = l2->resx_nt[i][ip]; |
636 |
|
t_track->resy[ip] = l2->resy_nt[i][ip]; |
637 |
|
t_track->xv[ip] = l2->xv_nt[i][ip]; |
638 |
|
t_track->yv[ip] = l2->yv_nt[i][ip]; |
639 |
|
t_track->zv[ip] = l2->zv_nt[i][ip]; |
640 |
|
t_track->axv[ip] = l2->axv_nt[i][ip]; |
641 |
|
t_track->ayv[ip] = l2->ayv_nt[i][ip]; |
642 |
|
t_track->dedx_x[ip] = l2->dedx_x[i][ip]; |
643 |
|
t_track->dedx_y[ip] = l2->dedx_y[i][ip]; |
644 |
|
// cout << "traccia "<<i<<" -- "<< ip << " "<< l2->cltrx[i][ip] <<" "<< l2->cltry[i][ip] <<" "<< t_track->xgood[ip] << t_track->ygood[ip]<<endl; |
645 |
|
//----------------------------------------------------- |
646 |
|
// t_track->clx[ip] = l1->GetCluster(l2->cltrx[i][ip]-1); |
647 |
|
// t_track->cly[ip] = l1->GetCluster(l2->cltry[i][ip]-1); |
648 |
|
if(t_track->xgood[ip])t_track->clx->AddAt(l1->GetCluster(l2->cltrx[i][ip]-1),ip); |
649 |
|
if(t_track->ygood[ip])t_track->cly->AddAt(l1->GetCluster(l2->cltry[i][ip]-1),ip); |
650 |
|
// if(t_track->ygood[ip])cout<<" i "<<i<<" ip "<<ip<<" l2->cltry[i][ip] "<<l2->cltry[i][ip]<< " l1->GetCluster(l2->cltry[i][ip]-1) "<<l1->GetCluster(l2->cltry[i][ip]-1)<<endl; |
651 |
|
// if(t_track->xgood[ip])cout<<" i "<<i<<" ip "<<ip<<" l2->cltrx[i][ip] "<<l2->cltrx[i][ip]<< " l1->GetCluster(l2->cltrx[i][ip]-1) "<<l1->GetCluster(l2->cltrx[i][ip]-1)<<endl; |
652 |
|
//----------------------------------------------------- |
653 |
|
}; |
654 |
|
new(t[i]) TrkTrack(*t_track); |
655 |
|
t_track->Clear(); |
656 |
|
}; |
657 |
|
// *** SINGLETS *** |
658 |
|
TClonesArray &sx = *SingletX; |
659 |
|
for(int i=0; i<l2->nclsx; i++){ |
660 |
|
t_singlet->plane = l2->planex[i]; |
661 |
|
t_singlet->coord[0] = l2->xs[i][0]; |
662 |
|
t_singlet->coord[1] = l2->xs[i][1]; |
663 |
|
t_singlet->sgnl = l2->signlxs[i]; |
664 |
|
//----------------------------------------------------- |
665 |
|
// cout << "singolo x "<<i<<" -- "<< l2->clsx[i] <<endl; |
666 |
|
t_singlet->cls = l1->GetCluster(l2->clsx[i]-1); |
667 |
|
// cout<<" i "<<i<<" l2->clsx[i] "<<l2->clsx[i]<< " l1->GetCluster(l2->clsx[i]-1) "<<l1->GetCluster(l2->clsx[i]-1)<<endl; |
668 |
|
//----------------------------------------------------- |
669 |
|
new(sx[i]) TrkSinglet(*t_singlet); |
670 |
|
t_singlet->Clear(); |
671 |
|
} |
672 |
|
TClonesArray &sy = *SingletY; |
673 |
|
for(int i=0; i<l2->nclsy; i++){ |
674 |
|
t_singlet->plane = l2->planey[i]; |
675 |
|
t_singlet->coord[0] = l2->ys[i][0]; |
676 |
|
t_singlet->coord[1] = l2->ys[i][1]; |
677 |
|
t_singlet->sgnl = l2->signlys[i]; |
678 |
|
//----------------------------------------------------- |
679 |
|
// cout << "singolo y "<<i<<" -- "<< l2->clsy[i] <<endl; |
680 |
|
t_singlet->cls = l1->GetCluster(l2->clsy[i]-1); |
681 |
|
// cout<<" i "<<i<<" l2->clsy[i] "<<l2->clsy[i]<< " l1->GetCluster(l2->clsy[i]-1) "<<l1->GetCluster(l2->clsy[i]-1)<<endl; |
682 |
|
//----------------------------------------------------- |
683 |
|
new(sy[i]) TrkSinglet(*t_singlet); |
684 |
|
t_singlet->Clear(); |
685 |
|
}; |
686 |
|
|
687 |
|
delete t_track; |
688 |
|
delete t_singlet; |
689 |
|
} |
690 |
|
/** |
691 |
|
* Fills a struct cTrkLevel2 with values from a TrkLevel2 object (to put data into a F77 common). |
692 |
|
*/ |
693 |
|
|
694 |
|
void TrkLevel2::GetLevel2Struct(cTrkLevel2 *l2) const { |
695 |
|
|
696 |
|
// general variables |
697 |
|
// l2->good2 = good2 ; |
698 |
for(Int_t i=0; i<12 ; i++){ |
for(Int_t i=0; i<12 ; i++){ |
699 |
crc[i] = -1; |
// l2->crc[i] = crc[i]; |
700 |
|
l2->good[i] = good[i]; |
701 |
}; |
}; |
702 |
Track->RemoveAll(); |
// *** TRACKS *** |
703 |
|
|
704 |
|
l2->ntrk = Track->GetEntries(); |
705 |
|
for(Int_t i=0;i<l2->ntrk;i++){ |
706 |
|
l2->image[i] = 1 + ((TrkTrack *)Track->At(i))->image; |
707 |
|
l2->chi2_nt[i] = ((TrkTrack *)Track->At(i))->chi2; |
708 |
|
l2->nstep_nt[i] = ((TrkTrack *)Track->At(i))->nstep; |
709 |
|
for(int it1=0;it1<5;it1++){ |
710 |
|
l2->al_nt[i][it1] = ((TrkTrack *)Track->At(i))->al[it1]; |
711 |
|
for(int it2=0;it2<5;it2++) |
712 |
|
l2->coval[i][it2][it1] = ((TrkTrack *)Track->At(i))->coval[it1][it2]; |
713 |
|
}; |
714 |
|
for(int ip=0;ip<6;ip++){ |
715 |
|
l2->xgood_nt[i][ip] = ((TrkTrack *)Track->At(i))->xgood[ip]; |
716 |
|
l2->ygood_nt[i][ip] = ((TrkTrack *)Track->At(i))->ygood[ip]; |
717 |
|
l2->xm_nt[i][ip] = ((TrkTrack *)Track->At(i))->xm[ip]; |
718 |
|
l2->ym_nt[i][ip] = ((TrkTrack *)Track->At(i))->ym[ip]; |
719 |
|
l2->zm_nt[i][ip] = ((TrkTrack *)Track->At(i))->zm[ip]; |
720 |
|
l2->resx_nt[i][ip] = ((TrkTrack *)Track->At(i))->resx[ip]; |
721 |
|
l2->resy_nt[i][ip] = ((TrkTrack *)Track->At(i))->resy[ip]; |
722 |
|
l2->xv_nt[i][ip] = ((TrkTrack *)Track->At(i))->xv[ip]; |
723 |
|
l2->yv_nt[i][ip] = ((TrkTrack *)Track->At(i))->yv[ip]; |
724 |
|
l2->zv_nt[i][ip] = ((TrkTrack *)Track->At(i))->zv[ip]; |
725 |
|
l2->axv_nt[i][ip] = ((TrkTrack *)Track->At(i))->axv[ip]; |
726 |
|
l2->ayv_nt[i][ip] = ((TrkTrack *)Track->At(i))->ayv[ip]; |
727 |
|
l2->dedx_x[i][ip] = ((TrkTrack *)Track->At(i))->dedx_x[ip]; |
728 |
|
l2->dedx_y[i][ip] = ((TrkTrack *)Track->At(i))->dedx_y[ip]; |
729 |
|
}; |
730 |
|
} |
731 |
|
|
732 |
|
// *** SINGLETS *** |
733 |
|
l2->nclsx = SingletX->GetEntries(); |
734 |
|
for(Int_t i=0;i<l2->nclsx;i++){ |
735 |
|
l2->planex[i] = ((TrkSinglet *)SingletX->At(i))->plane; |
736 |
|
l2->xs[i][0] = ((TrkSinglet *)SingletX->At(i))->coord[0]; |
737 |
|
l2->xs[i][1] = ((TrkSinglet *)SingletX->At(i))->coord[1]; |
738 |
|
l2->signlxs[i] = ((TrkSinglet *)SingletX->At(i))->sgnl; |
739 |
|
} |
740 |
|
l2->nclsy = SingletY->GetEntries(); |
741 |
|
for(Int_t i=0;i<l2->nclsy;i++){ |
742 |
|
l2->planey[i] = ((TrkSinglet *)SingletY->At(i))->plane; |
743 |
|
l2->ys[i][0] = ((TrkSinglet *)SingletY->At(i))->coord[0]; |
744 |
|
l2->ys[i][1] = ((TrkSinglet *)SingletY->At(i))->coord[1]; |
745 |
|
l2->signlys[i] = ((TrkSinglet *)SingletY->At(i))->sgnl; |
746 |
|
} |
747 |
|
} |
748 |
|
//-------------------------------------- |
749 |
|
// |
750 |
|
// |
751 |
|
//-------------------------------------- |
752 |
|
void TrkLevel2::Clear(){ |
753 |
|
// good2 = -1; |
754 |
|
for(Int_t i=0; i<12 ; i++){ |
755 |
|
// crc[i] = -1; |
756 |
|
good[i] = -1; |
757 |
|
}; |
758 |
|
/* Track->RemoveAll(); |
759 |
SingletX->RemoveAll(); |
SingletX->RemoveAll(); |
760 |
SingletY->RemoveAll(); |
SingletY->RemoveAll();*/ |
761 |
|
// modify to avoid memory leakage |
762 |
|
Track->Clear(); |
763 |
|
SingletX->Clear(); |
764 |
|
SingletY->Clear(); |
765 |
|
} |
766 |
|
//-------------------------------------- |
767 |
|
// |
768 |
|
// |
769 |
|
//-------------------------------------- |
770 |
|
void TrkLevel2::Delete(){ |
771 |
|
|
772 |
|
Clear(); |
773 |
|
Track->Delete(); |
774 |
|
SingletX->Delete(); |
775 |
|
SingletY->Delete(); |
776 |
} |
} |
777 |
//-------------------------------------- |
//-------------------------------------- |
778 |
// |
// |
782 |
* Sort physical tracks and stores them in a TObjectArray, ordering by increasing chi**2 value (in case of track image, it selects the one with lower chi**2). The total number of physical tracks is given by GetNTracks() and the it-th physical track can be retrieved by means of the method GetTrack(int it). |
* Sort physical tracks and stores them in a TObjectArray, ordering by increasing chi**2 value (in case of track image, it selects the one with lower chi**2). The total number of physical tracks is given by GetNTracks() and the it-th physical track can be retrieved by means of the method GetTrack(int it). |
783 |
* This method is overridden by PamLevel2::GetTracks(), where calorimeter and TOF information is used. |
* This method is overridden by PamLevel2::GetTracks(), where calorimeter and TOF information is used. |
784 |
*/ |
*/ |
785 |
TClonesArray *TrkLevel2::GetTracks(){ |
TRefArray *TrkLevel2::GetTracks_NFitSorted(){ |
|
TClonesArray *sorted = GetTracks_NFitSorted(); |
|
|
return sorted; |
|
|
}; |
|
|
|
|
|
TClonesArray *TrkLevel2::GetTracks_Chi2Sorted(){ |
|
786 |
|
|
787 |
TClonesArray *sorted = new TClonesArray("TrkTrack"); |
TRefArray *sorted = new TRefArray(); |
788 |
TClonesArray &t = *Track; |
|
789 |
TClonesArray &ts = *sorted; |
TClonesArray &t = *Track; |
790 |
int N=this->ntrk(); |
// TClonesArray &ts = *PhysicalTrack; |
791 |
vector<int> m(N); for(int i=0; i<N; i++)m[i]=1; |
int N = ntrk(); |
792 |
|
vector<int> m(N); for(int i=0; i<N; i++)m[i]=1; |
793 |
int indo=0; |
// int m[50]; for(int i=0; i<N; i++)m[i]=1; |
794 |
int indi=0; |
|
795 |
while(N != 0){ |
int indo=0; |
796 |
float chi2ref=1000000; |
int indi=0; |
797 |
for(int i=0; i<this->ntrk(); i++){ |
while(N != 0){ |
798 |
if(((TrkTrack *)t[i])->chi2 < chi2ref && m[i]==1){ |
int nfit =0; |
799 |
chi2ref = ((TrkTrack *)t[i])->chi2; |
float chi2ref = numeric_limits<float>::max(); |
800 |
indi = i; |
|
801 |
} |
// first loop to search maximum num. of fit points |
802 |
} |
for(int i=0; i < ntrk(); i++){ |
803 |
if( ((TrkTrack *)t[indi])->image != -1 ){ |
if( ((TrkTrack *)t[i])->GetNtot() >= nfit && m[i]==1){ |
804 |
m[((TrkTrack *)t[indi])->image] = 0; |
nfit = ((TrkTrack *)t[i])->GetNtot(); |
805 |
N--; |
} |
806 |
} |
} |
807 |
new(ts[indo]) TrkTrack(*(TrkTrack*)t[indi]); |
//second loop to search minimum chi2 among selected |
808 |
m[indi] = 0; |
for(int i=0; i<this->ntrk(); i++){ |
809 |
N--; |
Float_t chi2 = ((TrkTrack *)t[i])->chi2; |
810 |
indo++; |
if(chi2 < 0) chi2 = chi2*1000; |
811 |
} |
if( chi2 < chi2ref |
812 |
return sorted; |
&& ((TrkTrack *)t[i])->GetNtot() == nfit |
813 |
} |
&& m[i]==1){ |
814 |
TClonesArray *TrkLevel2::GetTracks_NFitSorted(){ |
chi2ref = ((TrkTrack *)t[i])->chi2; |
815 |
|
indi = i; |
816 |
TClonesArray *sorted = new TClonesArray("TrkTrack"); |
}; |
817 |
TClonesArray &t = *Track; |
}; |
818 |
TClonesArray &ts = *sorted; |
if( ((TrkTrack *)t[indi])->HasImage() ){ |
819 |
int N=this->ntrk(); |
m[((TrkTrack *)t[indi])->image] = 0; |
820 |
vector<int> m(N); for(int i=0; i<N; i++)m[i]=1; |
N--; |
821 |
|
|
822 |
int indo=0; |
// cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl; |
823 |
int indi=0; |
}; |
824 |
while(N != 0){ |
sorted->Add( (TrkTrack*)t[indi] ); |
|
int nfit =0; |
|
|
float chi2ref=1000000; |
|
|
// first loop to search maximum num. of fit points |
|
|
for(int i=0; i<this->ntrk(); i++){ |
|
|
if( ((TrkTrack *)t[i])->GetNtot() >= nfit && m[i]==1){ |
|
|
nfit = ((TrkTrack *)t[i])->GetNtot(); |
|
|
// cout << "1** "<<i<< " " << nfit<<endl; |
|
|
} |
|
|
} |
|
|
//second loop to search minimum chi2 among selected |
|
|
for(int i=0; i<this->ntrk(); i++){ |
|
|
if( ((TrkTrack *)t[i])->chi2 < chi2ref |
|
|
&& ((TrkTrack *)t[i])->GetNtot()== nfit |
|
|
&& m[i]==1){ |
|
|
chi2ref = ((TrkTrack *)t[i])->chi2; |
|
|
indi = i; |
|
|
// cout << "2** "<<i<< " " << nfit <<" "<<chi2ref<<endl; |
|
|
} |
|
|
} |
|
|
if( ((TrkTrack *)t[indi])->HasImage() ){ |
|
|
m[((TrkTrack *)t[indi])->image] = 0; |
|
|
N--; |
|
|
|
|
|
// Int_t nfiti=((TrkTrack *)t[((TrkTrack *)t[indi])->image ])->GetNtot(); |
|
|
// Float_t chi2i=((TrkTrack *)t[((TrkTrack *)t[indi])->image ])->chi2; |
|
825 |
|
|
826 |
// cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl; |
m[indi] = 0; |
827 |
|
// cout << "SORTED "<< indo << " "<< indi << " "<< N << endl; |
828 |
|
N--; |
829 |
|
indo++; |
830 |
} |
} |
831 |
new(ts[indo]) TrkTrack(*(TrkTrack*)t[indi]); |
m.clear(); |
832 |
m[indi] = 0; |
// cout << "GetTracks_NFitSorted(it): Done"<< endl; |
833 |
N--; |
|
834 |
indo++; |
return sorted; |
835 |
} |
// return PhysicalTrack; |
|
return sorted; |
|
836 |
} |
} |
837 |
//-------------------------------------- |
//-------------------------------------- |
838 |
// |
// |
859 |
// |
// |
860 |
//-------------------------------------- |
//-------------------------------------- |
861 |
/** |
/** |
862 |
|
* Retrieves the is-th stored X singlet. |
863 |
|
* @param it Singlet number, ranging from 0 to nclsx(). |
864 |
|
*/ |
865 |
|
TrkSinglet *TrkLevel2::GetSingletX(int is){ |
866 |
|
|
867 |
|
if(is >= this->nclsx()){ |
868 |
|
cout << "** TrkLevel2 ** Singlet "<< is << "doen not exits! " << endl; |
869 |
|
cout << " Stored x-singlets nclsx() = "<< this->nclsx() << endl; |
870 |
|
return 0; |
871 |
|
} |
872 |
|
TClonesArray &t = *(SingletX); |
873 |
|
TrkSinglet *singlet = (TrkSinglet*)t[is]; |
874 |
|
return singlet; |
875 |
|
} |
876 |
|
//-------------------------------------- |
877 |
|
// |
878 |
|
// |
879 |
|
//-------------------------------------- |
880 |
|
/** |
881 |
|
* Retrieves the is-th stored Y singlet. |
882 |
|
* @param it Singlet number, ranging from 0 to nclsx(). |
883 |
|
*/ |
884 |
|
TrkSinglet *TrkLevel2::GetSingletY(int is){ |
885 |
|
|
886 |
|
if(is >= this->nclsy()){ |
887 |
|
cout << "** TrkLevel2 ** Singlet "<< is << "doen not exits! " << endl; |
888 |
|
cout << " Stored y-singlets nclsy() = "<< this->nclsx() << endl; |
889 |
|
return 0; |
890 |
|
} |
891 |
|
TClonesArray &t = *(SingletY); |
892 |
|
TrkSinglet *singlet = (TrkSinglet*)t[is]; |
893 |
|
return singlet; |
894 |
|
} |
895 |
|
//-------------------------------------- |
896 |
|
// |
897 |
|
// |
898 |
|
//-------------------------------------- |
899 |
|
/** |
900 |
* Retrieves the it-th "physical" track, sorted by the method GetNTracks(). |
* Retrieves the it-th "physical" track, sorted by the method GetNTracks(). |
901 |
* @param it Track number, ranging from 0 to GetNTracks(). |
* @param it Track number, ranging from 0 to GetNTracks(). |
902 |
*/ |
*/ |
903 |
|
|
904 |
TrkTrack *TrkLevel2::GetTrack(int it){ |
TrkTrack *TrkLevel2::GetTrack(int it){ |
905 |
|
|
906 |
if(it >= this->GetNTracks()){ |
if(it >= this->GetNTracks()){ |
907 |
cout << "** TrkLevel2 ** Track "<< it << "does not exits! " << endl; |
cout << "** TrkLevel2 ** Track "<< it << "does not exits! " << endl; |
908 |
cout << " Physical tracks GetNTracks() = "<< this->ntrk() << endl; |
cout << " Physical tracks GetNTracks() = "<< this->ntrk() << endl; |
909 |
return 0; |
return 0; |
910 |
} |
} |
911 |
TrkTrack *track = (TrkTrack*)(*(this->GetTracks()))[it]; |
|
912 |
return track; |
TRefArray *sorted = GetTracks(); //TEMPORANEO |
913 |
|
TrkTrack *track = (TrkTrack*)sorted->At(it); |
914 |
|
sorted->Delete(); |
915 |
|
return track; |
916 |
} |
} |
917 |
|
/** |
918 |
|
* Give the number of "physical" tracks, sorted by the method GetTracks(). |
919 |
|
*/ |
920 |
|
Int_t TrkLevel2::GetNTracks(){ |
921 |
|
|
922 |
|
Float_t ntot=0; |
923 |
|
TClonesArray &t = *Track; |
924 |
|
for(int i=0; i<ntrk(); i++) { |
925 |
|
if( ((TrkTrack *)t[i])->GetImageSeqNo() == -1 ) ntot+=1.; |
926 |
|
else ntot+=0.5; |
927 |
|
} |
928 |
|
return (Int_t)ntot; |
929 |
|
|
930 |
|
}; |
931 |
//-------------------------------------- |
//-------------------------------------- |
932 |
// |
// |
933 |
// |
// |
938 |
*/ |
*/ |
939 |
TrkTrack *TrkLevel2::GetTrackImage(int it){ |
TrkTrack *TrkLevel2::GetTrackImage(int it){ |
940 |
|
|
941 |
if(it >= this->GetNTracks()){ |
if(it >= this->GetNTracks()){ |
942 |
cout << "** TrkLevel2 ** Track "<< it << "does not exits! " << endl; |
cout << "** TrkLevel2 ** Track "<< it << "does not exits! " << endl; |
943 |
cout << " Physical tracks GetNTracks() = "<< this->ntrk() << endl; |
cout << " Physical tracks GetNTracks() = "<< this->ntrk() << endl; |
944 |
return 0; |
return 0; |
945 |
} |
} |
946 |
TrkTrack *track = (TrkTrack*)(*(this->GetTracks()))[it]; |
|
947 |
if(!track->HasImage()){ |
TRefArray* sorted = GetTracks(); //TEMPORANEO |
948 |
cout << "** TrkLevel2 ** Track "<< it << "does not have image! " << endl; |
TrkTrack *track = (TrkTrack*)sorted->At(it); |
949 |
return 0; |
|
950 |
} |
if(!track->HasImage()){ |
951 |
TrkTrack *image = (TrkTrack*)(*Track)[track->image]; |
cout << "** TrkLevel2 ** Track "<< it << "does not have image! " << endl; |
952 |
return image; |
return 0; |
953 |
|
} |
954 |
|
TrkTrack *image = (TrkTrack*)(*Track)[track->image]; |
955 |
|
|
956 |
|
sorted->Delete(); |
957 |
|
|
958 |
|
return image; |
959 |
|
|
960 |
} |
} |
961 |
//-------------------------------------- |
//-------------------------------------- |
966 |
* Loads the magnetic field. |
* Loads the magnetic field. |
967 |
* @param s Path of the magnetic-field files. |
* @param s Path of the magnetic-field files. |
968 |
*/ |
*/ |
969 |
void TrkLevel2::LoadField(TString s){ |
void TrkLevel2::LoadField(TString path){ |
970 |
readb_(s.Data()); |
// |
971 |
|
strcpy(path_.path,path.Data()); |
972 |
|
path_.pathlen = path.Length(); |
973 |
|
path_.error = 0; |
974 |
|
readb_(); |
975 |
|
// |
976 |
|
}; |
977 |
|
//-------------------------------------- |
978 |
|
// |
979 |
|
// |
980 |
|
//-------------------------------------- |
981 |
|
/** |
982 |
|
* Get tracker-plane (mechanical) z-coordinate |
983 |
|
* @param plane_id plane index (1=TOP,2,3,4,5,6=BOTTOM) |
984 |
|
*/ |
985 |
|
Float_t TrkLevel2::GetZTrk(Int_t plane_id){ |
986 |
|
switch(plane_id){ |
987 |
|
case 1: return ZTRK1; |
988 |
|
case 2: return ZTRK2; |
989 |
|
case 3: return ZTRK3; |
990 |
|
case 4: return ZTRK4; |
991 |
|
case 5: return ZTRK5; |
992 |
|
case 6: return ZTRK6; |
993 |
|
default: return 0.; |
994 |
|
}; |
995 |
}; |
}; |
996 |
//-------------------------------------- |
//-------------------------------------- |
997 |
// |
// |
1009 |
thx = new float[npoint]; |
thx = new float[npoint]; |
1010 |
thy = new float[npoint]; |
thy = new float[npoint]; |
1011 |
tl = new float[npoint]; |
tl = new float[npoint]; |
1012 |
float dz = ((ZTRKUP)-(ZTRKDW))/(npoint-1); |
float dz = ((ZTRK1)-(ZTRK6))/(npoint-1); |
1013 |
for(int i=0; i<npoint; i++){ |
for(int i=0; i<npoint; i++){ |
1014 |
x[i] = 0; |
x[i] = 0; |
1015 |
y[i] = 0; |
y[i] = 0; |
1016 |
z[i] = (ZTRKUP) - i*dz; |
z[i] = (ZTRK1) - i*dz; |
1017 |
thx[i] = 0; |
thx[i] = 0; |
1018 |
thy[i] = 0; |
thy[i] = 0; |
1019 |
tl[i] = 0; |
tl[i] = 0; |
1040 |
thx = new float[npoint]; |
thx = new float[npoint]; |
1041 |
thy = new float[npoint]; |
thy = new float[npoint]; |
1042 |
tl = new float[npoint]; |
tl = new float[npoint]; |
1043 |
float dz = ((ZTRKUP)-(ZTRKDW))/(npoint-1); |
float dz = ((ZTRK1)-(ZTRK6))/(npoint-1); |
1044 |
for(int i=0; i<npoint; i++){ |
for(int i=0; i<npoint; i++){ |
1045 |
x[i] = 0; |
x[i] = 0; |
1046 |
y[i] = 0; |
y[i] = 0; |
1047 |
z[i] = (ZTRKUP) - i*dz; |
z[i] = (ZTRK1) - i*dz; |
1048 |
thx[i] = 0; |
thx[i] = 0; |
1049 |
thy[i] = 0; |
thy[i] = 0; |
1050 |
tl[i] = 0; |
tl[i] = 0; |
1070 |
tl = new float[npoint]; |
tl = new float[npoint]; |
1071 |
int i=0; |
int i=0; |
1072 |
do{ |
do{ |
1073 |
x[i] = 0; |
x[i] = 0; |
1074 |
y[i] = 0; |
y[i] = 0; |
1075 |
z[i] = zin[i]; |
z[i] = zin[i]; |
1076 |
thx[i] = 0; |
thx[i] = 0; |
1077 |
thy[i] = 0; |
thy[i] = 0; |
1078 |
tl[i] = 0; |
tl[i] = 0; |
1079 |
i++; |
i++; |
1080 |
}while(zin[i-1] > zin[i] && i < npoint); |
}while(zin[i-1] > zin[i] && i < npoint); |
1081 |
npoint=i; |
npoint=i; |
1082 |
if(npoint != n)cout << "NB! Trajectory created with "<<npoint<<" points"<<endl; |
if(npoint != n)cout << "NB! Trajectory created with "<<npoint<<" points"<<endl; |
1118 |
return l; |
return l; |
1119 |
|
|
1120 |
} |
} |
1121 |
|
|
1122 |
|
/** |
1123 |
|
* Evaluates the trajectory in the apparatus associated to the track. |
1124 |
|
* It integrates the equations of motion in the magnetic field. The magnetic field should be previously loaded ( by calling TrkLevel2::LoadField() ), otherwise an error message is returned. |
1125 |
|
* @param t pointer to an object of the class Trajectory, |
1126 |
|
* which z coordinates should be previously initialized by calling the proper constructor ( Trajectory::Trajectory(int n, float* zin) ). |
1127 |
|
* @return error flag. |
1128 |
|
*/ |
1129 |
|
int Trajectory::DoTrack2(float* al){ |
1130 |
|
|
1131 |
|
double *dxout = new double[npoint]; |
1132 |
|
double *dyout = new double[npoint]; |
1133 |
|
double *dthxout = new double[npoint]; |
1134 |
|
double *dthyout = new double[npoint]; |
1135 |
|
double *dtlout = new double[npoint]; |
1136 |
|
double *dzin = new double[npoint]; |
1137 |
|
double dal[5]; |
1138 |
|
|
1139 |
|
int ifail = 0; |
1140 |
|
|
1141 |
|
for (int i=0; i<5; i++) dal[i] = (double)al[i]; |
1142 |
|
for (int i=0; i<npoint; i++) dzin[i] = (double)z[i]; |
1143 |
|
|
1144 |
|
dotrack2_(&(npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail); |
1145 |
|
|
1146 |
|
for (int i=0; i<npoint; i++){ |
1147 |
|
x[i] = (float)*dxout++; |
1148 |
|
y[i] = (float)*dyout++; |
1149 |
|
thx[i] = (float)*dthxout++; |
1150 |
|
thy[i] = (float)*dthyout++; |
1151 |
|
tl[i] = (float)*dtlout++; |
1152 |
|
} |
1153 |
|
|
1154 |
|
return ifail; |
1155 |
|
}; |
1156 |
|
|
1157 |
ClassImp(TrkLevel2); |
ClassImp(TrkLevel2); |
1158 |
ClassImp(TrkSinglet); |
ClassImp(TrkSinglet); |
1159 |
ClassImp(TrkTrack); |
ClassImp(TrkTrack); |