4 |
*/ |
*/ |
5 |
#include <TrkLevel2.h> |
#include <TrkLevel2.h> |
6 |
#include <iostream> |
#include <iostream> |
7 |
|
#include <math.h> |
8 |
using namespace std; |
using namespace std; |
9 |
//...................................... |
//...................................... |
10 |
// F77 routines |
// F77 routines |
12 |
extern "C" { |
extern "C" { |
13 |
void dotrack_(int*, double*, double*, double*, double*, int*); |
void dotrack_(int*, double*, double*, double*, double*, int*); |
14 |
void dotrack2_(int*, double*, double*, double*, double*,double*, double*, double*,int*); |
void dotrack2_(int*, double*, double*, double*, double*,double*, double*, double*,int*); |
15 |
int readb_(const char*); |
// int readb_(const char*); |
16 |
|
int readb_(); |
17 |
|
void mini2_(int*,int*,int*); |
18 |
|
void guess_(); |
19 |
} |
} |
20 |
//-------------------------------------- |
//-------------------------------------- |
21 |
// |
// |
22 |
// |
// |
23 |
//-------------------------------------- |
//-------------------------------------- |
24 |
|
/** |
25 |
|
* Evaluates the trajectory in the apparatus associated to the track. |
26 |
|
* 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. |
27 |
|
* @param t pointer to an object of the class Trajectory, |
28 |
|
* which z coordinates should be previously initialized by calling the proper constructor ( Trajectory::Trajectory(int n, float* zin) ). |
29 |
|
* @return error flag. |
30 |
|
*/ |
31 |
|
int Trajectory::DoTrack2(float* al){ |
32 |
|
|
33 |
|
double *dxout = new double[t->npoint]; |
34 |
|
double *dyout = new double[t->npoint]; |
35 |
|
double *dthxout = new double[t->npoint]; |
36 |
|
double *dthyout = new double[t->npoint]; |
37 |
|
double *dtlout = new double[t->npoint]; |
38 |
|
double *dzin = new double[t->npoint]; |
39 |
|
double dal[5]; |
40 |
|
|
41 |
|
int ifail = 0; |
42 |
|
|
43 |
|
for (int i=0; i<5; i++) dal[i] = (double)al[i]; |
44 |
|
for (int i=0; i<t->npoint; i++) dzin[i] = (double)z[i]; |
45 |
|
|
46 |
|
dotrack2_(&(t->npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail); |
47 |
|
|
48 |
|
for (int i=0; i<t->npoint; i++){ |
49 |
|
x[i] = (float)*dxout++; |
50 |
|
y[i] = (float)*dyout++; |
51 |
|
thx[i] = (float)*dthxout++; |
52 |
|
thy[i] = (float)*dthyout++; |
53 |
|
tl[i] = (float)*dtlout++; |
54 |
|
} |
55 |
|
|
56 |
|
return ifail; |
57 |
|
}; |
58 |
|
//--------------------------------------------- |
59 |
|
//--------------------------------------------- |
60 |
TrkTrack::TrkTrack(){ |
TrkTrack::TrkTrack(){ |
61 |
seqno = -1; |
seqno = -1; |
62 |
image = -1; |
image = -1; |
63 |
chi2 = 0; |
chi2 = 0; |
64 |
|
nstep = 0; |
65 |
for(int it1=0;it1<5;it1++){ |
for(int it1=0;it1<5;it1++){ |
66 |
al[it1] = 0; |
al[it1] = 0; |
67 |
for(int it2=0;it2<5;it2++)coval[it1][it2] = 0; |
for(int it2=0;it2<5;it2++)coval[it1][it2] = 0; |
68 |
}; |
}; |
69 |
for(int ip=0;ip<6;ip++){ |
for(int ip=0;ip<6;ip++){ |
70 |
xgood[ip] = 0; |
xgood[ip] = 0; |
95 |
seqno = t.seqno; |
seqno = t.seqno; |
96 |
image = t.image; |
image = t.image; |
97 |
chi2 = t.chi2; |
chi2 = t.chi2; |
98 |
|
nstep = t.nstep; |
99 |
for(int it1=0;it1<5;it1++){ |
for(int it1=0;it1<5;it1++){ |
100 |
al[it1] = t.al[it1]; |
al[it1] = t.al[it1]; |
101 |
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]; |
102 |
}; |
}; |
103 |
for(int ip=0;ip<6;ip++){ |
for(int ip=0;ip<6;ip++){ |
104 |
xgood[ip] = t.xgood[ip]; |
xgood[ip] = t.xgood[ip]; |
236 |
//-------------------------------------- |
//-------------------------------------- |
237 |
void TrkTrack::Dump(){ |
void TrkTrack::Dump(){ |
238 |
cout << endl << "========== Track " ; |
cout << endl << "========== Track " ; |
239 |
|
cout << endl << "seq. n. : "<< seqno; |
240 |
|
cout << endl << "image n. : "<< image; |
241 |
cout << endl << "al : "; for(int i=0; i<5; i++)cout << al[i] << " "; |
cout << endl << "al : "; for(int i=0; i<5; i++)cout << al[i] << " "; |
242 |
cout << endl << "chi^2 : "<< chi2; |
cout << endl << "chi^2 : "<< chi2; |
243 |
|
cout << endl << "n.step : "<< nstep; |
244 |
cout << endl << "xgood : "; for(int i=0; i<6; i++)cout << xgood[i] ; |
cout << endl << "xgood : "; for(int i=0; i<6; i++)cout << xgood[i] ; |
245 |
cout << endl << "ygood : "; for(int i=0; i<6; i++)cout << ygood[i] ; |
cout << endl << "ygood : "; for(int i=0; i<6; i++)cout << ygood[i] ; |
246 |
cout << endl << "xm : "; for(int i=0; i<6; i++)cout << xm[i] << " "; |
cout << endl << "xm : "; for(int i=0; i<6; i++)cout << xm[i] << " "; |
247 |
cout << endl << "ym : "; for(int i=0; i<6; i++)cout << ym[i] << " "; |
cout << endl << "ym : "; for(int i=0; i<6; i++)cout << ym[i] << " "; |
248 |
cout << endl << "zm : "; for(int i=0; i<6; i++)cout << zm[i] << " "; |
cout << endl << "zm : "; for(int i=0; i<6; i++)cout << zm[i] << " "; |
249 |
|
cout << endl << "xv : "; for(int i=0; i<6; i++)cout << xv[i] << " "; |
250 |
|
cout << endl << "yv : "; for(int i=0; i<6; i++)cout << yv[i] << " "; |
251 |
|
cout << endl << "zv : "; for(int i=0; i<6; i++)cout << zv[i] << " "; |
252 |
|
cout << endl << "resx : "; for(int i=0; i<6; i++)cout << resx[i] << " "; |
253 |
|
cout << endl << "resy : "; for(int i=0; i<6; i++)cout << resy[i] << " "; |
254 |
|
cout << endl << "coval : "; for(int i=0; i<5; i++)cout << coval[0][i]<<" "; |
255 |
|
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[1][i]<<" "; |
256 |
|
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[2][i]<<" "; |
257 |
|
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[3][i]<<" "; |
258 |
|
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[4][i]<<" "; |
259 |
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] << " "; |
260 |
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] << " "; |
261 |
|
cout << endl; |
262 |
|
} |
263 |
|
/** |
264 |
|
* Set the TrkTrack position measurements |
265 |
|
*/ |
266 |
|
void TrkTrack::SetMeasure(double *xmeas, double *ymeas, double *zmeas){ |
267 |
|
for(int i=0; i<6; i++) xm[i]=*xmeas++; |
268 |
|
for(int i=0; i<6; i++) ym[i]=*ymeas++; |
269 |
|
for(int i=0; i<6; i++) zm[i]=*zmeas++; |
270 |
|
} |
271 |
|
/** |
272 |
|
* Set the TrkTrack position resolution |
273 |
|
*/ |
274 |
|
void TrkTrack::SetResolution(double *rx, double *ry){ |
275 |
|
for(int i=0; i<6; i++) resx[i]=*rx++; |
276 |
|
for(int i=0; i<6; i++) resy[i]=*ry++; |
277 |
|
} |
278 |
|
/** |
279 |
|
* Set the TrkTrack good measurement |
280 |
|
*/ |
281 |
|
void TrkTrack::SetGood(int *xg, int *yg){ |
282 |
|
for(int i=0; i<6; i++) xgood[i]=*xg++; |
283 |
|
for(int i=0; i<6; i++) ygood[i]=*yg++; |
284 |
|
} |
285 |
|
|
286 |
|
/** |
287 |
|
* Load the magnetic field |
288 |
|
*/ |
289 |
|
void TrkTrack::LoadField(TString path){ |
290 |
|
|
291 |
|
strcpy(path_.path,path.Data()); |
292 |
|
path_.pathlen = path.Length(); |
293 |
|
path_.error = 0; |
294 |
|
readb_(); |
295 |
|
|
296 |
|
}; |
297 |
|
/** |
298 |
|
* Tracking method. It calls F77 mini routine. |
299 |
|
*/ |
300 |
|
void TrkTrack::Fit(double pfixed, int& fail, int iprint){ |
301 |
|
|
302 |
|
float al_ini[] = {0.,0.,0.,0.,0.}; |
303 |
|
|
304 |
|
extern cMini2track track_; |
305 |
|
fail = 0; |
306 |
|
|
307 |
|
for(int i=0; i<6; i++) track_.xm[i]=xm[i]; |
308 |
|
for(int i=0; i<6; i++) track_.ym[i]=ym[i]; |
309 |
|
for(int i=0; i<6; i++) track_.zm[i]=zm[i]; |
310 |
|
for(int i=0; i<6; i++) track_.resx[i]=resx[i]; |
311 |
|
for(int i=0; i<6; i++) track_.resy[i]=resy[i]; |
312 |
|
for(int i=0; i<6; i++) track_.xgood[i]=xgood[i]; |
313 |
|
for(int i=0; i<6; i++) track_.ygood[i]=ygood[i]; |
314 |
|
|
315 |
|
// initial guess of "al" with linear fit |
316 |
|
// if(al[0]==-9999.&&al[1]==-9999.&&al[2]==-9999.&&al[3]==-9999.&&al[4]==-9999.){ |
317 |
|
// cout << "initial guess "<<endl; |
318 |
|
// double szz=0., szx=0., szy=0., ssx=0., ssy=0., sz=0., s1=0.; |
319 |
|
// double det, ax, ay, bx, by; |
320 |
|
// for(int i=0; i<NPLANE; i++) { |
321 |
|
// szz=szz+zm[i]*zm[i]; |
322 |
|
// szx=szx+zm[i]*xm[i]; |
323 |
|
// szy=szy+zm[i]*ym[i]; |
324 |
|
// ssx=ssx+xm[i]; |
325 |
|
// ssy=ssy+ym[i]; |
326 |
|
// sz=sz+zm[i]; |
327 |
|
// s1=s1+1.; |
328 |
|
// } |
329 |
|
// det=szz*s1-sz*sz; |
330 |
|
// ax=(szx*s1-sz*ssx)/det; |
331 |
|
// bx=(szz*ssx-szx*sz)/det; |
332 |
|
// ay=(szy*s1-sz*ssy)/det; |
333 |
|
// by=(szz*ssy-szy*sz)/det; |
334 |
|
// al[0]=ax*23.5+bx; // ZINI = 23.5 !!! it should be the same parameter in all codes |
335 |
|
// al[1]=ay*23.5+by; // " |
336 |
|
// al[2]= sqrt(pow(ax,2)+pow(ay,2))/ sqrt(pow(ax,2)+pow(ay,2)+1.); |
337 |
|
// al[3]=0.; |
338 |
|
// if( (ax!=0.)||(ay!=0.) ) { |
339 |
|
// al[3]= asin(ay/ sqrt(pow(ax,2)+pow(ay,2))); |
340 |
|
// if(ax<0.) al[3]=acos(-1.)-al[3]; |
341 |
|
// } |
342 |
|
// al[4]=0.; |
343 |
|
// } |
344 |
|
// end guess |
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 |
|
if(al[0]==-9999.&&al[1]==-9999.&&al[2]==-9999.&&al[3]==-9999.&&al[4]==-9999.)guess_(); |
351 |
|
|
352 |
|
// --------------------- free momentum |
353 |
|
if(pfixed==0.) { |
354 |
|
// al[4]=0.; // free momentum |
355 |
|
track_.pfixed=0.; // " |
356 |
|
} |
357 |
|
// --------------------- fixed momentum |
358 |
|
if(pfixed!=0.) { |
359 |
|
al[4]=1./pfixed; // to fix the momentum |
360 |
|
track_.pfixed=pfixed; // " |
361 |
|
} |
362 |
|
|
363 |
|
// store temporarily the initial guess |
364 |
|
for(int i=0; i<5; i++) al_ini[i]=track_.al[i]; |
365 |
|
|
366 |
|
|
367 |
|
int istep=0; |
368 |
|
int ifail=0; |
369 |
|
mini2_(&istep,&ifail, &iprint); |
370 |
|
if(ifail!=0) { |
371 |
|
if(iprint==1)cout << "ERROR: ifail= " << ifail << endl; |
372 |
|
fail = 1; |
373 |
|
// return; |
374 |
|
} |
375 |
|
|
376 |
|
|
377 |
|
// cout << endl << "eta ===> " << track_.al[4] << endl; |
378 |
|
|
379 |
|
for(int i=0; i<5; i++) al[i]=track_.al[i]; |
380 |
|
chi2=track_.chi2; |
381 |
|
nstep=track_.nstep; |
382 |
|
for(int i=0; i<6; i++) xv[i]=track_.xv[i]; |
383 |
|
for(int i=0; i<6; i++) yv[i]=track_.yv[i]; |
384 |
|
for(int i=0; i<6; i++) zv[i]=track_.zv[i]; |
385 |
|
for(int i=0; i<6; i++) axv[i]=track_.axv[i]; |
386 |
|
for(int i=0; i<6; i++) ayv[i]=track_.ayv[i]; |
387 |
|
for(int i=0; i<5; i++) { |
388 |
|
for(int j=0; j<5; j++) coval[i][j]=track_.cov[i][j]; |
389 |
|
} |
390 |
|
|
391 |
|
if(fail){ |
392 |
|
cout << " >>>> fit failed >>>> drawing initial par"<<endl; |
393 |
|
for(int i=0; i<5; i++) al[i]=al_ini[i]; |
394 |
|
} |
395 |
|
|
396 |
|
}; |
397 |
|
/* |
398 |
|
* Reset the fit parameters |
399 |
|
*/ |
400 |
|
void TrkTrack::FitReset(){ |
401 |
|
for(int i=0; i<5; i++) al[i]=-9999.; |
402 |
|
chi2=0.; |
403 |
|
nstep=0; |
404 |
|
for(int i=0; i<6; i++) xv[i]=0.; |
405 |
|
for(int i=0; i<6; i++) yv[i]=0.; |
406 |
|
for(int i=0; i<6; i++) zv[i]=0.; |
407 |
|
for(int i=0; i<6; i++) axv[i]=0.; |
408 |
|
for(int i=0; i<6; i++) ayv[i]=0.; |
409 |
|
for(int i=0; i<5; i++) { |
410 |
|
for(int j=0; j<5; j++) coval[i][j]=0.; |
411 |
|
} |
412 |
} |
} |
413 |
|
|
414 |
|
//-------------------------------------- |
415 |
|
// |
416 |
|
// |
417 |
|
//-------------------------------------- |
418 |
|
void TrkTrack::Clear(){ |
419 |
|
seqno = -1; |
420 |
|
image = -1; |
421 |
|
chi2 = 0; |
422 |
|
nstep = 0; |
423 |
|
for(int it1=0;it1<5;it1++){ |
424 |
|
al[it1] = 0; |
425 |
|
for(int it2=0;it2<5;it2++)coval[it1][it2] = 0; |
426 |
|
}; |
427 |
|
for(int ip=0;ip<6;ip++){ |
428 |
|
xgood[ip] = 0; |
429 |
|
ygood[ip] = 0; |
430 |
|
xm[ip] = 0; |
431 |
|
ym[ip] = 0; |
432 |
|
zm[ip] = 0; |
433 |
|
resx[ip] = 0; |
434 |
|
resy[ip] = 0; |
435 |
|
xv[ip] = 0; |
436 |
|
yv[ip] = 0; |
437 |
|
zv[ip] = 0; |
438 |
|
axv[ip] = 0; |
439 |
|
ayv[ip] = 0; |
440 |
|
dedx_x[ip] = 0; |
441 |
|
dedx_y[ip] = 0; |
442 |
|
// clx[ip] = 0; |
443 |
|
// cly[ip] = 0; |
444 |
|
}; |
445 |
|
clx->Clear(); |
446 |
|
cly->Clear(); |
447 |
|
}; |
448 |
|
//-------------------------------------- |
449 |
|
// |
450 |
|
// |
451 |
|
//-------------------------------------- |
452 |
|
void TrkTrack::Delete(){ |
453 |
|
Clear(); |
454 |
|
clx->Delete(); |
455 |
|
cly->Delete(); |
456 |
|
}; |
457 |
|
//-------------------------------------- |
458 |
|
// |
459 |
|
// |
460 |
|
//-------------------------------------- |
461 |
|
|
462 |
//-------------------------------------- |
//-------------------------------------- |
463 |
// |
// |
464 |
// |
// |
498 |
// |
// |
499 |
//-------------------------------------- |
//-------------------------------------- |
500 |
TrkLevel2::TrkLevel2(){ |
TrkLevel2::TrkLevel2(){ |
501 |
good2 = -1; |
// good2 = -1; |
502 |
for(Int_t i=0; i<12 ; i++){ |
for(Int_t i=0; i<12 ; i++){ |
503 |
crc[i] = -1; |
// crc[i] = -1; |
504 |
}; |
good[i] = -1; |
505 |
|
}; |
506 |
Track = new TClonesArray("TrkTrack"); |
Track = new TClonesArray("TrkTrack"); |
507 |
SingletX = new TClonesArray("TrkSinglet"); |
SingletX = new TClonesArray("TrkSinglet"); |
508 |
SingletY = new TClonesArray("TrkSinglet"); |
SingletY = new TClonesArray("TrkSinglet"); |
515 |
// |
// |
516 |
//-------------------------------------- |
//-------------------------------------- |
517 |
void TrkLevel2::Dump(){ |
void TrkLevel2::Dump(){ |
518 |
|
|
519 |
TClonesArray &t = *Track; |
TClonesArray &t = *Track; |
520 |
TClonesArray &sx = *SingletX; |
TClonesArray &sx = *SingletX; |
521 |
TClonesArray &sy = *SingletY; |
TClonesArray &sy = *SingletY; |
522 |
|
// |
523 |
cout << endl << endl << "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"; |
cout << endl << endl << "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"; |
524 |
cout << endl << "good2 : " << good2; |
cout << endl << "good : "; for(int i=0; i<12; i++) cout << good[i]<<" "; |
|
cout << endl << "crc : "; for(int i=0; i<12; i++) cout << crc[i]; |
|
525 |
cout << endl << "ntrk() : " << this->ntrk() ; |
cout << endl << "ntrk() : " << this->ntrk() ; |
526 |
cout << endl << "nclsx() : " << this->nclsx(); |
cout << endl << "nclsx() : " << this->nclsx(); |
527 |
cout << endl << "nclsy() : " << this->nclsy(); |
cout << endl << "nclsy() : " << this->nclsy(); |
537 |
* 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). |
538 |
*/ |
*/ |
539 |
void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2){ |
void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2){ |
540 |
// |
|
541 |
// Track = new TClonesArray("TrkTrack"); |
// temporary objects: |
|
// SingletX = new TClonesArray("TrkSinglet"); |
|
|
// SingletY = new TClonesArray("TrkSinglet"); |
|
|
// temporary objects: |
|
542 |
TrkSinglet* t_singlet = new TrkSinglet(); |
TrkSinglet* t_singlet = new TrkSinglet(); |
543 |
TrkTrack* t_track = new TrkTrack(); |
TrkTrack* t_track = new TrkTrack(); |
544 |
// general variables |
|
545 |
good2 = l2->good2; |
// **** general variables **** |
546 |
|
// good2 = l2->good2; |
547 |
for(Int_t i=0; i<12 ; i++){ |
for(Int_t i=0; i<12 ; i++){ |
548 |
crc[i] = l2->crc[i]; |
// crc[i] = l2->crc[i]; |
549 |
}; |
good[i] = l2->good[i]; |
550 |
// *** TRACKS *** |
}; |
551 |
|
// *** TRACKS *** |
552 |
TClonesArray &t = *Track; |
TClonesArray &t = *Track; |
553 |
for(int i=0; i<l2->ntrk; i++){ |
for(int i=0; i<l2->ntrk; i++){ |
554 |
t_track->seqno = i;// NBNBNBNB deve sempre essere = i |
t_track->seqno = i;// NBNBNBNB deve sempre essere = i |
555 |
t_track->image = l2->image[i]-1; |
t_track->image = l2->image[i]-1; |
556 |
// cout << "track "<<i<<t_track->seqno << t_track->image<<endl; |
// cout << "track "<<i<<t_track->seqno << t_track->image<<endl; |
557 |
t_track->chi2 = l2->chi2_nt[i]; |
t_track->chi2 = l2->chi2_nt[i]; |
558 |
|
t_track->nstep = l2->nstep_nt[i]; |
559 |
for(int it1=0;it1<5;it1++){ |
for(int it1=0;it1<5;it1++){ |
560 |
t_track->al[it1] = l2->al_nt[i][it1]; |
t_track->al[it1] = l2->al_nt[i][it1]; |
561 |
for(int it2=0;it2<5;it2++) |
for(int it2=0;it2<5;it2++) |
621 |
TrkSinglet* t_singlet = new TrkSinglet(); |
TrkSinglet* t_singlet = new TrkSinglet(); |
622 |
TrkTrack* t_track = new TrkTrack(); |
TrkTrack* t_track = new TrkTrack(); |
623 |
// general variables |
// general variables |
624 |
good2 = l2->good2; |
// good2 = l2->good2; |
625 |
for(Int_t i=0; i<12 ; i++){ |
for(Int_t i=0; i<12 ; i++){ |
626 |
crc[i] = l2->crc[i]; |
// crc[i] = l2->crc[i]; |
627 |
|
good[i] = l2->good[i]; |
628 |
}; |
}; |
629 |
// *** TRACKS *** |
// *** TRACKS *** |
630 |
TClonesArray &t = *Track; |
TClonesArray &t = *Track; |
633 |
t_track->image = l2->image[i]-1; |
t_track->image = l2->image[i]-1; |
634 |
// cout << "track "<<i<<t_track->seqno << t_track->image<<endl; |
// cout << "track "<<i<<t_track->seqno << t_track->image<<endl; |
635 |
t_track->chi2 = l2->chi2_nt[i]; |
t_track->chi2 = l2->chi2_nt[i]; |
636 |
|
t_track->nstep = l2->nstep_nt[i]; |
637 |
for(int it1=0;it1<5;it1++){ |
for(int it1=0;it1<5;it1++){ |
638 |
t_track->al[it1] = l2->al_nt[i][it1]; |
t_track->al[it1] = l2->al_nt[i][it1]; |
639 |
for(int it2=0;it2<5;it2++) |
for(int it2=0;it2<5;it2++) |
660 |
// t_track->cly[ip] = l1->GetCluster(l2->cltry[i][ip]-1); |
// t_track->cly[ip] = l1->GetCluster(l2->cltry[i][ip]-1); |
661 |
if(t_track->xgood[ip])t_track->clx->AddAt(l1->GetCluster(l2->cltrx[i][ip]-1),ip); |
if(t_track->xgood[ip])t_track->clx->AddAt(l1->GetCluster(l2->cltrx[i][ip]-1),ip); |
662 |
if(t_track->ygood[ip])t_track->cly->AddAt(l1->GetCluster(l2->cltry[i][ip]-1),ip); |
if(t_track->ygood[ip])t_track->cly->AddAt(l1->GetCluster(l2->cltry[i][ip]-1),ip); |
663 |
|
// 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; |
664 |
|
// 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; |
665 |
//----------------------------------------------------- |
//----------------------------------------------------- |
666 |
}; |
}; |
667 |
new(t[i]) TrkTrack(*t_track); |
new(t[i]) TrkTrack(*t_track); |
677 |
//----------------------------------------------------- |
//----------------------------------------------------- |
678 |
// cout << "singolo x "<<i<<" -- "<< l2->clsx[i] <<endl; |
// cout << "singolo x "<<i<<" -- "<< l2->clsx[i] <<endl; |
679 |
t_singlet->cls = l1->GetCluster(l2->clsx[i]-1); |
t_singlet->cls = l1->GetCluster(l2->clsx[i]-1); |
680 |
|
// cout<<" i "<<i<<" l2->clsx[i] "<<l2->clsx[i]<< " l1->GetCluster(l2->clsx[i]-1) "<<l1->GetCluster(l2->clsx[i]-1)<<endl; |
681 |
//----------------------------------------------------- |
//----------------------------------------------------- |
682 |
new(sx[i]) TrkSinglet(*t_singlet); |
new(sx[i]) TrkSinglet(*t_singlet); |
683 |
t_singlet->Clear(); |
t_singlet->Clear(); |
691 |
//----------------------------------------------------- |
//----------------------------------------------------- |
692 |
// cout << "singolo y "<<i<<" -- "<< l2->clsy[i] <<endl; |
// cout << "singolo y "<<i<<" -- "<< l2->clsy[i] <<endl; |
693 |
t_singlet->cls = l1->GetCluster(l2->clsy[i]-1); |
t_singlet->cls = l1->GetCluster(l2->clsy[i]-1); |
694 |
|
// cout<<" i "<<i<<" l2->clsy[i] "<<l2->clsy[i]<< " l1->GetCluster(l2->clsy[i]-1) "<<l1->GetCluster(l2->clsy[i]-1)<<endl; |
695 |
//----------------------------------------------------- |
//----------------------------------------------------- |
696 |
new(sy[i]) TrkSinglet(*t_singlet); |
new(sy[i]) TrkSinglet(*t_singlet); |
697 |
t_singlet->Clear(); |
t_singlet->Clear(); |
707 |
void TrkLevel2::GetLevel2Struct(cTrkLevel2 *l2) const { |
void TrkLevel2::GetLevel2Struct(cTrkLevel2 *l2) const { |
708 |
|
|
709 |
// general variables |
// general variables |
710 |
l2->good2 = good2 ; |
// l2->good2 = good2 ; |
711 |
for(Int_t i=0; i<12 ; i++){ |
for(Int_t i=0; i<12 ; i++){ |
712 |
l2->crc[i] = crc[i]; |
// l2->crc[i] = crc[i]; |
713 |
|
l2->good[i] = good[i]; |
714 |
}; |
}; |
715 |
// *** TRACKS *** |
// *** TRACKS *** |
716 |
|
|
718 |
for(Int_t i=0;i<l2->ntrk;i++){ |
for(Int_t i=0;i<l2->ntrk;i++){ |
719 |
l2->image[i] = 1 + ((TrkTrack *)Track->At(i))->image; |
l2->image[i] = 1 + ((TrkTrack *)Track->At(i))->image; |
720 |
l2->chi2_nt[i] = ((TrkTrack *)Track->At(i))->chi2; |
l2->chi2_nt[i] = ((TrkTrack *)Track->At(i))->chi2; |
721 |
for(int it1=0;it1<5;it1++){ |
l2->nstep_nt[i] = ((TrkTrack *)Track->At(i))->nstep; |
722 |
|
for(int it1=0;it1<5;it1++){ |
723 |
l2->al_nt[i][it1] = ((TrkTrack *)Track->At(i))->al[it1]; |
l2->al_nt[i][it1] = ((TrkTrack *)Track->At(i))->al[it1]; |
724 |
for(int it2=0;it2<5;it2++) |
for(int it2=0;it2<5;it2++) |
725 |
l2->coval[i][it2][it1] = ((TrkTrack *)Track->At(i))->coval[it1][it2]; |
l2->coval[i][it2][it1] = ((TrkTrack *)Track->At(i))->coval[it1][it2]; |
763 |
// |
// |
764 |
//-------------------------------------- |
//-------------------------------------- |
765 |
void TrkLevel2::Clear(){ |
void TrkLevel2::Clear(){ |
766 |
good2 = -1; |
// good2 = -1; |
767 |
for(Int_t i=0; i<12 ; i++){ |
for(Int_t i=0; i<12 ; i++){ |
768 |
crc[i] = -1; |
// crc[i] = -1; |
769 |
}; |
good[i] = -1; |
770 |
|
}; |
771 |
/* Track->RemoveAll(); |
/* Track->RemoveAll(); |
772 |
SingletX->RemoveAll(); |
SingletX->RemoveAll(); |
773 |
SingletY->RemoveAll();*/ |
SingletY->RemoveAll();*/ |
780 |
// |
// |
781 |
// |
// |
782 |
//-------------------------------------- |
//-------------------------------------- |
783 |
|
void TrkLevel2::Delete(){ |
784 |
|
|
785 |
|
Clear(); |
786 |
|
Track->Delete(); |
787 |
|
SingletX->Delete(); |
788 |
|
SingletY->Delete(); |
789 |
|
} |
790 |
|
//-------------------------------------- |
791 |
|
// |
792 |
|
// |
793 |
|
//-------------------------------------- |
794 |
/** |
/** |
795 |
* Sort physical tracks and stores them in a TObjectArray, ordering by increasing chi**2 value (in case of track image, it selects the one with lower chi**2). The total number of physical tracks is given by GetNTracks() and the it-th physical track can be retrieved by means of the method GetTrack(int it). |
* Sort physical tracks and stores them in a TObjectArray, ordering by increasing chi**2 value (in case of track image, it selects the one with lower chi**2). The total number of physical tracks is given by GetNTracks() and the it-th physical track can be retrieved by means of the method GetTrack(int it). |
796 |
* This method is overridden by PamLevel2::GetTracks(), where calorimeter and TOF information is used. |
* This method is overridden by PamLevel2::GetTracks(), where calorimeter and TOF information is used. |
797 |
*/ |
*/ |
|
// TClonesArray *TrkLevel2::GetTracks(){ |
|
|
// TClonesArray *sorted = GetTracks_NFitSorted(); |
|
|
// return sorted; |
|
|
// }; |
|
|
|
|
|
/*TClonesArray *TrkLevel2::GetTracks_Chi2Sorted(){ |
|
|
|
|
|
TClonesArray *sorted = new TClonesArray("TrkTrack"); |
|
|
TClonesArray &t = *Track; |
|
|
TClonesArray &ts = *sorted; |
|
|
int N=this->ntrk(); |
|
|
vector<int> m(N); for(int i=0; i<N; i++)m[i]=1; |
|
|
|
|
|
int indo=0; |
|
|
int indi=0; |
|
|
while(N != 0){ |
|
|
float chi2ref=1000000; |
|
|
for(int i=0; i<this->ntrk(); i++){ |
|
|
if(((TrkTrack *)t[i])->chi2 < chi2ref && m[i]==1){ |
|
|
chi2ref = ((TrkTrack *)t[i])->chi2; |
|
|
indi = i; |
|
|
} |
|
|
} |
|
|
if( ((TrkTrack *)t[indi])->image != -1 ){ |
|
|
m[((TrkTrack *)t[indi])->image] = 0; |
|
|
N--; |
|
|
} |
|
|
new(ts[indo]) TrkTrack(*(TrkTrack*)t[indi]); |
|
|
m[indi] = 0; |
|
|
N--; |
|
|
indo++; |
|
|
} |
|
|
return sorted; |
|
|
}*/ |
|
|
/*TClonesArray *TrkLevel2::GetTracks_NFitSorted(){ |
|
|
|
|
|
TClonesArray *sorted = new TClonesArray("TrkTrack"); |
|
|
TClonesArray &t = *Track; |
|
|
TClonesArray &ts = *sorted; |
|
|
// TClonesArray &ts = *PhysicalTrack; |
|
|
int N = ntrk(); |
|
|
vector<int> m(N); for(int i=0; i<N; i++)m[i]=1; |
|
|
// int m[50]; for(int i=0; i<N; i++)m[i]=1; |
|
|
|
|
|
int indo=0; |
|
|
int indi=0; |
|
|
while(N != 0){ |
|
|
int nfit =0; |
|
|
float chi2ref = numeric_limits<float>::max(); |
|
|
// first loop to search maximum num. of fit points |
|
|
for(int i=0; i < ntrk(); i++){ |
|
|
// if(N==ntrk())cout << "** "<<i<< " " << ((TrkTrack *)t[i])->GetImageSeqNo()<< " " <<((TrkTrack *)t[i])->GetNtot() << " " <<((TrkTrack *)t[i])->chi2 << endl; |
|
|
if( ((TrkTrack *)t[i])->GetNtot() >= nfit && m[i]==1){ |
|
|
nfit = ((TrkTrack *)t[i])->GetNtot(); |
|
|
} |
|
|
} |
|
|
//second loop to search minimum chi2 among selected |
|
|
for(int i=0; i<this->ntrk(); i++){ |
|
|
if( ((TrkTrack *)t[i])->chi2 < chi2ref |
|
|
&& ((TrkTrack *)t[i])->GetNtot()== nfit |
|
|
&& m[i]==1){ |
|
|
chi2ref = ((TrkTrack *)t[i])->chi2; |
|
|
indi = i; |
|
|
// cout << "2** "<<i<< " " << nfit <<" "<<chi2ref<<endl; |
|
|
} |
|
|
} |
|
|
if( ((TrkTrack *)t[indi])->HasImage() ){ |
|
|
m[((TrkTrack *)t[indi])->image] = 0; |
|
|
N--; |
|
|
|
|
|
// Int_t nfiti=((TrkTrack *)t[((TrkTrack *)t[indi])->image ])->GetNtot(); |
|
|
// Float_t chi2i=((TrkTrack *)t[((TrkTrack *)t[indi])->image ])->chi2; |
|
|
|
|
|
// cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl; |
|
|
} |
|
|
new(ts[indo]) TrkTrack(*(TrkTrack*)t[indi]); |
|
|
m[indi] = 0; |
|
|
// cout << "SORTED "<< indo << " "<< indi << " "<< N << endl; |
|
|
N--; |
|
|
indo++; |
|
|
} |
|
|
m.clear(); |
|
|
return sorted; |
|
|
// return PhysicalTrack; |
|
|
}*/ |
|
|
//TClonesArray *TrkLevel2::GetTracks_NFitSorted(){ |
|
798 |
TRefArray *TrkLevel2::GetTracks_NFitSorted(){ |
TRefArray *TrkLevel2::GetTracks_NFitSorted(){ |
799 |
|
|
|
// cout << "GetTracks_NFitSorted(it): new TRefArray()"<< endl; |
|
|
// TClonesArray *sorted = new TClonesArray("TrkTrack"); |
|
|
// TClonesArray &ts = *sorted; |
|
800 |
TRefArray *sorted = new TRefArray(); |
TRefArray *sorted = new TRefArray(); |
801 |
|
|
802 |
TClonesArray &t = *Track; |
TClonesArray &t = *Track; |
832 |
m[((TrkTrack *)t[indi])->image] = 0; |
m[((TrkTrack *)t[indi])->image] = 0; |
833 |
N--; |
N--; |
834 |
|
|
|
// Int_t nfiti=((TrkTrack *)t[((TrkTrack *)t[indi])->image ])->GetNtot(); |
|
|
// Float_t chi2i=((TrkTrack *)t[((TrkTrack *)t[indi])->image ])->chi2; |
|
|
|
|
835 |
// cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl; |
// cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl; |
836 |
}; |
}; |
|
// new(ts[indo]) TrkTrack(*(TrkTrack*)t[indi]); |
|
|
// cout << "GetTracks_NFitSorted(it): Add("<<indo<<")"<< endl; |
|
837 |
sorted->Add( (TrkTrack*)t[indi] ); |
sorted->Add( (TrkTrack*)t[indi] ); |
838 |
|
|
839 |
m[indi] = 0; |
m[indi] = 0; |
913 |
* Retrieves the it-th "physical" track, sorted by the method GetNTracks(). |
* Retrieves the it-th "physical" track, sorted by the method GetNTracks(). |
914 |
* @param it Track number, ranging from 0 to GetNTracks(). |
* @param it Track number, ranging from 0 to GetNTracks(). |
915 |
*/ |
*/ |
916 |
/*TrkTrack *TrkLevel2::GetTrack(int it){ |
|
|
|
|
|
if(it >= this->GetNTracks()){ |
|
|
cout << "** TrkLevel2 ** Track "<< it << "does not exits! " << endl; |
|
|
cout << " Physical tracks GetNTracks() = "<< this->ntrk() << endl; |
|
|
return 0; |
|
|
} |
|
|
TClonesArray* sorted = GetTracks(); |
|
|
TClonesArray &ts = *sorted; |
|
|
|
|
|
// TrkTrack *track = (TrkTrack*)ts[it]; |
|
|
TrkTrack *track = new TrkTrack( *(TrkTrack*)ts[it] ); //copia |
|
|
sorted->Delete("all");////TEMPORANEO |
|
|
return track; |
|
|
}*/ |
|
917 |
TrkTrack *TrkLevel2::GetTrack(int it){ |
TrkTrack *TrkLevel2::GetTrack(int it){ |
918 |
|
|
919 |
if(it >= this->GetNTracks()){ |
if(it >= this->GetNTracks()){ |
934 |
|
|
935 |
Float_t ntot=0; |
Float_t ntot=0; |
936 |
TClonesArray &t = *Track; |
TClonesArray &t = *Track; |
937 |
for(int i=0; i<ntrk(); i++) { |
for(int i=0; i<ntrk(); i++) { |
938 |
if( ((TrkTrack *)t[i])->GetImageSeqNo() == -1 ) ntot+=1.; |
if( ((TrkTrack *)t[i])->GetImageSeqNo() == -1 ) ntot+=1.; |
939 |
else ntot+=0.5; |
else ntot+=0.5; |
940 |
} |
} |
949 |
* Retrieves (if present) the image of the it-th "physical" track, sorted by the method GetNTracks(). |
* Retrieves (if present) the image of the it-th "physical" track, sorted by the method GetNTracks(). |
950 |
* @param it Track number, ranging from 0 to GetNTracks(). |
* @param it Track number, ranging from 0 to GetNTracks(). |
951 |
*/ |
*/ |
|
/*TrkTrack *TrkLevel2::GetTrackImage(int it){ |
|
|
|
|
|
if(it >= this->GetNTracks()){ |
|
|
cout << "** TrkLevel2 ** Track "<< it << "does not exits! " << endl; |
|
|
cout << " Physical tracks GetNTracks() = "<< this->ntrk() << endl; |
|
|
return 0; |
|
|
} |
|
|
|
|
|
TClonesArray* sorted = GetTracks(); |
|
|
TClonesArray &ts = *sorted; |
|
|
TrkTrack *track = (TrkTrack*)ts[it]; |
|
|
// TrkTrack *track = (TrkTrack*)(*(this->GetTracks()))[it]; |
|
|
|
|
|
if(!track->HasImage()){ |
|
|
cout << "** TrkLevel2 ** Track "<< it << "does not have image! " << endl; |
|
|
return 0; |
|
|
} |
|
|
TrkTrack *image = (TrkTrack*)(*Track)[track->image]; |
|
|
|
|
|
// GetTracks()->Delete(); ////TEMPORANEO |
|
|
sorted->Delete(); ////TEMPORANEO |
|
|
|
|
|
return image; |
|
|
|
|
|
}*/ |
|
952 |
TrkTrack *TrkLevel2::GetTrackImage(int it){ |
TrkTrack *TrkLevel2::GetTrackImage(int it){ |
953 |
|
|
954 |
if(it >= this->GetNTracks()){ |
if(it >= this->GetNTracks()){ |
979 |
* Loads the magnetic field. |
* Loads the magnetic field. |
980 |
* @param s Path of the magnetic-field files. |
* @param s Path of the magnetic-field files. |
981 |
*/ |
*/ |
982 |
void TrkLevel2::LoadField(TString s){ |
void TrkLevel2::LoadField(TString path){ |
983 |
readb_(s.Data()); |
// |
984 |
|
strcpy(path_.path,path.Data()); |
985 |
|
path_.pathlen = path.Length(); |
986 |
|
path_.error = 0; |
987 |
|
readb_(); |
988 |
|
// |
989 |
}; |
}; |
990 |
//-------------------------------------- |
//-------------------------------------- |
991 |
// |
// |
1132 |
|
|
1133 |
} |
} |
1134 |
|
|
1135 |
|
|
1136 |
ClassImp(TrkLevel2); |
ClassImp(TrkLevel2); |
1137 |
ClassImp(TrkSinglet); |
ClassImp(TrkSinglet); |
1138 |
ClassImp(TrkTrack); |
ClassImp(TrkTrack); |