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 |
void mini2_(int*,int*,int*); |
// 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; |
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++)coval[it1][it2] = 0; |
for(int it2=0;it2<5;it2++)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; |
38 |
ygood[ip] = 0; |
ygood[ip] = 0; |
39 |
xm[ip] = 0; |
xm[ip] = 0; |
40 |
ym[ip] = 0; |
ym[ip] = 0; |
41 |
zm[ip] = 0; |
zm[ip] = 0; |
42 |
resx[ip] = 0; |
resx[ip] = 0; |
43 |
resy[ip] = 0; |
resy[ip] = 0; |
44 |
xv[ip] = 0; |
xv[ip] = 0; |
45 |
yv[ip] = 0; |
yv[ip] = 0; |
46 |
zv[ip] = 0; |
zv[ip] = 0; |
47 |
axv[ip] = 0; |
axv[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 |
// clx[ip] = 0; |
}; |
52 |
// cly[ip] = 0; |
clx = 0; |
53 |
}; |
cly = 0; |
54 |
clx = new TRefArray(6,0); |
// clx = new TRefArray(6,0); |
55 |
cly = new TRefArray(6,0); |
// 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; |
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++)coval[it1][it2] = t.coval[it1][it2]; |
for(int it2=0;it2<5;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]; |
72 |
ygood[ip] = t.ygood[ip]; |
ygood[ip] = t.ygood[ip]; |
73 |
xm[ip] = t.xm[ip]; |
xm[ip] = t.xm[ip]; |
74 |
ym[ip] = t.ym[ip]; |
ym[ip] = t.ym[ip]; |
75 |
zm[ip] = t.zm[ip]; |
zm[ip] = t.zm[ip]; |
76 |
resx[ip] = t.resx[ip]; |
resx[ip] = t.resx[ip]; |
77 |
resy[ip] = t.resy[ip]; |
resy[ip] = t.resy[ip]; |
78 |
xv[ip] = t.xv[ip]; |
xv[ip] = t.xv[ip]; |
79 |
yv[ip] = t.yv[ip]; |
yv[ip] = t.yv[ip]; |
80 |
zv[ip] = t.zv[ip]; |
zv[ip] = t.zv[ip]; |
81 |
axv[ip] = t.axv[ip]; |
axv[ip] = t.axv[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 |
// clx[ip] = 0;//<<<<pointer |
}; |
86 |
// cly[ip] = 0;//<<<<pointer |
clx = 0; |
87 |
}; |
cly = 0; |
88 |
clx = new TRefArray(*(t.clx)); |
if(t.clx)clx = new TRefArray(*(t.clx)); |
89 |
cly = new TRefArray(*(t.cly)); |
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 |
|
// |
127 |
|
// |
128 |
|
//-------------------------------------- |
129 |
/** |
/** |
130 |
* Evaluates the trajectory in the apparatus associated to the track. |
* Evaluates the trajectory in the apparatus associated to the track. |
131 |
* 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. |
* 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. |
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++){ |
268 |
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[4][i]<<" "; |
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 |
* Set the TrkTrack position measurements |
296 |
/** |
/** |
297 |
* Load the magnetic field |
* Load the magnetic field |
298 |
*/ |
*/ |
299 |
void TrkTrack::LoadField(TString s){ |
void TrkTrack::LoadField(TString path){ |
300 |
readb_(s.Data()); |
|
301 |
|
// strcpy(path_.path,path.Data()); |
302 |
|
// path_.pathlen = path.Length(); |
303 |
|
// path_.error = 0; |
304 |
|
// readb_(); |
305 |
|
|
306 |
|
TrkParams::Set(path,1); |
307 |
|
TrkParams::Load(1); |
308 |
|
|
309 |
}; |
}; |
310 |
|
|
311 |
|
|
312 |
|
/** |
313 |
|
* Method to fill minimization-routine common |
314 |
|
*/ |
315 |
|
void TrkTrack::FillMiniStruct(cMini2track& track){ |
316 |
|
|
317 |
|
for(int i=0; i<6; i++){ |
318 |
|
|
319 |
|
track.xgood[i]=xgood[i]; |
320 |
|
track.ygood[i]=ygood[i]; |
321 |
|
|
322 |
|
track.xm[i]=xm[i]; |
323 |
|
track.ym[i]=ym[i]; |
324 |
|
track.zm[i]=zm[i]; |
325 |
|
|
326 |
|
// --- temporaneo ---------------------------- |
327 |
|
// andrebbe inserita la dimensione del sensore |
328 |
|
float segment = 100.; |
329 |
|
track.xm_a[i]=xm[i]; |
330 |
|
track.xm_b[i]=xm[i]; |
331 |
|
track.ym_a[i]=ym[i]; |
332 |
|
track.ym_b[i]=ym[i]; |
333 |
|
if( xgood[i] && !ygood[i] ){ |
334 |
|
track.ym_a[i] = track.ym_a[i]+segment; |
335 |
|
track.ym_b[i] = track.ym_b[i]-segment; |
336 |
|
}else if( !xgood[i] && ygood[i]){ |
337 |
|
track.xm_a[i] = track.xm_a[i]+segment; |
338 |
|
track.xm_b[i] = track.xm_b[i]-segment; |
339 |
|
} |
340 |
|
// --- temporaneo ---------------------------- |
341 |
|
|
342 |
|
track.resx[i]=resx[i]; |
343 |
|
track.resy[i]=resy[i]; |
344 |
|
} |
345 |
|
|
346 |
|
for(int i=0; i<5; i++) track.al[i]=al[i]; |
347 |
|
track.zini = 23.5; |
348 |
|
// ZINI = 23.5 !!! it should be the same parameter in all codes |
349 |
|
|
350 |
|
} |
351 |
|
/** |
352 |
|
* Method to set values from minimization-routine common |
353 |
|
*/ |
354 |
|
void TrkTrack::SetFromMiniStruct(cMini2track *track){ |
355 |
|
|
356 |
|
for(int i=0; i<5; i++) { |
357 |
|
al[i]=track->al[i]; |
358 |
|
for(int j=0; j<5; j++) coval[i][j]=track->cov[i][j]; |
359 |
|
} |
360 |
|
chi2 = track->chi2; |
361 |
|
nstep = track->nstep; |
362 |
|
for(int i=0; i<6; i++){ |
363 |
|
xv[i] = track->xv[i]; |
364 |
|
yv[i] = track->yv[i]; |
365 |
|
zv[i] = track->zv[i]; |
366 |
|
xm[i] = track->xm[i]; |
367 |
|
ym[i] = track->ym[i]; |
368 |
|
zm[i] = track->zm[i]; |
369 |
|
axv[i] = track->axv[i]; |
370 |
|
ayv[i] = track->ayv[i]; |
371 |
|
} |
372 |
|
|
373 |
|
} |
374 |
/** |
/** |
375 |
* Tracking method. It calls F77 mini routine. |
* Tracking method. It calls F77 mini routine. |
376 |
*/ |
*/ |
377 |
void TrkTrack::Fit(double pfixed, int& fail, int iprint){ |
void TrkTrack::Fit(double pfixed, int& fail, int iprint){ |
378 |
|
|
379 |
|
float al_ini[] = {0.,0.,0.,0.,0.}; |
380 |
|
|
381 |
extern cMini2track track_; |
extern cMini2track track_; |
382 |
fail = 0; |
fail = 0; |
383 |
// extern cMini2fitinfo fit_info_; |
FillMiniStruct(track_); |
384 |
// extern void mini_2_(int*,int*); |
|
385 |
// track_.xm[0]=1.0; |
// if fit variables have been reset, evaluate the initial guess |
386 |
for(int i=0; i<6; i++) track_.xm[i]=xm[i]; |
if(al[0]==-9999.&&al[1]==-9999.&&al[2]==-9999.&&al[3]==-9999.&&al[4]==-9999.)guess_(); |
387 |
for(int i=0; i<6; i++) track_.ym[i]=ym[i]; |
|
388 |
for(int i=0; i<6; i++) track_.zm[i]=zm[i]; |
// --------------------- free momentum |
389 |
for(int i=0; i<6; i++) track_.resx[i]=resx[i]; |
if(pfixed==0.) { |
390 |
for(int i=0; i<6; i++) track_.resy[i]=resy[i]; |
track_.pfixed=0.; |
|
for(int i=0; i<6; i++) track_.xgood[i]=xgood[i]; |
|
|
for(int i=0; i<6; i++) track_.ygood[i]=ygood[i]; |
|
|
// initial guess of "al" with linear fit |
|
|
if(al[0]==-9999.&&al[1]==-9999.&&al[2]==-9999.&&al[3]==-9999.&&al[4]==-9999.){ |
|
|
double szz=0., szx=0., szy=0., ssx=0., ssy=0., sz=0., s1=0.; |
|
|
double det, ax, ay, bx, by; |
|
|
for(int i=0; i<NPLANE; i++) { |
|
|
szz=szz+zm[i]*zm[i]; |
|
|
szx=szx+zm[i]*xm[i]; |
|
|
szy=szy+zm[i]*ym[i]; |
|
|
ssx=ssx+xm[i]; |
|
|
ssy=ssy+ym[i]; |
|
|
sz=sz+zm[i]; |
|
|
s1=s1+1.; |
|
|
} |
|
|
det=szz*s1-sz*sz; |
|
|
ax=(szx*s1-sz*ssx)/det; |
|
|
bx=(szz*ssx-szx*sz)/det; |
|
|
ay=(szy*s1-sz*ssy)/det; |
|
|
by=(szz*ssy-szy*sz)/det; |
|
|
al[0]=ax*23.5+bx; // ZINI = 23.5 !!! it should be the same parameter in all codes |
|
|
al[1]=ay*23.5+by; // " |
|
|
al[2]= sqrt(pow(ax,2)+pow(ay,2))/ sqrt(pow(ax,2)+pow(ay,2)+1.); |
|
|
al[3]=0.; |
|
|
if( (ax!=0.)||(ay!=0.) ) { |
|
|
al[3]= asin(ay/ sqrt(pow(ax,2)+pow(ay,2))); |
|
|
if(ax<0.) al[3]=acos(-1.)-al[3]; |
|
|
} |
|
|
al[4]=0.; |
|
391 |
} |
} |
392 |
// end guess |
// --------------------- fixed momentum |
|
for(int i=0; i<5; i++) track_.al[i]=al[i]; |
|
393 |
if(pfixed!=0.) { |
if(pfixed!=0.) { |
394 |
al[4]=1./pfixed; // to fix the momentum |
al[4]=1./pfixed; |
395 |
track_.pfixed=pfixed; // " |
track_.pfixed=pfixed; |
396 |
|
} |
397 |
|
|
398 |
|
// store temporarily the initial guess |
399 |
|
for(int i=0; i<5; i++) al_ini[i]=track_.al[i]; |
400 |
|
|
401 |
|
// ------------------------------------------ |
402 |
|
// call mini routine |
403 |
|
TrkParams::Load(1); |
404 |
|
if( !TrkParams::IsLoaded(1) ){ |
405 |
|
cout << "void TrkTrack::Fit(double pfixed, int& fail, int iprint) --- ERROR --- m.field not loaded"<<endl; |
406 |
|
return; |
407 |
} |
} |
408 |
int istep=0; |
int istep=0; |
409 |
int ifail=0; |
int ifail=0; |
410 |
mini2_(&istep,&ifail, &iprint); |
mini2_(&istep,&ifail, &iprint); |
411 |
if(ifail!=0) { |
if(ifail!=0) { |
412 |
if(iprint==1)cout << "ERROR: ifail= " << ifail << endl; |
if(iprint)cout << "ERROR: ifail= " << ifail << endl; |
413 |
fail = 1; |
fail = 1; |
|
// return; |
|
414 |
} |
} |
415 |
|
// ------------------------------------------ |
416 |
|
|
417 |
|
SetFromMiniStruct(&track_); |
418 |
// cout << endl << "eta ===> " << track_.al[4] << endl; |
// cout << endl << "eta ===> " << track_.al[4] << endl; |
419 |
|
|
420 |
for(int i=0; i<5; i++) al[i]=track_.al[i]; |
// for(int i=0; i<5; i++) al[i]=track_.al[i]; |
421 |
chi2=track_.chi2; |
// chi2=track_.chi2; |
422 |
nstep=track_.nstep; |
// nstep=track_.nstep; |
423 |
for(int i=0; i<6; i++) xv[i]=track_.xv[i]; |
// for(int i=0; i<6; i++) xv[i]=track_.xv[i]; |
424 |
for(int i=0; i<6; i++) yv[i]=track_.yv[i]; |
// for(int i=0; i<6; i++) yv[i]=track_.yv[i]; |
425 |
for(int i=0; i<6; i++) zv[i]=track_.zv[i]; |
// for(int i=0; i<6; i++) zv[i]=track_.zv[i]; |
426 |
for(int i=0; i<6; i++) axv[i]=track_.axv[i]; |
// for(int i=0; i<6; i++) axv[i]=track_.axv[i]; |
427 |
for(int i=0; i<6; i++) ayv[i]=track_.ayv[i]; |
// for(int i=0; i<6; i++) ayv[i]=track_.ayv[i]; |
428 |
for(int i=0; i<5; i++) { |
// for(int i=0; i<5; i++) { |
429 |
for(int j=0; j<5; j++) coval[i][j]=track_.cov[i][j]; |
// for(int j=0; j<5; j++) coval[i][j]=track_.cov[i][j]; |
430 |
|
// } |
431 |
|
|
432 |
|
if(fail){ |
433 |
|
if(iprint)cout << " >>>> fit failed >>>> drawing initial par"<<endl; |
434 |
|
for(int i=0; i<5; i++) al[i]=al_ini[i]; |
435 |
} |
} |
436 |
|
|
437 |
}; |
}; |
438 |
/* |
/* |
439 |
* Reset the parameters fit |
* Reset the fit parameters |
440 |
*/ |
*/ |
441 |
void TrkTrack::FitReset(){ |
void TrkTrack::FitReset(){ |
442 |
for(int i=0; i<5; i++) al[i]=-9999.; |
for(int i=0; i<5; i++) al[i]=-9999.; |
451 |
for(int j=0; j<5; j++) coval[i][j]=0.; |
for(int j=0; j<5; j++) coval[i][j]=0.; |
452 |
} |
} |
453 |
} |
} |
454 |
|
void TrkTrack::SetTrackingMode(int trackmode){ |
455 |
|
extern cMini2track track_; |
456 |
|
track_.trackmode = trackmode; |
457 |
|
} |
458 |
|
|
459 |
//-------------------------------------- |
//-------------------------------------- |
460 |
// |
// |
461 |
// |
// |
462 |
//-------------------------------------- |
//-------------------------------------- |
463 |
void TrkTrack::Clear(){ |
void TrkTrack::Clear(){ |
464 |
seqno = -1; |
// cout << "TrkTrack::Clear()"<<endl; |
465 |
image = -1; |
seqno = -1; |
466 |
chi2 = 0; |
image = -1; |
467 |
nstep = 0; |
chi2 = 0; |
468 |
for(int it1=0;it1<5;it1++){ |
nstep = 0; |
469 |
al[it1] = 0; |
for(int it1=0;it1<5;it1++){ |
470 |
for(int it2=0;it2<5;it2++)coval[it1][it2] = 0; |
al[it1] = 0; |
471 |
}; |
for(int it2=0;it2<5;it2++)coval[it1][it2] = 0; |
472 |
for(int ip=0;ip<6;ip++){ |
}; |
473 |
xgood[ip] = 0; |
for(int ip=0;ip<6;ip++){ |
474 |
ygood[ip] = 0; |
xgood[ip] = 0; |
475 |
xm[ip] = 0; |
ygood[ip] = 0; |
476 |
ym[ip] = 0; |
xm[ip] = 0; |
477 |
zm[ip] = 0; |
ym[ip] = 0; |
478 |
resx[ip] = 0; |
zm[ip] = 0; |
479 |
resy[ip] = 0; |
resx[ip] = 0; |
480 |
xv[ip] = 0; |
resy[ip] = 0; |
481 |
yv[ip] = 0; |
xv[ip] = 0; |
482 |
zv[ip] = 0; |
yv[ip] = 0; |
483 |
axv[ip] = 0; |
zv[ip] = 0; |
484 |
ayv[ip] = 0; |
axv[ip] = 0; |
485 |
dedx_x[ip] = 0; |
ayv[ip] = 0; |
486 |
dedx_y[ip] = 0; |
dedx_x[ip] = 0; |
487 |
// clx[ip] = 0; |
dedx_y[ip] = 0; |
488 |
// cly[ip] = 0; |
|
489 |
}; |
}; |
490 |
clx->Clear(); |
if(clx)clx->Clear(); |
491 |
cly->Clear(); |
if(cly)cly->Clear(); |
492 |
}; |
}; |
493 |
//-------------------------------------- |
//-------------------------------------- |
494 |
// |
// |
495 |
// |
// |
496 |
//-------------------------------------- |
//-------------------------------------- |
497 |
void TrkTrack::Delete(){ |
void TrkTrack::Delete(){ |
498 |
Clear(); |
// cout << "TrkTrack::Delete()"<<endl; |
499 |
clx->Delete(); |
// Clear(); |
500 |
cly->Delete(); |
if(clx)delete clx; |
501 |
|
if(cly)delete cly; |
502 |
}; |
}; |
503 |
//-------------------------------------- |
//-------------------------------------- |
504 |
// |
// |
505 |
// |
// |
506 |
//-------------------------------------- |
//-------------------------------------- |
510 |
// |
// |
511 |
//-------------------------------------- |
//-------------------------------------- |
512 |
TrkSinglet::TrkSinglet(){ |
TrkSinglet::TrkSinglet(){ |
513 |
|
// cout << "TrkSinglet::TrkSinglet() " << GetUniqueID()<<endl; |
514 |
plane = 0; |
plane = 0; |
515 |
coord[0] = 0; |
coord[0] = 0; |
516 |
coord[1] = 0; |
coord[1] = 0; |
517 |
sgnl = 0; |
sgnl = 0; |
518 |
cls = 0; |
// cls = 0; |
519 |
}; |
}; |
520 |
//-------------------------------------- |
//-------------------------------------- |
521 |
// |
// |
522 |
// |
// |
523 |
//-------------------------------------- |
//-------------------------------------- |
524 |
TrkSinglet::TrkSinglet(const TrkSinglet& s){ |
TrkSinglet::TrkSinglet(const TrkSinglet& s){ |
525 |
|
// cout << "TrkSinglet::TrkSinglet(const TrkSinglet& s) " << GetUniqueID()<<endl; |
526 |
plane = s.plane; |
plane = s.plane; |
527 |
coord[0] = s.coord[0]; |
coord[0] = s.coord[0]; |
528 |
coord[1] = s.coord[1]; |
coord[1] = s.coord[1]; |
529 |
sgnl = s.sgnl; |
sgnl = s.sgnl; |
530 |
// cls = 0;//<<<<pointer |
// cls = 0;//<<<<pointer |
531 |
cls = TRef(s.cls); |
cls = TRef(s.cls); |
532 |
}; |
}; |
533 |
//-------------------------------------- |
//-------------------------------------- |
534 |
// |
// |
545 |
// |
// |
546 |
// |
// |
547 |
//-------------------------------------- |
//-------------------------------------- |
548 |
|
void TrkSinglet::Clear(){ |
549 |
|
// cout << "TrkSinglet::Clear() " << GetUniqueID()<<endl; |
550 |
|
// cls=0; |
551 |
|
plane=-1; |
552 |
|
coord[0]=-999; |
553 |
|
coord[1]=-999; |
554 |
|
sgnl=0; |
555 |
|
|
556 |
|
} |
557 |
|
//-------------------------------------- |
558 |
|
// |
559 |
|
// |
560 |
|
//-------------------------------------- |
561 |
TrkLevel2::TrkLevel2(){ |
TrkLevel2::TrkLevel2(){ |
562 |
// good2 = -1; |
// cout <<"TrkLevel2::TrkLevel2()"<<endl; |
563 |
for(Int_t i=0; i<12 ; i++){ |
for(Int_t i=0; i<12 ; i++){ |
|
// crc[i] = -1; |
|
564 |
good[i] = -1; |
good[i] = -1; |
565 |
}; |
}; |
566 |
Track = new TClonesArray("TrkTrack"); |
// okkio!! memory-leak |
567 |
SingletX = new TClonesArray("TrkSinglet"); |
// Track = new TClonesArray("TrkTrack"); |
568 |
SingletY = new TClonesArray("TrkSinglet"); |
// SingletX = new TClonesArray("TrkSinglet"); |
569 |
|
// SingletY = new TClonesArray("TrkSinglet"); |
570 |
|
Track = 0; |
571 |
|
SingletX = 0; |
572 |
|
SingletY = 0; |
573 |
|
|
574 |
// PhysicalTrack = new TClonesArray("TrkTrack"); |
} |
575 |
//sostituire con TRefArray... appena ho capito come si usa |
//-------------------------------------- |
576 |
|
// |
577 |
|
// |
578 |
|
//-------------------------------------- |
579 |
|
void TrkLevel2::Set(){ |
580 |
|
if(!Track)Track = new TClonesArray("TrkTrack"); |
581 |
|
if(!SingletX)SingletX = new TClonesArray("TrkSinglet"); |
582 |
|
if(!SingletY)SingletY = new TClonesArray("TrkSinglet"); |
583 |
} |
} |
584 |
//-------------------------------------- |
//-------------------------------------- |
585 |
// |
// |
587 |
//-------------------------------------- |
//-------------------------------------- |
588 |
void TrkLevel2::Dump(){ |
void TrkLevel2::Dump(){ |
589 |
|
|
|
TClonesArray &t = *Track; |
|
|
TClonesArray &sx = *SingletX; |
|
|
TClonesArray &sy = *SingletY; |
|
590 |
// |
// |
591 |
cout << endl << endl << "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"; |
cout << endl << endl << "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"; |
592 |
cout << endl << "good : "; for(int i=0; i<12; i++) cout << good[i]<<" "; |
cout << endl << "good : "; for(int i=0; i<12; i++) cout << good[i]<<" "; |
593 |
cout << endl << "ntrk() : " << this->ntrk() ; |
cout << endl << "ntrk() : " << this->ntrk() ; |
594 |
cout << endl << "nclsx() : " << this->nclsx(); |
cout << endl << "nclsx() : " << this->nclsx(); |
595 |
cout << endl << "nclsy() : " << this->nclsy(); |
cout << endl << "nclsy() : " << this->nclsy(); |
596 |
for(int i=0; i<this->ntrk(); i++) ((TrkTrack *)t[i])->Dump(); |
// TClonesArray &t = *Track; |
597 |
for(int i=0; i<this->nclsx(); i++) ((TrkSinglet *)sx[i])->Dump(); |
// TClonesArray &sx = *SingletX; |
598 |
for(int i=0; i<this->nclsy(); i++) ((TrkSinglet *)sy[i])->Dump(); |
// TClonesArray &sy = *SingletY; |
599 |
|
// for(int i=0; i<ntrk(); i++) ((TrkTrack *)t[i])->Dump(); |
600 |
|
// for(int i=0; i<nclsx(); i++) ((TrkSinglet *)sx[i])->Dump(); |
601 |
|
// for(int i=0; i<nclsy(); i++) ((TrkSinglet *)sy[i])->Dump(); |
602 |
|
if(Track){ |
603 |
|
TClonesArray &t = *Track; |
604 |
|
for(int i=0; i<ntrk(); i++) ((TrkTrack *)t[i])->Dump(); |
605 |
|
} |
606 |
|
if(SingletX){ |
607 |
|
TClonesArray &sx = *SingletX; |
608 |
|
for(int i=0; i<nclsx(); i++) ((TrkSinglet *)sx[i])->Dump(); |
609 |
|
} |
610 |
|
if(SingletY){ |
611 |
|
TClonesArray &sy = *SingletY; |
612 |
|
for(int i=0; i<nclsy(); i++) ((TrkSinglet *)sy[i])->Dump(); |
613 |
|
} |
614 |
} |
} |
615 |
//-------------------------------------- |
//-------------------------------------- |
616 |
// |
// |
619 |
/** |
/** |
620 |
* 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). |
621 |
*/ |
*/ |
622 |
void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2){ |
// void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2){ |
623 |
|
|
624 |
// temporary objects: |
// // temporary objects: |
625 |
TrkSinglet* t_singlet = new TrkSinglet(); |
// TrkSinglet* t_singlet = new TrkSinglet(); |
626 |
TrkTrack* t_track = new TrkTrack(); |
// TrkTrack* t_track = new TrkTrack(); |
627 |
|
|
628 |
// **** general variables **** |
// // **** general variables **** |
629 |
// good2 = l2->good2; |
// // good2 = l2->good2; |
630 |
for(Int_t i=0; i<12 ; i++){ |
// for(Int_t i=0; i<12 ; i++){ |
631 |
// crc[i] = l2->crc[i]; |
// // crc[i] = l2->crc[i]; |
632 |
good[i] = l2->good[i]; |
// good[i] = l2->good[i]; |
633 |
}; |
// }; |
634 |
// *** TRACKS *** |
// // *** TRACKS *** |
635 |
TClonesArray &t = *Track; |
// if(!Track) Track = new TClonesArray("TrkTrack"); |
636 |
for(int i=0; i<l2->ntrk; i++){ |
// TClonesArray &t = *Track; |
637 |
t_track->seqno = i;// NBNBNBNB deve sempre essere = i |
// for(int i=0; i<l2->ntrk; i++){ |
638 |
t_track->image = l2->image[i]-1; |
// t_track->seqno = i;// NBNBNBNB deve sempre essere = i |
639 |
// cout << "track "<<i<<t_track->seqno << t_track->image<<endl; |
// t_track->image = l2->image[i]-1; |
640 |
t_track->chi2 = l2->chi2_nt[i]; |
// // cout << "track "<<i<<t_track->seqno << t_track->image<<endl; |
641 |
t_track->nstep = l2->nstep_nt[i]; |
// t_track->chi2 = l2->chi2_nt[i]; |
642 |
for(int it1=0;it1<5;it1++){ |
// t_track->nstep = l2->nstep_nt[i]; |
643 |
t_track->al[it1] = l2->al_nt[i][it1]; |
// for(int it1=0;it1<5;it1++){ |
644 |
for(int it2=0;it2<5;it2++) |
// t_track->al[it1] = l2->al_nt[i][it1]; |
645 |
t_track->coval[it1][it2] = l2->coval[i][it2][it1]; |
// for(int it2=0;it2<5;it2++) |
646 |
}; |
// t_track->coval[it1][it2] = l2->coval[i][it2][it1]; |
647 |
for(int ip=0;ip<6;ip++){ |
// }; |
648 |
t_track->xgood[ip] = l2->xgood_nt[i][ip]; |
// for(int ip=0;ip<6;ip++){ |
649 |
t_track->ygood[ip] = l2->ygood_nt[i][ip]; |
// t_track->xgood[ip] = l2->xgood_nt[i][ip]; |
650 |
t_track->xm[ip] = l2->xm_nt[i][ip]; |
// t_track->ygood[ip] = l2->ygood_nt[i][ip]; |
651 |
t_track->ym[ip] = l2->ym_nt[i][ip]; |
// t_track->xm[ip] = l2->xm_nt[i][ip]; |
652 |
t_track->zm[ip] = l2->zm_nt[i][ip]; |
// t_track->ym[ip] = l2->ym_nt[i][ip]; |
653 |
t_track->resx[ip] = l2->resx_nt[i][ip]; |
// t_track->zm[ip] = l2->zm_nt[i][ip]; |
654 |
t_track->resy[ip] = l2->resy_nt[i][ip]; |
// t_track->resx[ip] = l2->resx_nt[i][ip]; |
655 |
t_track->xv[ip] = l2->xv_nt[i][ip]; |
// t_track->resy[ip] = l2->resy_nt[i][ip]; |
656 |
t_track->yv[ip] = l2->yv_nt[i][ip]; |
// t_track->xv[ip] = l2->xv_nt[i][ip]; |
657 |
t_track->zv[ip] = l2->zv_nt[i][ip]; |
// t_track->yv[ip] = l2->yv_nt[i][ip]; |
658 |
t_track->axv[ip] = l2->axv_nt[i][ip]; |
// t_track->zv[ip] = l2->zv_nt[i][ip]; |
659 |
t_track->ayv[ip] = l2->ayv_nt[i][ip]; |
// t_track->axv[ip] = l2->axv_nt[i][ip]; |
660 |
t_track->dedx_x[ip] = l2->dedx_x[i][ip]; |
// t_track->ayv[ip] = l2->ayv_nt[i][ip]; |
661 |
t_track->dedx_y[ip] = l2->dedx_y[i][ip]; |
// t_track->dedx_x[ip] = l2->dedx_x[i][ip]; |
662 |
// t_track->clx[ip] = 0; |
// t_track->dedx_y[ip] = l2->dedx_y[i][ip]; |
663 |
// t_track->cly[ip] = 0; |
// // t_track->clx[ip] = 0; |
664 |
}; |
// // t_track->cly[ip] = 0; |
665 |
new(t[i]) TrkTrack(*t_track); |
// }; |
666 |
t_track->Clear(); |
// new(t[i]) TrkTrack(*t_track); |
667 |
}; |
// t_track->Clear(); |
668 |
// *** SINGLETS *** |
// }; |
669 |
TClonesArray &sx = *SingletX; |
// // *** SINGLETS *** |
670 |
for(int i=0; i<l2->nclsx; i++){ |
// if(!SingletX)SingletX = new TClonesArray("TrkSinglet"); |
671 |
t_singlet->plane = l2->planex[i]; |
// TClonesArray &sx = *SingletX; |
672 |
t_singlet->coord[0] = l2->xs[i][0]; |
// for(int i=0; i<l2->nclsx; i++){ |
673 |
t_singlet->coord[1] = l2->xs[i][1]; |
// t_singlet->plane = l2->planex[i]; |
674 |
t_singlet->sgnl = l2->signlxs[i]; |
// t_singlet->coord[0] = l2->xs[i][0]; |
675 |
// t_singlet->cls = 0; |
// t_singlet->coord[1] = l2->xs[i][1]; |
676 |
new(sx[i]) TrkSinglet(*t_singlet); |
// t_singlet->sgnl = l2->signlxs[i]; |
677 |
t_singlet->Clear(); |
// // t_singlet->cls = 0; |
678 |
} |
// new(sx[i]) TrkSinglet(*t_singlet); |
679 |
TClonesArray &sy = *SingletY; |
// t_singlet->Clear(); |
680 |
for(int i=0; i<l2->nclsy; i++){ |
// } |
681 |
t_singlet->plane = l2->planey[i]; |
// if(!SingletY)SingletY = new TClonesArray("TrkSinglet"); |
682 |
t_singlet->coord[0] = l2->ys[i][0]; |
// TClonesArray &sy = *SingletY; |
683 |
t_singlet->coord[1] = l2->ys[i][1]; |
// for(int i=0; i<l2->nclsy; i++){ |
684 |
t_singlet->sgnl = l2->signlys[i]; |
// t_singlet->plane = l2->planey[i]; |
685 |
// t_singlet->cls = 0; |
// t_singlet->coord[0] = l2->ys[i][0]; |
686 |
new(sy[i]) TrkSinglet(*t_singlet); |
// t_singlet->coord[1] = l2->ys[i][1]; |
687 |
t_singlet->Clear(); |
// t_singlet->sgnl = l2->signlys[i]; |
688 |
}; |
// // t_singlet->cls = 0; |
689 |
|
// new(sy[i]) TrkSinglet(*t_singlet); |
690 |
|
// t_singlet->Clear(); |
691 |
|
// }; |
692 |
|
|
693 |
delete t_track; |
// delete t_track; |
694 |
delete t_singlet; |
// delete t_singlet; |
695 |
} |
// } |
696 |
//-------------------------------------- |
//-------------------------------------- |
697 |
// |
// |
698 |
// |
// |
713 |
good[i] = l2->good[i]; |
good[i] = l2->good[i]; |
714 |
}; |
}; |
715 |
// *** TRACKS *** |
// *** TRACKS *** |
716 |
|
if(!Track) Track = new TClonesArray("TrkTrack"); |
717 |
TClonesArray &t = *Track; |
TClonesArray &t = *Track; |
718 |
|
//----------------------------------------------------- |
719 |
|
if(l1 && !t_track->clx)t_track->clx = new TRefArray(6,0); |
720 |
|
if(l1 && !t_track->cly)t_track->cly = new TRefArray(6,0); |
721 |
|
//----------------------------------------------------- |
722 |
for(int i=0; i<l2->ntrk; i++){ |
for(int i=0; i<l2->ntrk; i++){ |
723 |
t_track->seqno = i;// NBNBNBNB deve sempre essere = i |
t_track->seqno = i;// NBNBNBNB deve sempre essere = i |
724 |
t_track->image = l2->image[i]-1; |
t_track->image = l2->image[i]-1; |
745 |
t_track->ayv[ip] = l2->ayv_nt[i][ip]; |
t_track->ayv[ip] = l2->ayv_nt[i][ip]; |
746 |
t_track->dedx_x[ip] = l2->dedx_x[i][ip]; |
t_track->dedx_x[ip] = l2->dedx_x[i][ip]; |
747 |
t_track->dedx_y[ip] = l2->dedx_y[i][ip]; |
t_track->dedx_y[ip] = l2->dedx_y[i][ip]; |
|
// cout << "traccia "<<i<<" -- "<< ip << " "<< l2->cltrx[i][ip] <<" "<< l2->cltry[i][ip] <<" "<< t_track->xgood[ip] << t_track->ygood[ip]<<endl; |
|
748 |
//----------------------------------------------------- |
//----------------------------------------------------- |
749 |
// t_track->clx[ip] = l1->GetCluster(l2->cltrx[i][ip]-1); |
//----------------------------------------------------- |
750 |
// t_track->cly[ip] = l1->GetCluster(l2->cltry[i][ip]-1); |
if(l1 && t_track->xgood[ip])t_track->clx->AddAt(l1->GetCluster(l2->cltrx[i][ip]-1),ip); |
751 |
if(t_track->xgood[ip])t_track->clx->AddAt(l1->GetCluster(l2->cltrx[i][ip]-1),ip); |
if(l1 && t_track->ygood[ip])t_track->cly->AddAt(l1->GetCluster(l2->cltry[i][ip]-1),ip); |
752 |
if(t_track->ygood[ip])t_track->cly->AddAt(l1->GetCluster(l2->cltry[i][ip]-1),ip); |
//----------------------------------------------------- |
|
// 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; |
|
|
// 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; |
|
753 |
//----------------------------------------------------- |
//----------------------------------------------------- |
754 |
}; |
}; |
755 |
new(t[i]) TrkTrack(*t_track); |
new(t[i]) TrkTrack(*t_track); |
756 |
t_track->Clear(); |
t_track->Clear(); |
757 |
}; |
}; |
758 |
// *** SINGLETS *** |
// *** SINGLETS *** |
759 |
|
if(!SingletX)SingletX = new TClonesArray("TrkSinglet"); |
760 |
TClonesArray &sx = *SingletX; |
TClonesArray &sx = *SingletX; |
761 |
for(int i=0; i<l2->nclsx; i++){ |
for(int i=0; i<l2->nclsx; i++){ |
762 |
t_singlet->plane = l2->planex[i]; |
t_singlet->plane = l2->planex[i]; |
764 |
t_singlet->coord[1] = l2->xs[i][1]; |
t_singlet->coord[1] = l2->xs[i][1]; |
765 |
t_singlet->sgnl = l2->signlxs[i]; |
t_singlet->sgnl = l2->signlxs[i]; |
766 |
//----------------------------------------------------- |
//----------------------------------------------------- |
767 |
// cout << "singolo x "<<i<<" -- "<< l2->clsx[i] <<endl; |
if(l1) t_singlet->cls = l1->GetCluster(l2->clsx[i]-1); |
|
t_singlet->cls = l1->GetCluster(l2->clsx[i]-1); |
|
|
// cout<<" i "<<i<<" l2->clsx[i] "<<l2->clsx[i]<< " l1->GetCluster(l2->clsx[i]-1) "<<l1->GetCluster(l2->clsx[i]-1)<<endl; |
|
768 |
//----------------------------------------------------- |
//----------------------------------------------------- |
769 |
new(sx[i]) TrkSinglet(*t_singlet); |
new(sx[i]) TrkSinglet(*t_singlet); |
770 |
t_singlet->Clear(); |
t_singlet->Clear(); |
771 |
} |
} |
772 |
|
if(!SingletY)SingletY = new TClonesArray("TrkSinglet"); |
773 |
TClonesArray &sy = *SingletY; |
TClonesArray &sy = *SingletY; |
774 |
for(int i=0; i<l2->nclsy; i++){ |
for(int i=0; i<l2->nclsy; i++){ |
775 |
t_singlet->plane = l2->planey[i]; |
t_singlet->plane = l2->planey[i]; |
777 |
t_singlet->coord[1] = l2->ys[i][1]; |
t_singlet->coord[1] = l2->ys[i][1]; |
778 |
t_singlet->sgnl = l2->signlys[i]; |
t_singlet->sgnl = l2->signlys[i]; |
779 |
//----------------------------------------------------- |
//----------------------------------------------------- |
780 |
// cout << "singolo y "<<i<<" -- "<< l2->clsy[i] <<endl; |
if(l1) t_singlet->cls = l1->GetCluster(l2->clsy[i]-1); |
|
t_singlet->cls = l1->GetCluster(l2->clsy[i]-1); |
|
|
// cout<<" i "<<i<<" l2->clsy[i] "<<l2->clsy[i]<< " l1->GetCluster(l2->clsy[i]-1) "<<l1->GetCluster(l2->clsy[i]-1)<<endl; |
|
781 |
//----------------------------------------------------- |
//----------------------------------------------------- |
782 |
new(sy[i]) TrkSinglet(*t_singlet); |
new(sy[i]) TrkSinglet(*t_singlet); |
783 |
t_singlet->Clear(); |
t_singlet->Clear(); |
800 |
}; |
}; |
801 |
// *** TRACKS *** |
// *** TRACKS *** |
802 |
|
|
803 |
l2->ntrk = Track->GetEntries(); |
if(Track){ |
804 |
for(Int_t i=0;i<l2->ntrk;i++){ |
l2->ntrk = Track->GetEntries(); |
805 |
l2->image[i] = 1 + ((TrkTrack *)Track->At(i))->image; |
for(Int_t i=0;i<l2->ntrk;i++){ |
806 |
l2->chi2_nt[i] = ((TrkTrack *)Track->At(i))->chi2; |
l2->image[i] = 1 + ((TrkTrack *)Track->At(i))->image; |
807 |
l2->nstep_nt[i] = ((TrkTrack *)Track->At(i))->nstep; |
l2->chi2_nt[i] = ((TrkTrack *)Track->At(i))->chi2; |
808 |
for(int it1=0;it1<5;it1++){ |
l2->nstep_nt[i] = ((TrkTrack *)Track->At(i))->nstep; |
809 |
l2->al_nt[i][it1] = ((TrkTrack *)Track->At(i))->al[it1]; |
for(int it1=0;it1<5;it1++){ |
810 |
for(int it2=0;it2<5;it2++) |
l2->al_nt[i][it1] = ((TrkTrack *)Track->At(i))->al[it1]; |
811 |
l2->coval[i][it2][it1] = ((TrkTrack *)Track->At(i))->coval[it1][it2]; |
for(int it2=0;it2<5;it2++) |
812 |
}; |
l2->coval[i][it2][it1] = ((TrkTrack *)Track->At(i))->coval[it1][it2]; |
813 |
for(int ip=0;ip<6;ip++){ |
}; |
814 |
l2->xgood_nt[i][ip] = ((TrkTrack *)Track->At(i))->xgood[ip]; |
for(int ip=0;ip<6;ip++){ |
815 |
l2->ygood_nt[i][ip] = ((TrkTrack *)Track->At(i))->ygood[ip]; |
l2->xgood_nt[i][ip] = ((TrkTrack *)Track->At(i))->xgood[ip]; |
816 |
l2->xm_nt[i][ip] = ((TrkTrack *)Track->At(i))->xm[ip]; |
l2->ygood_nt[i][ip] = ((TrkTrack *)Track->At(i))->ygood[ip]; |
817 |
l2->ym_nt[i][ip] = ((TrkTrack *)Track->At(i))->ym[ip]; |
l2->xm_nt[i][ip] = ((TrkTrack *)Track->At(i))->xm[ip]; |
818 |
l2->zm_nt[i][ip] = ((TrkTrack *)Track->At(i))->zm[ip]; |
l2->ym_nt[i][ip] = ((TrkTrack *)Track->At(i))->ym[ip]; |
819 |
l2->resx_nt[i][ip] = ((TrkTrack *)Track->At(i))->resx[ip]; |
l2->zm_nt[i][ip] = ((TrkTrack *)Track->At(i))->zm[ip]; |
820 |
l2->resy_nt[i][ip] = ((TrkTrack *)Track->At(i))->resy[ip]; |
l2->resx_nt[i][ip] = ((TrkTrack *)Track->At(i))->resx[ip]; |
821 |
l2->xv_nt[i][ip] = ((TrkTrack *)Track->At(i))->xv[ip]; |
l2->resy_nt[i][ip] = ((TrkTrack *)Track->At(i))->resy[ip]; |
822 |
l2->yv_nt[i][ip] = ((TrkTrack *)Track->At(i))->yv[ip]; |
l2->xv_nt[i][ip] = ((TrkTrack *)Track->At(i))->xv[ip]; |
823 |
l2->zv_nt[i][ip] = ((TrkTrack *)Track->At(i))->zv[ip]; |
l2->yv_nt[i][ip] = ((TrkTrack *)Track->At(i))->yv[ip]; |
824 |
l2->axv_nt[i][ip] = ((TrkTrack *)Track->At(i))->axv[ip]; |
l2->zv_nt[i][ip] = ((TrkTrack *)Track->At(i))->zv[ip]; |
825 |
l2->ayv_nt[i][ip] = ((TrkTrack *)Track->At(i))->ayv[ip]; |
l2->axv_nt[i][ip] = ((TrkTrack *)Track->At(i))->axv[ip]; |
826 |
l2->dedx_x[i][ip] = ((TrkTrack *)Track->At(i))->dedx_x[ip]; |
l2->ayv_nt[i][ip] = ((TrkTrack *)Track->At(i))->ayv[ip]; |
827 |
l2->dedx_y[i][ip] = ((TrkTrack *)Track->At(i))->dedx_y[ip]; |
l2->dedx_x[i][ip] = ((TrkTrack *)Track->At(i))->dedx_x[ip]; |
828 |
}; |
l2->dedx_y[i][ip] = ((TrkTrack *)Track->At(i))->dedx_y[ip]; |
829 |
|
}; |
830 |
|
} |
831 |
} |
} |
|
|
|
832 |
// *** SINGLETS *** |
// *** SINGLETS *** |
833 |
l2->nclsx = SingletX->GetEntries(); |
if(SingletX){ |
834 |
for(Int_t i=0;i<l2->nclsx;i++){ |
l2->nclsx = SingletX->GetEntries(); |
835 |
l2->planex[i] = ((TrkSinglet *)SingletX->At(i))->plane; |
for(Int_t i=0;i<l2->nclsx;i++){ |
836 |
l2->xs[i][0] = ((TrkSinglet *)SingletX->At(i))->coord[0]; |
l2->planex[i] = ((TrkSinglet *)SingletX->At(i))->plane; |
837 |
l2->xs[i][1] = ((TrkSinglet *)SingletX->At(i))->coord[1]; |
l2->xs[i][0] = ((TrkSinglet *)SingletX->At(i))->coord[0]; |
838 |
l2->signlxs[i] = ((TrkSinglet *)SingletX->At(i))->sgnl; |
l2->xs[i][1] = ((TrkSinglet *)SingletX->At(i))->coord[1]; |
839 |
} |
l2->signlxs[i] = ((TrkSinglet *)SingletX->At(i))->sgnl; |
840 |
l2->nclsy = SingletY->GetEntries(); |
} |
841 |
for(Int_t i=0;i<l2->nclsy;i++){ |
} |
842 |
l2->planey[i] = ((TrkSinglet *)SingletY->At(i))->plane; |
|
843 |
l2->ys[i][0] = ((TrkSinglet *)SingletY->At(i))->coord[0]; |
if(SingletY){ |
844 |
l2->ys[i][1] = ((TrkSinglet *)SingletY->At(i))->coord[1]; |
l2->nclsy = SingletY->GetEntries(); |
845 |
l2->signlys[i] = ((TrkSinglet *)SingletY->At(i))->sgnl; |
for(Int_t i=0;i<l2->nclsy;i++){ |
846 |
|
l2->planey[i] = ((TrkSinglet *)SingletY->At(i))->plane; |
847 |
|
l2->ys[i][0] = ((TrkSinglet *)SingletY->At(i))->coord[0]; |
848 |
|
l2->ys[i][1] = ((TrkSinglet *)SingletY->At(i))->coord[1]; |
849 |
|
l2->signlys[i] = ((TrkSinglet *)SingletY->At(i))->sgnl; |
850 |
|
} |
851 |
} |
} |
852 |
} |
} |
853 |
//-------------------------------------- |
//-------------------------------------- |
855 |
// |
// |
856 |
//-------------------------------------- |
//-------------------------------------- |
857 |
void TrkLevel2::Clear(){ |
void TrkLevel2::Clear(){ |
|
// good2 = -1; |
|
858 |
for(Int_t i=0; i<12 ; i++){ |
for(Int_t i=0; i<12 ; i++){ |
859 |
// crc[i] = -1; |
good[i] = -1; |
860 |
good[i] = -1; |
}; |
861 |
}; |
// if(Track)Track->Clear("C"); |
862 |
/* Track->RemoveAll(); |
// if(SingletX)SingletX->Clear("C"); |
863 |
SingletX->RemoveAll(); |
// if(SingletY)SingletY->Clear("C"); |
864 |
SingletY->RemoveAll();*/ |
if(Track)Track->Delete(); |
865 |
// modify to avoid memory leakage |
if(SingletX)SingletX->Delete(); |
866 |
Track->Clear(); |
if(SingletY)SingletY->Delete(); |
867 |
SingletX->Clear(); |
} |
868 |
SingletY->Clear(); |
// //-------------------------------------- |
869 |
} |
// // |
870 |
//-------------------------------------- |
// // |
871 |
// |
// //-------------------------------------- |
|
// |
|
|
//-------------------------------------- |
|
872 |
void TrkLevel2::Delete(){ |
void TrkLevel2::Delete(){ |
873 |
|
|
874 |
Clear(); |
// cout << "void TrkLevel2::Delete()"<<endl; |
875 |
Track->Delete(); |
Clear(); |
876 |
SingletX->Delete(); |
if(Track)delete Track; |
877 |
SingletY->Delete(); |
if(SingletX)delete SingletX; |
878 |
|
if(SingletY)delete SingletY; |
879 |
|
|
880 |
} |
} |
881 |
//-------------------------------------- |
//-------------------------------------- |
882 |
// |
// |
888 |
*/ |
*/ |
889 |
TRefArray *TrkLevel2::GetTracks_NFitSorted(){ |
TRefArray *TrkLevel2::GetTracks_NFitSorted(){ |
890 |
|
|
891 |
TRefArray *sorted = new TRefArray(); |
if(!Track)return 0; |
892 |
|
|
893 |
|
TRefArray *sorted = new TRefArray(); |
894 |
|
|
895 |
TClonesArray &t = *Track; |
TClonesArray &t = *Track; |
896 |
// TClonesArray &ts = *PhysicalTrack; |
// TClonesArray &ts = *PhysicalTrack; |
897 |
int N = ntrk(); |
int N = ntrk(); |
898 |
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; |
899 |
// int m[50]; for(int i=0; i<N; i++)m[i]=1; |
// int m[50]; for(int i=0; i<N; i++)m[i]=1; |
900 |
|
|
901 |
int indo=0; |
int indo=0; |
902 |
int indi=0; |
int indi=0; |
903 |
while(N != 0){ |
while(N > 0){ |
904 |
int nfit =0; |
// while(N != 0){ |
905 |
float chi2ref = numeric_limits<float>::max(); |
int nfit =0; |
906 |
|
float chi2ref = numeric_limits<float>::max(); |
907 |
|
|
908 |
// first loop to search maximum num. of fit points |
// first loop to search maximum num. of fit points |
909 |
for(int i=0; i < ntrk(); i++){ |
for(int i=0; i < ntrk(); i++){ |
910 |
if( ((TrkTrack *)t[i])->GetNtot() >= nfit && m[i]==1){ |
if( ((TrkTrack *)t[i])->GetNtot() >= nfit && m[i]==1){ |
911 |
nfit = ((TrkTrack *)t[i])->GetNtot(); |
nfit = ((TrkTrack *)t[i])->GetNtot(); |
912 |
} |
} |
913 |
} |
} |
914 |
//second loop to search minimum chi2 among selected |
//second loop to search minimum chi2 among selected |
915 |
for(int i=0; i<this->ntrk(); i++){ |
for(int i=0; i<ntrk(); i++){ |
916 |
Float_t chi2 = ((TrkTrack *)t[i])->chi2; |
Float_t chi2 = ((TrkTrack *)t[i])->chi2; |
917 |
if(chi2 < 0) chi2 = chi2*1000; |
if(chi2 < 0) chi2 = -chi2*1000; |
918 |
if( chi2 < chi2ref |
if( chi2 < chi2ref |
919 |
&& ((TrkTrack *)t[i])->GetNtot() == nfit |
&& ((TrkTrack *)t[i])->GetNtot() == nfit |
920 |
&& m[i]==1){ |
&& m[i]==1){ |
921 |
chi2ref = ((TrkTrack *)t[i])->chi2; |
chi2ref = ((TrkTrack *)t[i])->chi2; |
922 |
indi = i; |
indi = i; |
923 |
}; |
}; |
924 |
}; |
}; |
925 |
if( ((TrkTrack *)t[indi])->HasImage() ){ |
if( ((TrkTrack *)t[indi])->HasImage() ){ |
926 |
m[((TrkTrack *)t[indi])->image] = 0; |
m[((TrkTrack *)t[indi])->image] = 0; |
927 |
N--; |
N--; |
928 |
|
|
929 |
// cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl; |
// cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl; |
930 |
}; |
}; |
931 |
sorted->Add( (TrkTrack*)t[indi] ); |
sorted->Add( (TrkTrack*)t[indi] ); |
932 |
|
|
933 |
m[indi] = 0; |
m[indi] = 0; |
934 |
// cout << "SORTED "<< indo << " "<< indi << " "<< N << endl; |
// cout << "SORTED "<< indo << " "<< indi << " "<< N << " "<<((TrkTrack *)t[indi])->image<<" "<<chi2ref<<endl; |
935 |
N--; |
N--; |
936 |
indo++; |
indo++; |
937 |
} |
} |
938 |
m.clear(); |
m.clear(); |
939 |
// cout << "GetTracks_NFitSorted(it): Done"<< endl; |
// cout << "GetTracks_NFitSorted(it): Done"<< endl; |
940 |
|
|
941 |
return sorted; |
return sorted; |
942 |
// return PhysicalTrack; |
// return PhysicalTrack; |
943 |
} |
} |
944 |
//-------------------------------------- |
//-------------------------------------- |
957 |
cout << " Stored tracks ntrk() = "<< this->ntrk() << endl; |
cout << " Stored tracks ntrk() = "<< this->ntrk() << endl; |
958 |
return 0; |
return 0; |
959 |
} |
} |
960 |
|
if(!Track){ |
961 |
|
cout << "TrkTrack *TrkLevel2::GetStoredTrack(int is) >> (TClonesArray*) Track ==0 "<<endl; |
962 |
|
}; |
963 |
TClonesArray &t = *(Track); |
TClonesArray &t = *(Track); |
964 |
TrkTrack *track = (TrkTrack*)t[is]; |
TrkTrack *track = (TrkTrack*)t[is]; |
965 |
return track; |
return track; |
979 |
cout << " Stored x-singlets nclsx() = "<< this->nclsx() << endl; |
cout << " Stored x-singlets nclsx() = "<< this->nclsx() << endl; |
980 |
return 0; |
return 0; |
981 |
} |
} |
982 |
|
if(!SingletX)return 0; |
983 |
TClonesArray &t = *(SingletX); |
TClonesArray &t = *(SingletX); |
984 |
TrkSinglet *singlet = (TrkSinglet*)t[is]; |
TrkSinglet *singlet = (TrkSinglet*)t[is]; |
985 |
return singlet; |
return singlet; |
999 |
cout << " Stored y-singlets nclsy() = "<< this->nclsx() << endl; |
cout << " Stored y-singlets nclsy() = "<< this->nclsx() << endl; |
1000 |
return 0; |
return 0; |
1001 |
} |
} |
1002 |
|
if(!SingletY)return 0; |
1003 |
TClonesArray &t = *(SingletY); |
TClonesArray &t = *(SingletY); |
1004 |
TrkSinglet *singlet = (TrkSinglet*)t[is]; |
TrkSinglet *singlet = (TrkSinglet*)t[is]; |
1005 |
return singlet; |
return singlet; |
1022 |
} |
} |
1023 |
|
|
1024 |
TRefArray *sorted = GetTracks(); //TEMPORANEO |
TRefArray *sorted = GetTracks(); //TEMPORANEO |
1025 |
|
if(!sorted)return 0; |
1026 |
TrkTrack *track = (TrkTrack*)sorted->At(it); |
TrkTrack *track = (TrkTrack*)sorted->At(it); |
1027 |
sorted->Delete(); |
sorted->Clear(); |
1028 |
|
delete sorted; |
1029 |
return track; |
return track; |
1030 |
} |
} |
1031 |
/** |
/** |
1034 |
Int_t TrkLevel2::GetNTracks(){ |
Int_t TrkLevel2::GetNTracks(){ |
1035 |
|
|
1036 |
Float_t ntot=0; |
Float_t ntot=0; |
1037 |
|
if(!Track)return 0; |
1038 |
TClonesArray &t = *Track; |
TClonesArray &t = *Track; |
1039 |
for(int i=0; i<ntrk(); i++) { |
for(int i=0; i<ntrk(); i++) { |
1040 |
if( ((TrkTrack *)t[i])->GetImageSeqNo() == -1 ) ntot+=1.; |
if( ((TrkTrack *)t[i])->GetImageSeqNo() == -1 ) ntot+=1.; |
1053 |
*/ |
*/ |
1054 |
TrkTrack *TrkLevel2::GetTrackImage(int it){ |
TrkTrack *TrkLevel2::GetTrackImage(int it){ |
1055 |
|
|
1056 |
if(it >= this->GetNTracks()){ |
if(it >= this->GetNTracks()){ |
1057 |
cout << "** TrkLevel2 ** Track "<< it << "does not exits! " << endl; |
cout << "** TrkLevel2 ** Track "<< it << "does not exits! " << endl; |
1058 |
cout << " Physical tracks GetNTracks() = "<< this->ntrk() << endl; |
cout << " Physical tracks GetNTracks() = "<< this->ntrk() << endl; |
1059 |
return 0; |
return 0; |
1060 |
} |
} |
1061 |
|
|
1062 |
TRefArray* sorted = GetTracks(); //TEMPORANEO |
TRefArray* sorted = GetTracks(); //TEMPORANEO |
1063 |
TrkTrack *track = (TrkTrack*)sorted->At(it); |
if(!sorted)return 0; |
1064 |
|
TrkTrack *track = (TrkTrack*)sorted->At(it); |
1065 |
|
|
1066 |
if(!track->HasImage()){ |
if(!track->HasImage()){ |
1067 |
cout << "** TrkLevel2 ** Track "<< it << "does not have image! " << endl; |
cout << "** TrkLevel2 ** Track "<< it << "does not have image! " << endl; |
1068 |
return 0; |
return 0; |
1069 |
} |
} |
1070 |
TrkTrack *image = (TrkTrack*)(*Track)[track->image]; |
if(!Track)return 0; |
1071 |
|
TrkTrack *image = (TrkTrack*)(*Track)[track->image]; |
1072 |
|
|
1073 |
sorted->Delete(); |
sorted->Delete(); |
1074 |
|
delete sorted; |
1075 |
return image; |
|
1076 |
|
return image; |
1077 |
|
|
1078 |
} |
} |
1079 |
//-------------------------------------- |
//-------------------------------------- |
1084 |
* Loads the magnetic field. |
* Loads the magnetic field. |
1085 |
* @param s Path of the magnetic-field files. |
* @param s Path of the magnetic-field files. |
1086 |
*/ |
*/ |
1087 |
void TrkLevel2::LoadField(TString s){ |
void TrkLevel2::LoadField(TString path){ |
1088 |
readb_(s.Data()); |
// |
1089 |
|
// strcpy(path_.path,path.Data()); |
1090 |
|
// path_.pathlen = path.Length(); |
1091 |
|
// path_.error = 0; |
1092 |
|
// readb_(); |
1093 |
|
|
1094 |
|
TrkParams::Set(path,1); |
1095 |
|
TrkParams::Load(1); |
1096 |
|
|
1097 |
|
// |
1098 |
}; |
}; |
1099 |
|
/** |
1100 |
|
* Get BY (kGauss) |
1101 |
|
* @param v (x,y,z) coordinates in cm |
1102 |
|
*/ |
1103 |
|
float TrkLevel2::GetBX(float* v){ |
1104 |
|
float b[3]; |
1105 |
|
gufld_(v,b); |
1106 |
|
return b[0]/10.; |
1107 |
|
} |
1108 |
|
/** |
1109 |
|
* Get BY (kGauss) |
1110 |
|
* @param v (x,y,z) coordinates in cm |
1111 |
|
*/ |
1112 |
|
float TrkLevel2::GetBY(float* v){ |
1113 |
|
float b[3]; |
1114 |
|
gufld_(v,b); |
1115 |
|
return b[1]/10.; |
1116 |
|
} |
1117 |
|
/** |
1118 |
|
* Get BY (kGauss) |
1119 |
|
* @param v (x,y,z) coordinates in cm |
1120 |
|
*/ |
1121 |
|
float TrkLevel2::GetBZ(float* v){ |
1122 |
|
float b[3]; |
1123 |
|
gufld_(v,b); |
1124 |
|
return b[2]/10.; |
1125 |
|
} |
1126 |
//-------------------------------------- |
//-------------------------------------- |
1127 |
// |
// |
1128 |
// |
// |
1219 |
tl = new float[npoint]; |
tl = new float[npoint]; |
1220 |
int i=0; |
int i=0; |
1221 |
do{ |
do{ |
1222 |
x[i] = 0; |
x[i] = 0; |
1223 |
y[i] = 0; |
y[i] = 0; |
1224 |
z[i] = zin[i]; |
z[i] = zin[i]; |
1225 |
thx[i] = 0; |
thx[i] = 0; |
1226 |
thy[i] = 0; |
thy[i] = 0; |
1227 |
tl[i] = 0; |
tl[i] = 0; |
1228 |
i++; |
i++; |
1229 |
}while(zin[i-1] > zin[i] && i < npoint); |
}while(zin[i-1] > zin[i] && i < npoint); |
1230 |
npoint=i; |
npoint=i; |
1231 |
if(npoint != n)cout << "NB! Trajectory created with "<<npoint<<" points"<<endl; |
if(npoint != n)cout << "NB! Trajectory created with "<<npoint<<" points"<<endl; |
1232 |
} |
} |
1233 |
|
void Trajectory::Delete(){ |
1234 |
|
|
1235 |
|
if(x) delete [] x; |
1236 |
|
if(y) delete [] y; |
1237 |
|
if(z) delete [] z; |
1238 |
|
if(thx) delete [] thx; |
1239 |
|
if(thy) delete [] thy; |
1240 |
|
if(tl) delete [] tl; |
1241 |
|
|
1242 |
|
} |
1243 |
//-------------------------------------- |
//-------------------------------------- |
1244 |
// |
// |
1245 |
// |
// |
1278 |
|
|
1279 |
} |
} |
1280 |
|
|
1281 |
|
/** |
1282 |
|
* Evaluates the trajectory in the apparatus associated to the track. |
1283 |
|
* 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. |
1284 |
|
* @param t pointer to an object of the class Trajectory, |
1285 |
|
* which z coordinates should be previously initialized by calling the proper constructor ( Trajectory::Trajectory(int n, float* zin) ). |
1286 |
|
* @return error flag. |
1287 |
|
*/ |
1288 |
|
int Trajectory::DoTrack2(float* al){ |
1289 |
|
|
1290 |
|
double *dxout = new double[npoint]; |
1291 |
|
double *dyout = new double[npoint]; |
1292 |
|
double *dthxout = new double[npoint]; |
1293 |
|
double *dthyout = new double[npoint]; |
1294 |
|
double *dtlout = new double[npoint]; |
1295 |
|
double *dzin = new double[npoint]; |
1296 |
|
double dal[5]; |
1297 |
|
|
1298 |
|
int ifail = 0; |
1299 |
|
|
1300 |
|
for (int i=0; i<5; i++) dal[i] = (double)al[i]; |
1301 |
|
for (int i=0; i<npoint; i++) dzin[i] = (double)z[i]; |
1302 |
|
|
1303 |
|
TrkParams::Load(1); |
1304 |
|
if( !TrkParams::IsLoaded(1) ){ |
1305 |
|
cout << "int Trajectory::DoTrack2(float* al) --- ERROR --- m.field not loaded"<<endl; |
1306 |
|
return 0; |
1307 |
|
} |
1308 |
|
dotrack2_(&(npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail); |
1309 |
|
|
1310 |
|
for (int i=0; i<npoint; i++){ |
1311 |
|
x[i] = (float)*dxout++; |
1312 |
|
y[i] = (float)*dyout++; |
1313 |
|
thx[i] = (float)*dthxout++; |
1314 |
|
thy[i] = (float)*dthyout++; |
1315 |
|
tl[i] = (float)*dtlout++; |
1316 |
|
} |
1317 |
|
|
1318 |
|
return ifail; |
1319 |
|
}; |
1320 |
|
|
1321 |
ClassImp(TrkLevel2); |
ClassImp(TrkLevel2); |
1322 |
ClassImp(TrkSinglet); |
ClassImp(TrkSinglet); |