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