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 |
|
void gufld_(float*, float*); |
20 |
} |
} |
21 |
//-------------------------------------- |
//-------------------------------------- |
22 |
// |
// |
23 |
// |
// |
24 |
//-------------------------------------- |
//-------------------------------------- |
25 |
TrkTrack::TrkTrack(){ |
TrkTrack::TrkTrack(){ |
26 |
|
// cout << "TrkTrack::TrkTrack()" << endl; |
27 |
seqno = -1; |
seqno = -1; |
28 |
image = -1; |
image = -1; |
29 |
chi2 = 0; |
chi2 = 0; |
30 |
|
nstep = 0; |
31 |
for(int it1=0;it1<5;it1++){ |
for(int it1=0;it1<5;it1++){ |
32 |
al[it1] = 0; |
al[it1] = 0; |
33 |
for(int it2=0;it2<5;it2++) |
for(int it2=0;it2<5;it2++)coval[it1][it2] = 0; |
|
coval[it1][it2] = 0; |
|
34 |
}; |
}; |
35 |
for(int ip=0;ip<6;ip++){ |
for(int ip=0;ip<6;ip++){ |
36 |
xgood[ip] = 0; |
xgood[ip] = 0; |
47 |
ayv[ip] = 0; |
ayv[ip] = 0; |
48 |
dedx_x[ip] = 0; |
dedx_x[ip] = 0; |
49 |
dedx_y[ip] = 0; |
dedx_y[ip] = 0; |
50 |
}; |
}; |
51 |
|
clx = 0; |
52 |
|
cly = 0; |
53 |
|
// clx = new TRefArray(6,0); |
54 |
|
// cly = new TRefArray(6,0); |
55 |
}; |
}; |
56 |
//-------------------------------------- |
//-------------------------------------- |
57 |
// |
// |
61 |
seqno = t.seqno; |
seqno = t.seqno; |
62 |
image = t.image; |
image = t.image; |
63 |
chi2 = t.chi2; |
chi2 = t.chi2; |
64 |
|
nstep = t.nstep; |
65 |
for(int it1=0;it1<5;it1++){ |
for(int it1=0;it1<5;it1++){ |
66 |
al[it1] = t.al[it1]; |
al[it1] = t.al[it1]; |
67 |
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]; |
|
68 |
}; |
}; |
69 |
for(int ip=0;ip<6;ip++){ |
for(int ip=0;ip<6;ip++){ |
70 |
xgood[ip] = t.xgood[ip]; |
xgood[ip] = t.xgood[ip]; |
81 |
ayv[ip] = t.ayv[ip]; |
ayv[ip] = t.ayv[ip]; |
82 |
dedx_x[ip] = t.dedx_x[ip]; |
dedx_x[ip] = t.dedx_x[ip]; |
83 |
dedx_y[ip] = t.dedx_y[ip]; |
dedx_y[ip] = t.dedx_y[ip]; |
84 |
}; |
}; |
85 |
|
clx = 0; |
86 |
|
cly = 0; |
87 |
|
if(t.clx)clx = new TRefArray(*(t.clx)); |
88 |
|
if(t.cly)cly = new TRefArray(*(t.cly)); |
89 |
|
|
90 |
|
}; |
91 |
|
//-------------------------------------- |
92 |
|
// |
93 |
|
// |
94 |
|
//-------------------------------------- |
95 |
|
void TrkTrack::Copy(TrkTrack& t){ |
96 |
|
|
97 |
|
t.seqno = seqno; |
98 |
|
t.image = image; |
99 |
|
t.chi2 = chi2; |
100 |
|
t.nstep = nstep; |
101 |
|
for(int it1=0;it1<5;it1++){ |
102 |
|
t.al[it1] = al[it1]; |
103 |
|
for(int it2=0;it2<5;it2++)t.coval[it1][it2] = coval[it1][it2]; |
104 |
|
}; |
105 |
|
for(int ip=0;ip<6;ip++){ |
106 |
|
t.xgood[ip] = xgood[ip]; |
107 |
|
t.ygood[ip] = ygood[ip]; |
108 |
|
t.xm[ip] = xm[ip]; |
109 |
|
t.ym[ip] = ym[ip]; |
110 |
|
t.zm[ip] = zm[ip]; |
111 |
|
t.resx[ip] = resx[ip]; |
112 |
|
t.resy[ip] = resy[ip]; |
113 |
|
t.xv[ip] = xv[ip]; |
114 |
|
t.yv[ip] = yv[ip]; |
115 |
|
t.zv[ip] = zv[ip]; |
116 |
|
t.axv[ip] = axv[ip]; |
117 |
|
t.ayv[ip] = ayv[ip]; |
118 |
|
t.dedx_x[ip] = dedx_x[ip]; |
119 |
|
t.dedx_y[ip] = dedx_y[ip]; |
120 |
|
|
121 |
|
}; |
122 |
|
|
123 |
}; |
}; |
124 |
//-------------------------------------- |
//-------------------------------------- |
125 |
// |
// |
235 |
//-------------------------------------- |
//-------------------------------------- |
236 |
void TrkTrack::Dump(){ |
void TrkTrack::Dump(){ |
237 |
cout << endl << "========== Track " ; |
cout << endl << "========== Track " ; |
238 |
|
cout << endl << "seq. n. : "<< seqno; |
239 |
|
cout << endl << "image n. : "<< image; |
240 |
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] << " "; |
241 |
cout << endl << "chi^2 : "<< chi2; |
cout << endl << "chi^2 : "<< chi2; |
242 |
|
cout << endl << "n.step : "<< nstep; |
243 |
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] ; |
244 |
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] ; |
245 |
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] << " "; |
246 |
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] << " "; |
247 |
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] << " "; |
248 |
|
cout << endl << "xv : "; for(int i=0; i<6; i++)cout << xv[i] << " "; |
249 |
|
cout << endl << "yv : "; for(int i=0; i<6; i++)cout << yv[i] << " "; |
250 |
|
cout << endl << "zv : "; for(int i=0; i<6; i++)cout << zv[i] << " "; |
251 |
|
cout << endl << "resx : "; for(int i=0; i<6; i++)cout << resx[i] << " "; |
252 |
|
cout << endl << "resy : "; for(int i=0; i<6; i++)cout << resy[i] << " "; |
253 |
|
cout << endl << "coval : "; for(int i=0; i<5; i++)cout << coval[0][i]<<" "; |
254 |
|
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[1][i]<<" "; |
255 |
|
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[2][i]<<" "; |
256 |
|
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[3][i]<<" "; |
257 |
|
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[4][i]<<" "; |
258 |
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] << " "; |
259 |
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] << " "; |
260 |
|
cout << endl; |
261 |
|
} |
262 |
|
/** |
263 |
|
* Set the TrkTrack position measurements |
264 |
|
*/ |
265 |
|
void TrkTrack::SetMeasure(double *xmeas, double *ymeas, double *zmeas){ |
266 |
|
for(int i=0; i<6; i++) xm[i]=*xmeas++; |
267 |
|
for(int i=0; i<6; i++) ym[i]=*ymeas++; |
268 |
|
for(int i=0; i<6; i++) zm[i]=*zmeas++; |
269 |
|
} |
270 |
|
/** |
271 |
|
* Set the TrkTrack position resolution |
272 |
|
*/ |
273 |
|
void TrkTrack::SetResolution(double *rx, double *ry){ |
274 |
|
for(int i=0; i<6; i++) resx[i]=*rx++; |
275 |
|
for(int i=0; i<6; i++) resy[i]=*ry++; |
276 |
|
} |
277 |
|
/** |
278 |
|
* Set the TrkTrack good measurement |
279 |
|
*/ |
280 |
|
void TrkTrack::SetGood(int *xg, int *yg){ |
281 |
|
for(int i=0; i<6; i++) xgood[i]=*xg++; |
282 |
|
for(int i=0; i<6; i++) ygood[i]=*yg++; |
283 |
|
} |
284 |
|
|
285 |
|
/** |
286 |
|
* Load the magnetic field |
287 |
|
*/ |
288 |
|
void TrkTrack::LoadField(TString path){ |
289 |
|
|
290 |
|
strcpy(path_.path,path.Data()); |
291 |
|
path_.pathlen = path.Length(); |
292 |
|
path_.error = 0; |
293 |
|
readb_(); |
294 |
|
|
295 |
|
}; |
296 |
|
|
297 |
|
|
298 |
|
/** |
299 |
|
* Method to fill minimization-routine common |
300 |
|
*/ |
301 |
|
void TrkTrack::FillMiniStruct(cMini2track& track){ |
302 |
|
|
303 |
|
for(int i=0; i<6; i++){ |
304 |
|
|
305 |
|
track.xgood[i]=xgood[i]; |
306 |
|
track.ygood[i]=ygood[i]; |
307 |
|
|
308 |
|
track.xm[i]=xm[i]; |
309 |
|
track.ym[i]=ym[i]; |
310 |
|
track.zm[i]=zm[i]; |
311 |
|
|
312 |
|
// --- temporaneo ---------------------------- |
313 |
|
// andrebbe inserita la dimensione del sensore |
314 |
|
float segment = 100.; |
315 |
|
track.xm_a[i]=xm[i]; |
316 |
|
track.xm_b[i]=xm[i]; |
317 |
|
track.ym_a[i]=ym[i]; |
318 |
|
track.ym_b[i]=ym[i]; |
319 |
|
if( xgood[i] && !ygood[i] ){ |
320 |
|
track.ym_a[i] = track.ym_a[i]+segment; |
321 |
|
track.ym_b[i] = track.ym_b[i]-segment; |
322 |
|
}else if( !xgood[i] && ygood[i]){ |
323 |
|
track.xm_a[i] = track.xm_a[i]+segment; |
324 |
|
track.xm_b[i] = track.xm_b[i]-segment; |
325 |
|
} |
326 |
|
// --- temporaneo ---------------------------- |
327 |
|
|
328 |
|
track.resx[i]=resx[i]; |
329 |
|
track.resy[i]=resy[i]; |
330 |
|
} |
331 |
|
|
332 |
|
for(int i=0; i<5; i++) track.al[i]=al[i]; |
333 |
|
track.zini = 23.5; |
334 |
|
// ZINI = 23.5 !!! it should be the same parameter in all codes |
335 |
|
|
336 |
|
} |
337 |
|
/** |
338 |
|
* Method to set values from minimization-routine common |
339 |
|
*/ |
340 |
|
void TrkTrack::SetFromMiniStruct(cMini2track *track){ |
341 |
|
|
342 |
|
for(int i=0; i<5; i++) { |
343 |
|
al[i]=track->al[i]; |
344 |
|
for(int j=0; j<5; j++) coval[i][j]=track->cov[i][j]; |
345 |
|
} |
346 |
|
chi2 = track->chi2; |
347 |
|
nstep = track->nstep; |
348 |
|
for(int i=0; i<6; i++){ |
349 |
|
xv[i] = track->xv[i]; |
350 |
|
yv[i] = track->yv[i]; |
351 |
|
zv[i] = track->zv[i]; |
352 |
|
xm[i] = track->xm[i]; |
353 |
|
ym[i] = track->ym[i]; |
354 |
|
zm[i] = track->zm[i]; |
355 |
|
axv[i] = track->axv[i]; |
356 |
|
ayv[i] = track->ayv[i]; |
357 |
|
} |
358 |
|
|
359 |
|
|
360 |
|
} |
361 |
|
/** |
362 |
|
* Tracking method. It calls F77 mini routine. |
363 |
|
*/ |
364 |
|
void TrkTrack::Fit(double pfixed, int& fail, int iprint){ |
365 |
|
|
366 |
|
float al_ini[] = {0.,0.,0.,0.,0.}; |
367 |
|
|
368 |
|
extern cMini2track track_; |
369 |
|
fail = 0; |
370 |
|
FillMiniStruct(track_); |
371 |
|
|
372 |
|
// if fit variables have been reset, evaluate the initial guess |
373 |
|
if(al[0]==-9999.&&al[1]==-9999.&&al[2]==-9999.&&al[3]==-9999.&&al[4]==-9999.)guess_(); |
374 |
|
|
375 |
|
// --------------------- free momentum |
376 |
|
if(pfixed==0.) { |
377 |
|
track_.pfixed=0.; |
378 |
|
} |
379 |
|
// --------------------- fixed momentum |
380 |
|
if(pfixed!=0.) { |
381 |
|
al[4]=1./pfixed; |
382 |
|
track_.pfixed=pfixed; |
383 |
|
} |
384 |
|
|
385 |
|
// store temporarily the initial guess |
386 |
|
for(int i=0; i<5; i++) al_ini[i]=track_.al[i]; |
387 |
|
|
388 |
|
// ------------------------------------------ |
389 |
|
// call mini routine |
390 |
|
int istep=0; |
391 |
|
int ifail=0; |
392 |
|
mini2_(&istep,&ifail, &iprint); |
393 |
|
if(ifail!=0) { |
394 |
|
if(iprint)cout << "ERROR: ifail= " << ifail << endl; |
395 |
|
fail = 1; |
396 |
|
} |
397 |
|
// ------------------------------------------ |
398 |
|
|
399 |
|
SetFromMiniStruct(&track_); |
400 |
|
// cout << endl << "eta ===> " << track_.al[4] << endl; |
401 |
|
|
402 |
|
// for(int i=0; i<5; i++) al[i]=track_.al[i]; |
403 |
|
// chi2=track_.chi2; |
404 |
|
// nstep=track_.nstep; |
405 |
|
// for(int i=0; i<6; i++) xv[i]=track_.xv[i]; |
406 |
|
// for(int i=0; i<6; i++) yv[i]=track_.yv[i]; |
407 |
|
// for(int i=0; i<6; i++) zv[i]=track_.zv[i]; |
408 |
|
// for(int i=0; i<6; i++) axv[i]=track_.axv[i]; |
409 |
|
// for(int i=0; i<6; i++) ayv[i]=track_.ayv[i]; |
410 |
|
// for(int i=0; i<5; i++) { |
411 |
|
// for(int j=0; j<5; j++) coval[i][j]=track_.cov[i][j]; |
412 |
|
// } |
413 |
|
|
414 |
|
if(fail){ |
415 |
|
if(iprint)cout << " >>>> fit failed >>>> drawing initial par"<<endl; |
416 |
|
for(int i=0; i<5; i++) al[i]=al_ini[i]; |
417 |
|
} |
418 |
|
|
419 |
|
}; |
420 |
|
/* |
421 |
|
* Reset the fit parameters |
422 |
|
*/ |
423 |
|
void TrkTrack::FitReset(){ |
424 |
|
for(int i=0; i<5; i++) al[i]=-9999.; |
425 |
|
chi2=0.; |
426 |
|
nstep=0; |
427 |
|
for(int i=0; i<6; i++) xv[i]=0.; |
428 |
|
for(int i=0; i<6; i++) yv[i]=0.; |
429 |
|
for(int i=0; i<6; i++) zv[i]=0.; |
430 |
|
for(int i=0; i<6; i++) axv[i]=0.; |
431 |
|
for(int i=0; i<6; i++) ayv[i]=0.; |
432 |
|
for(int i=0; i<5; i++) { |
433 |
|
for(int j=0; j<5; j++) coval[i][j]=0.; |
434 |
|
} |
435 |
} |
} |
436 |
|
|
437 |
|
//-------------------------------------- |
438 |
|
// |
439 |
|
// |
440 |
|
//-------------------------------------- |
441 |
|
void TrkTrack::Clear(){ |
442 |
|
// cout << "TrkTrack::Clear()"<<endl; |
443 |
|
seqno = -1; |
444 |
|
image = -1; |
445 |
|
chi2 = 0; |
446 |
|
nstep = 0; |
447 |
|
for(int it1=0;it1<5;it1++){ |
448 |
|
al[it1] = 0; |
449 |
|
for(int it2=0;it2<5;it2++)coval[it1][it2] = 0; |
450 |
|
}; |
451 |
|
for(int ip=0;ip<6;ip++){ |
452 |
|
xgood[ip] = 0; |
453 |
|
ygood[ip] = 0; |
454 |
|
xm[ip] = 0; |
455 |
|
ym[ip] = 0; |
456 |
|
zm[ip] = 0; |
457 |
|
resx[ip] = 0; |
458 |
|
resy[ip] = 0; |
459 |
|
xv[ip] = 0; |
460 |
|
yv[ip] = 0; |
461 |
|
zv[ip] = 0; |
462 |
|
axv[ip] = 0; |
463 |
|
ayv[ip] = 0; |
464 |
|
dedx_x[ip] = 0; |
465 |
|
dedx_y[ip] = 0; |
466 |
|
|
467 |
|
}; |
468 |
|
if(clx)clx->Clear(); |
469 |
|
if(cly)cly->Clear(); |
470 |
|
}; |
471 |
|
//-------------------------------------- |
472 |
|
// |
473 |
|
// |
474 |
|
//-------------------------------------- |
475 |
|
void TrkTrack::Delete(){ |
476 |
|
// cout << "TrkTrack::Delete()"<<endl; |
477 |
|
// Clear(); |
478 |
|
if(clx)delete clx; |
479 |
|
if(cly)delete cly; |
480 |
|
}; |
481 |
|
//-------------------------------------- |
482 |
|
// |
483 |
|
// |
484 |
|
//-------------------------------------- |
485 |
|
|
486 |
//-------------------------------------- |
//-------------------------------------- |
487 |
// |
// |
488 |
// |
// |
489 |
//-------------------------------------- |
//-------------------------------------- |
490 |
TrkSinglet::TrkSinglet(){ |
TrkSinglet::TrkSinglet(){ |
491 |
|
// cout << "TrkSinglet::TrkSinglet() " << GetUniqueID()<<endl; |
492 |
plane = 0; |
plane = 0; |
493 |
coord[0] = 0; |
coord[0] = 0; |
494 |
coord[1] = 0; |
coord[1] = 0; |
495 |
sgnl = 0; |
sgnl = 0; |
496 |
|
// cls = 0; |
497 |
}; |
}; |
498 |
//-------------------------------------- |
//-------------------------------------- |
499 |
// |
// |
500 |
// |
// |
501 |
//-------------------------------------- |
//-------------------------------------- |
502 |
TrkSinglet::TrkSinglet(const TrkSinglet& s){ |
TrkSinglet::TrkSinglet(const TrkSinglet& s){ |
503 |
|
// cout << "TrkSinglet::TrkSinglet(const TrkSinglet& s) " << GetUniqueID()<<endl; |
504 |
plane = s.plane; |
plane = s.plane; |
505 |
coord[0] = s.coord[0]; |
coord[0] = s.coord[0]; |
506 |
coord[1] = s.coord[1]; |
coord[1] = s.coord[1]; |
507 |
sgnl = s.sgnl; |
sgnl = s.sgnl; |
508 |
|
// cls = 0;//<<<<pointer |
509 |
|
cls = TRef(s.cls); |
510 |
}; |
}; |
511 |
//-------------------------------------- |
//-------------------------------------- |
512 |
// |
// |
523 |
// |
// |
524 |
// |
// |
525 |
//-------------------------------------- |
//-------------------------------------- |
526 |
|
void TrkSinglet::Clear(){ |
527 |
|
// cout << "TrkSinglet::Clear() " << GetUniqueID()<<endl; |
528 |
|
// cls=0; |
529 |
|
plane=-1; |
530 |
|
coord[0]=-999; |
531 |
|
coord[1]=-999; |
532 |
|
sgnl=0; |
533 |
|
|
534 |
|
} |
535 |
|
//-------------------------------------- |
536 |
|
// |
537 |
|
// |
538 |
|
//-------------------------------------- |
539 |
TrkLevel2::TrkLevel2(){ |
TrkLevel2::TrkLevel2(){ |
540 |
good2 = -1; |
// cout <<"TrkLevel2::TrkLevel2()"<<endl; |
541 |
for(Int_t i=0; i<12 ; i++){ |
for(Int_t i=0; i<12 ; i++){ |
542 |
crc[i] = -1; |
good[i] = -1; |
543 |
}; |
}; |
544 |
Track = new TClonesArray("TrkTrack"); |
// okkio!! memory-leak |
545 |
SingletX = new TClonesArray("TrkSinglet"); |
// Track = new TClonesArray("TrkTrack"); |
546 |
SingletY = new TClonesArray("TrkSinglet"); |
// SingletX = new TClonesArray("TrkSinglet"); |
547 |
|
// SingletY = new TClonesArray("TrkSinglet"); |
548 |
|
Track = 0; |
549 |
|
SingletX = 0; |
550 |
|
SingletY = 0; |
551 |
|
|
552 |
// PhysicalTrack = new TClonesArray("TrkTrack"); |
} |
553 |
//sostituire con TRefArray... appena ho capito come si usa |
//-------------------------------------- |
554 |
|
// |
555 |
|
// |
556 |
|
//-------------------------------------- |
557 |
|
void TrkLevel2::Set(){ |
558 |
|
if(!Track)Track = new TClonesArray("TrkTrack"); |
559 |
|
if(!SingletX)SingletX = new TClonesArray("TrkSinglet"); |
560 |
|
if(!SingletY)SingletY = new TClonesArray("TrkSinglet"); |
561 |
} |
} |
562 |
//-------------------------------------- |
//-------------------------------------- |
563 |
// |
// |
564 |
// |
// |
565 |
//-------------------------------------- |
//-------------------------------------- |
566 |
void TrkLevel2::Dump(){ |
void TrkLevel2::Dump(){ |
567 |
TClonesArray &t = *Track; |
|
568 |
TClonesArray &sx = *SingletX; |
// |
|
TClonesArray &sy = *SingletY; |
|
|
|
|
569 |
cout << endl << endl << "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"; |
cout << endl << endl << "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"; |
570 |
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]; |
|
571 |
cout << endl << "ntrk() : " << this->ntrk() ; |
cout << endl << "ntrk() : " << this->ntrk() ; |
572 |
cout << endl << "nclsx() : " << this->nclsx(); |
cout << endl << "nclsx() : " << this->nclsx(); |
573 |
cout << endl << "nclsy() : " << this->nclsy(); |
cout << endl << "nclsy() : " << this->nclsy(); |
574 |
for(int i=0; i<this->ntrk(); i++) ((TrkTrack *)t[i])->Dump(); |
// TClonesArray &t = *Track; |
575 |
for(int i=0; i<this->nclsx(); i++) ((TrkSinglet *)sx[i])->Dump(); |
// TClonesArray &sx = *SingletX; |
576 |
for(int i=0; i<this->nclsy(); i++) ((TrkSinglet *)sy[i])->Dump(); |
// TClonesArray &sy = *SingletY; |
577 |
|
// for(int i=0; i<ntrk(); i++) ((TrkTrack *)t[i])->Dump(); |
578 |
|
// for(int i=0; i<nclsx(); i++) ((TrkSinglet *)sx[i])->Dump(); |
579 |
|
// for(int i=0; i<nclsy(); i++) ((TrkSinglet *)sy[i])->Dump(); |
580 |
|
if(Track){ |
581 |
|
TClonesArray &t = *Track; |
582 |
|
for(int i=0; i<ntrk(); i++) ((TrkTrack *)t[i])->Dump(); |
583 |
|
} |
584 |
|
if(SingletX){ |
585 |
|
TClonesArray &sx = *SingletX; |
586 |
|
for(int i=0; i<nclsx(); i++) ((TrkSinglet *)sx[i])->Dump(); |
587 |
|
} |
588 |
|
if(SingletY){ |
589 |
|
TClonesArray &sy = *SingletY; |
590 |
|
for(int i=0; i<nclsy(); i++) ((TrkSinglet *)sy[i])->Dump(); |
591 |
|
} |
592 |
} |
} |
593 |
//-------------------------------------- |
//-------------------------------------- |
594 |
// |
// |
598 |
* 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). |
599 |
*/ |
*/ |
600 |
void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2){ |
void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2){ |
601 |
// |
|
602 |
// Track = new TClonesArray("TrkTrack"); |
// temporary objects: |
|
// SingletX = new TClonesArray("TrkSinglet"); |
|
|
// SingletY = new TClonesArray("TrkSinglet"); |
|
|
// temporary objects: |
|
603 |
TrkSinglet* t_singlet = new TrkSinglet(); |
TrkSinglet* t_singlet = new TrkSinglet(); |
604 |
TrkTrack* t_track = new TrkTrack(); |
TrkTrack* t_track = new TrkTrack(); |
605 |
// general variables |
|
606 |
good2 = l2->good2; |
// **** general variables **** |
607 |
|
// good2 = l2->good2; |
608 |
for(Int_t i=0; i<12 ; i++){ |
for(Int_t i=0; i<12 ; i++){ |
609 |
crc[i] = l2->crc[i]; |
// crc[i] = l2->crc[i]; |
610 |
}; |
good[i] = l2->good[i]; |
611 |
// *** TRACKS *** |
}; |
612 |
|
// *** TRACKS *** |
613 |
|
if(!Track) Track = new TClonesArray("TrkTrack"); |
614 |
TClonesArray &t = *Track; |
TClonesArray &t = *Track; |
615 |
for(int i=0; i<l2->ntrk; i++){ |
for(int i=0; i<l2->ntrk; i++){ |
616 |
t_track->seqno = i; |
t_track->seqno = i;// NBNBNBNB deve sempre essere = i |
617 |
t_track->image = l2->image[i]-1; |
t_track->image = l2->image[i]-1; |
618 |
// cout << "track "<<i<<t_track->seqno << t_track->image<<endl; |
// cout << "track "<<i<<t_track->seqno << t_track->image<<endl; |
619 |
t_track->chi2 = l2->chi2_nt[i]; |
t_track->chi2 = l2->chi2_nt[i]; |
620 |
|
t_track->nstep = l2->nstep_nt[i]; |
621 |
for(int it1=0;it1<5;it1++){ |
for(int it1=0;it1<5;it1++){ |
622 |
t_track->al[it1] = l2->al_nt[i][it1]; |
t_track->al[it1] = l2->al_nt[i][it1]; |
623 |
for(int it2=0;it2<5;it2++) |
for(int it2=0;it2<5;it2++) |
638 |
t_track->ayv[ip] = l2->ayv_nt[i][ip]; |
t_track->ayv[ip] = l2->ayv_nt[i][ip]; |
639 |
t_track->dedx_x[ip] = l2->dedx_x[i][ip]; |
t_track->dedx_x[ip] = l2->dedx_x[i][ip]; |
640 |
t_track->dedx_y[ip] = l2->dedx_y[i][ip]; |
t_track->dedx_y[ip] = l2->dedx_y[i][ip]; |
641 |
|
// t_track->clx[ip] = 0; |
642 |
|
// t_track->cly[ip] = 0; |
643 |
}; |
}; |
644 |
new(t[i]) TrkTrack(*t_track); |
new(t[i]) TrkTrack(*t_track); |
645 |
t_track->Clear(); |
t_track->Clear(); |
646 |
}; |
}; |
647 |
// *** SINGLETS *** |
// *** SINGLETS *** |
648 |
|
if(!SingletX)SingletX = new TClonesArray("TrkSinglet"); |
649 |
TClonesArray &sx = *SingletX; |
TClonesArray &sx = *SingletX; |
650 |
for(int i=0; i<l2->nclsx; i++){ |
for(int i=0; i<l2->nclsx; i++){ |
651 |
t_singlet->plane = l2->planex[i]; |
t_singlet->plane = l2->planex[i]; |
652 |
t_singlet->coord[0] = l2->xs[i][0]; |
t_singlet->coord[0] = l2->xs[i][0]; |
653 |
t_singlet->coord[1] = l2->xs[i][1]; |
t_singlet->coord[1] = l2->xs[i][1]; |
654 |
t_singlet->sgnl = l2->signlxs[i]; |
t_singlet->sgnl = l2->signlxs[i]; |
655 |
|
// t_singlet->cls = 0; |
656 |
new(sx[i]) TrkSinglet(*t_singlet); |
new(sx[i]) TrkSinglet(*t_singlet); |
657 |
t_singlet->Clear(); |
t_singlet->Clear(); |
658 |
} |
} |
659 |
|
if(!SingletY)SingletY = new TClonesArray("TrkSinglet"); |
660 |
TClonesArray &sy = *SingletY; |
TClonesArray &sy = *SingletY; |
661 |
for(int i=0; i<l2->nclsy; i++){ |
for(int i=0; i<l2->nclsy; i++){ |
662 |
t_singlet->plane = l2->planey[i]; |
t_singlet->plane = l2->planey[i]; |
663 |
t_singlet->coord[0] = l2->ys[i][0]; |
t_singlet->coord[0] = l2->ys[i][0]; |
664 |
t_singlet->coord[1] = l2->ys[i][1]; |
t_singlet->coord[1] = l2->ys[i][1]; |
665 |
t_singlet->sgnl = l2->signlys[i]; |
t_singlet->sgnl = l2->signlys[i]; |
666 |
|
// t_singlet->cls = 0; |
667 |
new(sy[i]) TrkSinglet(*t_singlet); |
new(sy[i]) TrkSinglet(*t_singlet); |
668 |
t_singlet->Clear(); |
t_singlet->Clear(); |
669 |
|
}; |
670 |
|
|
671 |
|
delete t_track; |
672 |
|
delete t_singlet; |
673 |
|
} |
674 |
|
//-------------------------------------- |
675 |
|
// |
676 |
|
// |
677 |
|
//-------------------------------------- |
678 |
|
/** |
679 |
|
* Fills a TrkLevel2 object with values from a struct cTrkLevel2 (to get data from F77 common). |
680 |
|
* Ref to Level1 data (clusters) is also set. |
681 |
|
*/ |
682 |
|
void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2, TrkLevel1 *l1){ |
683 |
|
|
684 |
|
// temporary objects: |
685 |
|
TrkSinglet* t_singlet = new TrkSinglet(); |
686 |
|
TrkTrack* t_track = new TrkTrack(); |
687 |
|
// general variables |
688 |
|
// good2 = l2->good2; |
689 |
|
for(Int_t i=0; i<12 ; i++){ |
690 |
|
// crc[i] = l2->crc[i]; |
691 |
|
good[i] = l2->good[i]; |
692 |
|
}; |
693 |
|
// *** TRACKS *** |
694 |
|
if(!Track) Track = new TClonesArray("TrkTrack"); |
695 |
|
TClonesArray &t = *Track; |
696 |
|
if(!t_track->clx)t_track->clx = new TRefArray(6,0); |
697 |
|
if(!t_track->cly)t_track->cly = new TRefArray(6,0); |
698 |
|
for(int i=0; i<l2->ntrk; i++){ |
699 |
|
t_track->seqno = i;// NBNBNBNB deve sempre essere = i |
700 |
|
t_track->image = l2->image[i]-1; |
701 |
|
// cout << "track "<<i<<t_track->seqno << t_track->image<<endl; |
702 |
|
t_track->chi2 = l2->chi2_nt[i]; |
703 |
|
t_track->nstep = l2->nstep_nt[i]; |
704 |
|
for(int it1=0;it1<5;it1++){ |
705 |
|
t_track->al[it1] = l2->al_nt[i][it1]; |
706 |
|
for(int it2=0;it2<5;it2++) |
707 |
|
t_track->coval[it1][it2] = l2->coval[i][it2][it1]; |
708 |
|
}; |
709 |
|
for(int ip=0;ip<6;ip++){ |
710 |
|
t_track->xgood[ip] = l2->xgood_nt[i][ip]; |
711 |
|
t_track->ygood[ip] = l2->ygood_nt[i][ip]; |
712 |
|
t_track->xm[ip] = l2->xm_nt[i][ip]; |
713 |
|
t_track->ym[ip] = l2->ym_nt[i][ip]; |
714 |
|
t_track->zm[ip] = l2->zm_nt[i][ip]; |
715 |
|
t_track->resx[ip] = l2->resx_nt[i][ip]; |
716 |
|
t_track->resy[ip] = l2->resy_nt[i][ip]; |
717 |
|
t_track->xv[ip] = l2->xv_nt[i][ip]; |
718 |
|
t_track->yv[ip] = l2->yv_nt[i][ip]; |
719 |
|
t_track->zv[ip] = l2->zv_nt[i][ip]; |
720 |
|
t_track->axv[ip] = l2->axv_nt[i][ip]; |
721 |
|
t_track->ayv[ip] = l2->ayv_nt[i][ip]; |
722 |
|
t_track->dedx_x[ip] = l2->dedx_x[i][ip]; |
723 |
|
t_track->dedx_y[ip] = l2->dedx_y[i][ip]; |
724 |
|
// cout << "traccia "<<i<<" -- "<< ip << " "<< l2->cltrx[i][ip] <<" "<< l2->cltry[i][ip] <<" "<< t_track->xgood[ip] << t_track->ygood[ip]<<endl; |
725 |
|
//----------------------------------------------------- |
726 |
|
//----------------------------------------------------- |
727 |
|
if(t_track->xgood[ip])t_track->clx->AddAt(l1->GetCluster(l2->cltrx[i][ip]-1),ip); |
728 |
|
if(t_track->ygood[ip])t_track->cly->AddAt(l1->GetCluster(l2->cltry[i][ip]-1),ip); |
729 |
|
// 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; |
730 |
|
// 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; |
731 |
|
//----------------------------------------------------- |
732 |
|
//----------------------------------------------------- |
733 |
|
}; |
734 |
|
new(t[i]) TrkTrack(*t_track); |
735 |
|
t_track->Clear(); |
736 |
|
}; |
737 |
|
// *** SINGLETS *** |
738 |
|
if(!SingletX)SingletX = new TClonesArray("TrkSinglet"); |
739 |
|
TClonesArray &sx = *SingletX; |
740 |
|
for(int i=0; i<l2->nclsx; i++){ |
741 |
|
t_singlet->plane = l2->planex[i]; |
742 |
|
t_singlet->coord[0] = l2->xs[i][0]; |
743 |
|
t_singlet->coord[1] = l2->xs[i][1]; |
744 |
|
t_singlet->sgnl = l2->signlxs[i]; |
745 |
|
//----------------------------------------------------- |
746 |
|
// cout << "singolo x "<<i<<" -- "<< l2->clsx[i] <<endl; |
747 |
|
t_singlet->cls = l1->GetCluster(l2->clsx[i]-1); |
748 |
|
// cout<<" i "<<i<<" l2->clsx[i] "<<l2->clsx[i]<< " l1->GetCluster(l2->clsx[i]-1) "<<l1->GetCluster(l2->clsx[i]-1)<<endl; |
749 |
|
//----------------------------------------------------- |
750 |
|
new(sx[i]) TrkSinglet(*t_singlet); |
751 |
|
t_singlet->Clear(); |
752 |
|
} |
753 |
|
if(!SingletY)SingletY = new TClonesArray("TrkSinglet"); |
754 |
|
TClonesArray &sy = *SingletY; |
755 |
|
for(int i=0; i<l2->nclsy; i++){ |
756 |
|
t_singlet->plane = l2->planey[i]; |
757 |
|
t_singlet->coord[0] = l2->ys[i][0]; |
758 |
|
t_singlet->coord[1] = l2->ys[i][1]; |
759 |
|
t_singlet->sgnl = l2->signlys[i]; |
760 |
|
//----------------------------------------------------- |
761 |
|
// cout << "singolo y "<<i<<" -- "<< l2->clsy[i] <<endl; |
762 |
|
t_singlet->cls = l1->GetCluster(l2->clsy[i]-1); |
763 |
|
// cout<<" i "<<i<<" l2->clsy[i] "<<l2->clsy[i]<< " l1->GetCluster(l2->clsy[i]-1) "<<l1->GetCluster(l2->clsy[i]-1)<<endl; |
764 |
|
//----------------------------------------------------- |
765 |
|
new(sy[i]) TrkSinglet(*t_singlet); |
766 |
|
t_singlet->Clear(); |
767 |
}; |
}; |
768 |
|
|
769 |
delete t_track; |
delete t_track; |
776 |
void TrkLevel2::GetLevel2Struct(cTrkLevel2 *l2) const { |
void TrkLevel2::GetLevel2Struct(cTrkLevel2 *l2) const { |
777 |
|
|
778 |
// general variables |
// general variables |
779 |
l2->good2 = good2 ; |
// l2->good2 = good2 ; |
780 |
for(Int_t i=0; i<12 ; i++){ |
for(Int_t i=0; i<12 ; i++){ |
781 |
l2->crc[i] = crc[i]; |
// l2->crc[i] = crc[i]; |
782 |
|
l2->good[i] = good[i]; |
783 |
}; |
}; |
784 |
// *** TRACKS *** |
// *** TRACKS *** |
785 |
|
|
786 |
l2->ntrk = Track->GetEntries(); |
if(Track){ |
787 |
for(Int_t i=0;i<l2->ntrk;i++){ |
l2->ntrk = Track->GetEntries(); |
788 |
l2->image[i] = 1 + ((TrkTrack *)Track->At(i))->image; |
for(Int_t i=0;i<l2->ntrk;i++){ |
789 |
l2->chi2_nt[i] = ((TrkTrack *)Track->At(i))->chi2; |
l2->image[i] = 1 + ((TrkTrack *)Track->At(i))->image; |
790 |
for(int it1=0;it1<5;it1++){ |
l2->chi2_nt[i] = ((TrkTrack *)Track->At(i))->chi2; |
791 |
l2->al_nt[i][it1] = ((TrkTrack *)Track->At(i))->al[it1]; |
l2->nstep_nt[i] = ((TrkTrack *)Track->At(i))->nstep; |
792 |
for(int it2=0;it2<5;it2++) |
for(int it1=0;it1<5;it1++){ |
793 |
l2->coval[i][it2][it1] = ((TrkTrack *)Track->At(i))->coval[it1][it2]; |
l2->al_nt[i][it1] = ((TrkTrack *)Track->At(i))->al[it1]; |
794 |
}; |
for(int it2=0;it2<5;it2++) |
795 |
for(int ip=0;ip<6;ip++){ |
l2->coval[i][it2][it1] = ((TrkTrack *)Track->At(i))->coval[it1][it2]; |
796 |
l2->xgood_nt[i][ip] = ((TrkTrack *)Track->At(i))->xgood[ip]; |
}; |
797 |
l2->ygood_nt[i][ip] = ((TrkTrack *)Track->At(i))->ygood[ip]; |
for(int ip=0;ip<6;ip++){ |
798 |
l2->xm_nt[i][ip] = ((TrkTrack *)Track->At(i))->xm[ip]; |
l2->xgood_nt[i][ip] = ((TrkTrack *)Track->At(i))->xgood[ip]; |
799 |
l2->ym_nt[i][ip] = ((TrkTrack *)Track->At(i))->ym[ip]; |
l2->ygood_nt[i][ip] = ((TrkTrack *)Track->At(i))->ygood[ip]; |
800 |
l2->zm_nt[i][ip] = ((TrkTrack *)Track->At(i))->zm[ip]; |
l2->xm_nt[i][ip] = ((TrkTrack *)Track->At(i))->xm[ip]; |
801 |
l2->resx_nt[i][ip] = ((TrkTrack *)Track->At(i))->resx[ip]; |
l2->ym_nt[i][ip] = ((TrkTrack *)Track->At(i))->ym[ip]; |
802 |
l2->resy_nt[i][ip] = ((TrkTrack *)Track->At(i))->resy[ip]; |
l2->zm_nt[i][ip] = ((TrkTrack *)Track->At(i))->zm[ip]; |
803 |
l2->xv_nt[i][ip] = ((TrkTrack *)Track->At(i))->xv[ip]; |
l2->resx_nt[i][ip] = ((TrkTrack *)Track->At(i))->resx[ip]; |
804 |
l2->yv_nt[i][ip] = ((TrkTrack *)Track->At(i))->yv[ip]; |
l2->resy_nt[i][ip] = ((TrkTrack *)Track->At(i))->resy[ip]; |
805 |
l2->zv_nt[i][ip] = ((TrkTrack *)Track->At(i))->zv[ip]; |
l2->xv_nt[i][ip] = ((TrkTrack *)Track->At(i))->xv[ip]; |
806 |
l2->axv_nt[i][ip] = ((TrkTrack *)Track->At(i))->axv[ip]; |
l2->yv_nt[i][ip] = ((TrkTrack *)Track->At(i))->yv[ip]; |
807 |
l2->ayv_nt[i][ip] = ((TrkTrack *)Track->At(i))->ayv[ip]; |
l2->zv_nt[i][ip] = ((TrkTrack *)Track->At(i))->zv[ip]; |
808 |
l2->dedx_x[i][ip] = ((TrkTrack *)Track->At(i))->dedx_x[ip]; |
l2->axv_nt[i][ip] = ((TrkTrack *)Track->At(i))->axv[ip]; |
809 |
l2->dedx_y[i][ip] = ((TrkTrack *)Track->At(i))->dedx_y[ip]; |
l2->ayv_nt[i][ip] = ((TrkTrack *)Track->At(i))->ayv[ip]; |
810 |
}; |
l2->dedx_x[i][ip] = ((TrkTrack *)Track->At(i))->dedx_x[ip]; |
811 |
|
l2->dedx_y[i][ip] = ((TrkTrack *)Track->At(i))->dedx_y[ip]; |
812 |
|
}; |
813 |
|
} |
814 |
} |
} |
|
|
|
815 |
// *** SINGLETS *** |
// *** SINGLETS *** |
816 |
l2->nclsx = SingletX->GetEntries(); |
if(SingletX){ |
817 |
for(Int_t i=0;i<l2->nclsx;i++){ |
l2->nclsx = SingletX->GetEntries(); |
818 |
l2->planex[i] = ((TrkSinglet *)SingletX->At(i))->plane; |
for(Int_t i=0;i<l2->nclsx;i++){ |
819 |
l2->xs[i][0] = ((TrkSinglet *)SingletX->At(i))->coord[0]; |
l2->planex[i] = ((TrkSinglet *)SingletX->At(i))->plane; |
820 |
l2->xs[i][1] = ((TrkSinglet *)SingletX->At(i))->coord[1]; |
l2->xs[i][0] = ((TrkSinglet *)SingletX->At(i))->coord[0]; |
821 |
l2->signlxs[i] = ((TrkSinglet *)SingletX->At(i))->sgnl; |
l2->xs[i][1] = ((TrkSinglet *)SingletX->At(i))->coord[1]; |
822 |
} |
l2->signlxs[i] = ((TrkSinglet *)SingletX->At(i))->sgnl; |
823 |
l2->nclsy = SingletY->GetEntries(); |
} |
824 |
for(Int_t i=0;i<l2->nclsy;i++){ |
} |
825 |
l2->planey[i] = ((TrkSinglet *)SingletY->At(i))->plane; |
|
826 |
l2->ys[i][0] = ((TrkSinglet *)SingletY->At(i))->coord[0]; |
if(SingletY){ |
827 |
l2->ys[i][1] = ((TrkSinglet *)SingletY->At(i))->coord[1]; |
l2->nclsy = SingletY->GetEntries(); |
828 |
l2->signlys[i] = ((TrkSinglet *)SingletY->At(i))->sgnl; |
for(Int_t i=0;i<l2->nclsy;i++){ |
829 |
|
l2->planey[i] = ((TrkSinglet *)SingletY->At(i))->plane; |
830 |
|
l2->ys[i][0] = ((TrkSinglet *)SingletY->At(i))->coord[0]; |
831 |
|
l2->ys[i][1] = ((TrkSinglet *)SingletY->At(i))->coord[1]; |
832 |
|
l2->signlys[i] = ((TrkSinglet *)SingletY->At(i))->sgnl; |
833 |
|
} |
834 |
} |
} |
835 |
} |
} |
836 |
//-------------------------------------- |
//-------------------------------------- |
838 |
// |
// |
839 |
//-------------------------------------- |
//-------------------------------------- |
840 |
void TrkLevel2::Clear(){ |
void TrkLevel2::Clear(){ |
|
good2 = -1; |
|
841 |
for(Int_t i=0; i<12 ; i++){ |
for(Int_t i=0; i<12 ; i++){ |
842 |
crc[i] = -1; |
good[i] = -1; |
843 |
}; |
}; |
844 |
/* Track->RemoveAll(); |
// if(Track)Track->Clear("C"); |
845 |
SingletX->RemoveAll(); |
// if(SingletX)SingletX->Clear("C"); |
846 |
SingletY->RemoveAll();*/ |
// if(SingletY)SingletY->Clear("C"); |
847 |
// modify to avoid memory leakage |
if(Track)Track->Delete(); |
848 |
Track->Clear(); |
if(SingletX)SingletX->Delete(); |
849 |
SingletX->Clear(); |
if(SingletY)SingletY->Delete(); |
850 |
SingletY->Clear(); |
} |
851 |
|
// //-------------------------------------- |
852 |
|
// // |
853 |
|
// // |
854 |
|
// //-------------------------------------- |
855 |
|
void TrkLevel2::Delete(){ |
856 |
|
|
857 |
|
// cout << "void TrkLevel2::Delete()"<<endl; |
858 |
|
Clear(); |
859 |
|
if(Track)delete Track; |
860 |
|
if(SingletX)delete SingletX; |
861 |
|
if(SingletY)delete SingletY; |
862 |
|
|
863 |
} |
} |
864 |
//-------------------------------------- |
//-------------------------------------- |
865 |
// |
// |
869 |
* 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). |
870 |
* 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. |
871 |
*/ |
*/ |
872 |
// TClonesArray *TrkLevel2::GetTracks(){ |
TRefArray *TrkLevel2::GetTracks_NFitSorted(){ |
|
// TClonesArray *sorted = GetTracks_NFitSorted(); |
|
|
// return sorted; |
|
|
// }; |
|
873 |
|
|
874 |
/*TClonesArray *TrkLevel2::GetTracks_Chi2Sorted(){ |
if(!Track)return 0; |
875 |
|
|
876 |
TClonesArray *sorted = new TClonesArray("TrkTrack"); |
TRefArray *sorted = new TRefArray(); |
877 |
TClonesArray &t = *Track; |
|
878 |
TClonesArray &ts = *sorted; |
TClonesArray &t = *Track; |
879 |
int N=this->ntrk(); |
// TClonesArray &ts = *PhysicalTrack; |
880 |
|
int N = ntrk(); |
881 |
vector<int> m(N); for(int i=0; i<N; i++)m[i]=1; |
vector<int> m(N); for(int i=0; i<N; i++)m[i]=1; |
882 |
|
// int m[50]; for(int i=0; i<N; i++)m[i]=1; |
883 |
|
|
884 |
int indo=0; |
int indo=0; |
885 |
int indi=0; |
int indi=0; |
886 |
while(N != 0){ |
while(N != 0){ |
887 |
float chi2ref=1000000; |
int nfit =0; |
888 |
|
float chi2ref = numeric_limits<float>::max(); |
889 |
|
|
890 |
|
// first loop to search maximum num. of fit points |
891 |
|
for(int i=0; i < ntrk(); i++){ |
892 |
|
if( ((TrkTrack *)t[i])->GetNtot() >= nfit && m[i]==1){ |
893 |
|
nfit = ((TrkTrack *)t[i])->GetNtot(); |
894 |
|
} |
895 |
|
} |
896 |
|
//second loop to search minimum chi2 among selected |
897 |
for(int i=0; i<this->ntrk(); i++){ |
for(int i=0; i<this->ntrk(); i++){ |
898 |
if(((TrkTrack *)t[i])->chi2 < chi2ref && m[i]==1){ |
Float_t chi2 = ((TrkTrack *)t[i])->chi2; |
899 |
|
if(chi2 < 0) chi2 = chi2*1000; |
900 |
|
if( chi2 < chi2ref |
901 |
|
&& ((TrkTrack *)t[i])->GetNtot() == nfit |
902 |
|
&& m[i]==1){ |
903 |
chi2ref = ((TrkTrack *)t[i])->chi2; |
chi2ref = ((TrkTrack *)t[i])->chi2; |
904 |
indi = i; |
indi = i; |
905 |
} |
}; |
906 |
} |
}; |
907 |
if( ((TrkTrack *)t[indi])->image != -1 ){ |
if( ((TrkTrack *)t[indi])->HasImage() ){ |
908 |
m[((TrkTrack *)t[indi])->image] = 0; |
m[((TrkTrack *)t[indi])->image] = 0; |
909 |
N--; |
N--; |
910 |
} |
|
911 |
new(ts[indo]) TrkTrack(*(TrkTrack*)t[indi]); |
// cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl; |
912 |
|
}; |
913 |
|
sorted->Add( (TrkTrack*)t[indi] ); |
914 |
|
|
915 |
m[indi] = 0; |
m[indi] = 0; |
916 |
|
// cout << "SORTED "<< indo << " "<< indi << " "<< N << endl; |
917 |
N--; |
N--; |
918 |
indo++; |
indo++; |
919 |
} |
} |
920 |
return sorted; |
m.clear(); |
|
}*/ |
|
|
/*TClonesArray *TrkLevel2::GetTracks_NFitSorted(){ |
|
|
|
|
|
TClonesArray *sorted = new TClonesArray("TrkTrack"); |
|
|
TClonesArray &t = *Track; |
|
|
TClonesArray &ts = *sorted; |
|
|
// TClonesArray &ts = *PhysicalTrack; |
|
|
int N = ntrk(); |
|
|
vector<int> m(N); for(int i=0; i<N; i++)m[i]=1; |
|
|
// int m[50]; for(int i=0; i<N; i++)m[i]=1; |
|
|
|
|
|
int indo=0; |
|
|
int indi=0; |
|
|
while(N != 0){ |
|
|
int nfit =0; |
|
|
float chi2ref = numeric_limits<float>::max(); |
|
|
// first loop to search maximum num. of fit points |
|
|
for(int i=0; i < ntrk(); i++){ |
|
|
// if(N==ntrk())cout << "** "<<i<< " " << ((TrkTrack *)t[i])->GetImageSeqNo()<< " " <<((TrkTrack *)t[i])->GetNtot() << " " <<((TrkTrack *)t[i])->chi2 << endl; |
|
|
if( ((TrkTrack *)t[i])->GetNtot() >= nfit && m[i]==1){ |
|
|
nfit = ((TrkTrack *)t[i])->GetNtot(); |
|
|
} |
|
|
} |
|
|
//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; |
|
|
|
|
|
// cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl; |
|
|
} |
|
|
new(ts[indo]) TrkTrack(*(TrkTrack*)t[indi]); |
|
|
m[indi] = 0; |
|
|
// cout << "SORTED "<< indo << " "<< indi << " "<< N << endl; |
|
|
N--; |
|
|
indo++; |
|
|
} |
|
|
m.clear(); |
|
|
return sorted; |
|
|
// return PhysicalTrack; |
|
|
}*/ |
|
|
//TClonesArray *TrkLevel2::GetTracks_NFitSorted(){ |
|
|
TRefArray *TrkLevel2::GetTracks_NFitSorted(){ |
|
|
|
|
|
// cout << "GetTracks_NFitSorted(it): new TRefArray()"<< endl; |
|
|
// TClonesArray *sorted = new TClonesArray("TrkTrack"); |
|
|
// TClonesArray &ts = *sorted; |
|
|
TRefArray *sorted = new TRefArray(); |
|
|
|
|
|
TClonesArray &t = *Track; |
|
|
// TClonesArray &ts = *PhysicalTrack; |
|
|
int N = ntrk(); |
|
|
vector<int> m(N); for(int i=0; i<N; i++)m[i]=1; |
|
|
// int m[50]; for(int i=0; i<N; i++)m[i]=1; |
|
|
|
|
|
int indo=0; |
|
|
int indi=0; |
|
|
while(N != 0){ |
|
|
int nfit =0; |
|
|
float chi2ref = numeric_limits<float>::max(); |
|
|
// first loop to search maximum num. of fit points |
|
|
for(int i=0; i < ntrk(); i++){ |
|
|
// if(N==ntrk())cout << "** "<<i<< " " << ((TrkTrack *)t[i])->GetImageSeqNo()<< " " <<((TrkTrack *)t[i])->GetNtot() << " " <<((TrkTrack *)t[i])->chi2 << endl; |
|
|
if( ((TrkTrack *)t[i])->GetNtot() >= nfit && m[i]==1){ |
|
|
nfit = ((TrkTrack *)t[i])->GetNtot(); |
|
|
} |
|
|
} |
|
|
//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; |
|
|
|
|
|
// cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl; |
|
|
} |
|
|
// new(ts[indo]) TrkTrack(*(TrkTrack*)t[indi]); |
|
|
// cout << "GetTracks_NFitSorted(it): Add("<<indo<<")"<< endl; |
|
|
sorted->Add( (TrkTrack*)t[indi] ); |
|
|
|
|
|
m[indi] = 0; |
|
|
// cout << "SORTED "<< indo << " "<< indi << " "<< N << endl; |
|
|
N--; |
|
|
indo++; |
|
|
} |
|
|
m.clear(); |
|
921 |
// cout << "GetTracks_NFitSorted(it): Done"<< endl; |
// cout << "GetTracks_NFitSorted(it): Done"<< endl; |
922 |
|
|
923 |
return sorted; |
return sorted; |
924 |
// return PhysicalTrack; |
// return PhysicalTrack; |
925 |
} |
} |
926 |
//-------------------------------------- |
//-------------------------------------- |
939 |
cout << " Stored tracks ntrk() = "<< this->ntrk() << endl; |
cout << " Stored tracks ntrk() = "<< this->ntrk() << endl; |
940 |
return 0; |
return 0; |
941 |
} |
} |
942 |
|
if(!Track){ |
943 |
|
cout << "TrkTrack *TrkLevel2::GetStoredTrack(int is) >> (TClonesArray*) Track ==0 "<<endl; |
944 |
|
}; |
945 |
TClonesArray &t = *(Track); |
TClonesArray &t = *(Track); |
946 |
TrkTrack *track = (TrkTrack*)t[is]; |
TrkTrack *track = (TrkTrack*)t[is]; |
947 |
return track; |
return track; |
961 |
cout << " Stored x-singlets nclsx() = "<< this->nclsx() << endl; |
cout << " Stored x-singlets nclsx() = "<< this->nclsx() << endl; |
962 |
return 0; |
return 0; |
963 |
} |
} |
964 |
|
if(!SingletX)return 0; |
965 |
TClonesArray &t = *(SingletX); |
TClonesArray &t = *(SingletX); |
966 |
TrkSinglet *singlet = (TrkSinglet*)t[is]; |
TrkSinglet *singlet = (TrkSinglet*)t[is]; |
967 |
return singlet; |
return singlet; |
981 |
cout << " Stored y-singlets nclsy() = "<< this->nclsx() << endl; |
cout << " Stored y-singlets nclsy() = "<< this->nclsx() << endl; |
982 |
return 0; |
return 0; |
983 |
} |
} |
984 |
|
if(!SingletY)return 0; |
985 |
TClonesArray &t = *(SingletY); |
TClonesArray &t = *(SingletY); |
986 |
TrkSinglet *singlet = (TrkSinglet*)t[is]; |
TrkSinglet *singlet = (TrkSinglet*)t[is]; |
987 |
return singlet; |
return singlet; |
994 |
* Retrieves the it-th "physical" track, sorted by the method GetNTracks(). |
* Retrieves the it-th "physical" track, sorted by the method GetNTracks(). |
995 |
* @param it Track number, ranging from 0 to GetNTracks(). |
* @param it Track number, ranging from 0 to GetNTracks(). |
996 |
*/ |
*/ |
997 |
/*TrkTrack *TrkLevel2::GetTrack(int it){ |
|
|
|
|
|
if(it >= this->GetNTracks()){ |
|
|
cout << "** TrkLevel2 ** Track "<< it << "does not exits! " << endl; |
|
|
cout << " Physical tracks GetNTracks() = "<< this->ntrk() << endl; |
|
|
return 0; |
|
|
} |
|
|
TClonesArray* sorted = GetTracks(); |
|
|
TClonesArray &ts = *sorted; |
|
|
|
|
|
// TrkTrack *track = (TrkTrack*)ts[it]; |
|
|
TrkTrack *track = new TrkTrack( *(TrkTrack*)ts[it] ); //copia |
|
|
sorted->Delete("all");////TEMPORANEO |
|
|
return track; |
|
|
}*/ |
|
998 |
TrkTrack *TrkLevel2::GetTrack(int it){ |
TrkTrack *TrkLevel2::GetTrack(int it){ |
999 |
|
|
1000 |
if(it >= this->GetNTracks()){ |
if(it >= this->GetNTracks()){ |
1004 |
} |
} |
1005 |
|
|
1006 |
TRefArray *sorted = GetTracks(); //TEMPORANEO |
TRefArray *sorted = GetTracks(); //TEMPORANEO |
1007 |
|
if(!sorted)return 0; |
1008 |
TrkTrack *track = (TrkTrack*)sorted->At(it); |
TrkTrack *track = (TrkTrack*)sorted->At(it); |
1009 |
sorted->Delete(); |
sorted->Clear(); |
1010 |
|
delete sorted; |
1011 |
return track; |
return track; |
1012 |
} |
} |
1013 |
/** |
/** |
1016 |
Int_t TrkLevel2::GetNTracks(){ |
Int_t TrkLevel2::GetNTracks(){ |
1017 |
|
|
1018 |
Float_t ntot=0; |
Float_t ntot=0; |
1019 |
|
if(!Track)return 0; |
1020 |
TClonesArray &t = *Track; |
TClonesArray &t = *Track; |
1021 |
for(int i=0; i<ntrk(); i++) { |
for(int i=0; i<ntrk(); i++) { |
1022 |
if( ((TrkTrack *)t[i])->GetImageSeqNo() == -1 ) ntot+=1.; |
if( ((TrkTrack *)t[i])->GetImageSeqNo() == -1 ) ntot+=1.; |
1023 |
else ntot+=0.5; |
else ntot+=0.5; |
1024 |
} |
} |
1033 |
* Retrieves (if present) the image of the it-th "physical" track, sorted by the method GetNTracks(). |
* Retrieves (if present) the image of the it-th "physical" track, sorted by the method GetNTracks(). |
1034 |
* @param it Track number, ranging from 0 to GetNTracks(). |
* @param it Track number, ranging from 0 to GetNTracks(). |
1035 |
*/ |
*/ |
1036 |
/*TrkTrack *TrkLevel2::GetTrackImage(int it){ |
TrkTrack *TrkLevel2::GetTrackImage(int it){ |
1037 |
|
|
1038 |
if(it >= this->GetNTracks()){ |
if(it >= this->GetNTracks()){ |
1039 |
cout << "** TrkLevel2 ** Track "<< it << "does not exits! " << endl; |
cout << "** TrkLevel2 ** Track "<< it << "does not exits! " << endl; |
1041 |
return 0; |
return 0; |
1042 |
} |
} |
1043 |
|
|
1044 |
TClonesArray* sorted = GetTracks(); |
TRefArray* sorted = GetTracks(); //TEMPORANEO |
1045 |
TClonesArray &ts = *sorted; |
if(!sorted)return 0; |
1046 |
TrkTrack *track = (TrkTrack*)ts[it]; |
TrkTrack *track = (TrkTrack*)sorted->At(it); |
1047 |
// TrkTrack *track = (TrkTrack*)(*(this->GetTracks()))[it]; |
|
1048 |
|
if(!track->HasImage()){ |
|
if(!track->HasImage()){ |
|
1049 |
cout << "** TrkLevel2 ** Track "<< it << "does not have image! " << endl; |
cout << "** TrkLevel2 ** Track "<< it << "does not have image! " << endl; |
1050 |
return 0; |
return 0; |
1051 |
} |
} |
1052 |
|
if(!Track)return 0; |
1053 |
TrkTrack *image = (TrkTrack*)(*Track)[track->image]; |
TrkTrack *image = (TrkTrack*)(*Track)[track->image]; |
1054 |
|
|
1055 |
// GetTracks()->Delete(); ////TEMPORANEO |
sorted->Delete(); |
1056 |
sorted->Delete(); ////TEMPORANEO |
delete sorted; |
|
|
|
|
return image; |
|
|
|
|
|
}*/ |
|
|
TrkTrack *TrkLevel2::GetTrackImage(int it){ |
|
1057 |
|
|
1058 |
if(it >= this->GetNTracks()){ |
return image; |
|
cout << "** TrkLevel2 ** Track "<< it << "does not exits! " << endl; |
|
|
cout << " Physical tracks GetNTracks() = "<< this->ntrk() << endl; |
|
|
return 0; |
|
|
} |
|
|
|
|
|
TRefArray* sorted = GetTracks(); //TEMPORANEO |
|
|
TrkTrack *track = (TrkTrack*)sorted->At(it); |
|
|
|
|
|
if(!track->HasImage()){ |
|
|
cout << "** TrkLevel2 ** Track "<< it << "does not have image! " << endl; |
|
|
return 0; |
|
|
} |
|
|
TrkTrack *image = (TrkTrack*)(*Track)[track->image]; |
|
|
|
|
|
sorted->Delete(); |
|
|
|
|
|
return image; |
|
1059 |
|
|
1060 |
} |
} |
1061 |
//-------------------------------------- |
//-------------------------------------- |
1066 |
* Loads the magnetic field. |
* Loads the magnetic field. |
1067 |
* @param s Path of the magnetic-field files. |
* @param s Path of the magnetic-field files. |
1068 |
*/ |
*/ |
1069 |
void TrkLevel2::LoadField(TString s){ |
void TrkLevel2::LoadField(TString path){ |
1070 |
readb_(s.Data()); |
// |
1071 |
|
strcpy(path_.path,path.Data()); |
1072 |
|
path_.pathlen = path.Length(); |
1073 |
|
path_.error = 0; |
1074 |
|
readb_(); |
1075 |
|
// |
1076 |
}; |
}; |
1077 |
|
/** |
1078 |
|
* Get BY (kGauss) |
1079 |
|
* @param v (x,y,z) coordinates in cm |
1080 |
|
*/ |
1081 |
|
float TrkLevel2::GetBX(float* v){ |
1082 |
|
float b[3]; |
1083 |
|
gufld_(v,b); |
1084 |
|
return b[0]/10.; |
1085 |
|
} |
1086 |
|
/** |
1087 |
|
* Get BY (kGauss) |
1088 |
|
* @param v (x,y,z) coordinates in cm |
1089 |
|
*/ |
1090 |
|
float TrkLevel2::GetBY(float* v){ |
1091 |
|
float b[3]; |
1092 |
|
gufld_(v,b); |
1093 |
|
return b[1]/10.; |
1094 |
|
} |
1095 |
|
/** |
1096 |
|
* Get BY (kGauss) |
1097 |
|
* @param v (x,y,z) coordinates in cm |
1098 |
|
*/ |
1099 |
|
float TrkLevel2::GetBZ(float* v){ |
1100 |
|
float b[3]; |
1101 |
|
gufld_(v,b); |
1102 |
|
return b[2]/10.; |
1103 |
|
} |
1104 |
//-------------------------------------- |
//-------------------------------------- |
1105 |
// |
// |
1106 |
// |
// |
1208 |
npoint=i; |
npoint=i; |
1209 |
if(npoint != n)cout << "NB! Trajectory created with "<<npoint<<" points"<<endl; |
if(npoint != n)cout << "NB! Trajectory created with "<<npoint<<" points"<<endl; |
1210 |
} |
} |
1211 |
|
void Trajectory::Delete(){ |
1212 |
|
|
1213 |
|
if(x) delete [] x; |
1214 |
|
if(y) delete [] y; |
1215 |
|
if(z) delete [] z; |
1216 |
|
if(thx) delete [] thx; |
1217 |
|
if(thy) delete [] thy; |
1218 |
|
if(tl) delete [] tl; |
1219 |
|
|
1220 |
|
} |
1221 |
//-------------------------------------- |
//-------------------------------------- |
1222 |
// |
// |
1223 |
// |
// |
1256 |
|
|
1257 |
} |
} |
1258 |
|
|
1259 |
|
/** |
1260 |
|
* Evaluates the trajectory in the apparatus associated to the track. |
1261 |
|
* 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. |
1262 |
|
* @param t pointer to an object of the class Trajectory, |
1263 |
|
* which z coordinates should be previously initialized by calling the proper constructor ( Trajectory::Trajectory(int n, float* zin) ). |
1264 |
|
* @return error flag. |
1265 |
|
*/ |
1266 |
|
int Trajectory::DoTrack2(float* al){ |
1267 |
|
|
1268 |
|
double *dxout = new double[npoint]; |
1269 |
|
double *dyout = new double[npoint]; |
1270 |
|
double *dthxout = new double[npoint]; |
1271 |
|
double *dthyout = new double[npoint]; |
1272 |
|
double *dtlout = new double[npoint]; |
1273 |
|
double *dzin = new double[npoint]; |
1274 |
|
double dal[5]; |
1275 |
|
|
1276 |
|
int ifail = 0; |
1277 |
|
|
1278 |
|
for (int i=0; i<5; i++) dal[i] = (double)al[i]; |
1279 |
|
for (int i=0; i<npoint; i++) dzin[i] = (double)z[i]; |
1280 |
|
|
1281 |
|
dotrack2_(&(npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail); |
1282 |
|
|
1283 |
|
for (int i=0; i<npoint; i++){ |
1284 |
|
x[i] = (float)*dxout++; |
1285 |
|
y[i] = (float)*dyout++; |
1286 |
|
thx[i] = (float)*dthxout++; |
1287 |
|
thy[i] = (float)*dthyout++; |
1288 |
|
tl[i] = (float)*dtlout++; |
1289 |
|
} |
1290 |
|
|
1291 |
|
return ifail; |
1292 |
|
}; |
1293 |
|
|
1294 |
ClassImp(TrkLevel2); |
ClassImp(TrkLevel2); |
1295 |
ClassImp(TrkSinglet); |
ClassImp(TrkSinglet); |
1296 |
ClassImp(TrkTrack); |
ClassImp(TrkTrack); |