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; |
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 |
// |
// |
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++){ |
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 |
|
|
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. |
* Tracking method. It calls F77 mini routine. |
375 |
*/ |
*/ |
376 |
void TrkTrack::Fit(double pfixed, int& fail, int iprint){ |
void TrkTrack::Fit(double pfixed, int& fail, int iprint){ |
377 |
|
|
378 |
|
float al_ini[] = {0.,0.,0.,0.,0.}; |
379 |
|
|
380 |
extern cMini2track track_; |
extern cMini2track track_; |
381 |
fail = 0; |
fail = 0; |
382 |
// extern cMini2fitinfo fit_info_; |
FillMiniStruct(track_); |
383 |
// extern void mini_2_(int*,int*); |
|
384 |
// track_.xm[0]=1.0; |
// if fit variables have been reset, evaluate the initial guess |
385 |
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_(); |
386 |
for(int i=0; i<6; i++) track_.ym[i]=ym[i]; |
|
387 |
for(int i=0; i<6; i++) track_.zm[i]=zm[i]; |
// --------------------- free momentum |
|
for(int i=0; i<6; i++) track_.resx[i]=resx[i]; |
|
|
for(int i=0; i<6; i++) track_.resy[i]=resy[i]; |
|
|
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.; |
|
|
} |
|
|
// end guess |
|
388 |
if(pfixed==0.) { |
if(pfixed==0.) { |
389 |
al[4]=0.; // free momentum |
track_.pfixed=0.; |
|
track_.pfixed=0.; // " |
|
390 |
} |
} |
391 |
|
// --------------------- fixed momentum |
392 |
if(pfixed!=0.) { |
if(pfixed!=0.) { |
393 |
al[4]=1./pfixed; // to fix the momentum |
al[4]=1./pfixed; |
394 |
track_.pfixed=pfixed; // " |
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 |
} |
} |
|
track_.zini = 23.5; // ZINI = 23.5 !!! it should be the same parameter in all codes |
|
|
for(int i=0; i<5; i++) track_.al[i]=al[i]; |
|
407 |
int istep=0; |
int istep=0; |
408 |
int ifail=0; |
int ifail=0; |
409 |
mini2_(&istep,&ifail, &iprint); |
mini2_(&istep,&ifail, &iprint); |
410 |
if(ifail!=0) { |
if(ifail!=0) { |
411 |
if(iprint==1)cout << "ERROR: ifail= " << ifail << endl; |
if(iprint)cout << "ERROR: ifail= " << ifail << endl; |
412 |
fail = 1; |
fail = 1; |
|
// return; |
|
413 |
} |
} |
414 |
|
// ------------------------------------------ |
415 |
|
|
416 |
|
SetFromMiniStruct(&track_); |
417 |
// cout << endl << "eta ===> " << track_.al[4] << endl; |
// cout << endl << "eta ===> " << track_.al[4] << endl; |
418 |
|
|
419 |
for(int i=0; i<5; i++) al[i]=track_.al[i]; |
// for(int i=0; i<5; i++) al[i]=track_.al[i]; |
420 |
chi2=track_.chi2; |
// chi2=track_.chi2; |
421 |
nstep=track_.nstep; |
// nstep=track_.nstep; |
422 |
for(int i=0; i<6; i++) xv[i]=track_.xv[i]; |
// 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]; |
// 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]; |
// 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]; |
// 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]; |
// for(int i=0; i<6; i++) ayv[i]=track_.ayv[i]; |
427 |
for(int i=0; i<5; i++) { |
// for(int i=0; i<5; i++) { |
428 |
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]; |
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 parameters fit |
* Reset the fit parameters |
439 |
*/ |
*/ |
440 |
void TrkTrack::FitReset(){ |
void TrkTrack::FitReset(){ |
441 |
for(int i=0; i<5; i++) al[i]=-9999.; |
for(int i=0; i<5; i++) al[i]=-9999.; |
456 |
// |
// |
457 |
//-------------------------------------- |
//-------------------------------------- |
458 |
void TrkTrack::Clear(){ |
void TrkTrack::Clear(){ |
459 |
seqno = -1; |
// cout << "TrkTrack::Clear()"<<endl; |
460 |
image = -1; |
seqno = -1; |
461 |
chi2 = 0; |
image = -1; |
462 |
nstep = 0; |
chi2 = 0; |
463 |
for(int it1=0;it1<5;it1++){ |
nstep = 0; |
464 |
al[it1] = 0; |
for(int it1=0;it1<5;it1++){ |
465 |
for(int it2=0;it2<5;it2++)coval[it1][it2] = 0; |
al[it1] = 0; |
466 |
}; |
for(int it2=0;it2<5;it2++)coval[it1][it2] = 0; |
467 |
for(int ip=0;ip<6;ip++){ |
}; |
468 |
xgood[ip] = 0; |
for(int ip=0;ip<6;ip++){ |
469 |
ygood[ip] = 0; |
xgood[ip] = 0; |
470 |
xm[ip] = 0; |
ygood[ip] = 0; |
471 |
ym[ip] = 0; |
xm[ip] = 0; |
472 |
zm[ip] = 0; |
ym[ip] = 0; |
473 |
resx[ip] = 0; |
zm[ip] = 0; |
474 |
resy[ip] = 0; |
resx[ip] = 0; |
475 |
xv[ip] = 0; |
resy[ip] = 0; |
476 |
yv[ip] = 0; |
xv[ip] = 0; |
477 |
zv[ip] = 0; |
yv[ip] = 0; |
478 |
axv[ip] = 0; |
zv[ip] = 0; |
479 |
ayv[ip] = 0; |
axv[ip] = 0; |
480 |
dedx_x[ip] = 0; |
ayv[ip] = 0; |
481 |
dedx_y[ip] = 0; |
dedx_x[ip] = 0; |
482 |
// clx[ip] = 0; |
dedx_y[ip] = 0; |
483 |
// cly[ip] = 0; |
|
484 |
}; |
}; |
485 |
clx->Clear(); |
if(clx)clx->Clear(); |
486 |
cly->Clear(); |
if(cly)cly->Clear(); |
487 |
}; |
}; |
488 |
//-------------------------------------- |
//-------------------------------------- |
489 |
// |
// |
490 |
// |
// |
491 |
//-------------------------------------- |
//-------------------------------------- |
492 |
void TrkTrack::Delete(){ |
void TrkTrack::Delete(){ |
493 |
Clear(); |
// cout << "TrkTrack::Delete()"<<endl; |
494 |
clx->Delete(); |
// Clear(); |
495 |
cly->Delete(); |
if(clx)delete clx; |
496 |
|
if(cly)delete cly; |
497 |
}; |
}; |
498 |
//-------------------------------------- |
//-------------------------------------- |
499 |
// |
// |
500 |
// |
// |
501 |
//-------------------------------------- |
//-------------------------------------- |
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; |
// 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 |
// cls = 0;//<<<<pointer |
526 |
cls = TRef(s.cls); |
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++){ |
|
// crc[i] = -1; |
|
559 |
good[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 |
// |
// |
582 |
//-------------------------------------- |
//-------------------------------------- |
583 |
void TrkLevel2::Dump(){ |
void TrkLevel2::Dump(){ |
584 |
|
|
|
TClonesArray &t = *Track; |
|
|
TClonesArray &sx = *SingletX; |
|
|
TClonesArray &sy = *SingletY; |
|
585 |
// |
// |
586 |
cout << endl << endl << "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"; |
cout << endl << endl << "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"; |
587 |
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]<<" "; |
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::SetFromLevel2Struct(cTrkLevel2 *l2){ |
// void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2){ |
|
|
|
|
// temporary objects: |
|
|
TrkSinglet* t_singlet = new TrkSinglet(); |
|
|
TrkTrack* t_track = new TrkTrack(); |
|
618 |
|
|
619 |
// **** general variables **** |
// // temporary objects: |
620 |
// good2 = l2->good2; |
// TrkSinglet* t_singlet = new TrkSinglet(); |
621 |
for(Int_t i=0; i<12 ; i++){ |
// TrkTrack* t_track = new TrkTrack(); |
622 |
// crc[i] = l2->crc[i]; |
|
623 |
good[i] = l2->good[i]; |
// // **** general variables **** |
624 |
}; |
// // good2 = l2->good2; |
625 |
// *** TRACKS *** |
// for(Int_t i=0; i<12 ; i++){ |
626 |
TClonesArray &t = *Track; |
// // crc[i] = l2->crc[i]; |
627 |
for(int i=0; i<l2->ntrk; i++){ |
// good[i] = l2->good[i]; |
628 |
t_track->seqno = i;// NBNBNBNB deve sempre essere = i |
// }; |
629 |
t_track->image = l2->image[i]-1; |
// // *** TRACKS *** |
630 |
// cout << "track "<<i<<t_track->seqno << t_track->image<<endl; |
// if(!Track) Track = new TClonesArray("TrkTrack"); |
631 |
t_track->chi2 = l2->chi2_nt[i]; |
// TClonesArray &t = *Track; |
632 |
t_track->nstep = l2->nstep_nt[i]; |
// for(int i=0; i<l2->ntrk; i++){ |
633 |
for(int it1=0;it1<5;it1++){ |
// t_track->seqno = i;// NBNBNBNB deve sempre essere = i |
634 |
t_track->al[it1] = l2->al_nt[i][it1]; |
// t_track->image = l2->image[i]-1; |
635 |
for(int it2=0;it2<5;it2++) |
// // cout << "track "<<i<<t_track->seqno << t_track->image<<endl; |
636 |
t_track->coval[it1][it2] = l2->coval[i][it2][it1]; |
// t_track->chi2 = l2->chi2_nt[i]; |
637 |
}; |
// t_track->nstep = l2->nstep_nt[i]; |
638 |
for(int ip=0;ip<6;ip++){ |
// for(int it1=0;it1<5;it1++){ |
639 |
t_track->xgood[ip] = l2->xgood_nt[i][ip]; |
// t_track->al[it1] = l2->al_nt[i][it1]; |
640 |
t_track->ygood[ip] = l2->ygood_nt[i][ip]; |
// for(int it2=0;it2<5;it2++) |
641 |
t_track->xm[ip] = l2->xm_nt[i][ip]; |
// t_track->coval[it1][it2] = l2->coval[i][it2][it1]; |
642 |
t_track->ym[ip] = l2->ym_nt[i][ip]; |
// }; |
643 |
t_track->zm[ip] = l2->zm_nt[i][ip]; |
// for(int ip=0;ip<6;ip++){ |
644 |
t_track->resx[ip] = l2->resx_nt[i][ip]; |
// t_track->xgood[ip] = l2->xgood_nt[i][ip]; |
645 |
t_track->resy[ip] = l2->resy_nt[i][ip]; |
// t_track->ygood[ip] = l2->ygood_nt[i][ip]; |
646 |
t_track->xv[ip] = l2->xv_nt[i][ip]; |
// t_track->xm[ip] = l2->xm_nt[i][ip]; |
647 |
t_track->yv[ip] = l2->yv_nt[i][ip]; |
// t_track->ym[ip] = l2->ym_nt[i][ip]; |
648 |
t_track->zv[ip] = l2->zv_nt[i][ip]; |
// t_track->zm[ip] = l2->zm_nt[i][ip]; |
649 |
t_track->axv[ip] = l2->axv_nt[i][ip]; |
// t_track->resx[ip] = l2->resx_nt[i][ip]; |
650 |
t_track->ayv[ip] = l2->ayv_nt[i][ip]; |
// t_track->resy[ip] = l2->resy_nt[i][ip]; |
651 |
t_track->dedx_x[ip] = l2->dedx_x[i][ip]; |
// t_track->xv[ip] = l2->xv_nt[i][ip]; |
652 |
t_track->dedx_y[ip] = l2->dedx_y[i][ip]; |
// t_track->yv[ip] = l2->yv_nt[i][ip]; |
653 |
// t_track->clx[ip] = 0; |
// t_track->zv[ip] = l2->zv_nt[i][ip]; |
654 |
// t_track->cly[ip] = 0; |
// t_track->axv[ip] = l2->axv_nt[i][ip]; |
655 |
}; |
// t_track->ayv[ip] = l2->ayv_nt[i][ip]; |
656 |
new(t[i]) TrkTrack(*t_track); |
// t_track->dedx_x[ip] = l2->dedx_x[i][ip]; |
657 |
t_track->Clear(); |
// t_track->dedx_y[ip] = l2->dedx_y[i][ip]; |
658 |
}; |
// // t_track->clx[ip] = 0; |
659 |
// *** SINGLETS *** |
// // t_track->cly[ip] = 0; |
660 |
TClonesArray &sx = *SingletX; |
// }; |
661 |
for(int i=0; i<l2->nclsx; i++){ |
// new(t[i]) TrkTrack(*t_track); |
662 |
t_singlet->plane = l2->planex[i]; |
// t_track->Clear(); |
663 |
t_singlet->coord[0] = l2->xs[i][0]; |
// }; |
664 |
t_singlet->coord[1] = l2->xs[i][1]; |
// // *** SINGLETS *** |
665 |
t_singlet->sgnl = l2->signlxs[i]; |
// if(!SingletX)SingletX = new TClonesArray("TrkSinglet"); |
666 |
// t_singlet->cls = 0; |
// TClonesArray &sx = *SingletX; |
667 |
new(sx[i]) TrkSinglet(*t_singlet); |
// for(int i=0; i<l2->nclsx; i++){ |
668 |
t_singlet->Clear(); |
// t_singlet->plane = l2->planex[i]; |
669 |
} |
// t_singlet->coord[0] = l2->xs[i][0]; |
670 |
TClonesArray &sy = *SingletY; |
// t_singlet->coord[1] = l2->xs[i][1]; |
671 |
for(int i=0; i<l2->nclsy; i++){ |
// t_singlet->sgnl = l2->signlxs[i]; |
672 |
t_singlet->plane = l2->planey[i]; |
// // t_singlet->cls = 0; |
673 |
t_singlet->coord[0] = l2->ys[i][0]; |
// new(sx[i]) TrkSinglet(*t_singlet); |
674 |
t_singlet->coord[1] = l2->ys[i][1]; |
// t_singlet->Clear(); |
675 |
t_singlet->sgnl = l2->signlys[i]; |
// } |
676 |
// t_singlet->cls = 0; |
// if(!SingletY)SingletY = new TClonesArray("TrkSinglet"); |
677 |
new(sy[i]) TrkSinglet(*t_singlet); |
// TClonesArray &sy = *SingletY; |
678 |
t_singlet->Clear(); |
// 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; |
// delete t_track; |
689 |
delete t_singlet; |
// delete t_singlet; |
690 |
} |
// } |
691 |
//-------------------------------------- |
//-------------------------------------- |
692 |
// |
// |
693 |
// |
// |
708 |
good[i] = l2->good[i]; |
good[i] = l2->good[i]; |
709 |
}; |
}; |
710 |
// *** TRACKS *** |
// *** TRACKS *** |
711 |
|
if(!Track) Track = new TClonesArray("TrkTrack"); |
712 |
TClonesArray &t = *Track; |
TClonesArray &t = *Track; |
713 |
|
//----------------------------------------------------- |
714 |
|
if(l1 && !t_track->clx)t_track->clx = new TRefArray(6,0); |
715 |
|
if(l1 && !t_track->cly)t_track->cly = new TRefArray(6,0); |
716 |
|
//----------------------------------------------------- |
717 |
for(int i=0; i<l2->ntrk; i++){ |
for(int i=0; i<l2->ntrk; i++){ |
718 |
t_track->seqno = i;// NBNBNBNB deve sempre essere = i |
t_track->seqno = i;// NBNBNBNB deve sempre essere = i |
719 |
t_track->image = l2->image[i]-1; |
t_track->image = l2->image[i]-1; |
740 |
t_track->ayv[ip] = l2->ayv_nt[i][ip]; |
t_track->ayv[ip] = l2->ayv_nt[i][ip]; |
741 |
t_track->dedx_x[ip] = l2->dedx_x[i][ip]; |
t_track->dedx_x[ip] = l2->dedx_x[i][ip]; |
742 |
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; |
|
743 |
//----------------------------------------------------- |
//----------------------------------------------------- |
744 |
// t_track->clx[ip] = l1->GetCluster(l2->cltrx[i][ip]-1); |
//----------------------------------------------------- |
745 |
// 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); |
746 |
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); |
747 |
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; |
|
748 |
//----------------------------------------------------- |
//----------------------------------------------------- |
749 |
}; |
}; |
750 |
new(t[i]) TrkTrack(*t_track); |
new(t[i]) TrkTrack(*t_track); |
751 |
t_track->Clear(); |
t_track->Clear(); |
752 |
}; |
}; |
753 |
// *** SINGLETS *** |
// *** SINGLETS *** |
754 |
|
if(!SingletX)SingletX = new TClonesArray("TrkSinglet"); |
755 |
TClonesArray &sx = *SingletX; |
TClonesArray &sx = *SingletX; |
756 |
for(int i=0; i<l2->nclsx; i++){ |
for(int i=0; i<l2->nclsx; i++){ |
757 |
t_singlet->plane = l2->planex[i]; |
t_singlet->plane = l2->planex[i]; |
759 |
t_singlet->coord[1] = l2->xs[i][1]; |
t_singlet->coord[1] = l2->xs[i][1]; |
760 |
t_singlet->sgnl = l2->signlxs[i]; |
t_singlet->sgnl = l2->signlxs[i]; |
761 |
//----------------------------------------------------- |
//----------------------------------------------------- |
762 |
// 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; |
|
763 |
//----------------------------------------------------- |
//----------------------------------------------------- |
764 |
new(sx[i]) TrkSinglet(*t_singlet); |
new(sx[i]) TrkSinglet(*t_singlet); |
765 |
t_singlet->Clear(); |
t_singlet->Clear(); |
766 |
} |
} |
767 |
|
if(!SingletY)SingletY = new TClonesArray("TrkSinglet"); |
768 |
TClonesArray &sy = *SingletY; |
TClonesArray &sy = *SingletY; |
769 |
for(int i=0; i<l2->nclsy; i++){ |
for(int i=0; i<l2->nclsy; i++){ |
770 |
t_singlet->plane = l2->planey[i]; |
t_singlet->plane = l2->planey[i]; |
772 |
t_singlet->coord[1] = l2->ys[i][1]; |
t_singlet->coord[1] = l2->ys[i][1]; |
773 |
t_singlet->sgnl = l2->signlys[i]; |
t_singlet->sgnl = l2->signlys[i]; |
774 |
//----------------------------------------------------- |
//----------------------------------------------------- |
775 |
// 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; |
|
776 |
//----------------------------------------------------- |
//----------------------------------------------------- |
777 |
new(sy[i]) TrkSinglet(*t_singlet); |
new(sy[i]) TrkSinglet(*t_singlet); |
778 |
t_singlet->Clear(); |
t_singlet->Clear(); |
795 |
}; |
}; |
796 |
// *** TRACKS *** |
// *** TRACKS *** |
797 |
|
|
798 |
l2->ntrk = Track->GetEntries(); |
if(Track){ |
799 |
for(Int_t i=0;i<l2->ntrk;i++){ |
l2->ntrk = Track->GetEntries(); |
800 |
l2->image[i] = 1 + ((TrkTrack *)Track->At(i))->image; |
for(Int_t i=0;i<l2->ntrk;i++){ |
801 |
l2->chi2_nt[i] = ((TrkTrack *)Track->At(i))->chi2; |
l2->image[i] = 1 + ((TrkTrack *)Track->At(i))->image; |
802 |
l2->nstep_nt[i] = ((TrkTrack *)Track->At(i))->nstep; |
l2->chi2_nt[i] = ((TrkTrack *)Track->At(i))->chi2; |
803 |
for(int it1=0;it1<5;it1++){ |
l2->nstep_nt[i] = ((TrkTrack *)Track->At(i))->nstep; |
804 |
l2->al_nt[i][it1] = ((TrkTrack *)Track->At(i))->al[it1]; |
for(int it1=0;it1<5;it1++){ |
805 |
for(int it2=0;it2<5;it2++) |
l2->al_nt[i][it1] = ((TrkTrack *)Track->At(i))->al[it1]; |
806 |
l2->coval[i][it2][it1] = ((TrkTrack *)Track->At(i))->coval[it1][it2]; |
for(int it2=0;it2<5;it2++) |
807 |
}; |
l2->coval[i][it2][it1] = ((TrkTrack *)Track->At(i))->coval[it1][it2]; |
808 |
for(int ip=0;ip<6;ip++){ |
}; |
809 |
l2->xgood_nt[i][ip] = ((TrkTrack *)Track->At(i))->xgood[ip]; |
for(int ip=0;ip<6;ip++){ |
810 |
l2->ygood_nt[i][ip] = ((TrkTrack *)Track->At(i))->ygood[ip]; |
l2->xgood_nt[i][ip] = ((TrkTrack *)Track->At(i))->xgood[ip]; |
811 |
l2->xm_nt[i][ip] = ((TrkTrack *)Track->At(i))->xm[ip]; |
l2->ygood_nt[i][ip] = ((TrkTrack *)Track->At(i))->ygood[ip]; |
812 |
l2->ym_nt[i][ip] = ((TrkTrack *)Track->At(i))->ym[ip]; |
l2->xm_nt[i][ip] = ((TrkTrack *)Track->At(i))->xm[ip]; |
813 |
l2->zm_nt[i][ip] = ((TrkTrack *)Track->At(i))->zm[ip]; |
l2->ym_nt[i][ip] = ((TrkTrack *)Track->At(i))->ym[ip]; |
814 |
l2->resx_nt[i][ip] = ((TrkTrack *)Track->At(i))->resx[ip]; |
l2->zm_nt[i][ip] = ((TrkTrack *)Track->At(i))->zm[ip]; |
815 |
l2->resy_nt[i][ip] = ((TrkTrack *)Track->At(i))->resy[ip]; |
l2->resx_nt[i][ip] = ((TrkTrack *)Track->At(i))->resx[ip]; |
816 |
l2->xv_nt[i][ip] = ((TrkTrack *)Track->At(i))->xv[ip]; |
l2->resy_nt[i][ip] = ((TrkTrack *)Track->At(i))->resy[ip]; |
817 |
l2->yv_nt[i][ip] = ((TrkTrack *)Track->At(i))->yv[ip]; |
l2->xv_nt[i][ip] = ((TrkTrack *)Track->At(i))->xv[ip]; |
818 |
l2->zv_nt[i][ip] = ((TrkTrack *)Track->At(i))->zv[ip]; |
l2->yv_nt[i][ip] = ((TrkTrack *)Track->At(i))->yv[ip]; |
819 |
l2->axv_nt[i][ip] = ((TrkTrack *)Track->At(i))->axv[ip]; |
l2->zv_nt[i][ip] = ((TrkTrack *)Track->At(i))->zv[ip]; |
820 |
l2->ayv_nt[i][ip] = ((TrkTrack *)Track->At(i))->ayv[ip]; |
l2->axv_nt[i][ip] = ((TrkTrack *)Track->At(i))->axv[ip]; |
821 |
l2->dedx_x[i][ip] = ((TrkTrack *)Track->At(i))->dedx_x[ip]; |
l2->ayv_nt[i][ip] = ((TrkTrack *)Track->At(i))->ayv[ip]; |
822 |
l2->dedx_y[i][ip] = ((TrkTrack *)Track->At(i))->dedx_y[ip]; |
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 *** |
// *** SINGLETS *** |
828 |
l2->nclsx = SingletX->GetEntries(); |
if(SingletX){ |
829 |
for(Int_t i=0;i<l2->nclsx;i++){ |
l2->nclsx = SingletX->GetEntries(); |
830 |
l2->planex[i] = ((TrkSinglet *)SingletX->At(i))->plane; |
for(Int_t i=0;i<l2->nclsx;i++){ |
831 |
l2->xs[i][0] = ((TrkSinglet *)SingletX->At(i))->coord[0]; |
l2->planex[i] = ((TrkSinglet *)SingletX->At(i))->plane; |
832 |
l2->xs[i][1] = ((TrkSinglet *)SingletX->At(i))->coord[1]; |
l2->xs[i][0] = ((TrkSinglet *)SingletX->At(i))->coord[0]; |
833 |
l2->signlxs[i] = ((TrkSinglet *)SingletX->At(i))->sgnl; |
l2->xs[i][1] = ((TrkSinglet *)SingletX->At(i))->coord[1]; |
834 |
} |
l2->signlxs[i] = ((TrkSinglet *)SingletX->At(i))->sgnl; |
835 |
l2->nclsy = SingletY->GetEntries(); |
} |
836 |
for(Int_t i=0;i<l2->nclsy;i++){ |
} |
837 |
l2->planey[i] = ((TrkSinglet *)SingletY->At(i))->plane; |
|
838 |
l2->ys[i][0] = ((TrkSinglet *)SingletY->At(i))->coord[0]; |
if(SingletY){ |
839 |
l2->ys[i][1] = ((TrkSinglet *)SingletY->At(i))->coord[1]; |
l2->nclsy = SingletY->GetEntries(); |
840 |
l2->signlys[i] = ((TrkSinglet *)SingletY->At(i))->sgnl; |
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 |
//-------------------------------------- |
//-------------------------------------- |
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 |
good[i] = -1; |
}; |
856 |
}; |
// if(Track)Track->Clear("C"); |
857 |
/* Track->RemoveAll(); |
// if(SingletX)SingletX->Clear("C"); |
858 |
SingletX->RemoveAll(); |
// if(SingletY)SingletY->Clear("C"); |
859 |
SingletY->RemoveAll();*/ |
if(Track)Track->Delete(); |
860 |
// modify to avoid memory leakage |
if(SingletX)SingletX->Delete(); |
861 |
Track->Clear(); |
if(SingletY)SingletY->Delete(); |
862 |
SingletX->Clear(); |
} |
863 |
SingletY->Clear(); |
// //-------------------------------------- |
864 |
} |
// // |
865 |
//-------------------------------------- |
// // |
866 |
// |
// //-------------------------------------- |
|
// |
|
|
//-------------------------------------- |
|
867 |
void TrkLevel2::Delete(){ |
void TrkLevel2::Delete(){ |
868 |
|
|
869 |
Clear(); |
// cout << "void TrkLevel2::Delete()"<<endl; |
870 |
Track->Delete(); |
Clear(); |
871 |
SingletX->Delete(); |
if(Track)delete Track; |
872 |
SingletY->Delete(); |
if(SingletX)delete SingletX; |
873 |
|
if(SingletY)delete SingletY; |
874 |
|
|
875 |
} |
} |
876 |
//-------------------------------------- |
//-------------------------------------- |
877 |
// |
// |
883 |
*/ |
*/ |
884 |
TRefArray *TrkLevel2::GetTracks_NFitSorted(){ |
TRefArray *TrkLevel2::GetTracks_NFitSorted(){ |
885 |
|
|
886 |
TRefArray *sorted = new TRefArray(); |
if(!Track)return 0; |
887 |
|
|
888 |
|
TRefArray *sorted = new TRefArray(); |
889 |
|
|
890 |
TClonesArray &t = *Track; |
TClonesArray &t = *Track; |
891 |
// TClonesArray &ts = *PhysicalTrack; |
// TClonesArray &ts = *PhysicalTrack; |
892 |
int N = 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; |
// 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 |
int nfit =0; |
// while(N != 0){ |
900 |
float chi2ref = numeric_limits<float>::max(); |
int nfit =0; |
901 |
|
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 < 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(); |
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 |
Float_t chi2 = ((TrkTrack *)t[i])->chi2; |
Float_t chi2 = ((TrkTrack *)t[i])->chi2; |
912 |
if(chi2 < 0) chi2 = chi2*1000; |
if(chi2 < 0) chi2 = -chi2*1000; |
913 |
if( chi2 < chi2ref |
if( chi2 < chi2ref |
914 |
&& ((TrkTrack *)t[i])->GetNtot() == nfit |
&& ((TrkTrack *)t[i])->GetNtot() == nfit |
915 |
&& m[i]==1){ |
&& m[i]==1){ |
916 |
chi2ref = ((TrkTrack *)t[i])->chi2; |
chi2ref = ((TrkTrack *)t[i])->chi2; |
917 |
indi = i; |
indi = i; |
918 |
}; |
}; |
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 |
|
|
924 |
// cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl; |
// cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl; |
925 |
}; |
}; |
926 |
sorted->Add( (TrkTrack*)t[indi] ); |
sorted->Add( (TrkTrack*)t[indi] ); |
927 |
|
|
928 |
m[indi] = 0; |
m[indi] = 0; |
929 |
// cout << "SORTED "<< indo << " "<< indi << " "<< N << endl; |
// cout << "SORTED "<< indo << " "<< indi << " "<< N << " "<<((TrkTrack *)t[indi])->image<<" "<<chi2ref<<endl; |
930 |
N--; |
N--; |
931 |
indo++; |
indo++; |
932 |
} |
} |
933 |
m.clear(); |
m.clear(); |
934 |
// cout << "GetTracks_NFitSorted(it): Done"<< endl; |
// cout << "GetTracks_NFitSorted(it): Done"<< endl; |
935 |
|
|
936 |
return sorted; |
return sorted; |
937 |
// return PhysicalTrack; |
// return PhysicalTrack; |
938 |
} |
} |
939 |
//-------------------------------------- |
//-------------------------------------- |
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; |
1017 |
} |
} |
1018 |
|
|
1019 |
TRefArray *sorted = GetTracks(); //TEMPORANEO |
TRefArray *sorted = GetTracks(); //TEMPORANEO |
1020 |
|
if(!sorted)return 0; |
1021 |
TrkTrack *track = (TrkTrack*)sorted->At(it); |
TrkTrack *track = (TrkTrack*)sorted->At(it); |
1022 |
sorted->Delete(); |
sorted->Clear(); |
1023 |
|
delete sorted; |
1024 |
return track; |
return track; |
1025 |
} |
} |
1026 |
/** |
/** |
1029 |
Int_t TrkLevel2::GetNTracks(){ |
Int_t TrkLevel2::GetNTracks(){ |
1030 |
|
|
1031 |
Float_t ntot=0; |
Float_t ntot=0; |
1032 |
|
if(!Track)return 0; |
1033 |
TClonesArray &t = *Track; |
TClonesArray &t = *Track; |
1034 |
for(int i=0; i<ntrk(); i++) { |
for(int i=0; i<ntrk(); i++) { |
1035 |
if( ((TrkTrack *)t[i])->GetImageSeqNo() == -1 ) ntot+=1.; |
if( ((TrkTrack *)t[i])->GetImageSeqNo() == -1 ) ntot+=1.; |
1048 |
*/ |
*/ |
1049 |
TrkTrack *TrkLevel2::GetTrackImage(int it){ |
TrkTrack *TrkLevel2::GetTrackImage(int it){ |
1050 |
|
|
1051 |
if(it >= this->GetNTracks()){ |
if(it >= this->GetNTracks()){ |
1052 |
cout << "** TrkLevel2 ** Track "<< it << "does not exits! " << endl; |
cout << "** TrkLevel2 ** Track "<< it << "does not exits! " << endl; |
1053 |
cout << " Physical tracks GetNTracks() = "<< this->ntrk() << endl; |
cout << " Physical tracks GetNTracks() = "<< this->ntrk() << endl; |
1054 |
return 0; |
return 0; |
1055 |
} |
} |
1056 |
|
|
1057 |
TRefArray* sorted = GetTracks(); //TEMPORANEO |
TRefArray* sorted = GetTracks(); //TEMPORANEO |
1058 |
TrkTrack *track = (TrkTrack*)sorted->At(it); |
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 |
TrkTrack *image = (TrkTrack*)(*Track)[track->image]; |
if(!Track)return 0; |
1066 |
|
TrkTrack *image = (TrkTrack*)(*Track)[track->image]; |
1067 |
|
|
1068 |
sorted->Delete(); |
sorted->Delete(); |
1069 |
|
delete sorted; |
1070 |
return image; |
|
1071 |
|
return image; |
1072 |
|
|
1073 |
} |
} |
1074 |
//-------------------------------------- |
//-------------------------------------- |
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 |
// |
// |
1213 |
tl = new float[npoint]; |
tl = new float[npoint]; |
1214 |
int i=0; |
int i=0; |
1215 |
do{ |
do{ |
1216 |
x[i] = 0; |
x[i] = 0; |
1217 |
y[i] = 0; |
y[i] = 0; |
1218 |
z[i] = zin[i]; |
z[i] = zin[i]; |
1219 |
thx[i] = 0; |
thx[i] = 0; |
1220 |
thy[i] = 0; |
thy[i] = 0; |
1221 |
tl[i] = 0; |
tl[i] = 0; |
1222 |
i++; |
i++; |
1223 |
}while(zin[i-1] > zin[i] && i < npoint); |
}while(zin[i-1] > zin[i] && i < npoint); |
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); |