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 |
void mini2_(int*,int*,int*); |
void mini2_(int*,int*,int*); |
16 |
void guess_(); |
void guess_(); |
17 |
void gufld_(float*, float*); |
void gufld_(float*, float*); |
18 |
|
float risxeta2_(float *); |
19 |
|
float risxeta3_(float *); |
20 |
|
float risxeta4_(float *); |
21 |
|
float risyeta2_(float *); |
22 |
} |
} |
23 |
|
|
24 |
//-------------------------------------- |
//-------------------------------------- |
52 |
ayv[ip] = 0; |
ayv[ip] = 0; |
53 |
dedx_x[ip] = 0; |
dedx_x[ip] = 0; |
54 |
dedx_y[ip] = 0; |
dedx_y[ip] = 0; |
55 |
|
multmaxx[ip] = 0; |
56 |
|
multmaxy[ip] = 0; |
57 |
|
seedx[ip] = 0; |
58 |
|
seedy[ip] = 0; |
59 |
|
xpu[ip] = 0; |
60 |
|
ypu[ip] = 0; |
61 |
|
|
62 |
}; |
}; |
63 |
// clx = 0; |
|
64 |
// cly = 0; |
// TrkParams::SetTrackingMode(); |
65 |
// clx = new TRefArray(6,0); //forse causa memory leak??? |
// TrkParams::SetPrecisionFactor(); |
66 |
// cly = new TRefArray(6,0); //forse causa memory leak??? |
// TrkParams::SetStepMin(); |
67 |
// clx = TRefArray(6,0); |
TrkParams::SetMiniDefault(); |
68 |
// cly = TRefArray(6,0); |
TrkParams::SetPFA(); |
69 |
|
|
70 |
}; |
}; |
71 |
//-------------------------------------- |
//-------------------------------------- |
98 |
ayv[ip] = t.ayv[ip]; |
ayv[ip] = t.ayv[ip]; |
99 |
dedx_x[ip] = t.dedx_x[ip]; |
dedx_x[ip] = t.dedx_x[ip]; |
100 |
dedx_y[ip] = t.dedx_y[ip]; |
dedx_y[ip] = t.dedx_y[ip]; |
101 |
|
multmaxx[ip] = t.multmaxx[ip]; |
102 |
|
multmaxy[ip] = t.multmaxy[ip]; |
103 |
|
seedx[ip] = t.seedx[ip]; |
104 |
|
seedy[ip] = t.seedy[ip]; |
105 |
|
xpu[ip] = t.xpu[ip]; |
106 |
|
ypu[ip] = t.ypu[ip]; |
107 |
}; |
}; |
108 |
// clx = 0; |
|
109 |
// cly = 0; |
// TrkParams::SetTrackingMode(); |
110 |
// if(t.clx)clx = new TRefArray(*(t.clx)); |
// TrkParams::SetPrecisionFactor(); |
111 |
// if(t.cly)cly = new TRefArray(*(t.cly)); |
// TrkParams::SetStepMin(); |
112 |
// clx = TRefArray(t.clx); |
TrkParams::SetMiniDefault(); |
113 |
// cly = TRefArray(t.cly); |
TrkParams::SetPFA(); |
114 |
|
|
115 |
}; |
}; |
116 |
//-------------------------------------- |
//-------------------------------------- |
144 |
t.ayv[ip] = ayv[ip]; |
t.ayv[ip] = ayv[ip]; |
145 |
t.dedx_x[ip] = dedx_x[ip]; |
t.dedx_x[ip] = dedx_x[ip]; |
146 |
t.dedx_y[ip] = dedx_y[ip]; |
t.dedx_y[ip] = dedx_y[ip]; |
147 |
|
t.multmaxx[ip] = multmaxx[ip]; |
148 |
|
t.multmaxy[ip] = multmaxy[ip]; |
149 |
|
t.seedx[ip] = seedx[ip]; |
150 |
|
t.seedy[ip] = seedy[ip]; |
151 |
|
t.xpu[ip] = xpu[ip]; |
152 |
|
t.ypu[ip] = ypu[ip]; |
153 |
|
|
154 |
}; |
}; |
155 |
|
|
|
// t.clx = TRefArray(clx); |
|
|
// t.cly = TRefArray(cly); |
|
156 |
|
|
157 |
}; |
}; |
158 |
//-------------------------------------- |
//-------------------------------------- |
372 |
} |
} |
373 |
return (last_plane-first_plane+1); |
return (last_plane-first_plane+1); |
374 |
} |
} |
375 |
|
/** |
376 |
|
* Returns the reduced chi-square of track x-projection |
377 |
|
*/ |
378 |
|
Float_t TrkTrack::GetChi2X(){ |
379 |
|
float chiq=0; |
380 |
|
for(int ip=0; ip<6; ip++)if(XGood(ip))chiq+= pow((xv[ip]-xm[ip])/resx[ip],2.); |
381 |
|
if(GetNX()>3)chiq=chiq/(GetNX()-3); |
382 |
|
else chiq=0; |
383 |
|
if(chiq==0)cout << " Float_t TrkTrack::GetChi2X() -- WARNING -- value not defined "<<chiq<<endl; |
384 |
|
return chiq; |
385 |
|
} |
386 |
|
/** |
387 |
|
* Returns the reduced chi-square of track y-projection |
388 |
|
*/ |
389 |
|
Float_t TrkTrack::GetChi2Y(){ |
390 |
|
float chiq=0; |
391 |
|
for(int ip=0; ip<6; ip++)if(YGood(ip))chiq+= pow((yv[ip]-ym[ip])/resy[ip],2.); |
392 |
|
if(GetNY()>2)chiq=chiq/(GetNY()-2); |
393 |
|
else chiq=0; |
394 |
|
if(chiq==0)cout << " Float_t TrkTrack::GetChi2Y() -- WARNING -- value not defined "<<chiq<<endl; |
395 |
|
return chiq; |
396 |
|
} |
397 |
|
/** |
398 |
|
* Returns the logarythm of the likeliwood-function of track x-projection |
399 |
|
*/ |
400 |
|
Float_t TrkTrack::GetLnLX(){ |
401 |
|
float lnl=0; |
402 |
|
for(int ip=0; ip<6; ip++) |
403 |
|
if( XGood(ip) && tailx[ip]!=0 ) |
404 |
|
lnl += (tailx[ip]+1.) * log( (tailx[ip]*pow(resx[ip],2.) + pow(xv[ip]-xm[ip],2.)) / (tailx[ip]*pow(resx[ip],2)) ); |
405 |
|
if(GetNX()>3)lnl=lnl/(GetNX()-3); |
406 |
|
else lnl=0; |
407 |
|
if(lnl==0){ |
408 |
|
cout << " Float_t TrkTrack::GetLnLX() -- WARNING -- value not defined "<<lnl<<endl; |
409 |
|
Dump(); |
410 |
|
} |
411 |
|
return lnl; |
412 |
|
|
413 |
|
} |
414 |
|
/** |
415 |
|
* Returns the logarythm of the likeliwood-function of track y-projection |
416 |
|
*/ |
417 |
|
Float_t TrkTrack::GetLnLY(){ |
418 |
|
float lnl=0; |
419 |
|
for(int ip=0; ip<6; ip++) |
420 |
|
if( YGood(ip) && taily[ip]!=0 ) |
421 |
|
lnl += (taily[ip]+1.) * log( (taily[ip]*pow(resy[ip],2.) + pow(yv[ip]-ym[ip],2.)) / (taily[ip]*pow(resy[ip],2)) ); |
422 |
|
if(GetNY()>2)lnl=lnl/(GetNY()-2); |
423 |
|
else lnl=0; |
424 |
|
if(lnl==0){ |
425 |
|
cout << " Float_t TrkTrack::GetLnLY() -- WARNING -- value not defined "<<lnl<<endl; |
426 |
|
Dump(); |
427 |
|
} |
428 |
|
return lnl; |
429 |
|
|
430 |
|
} |
431 |
|
/** |
432 |
|
* Returns the effective angle, relative to the sensor, on each plane. |
433 |
|
* @param ip plane (0-5) |
434 |
|
* @param iv view (0=x 1=y) |
435 |
|
*/ |
436 |
|
Float_t TrkTrack::GetEffectiveAngle(int ip, int iv){ |
437 |
|
|
438 |
|
if(ip<0 || ip>5){ |
439 |
|
cout << "Float_t TrkTrack::GetEffectiveAngle(int "<<ip<<", int "<<iv<<") ==> wrong input"<<endl; |
440 |
|
return 0.; |
441 |
|
} |
442 |
|
|
443 |
|
float v[3]={xv[ip],yv[ip],zv[ip]}; |
444 |
|
//----------------------------------------- |
445 |
|
// effective angle (relative to the sensor) |
446 |
|
//----------------------------------------- |
447 |
|
float axv_geo = axv[ip]; |
448 |
|
float muhall_h = 297.61; //cm**2/Vs |
449 |
|
float BY = TrkParams::GetBY(v); |
450 |
|
float axv_eff = 0; |
451 |
|
if(ip==5) axv_geo = -1*axv_geo; |
452 |
|
if(ip==5) BY = -1*BY; |
453 |
|
axv_eff = 180.*atan( tan(axv_geo*acos(-1.)/180.) + muhall_h * BY * 0.0001)/acos(-1.); |
454 |
|
//----------------------------------------- |
455 |
|
// effective angle (relative to the sensor) |
456 |
|
//----------------------------------------- |
457 |
|
float ayv_geo = ayv[ip]; |
458 |
|
float muhall_e = 1258.18; //cm**2/Vs |
459 |
|
float BX = TrkParams::GetBX(v); |
460 |
|
float ayv_eff = 0; |
461 |
|
ayv_eff = 180.*atan( tan(ayv_geo*acos(-1.)/180.) + muhall_e * BX * 0.0001)/acos(-1.); |
462 |
|
|
463 |
|
if (iv==0)return axv_eff; |
464 |
|
else if(iv==1)return ayv_eff; |
465 |
|
else{ |
466 |
|
cout << "Float_t TrkTrack::GetEffectiveAngle(int "<<ip<<", int "<<iv<<") ==> wrong input"<<endl; |
467 |
|
return 0.; |
468 |
|
} |
469 |
|
|
470 |
|
}; |
471 |
|
|
472 |
//-------------------------------------- |
//-------------------------------------- |
473 |
// |
// |
474 |
// |
// |
490 |
cout << endl << "zv : "; for(int i=0; i<6; i++)cout << zv[i] << " "; |
cout << endl << "zv : "; for(int i=0; i<6; i++)cout << zv[i] << " "; |
491 |
cout << endl << "resx : "; for(int i=0; i<6; i++)cout << resx[i] << " "; |
cout << endl << "resx : "; for(int i=0; i<6; i++)cout << resx[i] << " "; |
492 |
cout << endl << "resy : "; for(int i=0; i<6; i++)cout << resy[i] << " "; |
cout << endl << "resy : "; for(int i=0; i<6; i++)cout << resy[i] << " "; |
493 |
|
cout << endl << "tailx : "; for(int i=0; i<6; i++)cout << tailx[i] << " "; |
494 |
|
cout << endl << "taily : "; for(int i=0; i<6; i++)cout << taily[i] << " "; |
495 |
cout << endl << "coval : "; for(int i=0; i<5; i++)cout << coval[0][i]<<" "; |
cout << endl << "coval : "; for(int i=0; i<5; i++)cout << coval[0][i]<<" "; |
496 |
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[1][i]<<" "; |
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[1][i]<<" "; |
497 |
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[2][i]<<" "; |
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[2][i]<<" "; |
499 |
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]<<" "; |
500 |
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] << " "; |
501 |
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] << " "; |
502 |
|
cout << endl << "maxs x : "; for(int i=0; i<6; i++)cout << GetClusterX_MaxStrip(i) << " "; |
503 |
|
cout << endl << "maxs y : "; for(int i=0; i<6; i++)cout << GetClusterY_MaxStrip(i) << " "; |
504 |
|
cout << endl << "mult x : "; for(int i=0; i<6; i++)cout << GetClusterX_Multiplicity(i) << " "; |
505 |
|
cout << endl << "mult y : "; for(int i=0; i<6; i++)cout << GetClusterY_Multiplicity(i) << " "; |
506 |
|
cout << endl << "seed x : "; for(int i=0; i<6; i++)cout << GetClusterX_Seed(i) << " "; |
507 |
|
cout << endl << "seed y : "; for(int i=0; i<6; i++)cout << GetClusterY_Seed(i) << " "; |
508 |
|
cout << endl << "xpu : "; for(int i=0; i<6; i++)cout << xpu[i] << " "; |
509 |
|
cout << endl << "ypu : "; for(int i=0; i<6; i++)cout << ypu[i] << " "; |
510 |
|
|
511 |
cout << endl; |
cout << endl; |
512 |
} |
} |
513 |
/** |
/** |
526 |
for(int i=0; i<6; i++) resy[i]=*ry++; |
for(int i=0; i<6; i++) resy[i]=*ry++; |
527 |
} |
} |
528 |
/** |
/** |
529 |
|
* Set the TrkTrack tails position resolution |
530 |
|
*/ |
531 |
|
void TrkTrack::SetTail(double *tx, double *ty, double factor){ |
532 |
|
for(int i=0; i<6; i++) tailx[i]=factor*(*tx++); |
533 |
|
for(int i=0; i<6; i++) taily[i]=factor*(*ty++); |
534 |
|
} |
535 |
|
/** |
536 |
|
* Set the TrkTrack Student parameter (resx,resy,tailx,taily) |
537 |
|
* from previous gausian fit |
538 |
|
*@param flag =0 standard, =1 with noise correction |
539 |
|
*/ |
540 |
|
void TrkTrack::SetStudentParam(int flag){ |
541 |
|
float sx[11]={0.000128242, |
542 |
|
0.000136942, |
543 |
|
0.000162718, |
544 |
|
0.000202644, |
545 |
|
0.00025597, |
546 |
|
0.000317456, |
547 |
|
0.000349048, |
548 |
|
0.000384638, |
549 |
|
0.000457295, |
550 |
|
0.000512319, |
551 |
|
0.000538573}; |
552 |
|
float tx[11]={1.79402, |
553 |
|
2.04876, |
554 |
|
2.88376, |
555 |
|
3.3, |
556 |
|
3.14084, |
557 |
|
4.07686, |
558 |
|
4.44736, |
559 |
|
3.5179, |
560 |
|
3.38697, |
561 |
|
3.45739, |
562 |
|
3.18627}; |
563 |
|
float sy[11]={0.000483075, |
564 |
|
0.000466925, |
565 |
|
0.000431658, |
566 |
|
0.000428317, |
567 |
|
0.000433854, |
568 |
|
0.000444044, |
569 |
|
0.000482098, |
570 |
|
0.000537579, |
571 |
|
0.000636279, |
572 |
|
0.000741998, |
573 |
|
0.000864261}; |
574 |
|
float ty[11]={0.997032, |
575 |
|
1.11147, |
576 |
|
1.18526, |
577 |
|
1.61404, |
578 |
|
2.21908, |
579 |
|
3.08959, |
580 |
|
4.48833, |
581 |
|
4.42687, |
582 |
|
4.65253, |
583 |
|
4.52043, |
584 |
|
4.29926}; |
585 |
|
int index; |
586 |
|
float fact; |
587 |
|
for(int i=0; i<6; i++) { |
588 |
|
index = int((fabs(axv[i])+1.)/2.); |
589 |
|
if(index>10) index=10; |
590 |
|
tailx[i]=tx[index]; |
591 |
|
if(flag==1) { |
592 |
|
if(fabs(axv[i])<=10.) fact = resx[i]/risxeta2_(&(axv[i])); |
593 |
|
if(fabs(axv[i])>10.&&fabs(axv[i])<=15.) fact = resx[i]/risxeta3_(&(axv[i])); |
594 |
|
if(fabs(axv[i])>15.) fact = resx[i]/risxeta4_(&(axv[i])); |
595 |
|
} else fact = 1.; |
596 |
|
resx[i] = sx[index]*fact; |
597 |
|
} |
598 |
|
for(int i=0; i<6; i++) { |
599 |
|
index = int((fabs(ayv[i])+1.)/2.); |
600 |
|
if(index>10) index=10; |
601 |
|
taily[i]=ty[index]; |
602 |
|
if(flag==1) fact = resy[i]/risyeta2_(&(ayv[i])); |
603 |
|
else fact = 1.; |
604 |
|
resy[i] = sy[index]*fact; |
605 |
|
} |
606 |
|
} |
607 |
|
/** |
608 |
* Set the TrkTrack good measurement |
* Set the TrkTrack good measurement |
609 |
*/ |
*/ |
610 |
void TrkTrack::SetGood(int *xg, int *yg){ |
void TrkTrack::SetGood(int *xg, int *yg){ |
611 |
// NB! si perdera` l'informazione sul numero del cluster |
|
612 |
for(int i=0; i<6; i++) xgood[i]=*xg++; |
for(int i=0; i<6; i++) xgood[i]=*xg++; |
613 |
for(int i=0; i<6; i++) ygood[i]=*yg++; |
for(int i=0; i<6; i++) ygood[i]=*yg++; |
614 |
} |
} |
623 |
// path_.error = 0; |
// path_.error = 0; |
624 |
// readb_(); |
// readb_(); |
625 |
|
|
626 |
|
// TrkParams::SetTrackingMode(); |
627 |
|
// TrkParams::SetPrecisionFactor(); |
628 |
|
// TrkParams::SetStepMin(); |
629 |
|
TrkParams::SetMiniDefault(); |
630 |
|
|
631 |
TrkParams::Set(path,1); |
TrkParams::Set(path,1); |
632 |
TrkParams::Load(1); |
TrkParams::Load(1); |
633 |
|
|
641 |
|
|
642 |
for(int i=0; i<6; i++){ |
for(int i=0; i<6; i++){ |
643 |
|
|
644 |
// track.xgood[i]=xgood[i]; |
// cout << i<<" - "<<xgood[i]<<" "<<XGood(i)<<endl; |
645 |
// track.ygood[i]=ygood[i]; |
// cout << i<<" - "<<ygood[i]<<" "<<YGood(i)<<endl; |
646 |
track.xgood[i]=XGood(i); |
track.xgood[i]=XGood(i); |
647 |
track.ygood[i]=YGood(i); |
track.ygood[i]=YGood(i); |
648 |
|
|
668 |
|
|
669 |
track.resx[i]=resx[i]; |
track.resx[i]=resx[i]; |
670 |
track.resy[i]=resy[i]; |
track.resy[i]=resy[i]; |
671 |
|
track.tailx[i]=tailx[i]; |
672 |
|
track.taily[i]=taily[i]; |
673 |
} |
} |
674 |
|
|
675 |
for(int i=0; i<5; i++) track.al[i]=al[i]; |
for(int i=0; i<5; i++) track.al[i]=al[i]; |
701 |
|
|
702 |
} |
} |
703 |
/** |
/** |
704 |
* Tracking method. It calls F77 mini routine. |
* \brief Method to re-evaluate coordinates of clusters associated with a track. |
705 |
|
* |
706 |
|
* The method can be applied only after recovering level1 information |
707 |
|
* (either by reprocessing single events from level0 or from |
708 |
|
* the TrkLevel1 branch, if present); it calls F77 subroutines that |
709 |
|
* read the level1 common and fill the minimization-routine common. |
710 |
|
* Some clusters can be excluded or added by means of the methods: |
711 |
|
* |
712 |
|
* TrkTrack::ResetXGood(int ip) |
713 |
|
* TrkTrack::ResetYGood(int ip) |
714 |
|
* TrkTrack::SetXGood(int ip, int cid, int is) |
715 |
|
* TrkTrack::SetYGood(int ip, int cid, int is) |
716 |
|
* |
717 |
|
* NB! The method TrkTrack::SetGood(int *xg, int *yg) set the plane-mask (0-1) |
718 |
|
* for the minimization-routine common. It deletes the cluster information |
719 |
|
* (at least for the moment...) thus cannot be applied before |
720 |
|
* TrkTrack::EvaluateClusterPositions(). |
721 |
|
* |
722 |
|
* Different p.f.a. can be applied by calling (once) the method: |
723 |
|
* |
724 |
|
* TrkParams::SetPFA(0); //Set ETA p.f.a. |
725 |
|
* |
726 |
|
* @see TrkParams::SetPFA(int) |
727 |
|
*/ |
728 |
|
Bool_t TrkTrack::EvaluateClusterPositions(){ |
729 |
|
|
730 |
|
// cout << "void TrkTrack::GetClusterPositions() "<<endl; |
731 |
|
|
732 |
|
TrkParams::Load( ); |
733 |
|
if( !TrkParams::IsLoaded() )return false; |
734 |
|
|
735 |
|
for(int ip=0; ip<6; ip++){ |
736 |
|
// cout << ip<<" ** "<<xm[ip]<<" / "<<ym[ip]<<endl;; |
737 |
|
int icx = GetClusterX_ID(ip)+1; |
738 |
|
int icy = GetClusterY_ID(ip)+1; |
739 |
|
int sensor = GetSensor(ip)+1;//<< convenzione "Paolo" |
740 |
|
if(ip==5 && sensor!=0)sensor=3-sensor;//<< convenzione "Elena" |
741 |
|
int ladder = GetLadder(ip)+1; |
742 |
|
float ax = axv[ip]; |
743 |
|
float ay = ayv[ip]; |
744 |
|
float v[3]; |
745 |
|
v[0]=xv[ip]; |
746 |
|
v[1]=yv[ip]; |
747 |
|
v[2]=zv[ip]; |
748 |
|
float bfx = 10*TrkParams::GetBX(v);//Tesla |
749 |
|
float bfy = 10*TrkParams::GetBY(v);//Tesla |
750 |
|
int ipp=ip+1; |
751 |
|
xyzpam_(&ipp,&icx,&icy,&ladder,&sensor,&ax,&ay,&bfx,&bfy); |
752 |
|
if(icx<0 || icy<0)return false; |
753 |
|
} |
754 |
|
return true; |
755 |
|
} |
756 |
|
/** |
757 |
|
* \brief Tracking method. It calls F77 mini routine. |
758 |
|
* |
759 |
|
* @param pfixed Particle momentum. If pfixed=0 the momentum |
760 |
|
* is left as a free parameter, otherwise it is fixed to the input value. |
761 |
|
* @param fail Output flag (!=0 if the fit failed). |
762 |
|
* @param iprint Flag to set debug mode ( 0 = no output; 1 = verbose; 2 = debug). |
763 |
|
* @param froml1 Flag to re-evaluate positions (see TrkTrack::GetClusterPositions()). |
764 |
|
* |
765 |
|
* The option to re-evaluate positions can be used only after recovering |
766 |
|
* level1 information, eg. by reprocessing the single event. |
767 |
|
* |
768 |
|
* Example: |
769 |
|
* |
770 |
|
* if( !event->GetTrkLevel0() )return false; |
771 |
|
* event->GetTrkLevel0()->ProcessEvent(); // re-processing level0->level1 |
772 |
|
* int fail=0; |
773 |
|
* event->GetTrkLevel2()->GetTrack(0)->Fit(0.,fail,0,1); |
774 |
|
* |
775 |
|
* @see EvaluateClusterPositions() |
776 |
|
* |
777 |
|
* The fitting procedure can be varied by changing the tracking mode, |
778 |
|
* the fit-precision factor, the minimum number of step, etc. |
779 |
|
* @see SetTrackingMode(int) |
780 |
|
* @see SetPrecisionFactor(double) |
781 |
|
* @see SetStepMin(int) |
782 |
|
* @see SetDeltaB(int,double) |
783 |
*/ |
*/ |
784 |
void TrkTrack::Fit(double pfixed, int& fail, int iprint){ |
void TrkTrack::Fit(double pfixed, int& fail, int iprint, int froml1){ |
785 |
|
|
786 |
float al_ini[] = {0.,0.,0.,0.,0.}; |
float al_ini[] = {0.,0.,0.,0.,0.}; |
787 |
|
|
788 |
|
TrkParams::Load( ); |
789 |
|
if( !TrkParams::IsLoaded() )return; |
790 |
|
|
791 |
extern cMini2track track_; |
extern cMini2track track_; |
792 |
fail = 0; |
fail = 0; |
|
FillMiniStruct(track_); |
|
793 |
|
|
794 |
|
FillMiniStruct(track_); |
795 |
|
|
796 |
|
if(froml1!=0){ |
797 |
|
if( !EvaluateClusterPositions() ){ |
798 |
|
cout << "void TrkTrack::Fit("<<pfixed<<","<<fail<<","<<iprint<<","<<froml1<<") --- ERROR evaluating cluster positions "<<endl; |
799 |
|
FillMiniStruct(track_) ; |
800 |
|
fail = 1; |
801 |
|
return; |
802 |
|
} |
803 |
|
}else{ |
804 |
|
FillMiniStruct(track_); |
805 |
|
} |
806 |
|
|
807 |
// if fit variables have been reset, evaluate the initial guess |
// if fit variables have been reset, evaluate the initial guess |
808 |
if(al[0]==-9999.&&al[1]==-9999.&&al[2]==-9999.&&al[3]==-9999.&&al[4]==-9999.)guess_(); |
if(al[0]==-9999.&&al[1]==-9999.&&al[2]==-9999.&&al[3]==-9999.&&al[4]==-9999.)guess_(); |
809 |
|
|
822 |
|
|
823 |
// ------------------------------------------ |
// ------------------------------------------ |
824 |
// call mini routine |
// call mini routine |
825 |
TrkParams::Load(1); |
// TrkParams::Load(1); |
826 |
if( !TrkParams::IsLoaded(1) ){ |
// if( !TrkParams::IsLoaded(1) ){ |
827 |
cout << "void TrkTrack::Fit(double pfixed, int& fail, int iprint) --- ERROR --- m.field not loaded"<<endl; |
// cout << "void TrkTrack::Fit(double pfixed, int& fail, int iprint) --- ERROR --- m.field not loaded"<<endl; |
828 |
return; |
// return; |
829 |
} |
// } |
830 |
int istep=0; |
int istep=0; |
831 |
int ifail=0; |
int ifail=0; |
832 |
mini2_(&istep,&ifail, &iprint); |
mini2_(&istep,&ifail, &iprint); |
837 |
// ------------------------------------------ |
// ------------------------------------------ |
838 |
|
|
839 |
SetFromMiniStruct(&track_); |
SetFromMiniStruct(&track_); |
|
// cout << endl << "eta ===> " << track_.al[4] << endl; |
|
|
|
|
|
// for(int i=0; i<5; i++) al[i]=track_.al[i]; |
|
|
// chi2=track_.chi2; |
|
|
// nstep=track_.nstep; |
|
|
// for(int i=0; i<6; i++) xv[i]=track_.xv[i]; |
|
|
// for(int i=0; i<6; i++) yv[i]=track_.yv[i]; |
|
|
// for(int i=0; i<6; i++) zv[i]=track_.zv[i]; |
|
|
// for(int i=0; i<6; i++) axv[i]=track_.axv[i]; |
|
|
// for(int i=0; i<6; i++) ayv[i]=track_.ayv[i]; |
|
|
// for(int i=0; i<5; i++) { |
|
|
// for(int j=0; j<5; j++) coval[i][j]=track_.cov[i][j]; |
|
|
// } |
|
840 |
|
|
841 |
if(fail){ |
if(fail){ |
842 |
if(iprint)cout << " >>>> fit failed >>>> drawing initial par"<<endl; |
if(iprint)cout << " >>>> fit failed "<<endl; |
843 |
for(int i=0; i<5; i++) al[i]=al_ini[i]; |
for(int i=0; i<5; i++) al[i]=al_ini[i]; |
844 |
} |
} |
845 |
|
|
846 |
}; |
}; |
847 |
/* |
/** |
848 |
* Reset the fit parameters |
* Reset the fit parameters |
849 |
*/ |
*/ |
850 |
void TrkTrack::FitReset(){ |
void TrkTrack::FitReset(){ |
851 |
for(int i=0; i<5; i++) al[i]=-9999.; |
for(int i=0; i<5; i++) al[i]=-9999.; |
852 |
chi2=0.; |
chi2=0.; |
853 |
nstep=0; |
nstep=0; |
854 |
for(int i=0; i<6; i++) xv[i]=0.; |
// for(int i=0; i<6; i++) xv[i]=0.; |
855 |
for(int i=0; i<6; i++) yv[i]=0.; |
// for(int i=0; i<6; i++) yv[i]=0.; |
856 |
for(int i=0; i<6; i++) zv[i]=0.; |
// for(int i=0; i<6; i++) zv[i]=0.; |
857 |
for(int i=0; i<6; i++) axv[i]=0.; |
// for(int i=0; i<6; i++) axv[i]=0.; |
858 |
for(int i=0; i<6; i++) ayv[i]=0.; |
// for(int i=0; i<6; i++) ayv[i]=0.; |
859 |
for(int i=0; i<5; i++) { |
for(int i=0; i<5; i++) { |
860 |
for(int j=0; j<5; j++) coval[i][j]=0.; |
for(int j=0; j<5; j++) coval[i][j]=0.; |
861 |
} |
} |
862 |
} |
} |
863 |
/* |
/** |
864 |
* Set the tracking mode |
* Set the tracking mode |
865 |
*/ |
*/ |
866 |
void TrkTrack::SetTrackingMode(int trackmode){ |
void TrkTrack::SetTrackingMode(int trackmode){ |
867 |
extern cMini2track track_; |
extern cMini2track track_; |
868 |
track_.trackmode = trackmode; |
track_.trackmode = trackmode; |
869 |
} |
} |
870 |
/* |
/** |
871 |
* Set the factor scale for tracking precision |
* Set the factor scale for tracking precision |
872 |
*/ |
*/ |
873 |
void TrkTrack::SetPrecisionFactor(double fact){ |
void TrkTrack::SetPrecisionFactor(double fact){ |
874 |
extern cMini2track track_; |
extern cMini2track track_; |
875 |
track_.fact = fact; |
track_.fact = fact; |
876 |
} |
} |
877 |
/* |
/** |
878 |
* Set the factor scale for tracking precision |
* Set the minimum number of steps for tracking precision |
879 |
*/ |
*/ |
880 |
void TrkTrack::SetStepMin(int istepmin){ |
void TrkTrack::SetStepMin(int istepmin){ |
881 |
extern cMini2track track_; |
extern cMini2track track_; |
882 |
track_.istepmin = istepmin; |
track_.istepmin = istepmin; |
883 |
} |
} |
884 |
|
/** |
885 |
|
* Set deltaB parameters (id=0,1). By default they are set to zero. |
886 |
|
*/ |
887 |
|
void TrkTrack::SetDeltaB(int id, double db){ |
888 |
|
if(id!=0 && id!=1)cout << "void TrkTrack::SetDeltaB(int id,double db) -- wrong input parameters: "<<id<<" "<<db<<endl; |
889 |
|
TrkParams::SetDeltaB(id,db); |
890 |
|
} |
891 |
|
|
892 |
|
/** |
893 |
/* |
* Returns 1 if the track is inside the magnet cavity |
894 |
|
* Set the minimum number of steps for tracking precision |
895 |
|
*/ |
896 |
|
Bool_t TrkTrack::IsInsideCavity(){ |
897 |
|
float xmagntop, ymagntop, xmagnbottom, ymagnbottom; |
898 |
|
xmagntop = xv[0] + (ZMAGNHIGH-zv[0])*tan(cos(-1.0)*axv[0]/180.); |
899 |
|
ymagntop = yv[0] + (ZMAGNHIGH-zv[0])*tan(cos(-1.0)*ayv[0]/180.); |
900 |
|
xmagnbottom = xv[5] + (ZMAGNLOW-zv[5])*tan(cos(-1.0)*axv[5]/180.); |
901 |
|
ymagnbottom = yv[5] + (ZMAGNLOW-zv[5])*tan(cos(-1.0)*ayv[5]/180.); |
902 |
|
if( xmagntop>XMAGNLOW && xmagntop<XMAGNHIGH && |
903 |
|
ymagntop>YMAGNLOW && ymagntop<YMAGNHIGH && |
904 |
|
xmagnbottom>XMAGNLOW && xmagnbottom<XMAGNHIGH && |
905 |
|
ymagnbottom>YMAGNLOW && ymagnbottom<YMAGNHIGH ) return(true); |
906 |
|
else return(false); |
907 |
|
} |
908 |
|
/** |
909 |
* Method to retrieve ID (0,1,...) of x-cluster (if any) associated to this track. |
* Method to retrieve ID (0,1,...) of x-cluster (if any) associated to this track. |
910 |
* If no cluster is associated, ID=-1. |
* If no cluster is associated, ID=-1. |
911 |
* @param ip Tracker plane (0-5) |
* @param ip Tracker plane (0-5) |
913 |
Int_t TrkTrack::GetClusterX_ID(int ip){ |
Int_t TrkTrack::GetClusterX_ID(int ip){ |
914 |
return ((Int_t)fabs(xgood[ip]))%10000000-1; |
return ((Int_t)fabs(xgood[ip]))%10000000-1; |
915 |
}; |
}; |
916 |
/* |
/** |
917 |
* Method to retrieve ID (0-xxx) of y-cluster (if any) associated to this track. |
* Method to retrieve ID (0-xxx) of y-cluster (if any) associated to this track. |
918 |
* If no cluster is associated, ID=-1. |
* If no cluster is associated, ID=-1. |
919 |
* @param ip Tracker plane (0-5) |
* @param ip Tracker plane (0-5) |
921 |
Int_t TrkTrack::GetClusterY_ID(int ip){ |
Int_t TrkTrack::GetClusterY_ID(int ip){ |
922 |
return ((Int_t)fabs(ygood[ip]))%10000000-1; |
return ((Int_t)fabs(ygood[ip]))%10000000-1; |
923 |
}; |
}; |
924 |
/* |
|
925 |
|
/** |
926 |
* Method to retrieve the ladder (0-4, increasing x) traversed by the track on this plane. |
* Method to retrieve the ladder (0-4, increasing x) traversed by the track on this plane. |
927 |
* If no ladder is traversed (dead area) the metod retuns -1. |
* If no ladder is traversed (dead area) the metod retuns -1. |
928 |
* @param ip Tracker plane (0-5) |
* @param ip Tracker plane (0-5) |
932 |
if(YGood(ip))return (Int_t)fabs(ygood[ip]/100000000)-1; |
if(YGood(ip))return (Int_t)fabs(ygood[ip]/100000000)-1; |
933 |
return -1; |
return -1; |
934 |
}; |
}; |
935 |
/* |
/** |
936 |
* Method to retrieve the sensor (0-1, increasing y) traversed by the track on this plane. |
* Method to retrieve the sensor (0-1, increasing y) traversed by the track on this plane. |
937 |
* If no sensor is traversed (dead area) the metod retuns -1. |
* If no sensor is traversed (dead area) the metod retuns -1. |
938 |
* @param ip Tracker plane (0-5) |
* @param ip Tracker plane (0-5) |
943 |
return -1; |
return -1; |
944 |
}; |
}; |
945 |
|
|
946 |
|
/** |
947 |
|
* \brief Method to include a x-cluster to the track. |
948 |
|
* @param ip Tracker plane (0-5) |
949 |
|
* @param clid Cluster ID (0,1,...) |
950 |
|
* @param is Sensor (0-1, increasing y) |
951 |
|
* @see Fit(double pfixed, int& fail, int iprint, int froml1) |
952 |
|
*/ |
953 |
|
void TrkTrack::SetXGood(int ip, int clid, int is){ |
954 |
|
int il=0; //ladder (temporary) |
955 |
|
bool bad=false; //ladder (temporary) |
956 |
|
xgood[ip]=il*100000000+is*10000000+clid; |
957 |
|
if(bad)xgood[ip]=-xgood[ip]; |
958 |
|
}; |
959 |
|
/** |
960 |
|
* \brief Method to include a y-cluster to the track. |
961 |
|
* @param ip Tracker plane (0-5) |
962 |
|
* @param clid Cluster ID (0,1,...) |
963 |
|
* @param is Sensor (0-1) |
964 |
|
* @see Fit(double pfixed, int& fail, int iprint, int froml1) |
965 |
|
*/ |
966 |
|
void TrkTrack::SetYGood(int ip, int clid, int is){ |
967 |
|
int il=0; //ladder (temporary) |
968 |
|
bool bad=false; //ladder (temporary) |
969 |
|
ygood[ip]=il*100000000+is*10000000+clid; |
970 |
|
if(bad)ygood[ip]=-ygood[ip]; |
971 |
|
}; |
972 |
|
|
973 |
//-------------------------------------- |
//-------------------------------------- |
974 |
// |
// |
1105 |
|
|
1106 |
// |
// |
1107 |
cout << endl << endl << "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"; |
cout << endl << endl << "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"; |
1108 |
cout << endl << "good : "; for(int i=0; i<12; i++) cout << good[i]<<" "; |
cout << endl << "good : "; for(int i=0; i<12; i++) cout << hex <<" 0x"<< good[i]<<dec; |
1109 |
cout << endl << "ntrk() : " << this->ntrk() ; |
cout << endl << "ntrk() : " << ntrk() ; |
1110 |
cout << endl << "nclsx() : " << this->nclsx(); |
cout << endl << "nclsx() : " << nclsx(); |
1111 |
cout << endl << "nclsy() : " << this->nclsy(); |
cout << endl << "nclsy() : " << nclsy(); |
1112 |
if(Track){ |
if(Track){ |
1113 |
TClonesArray &t = *Track; |
TClonesArray &t = *Track; |
1114 |
for(int i=0; i<ntrk(); i++) ((TrkTrack *)t[i])->Dump(); |
for(int i=0; i<ntrk(); i++) ((TrkTrack *)t[i])->Dump(); |
1115 |
} |
} |
1116 |
if(SingletX){ |
// if(SingletX){ |
1117 |
TClonesArray &sx = *SingletX; |
// TClonesArray &sx = *SingletX; |
1118 |
for(int i=0; i<nclsx(); i++) ((TrkSinglet *)sx[i])->Dump(); |
// for(int i=0; i<nclsx(); i++) ((TrkSinglet *)sx[i])->Dump(); |
1119 |
} |
// } |
1120 |
if(SingletY){ |
// if(SingletY){ |
1121 |
TClonesArray &sy = *SingletY; |
// TClonesArray &sy = *SingletY; |
1122 |
for(int i=0; i<nclsy(); i++) ((TrkSinglet *)sy[i])->Dump(); |
// for(int i=0; i<nclsy(); i++) ((TrkSinglet *)sy[i])->Dump(); |
1123 |
} |
// } |
1124 |
|
cout << endl; |
1125 |
} |
} |
1126 |
|
/** |
1127 |
|
* \brief Dump processing status |
1128 |
|
*/ |
1129 |
|
void TrkLevel2::StatusDump(int view){ |
1130 |
|
cout << "DSP n. "<<view+1<<" status: "<<hex<<good[view]<<endl; |
1131 |
|
}; |
1132 |
|
/** |
1133 |
|
* \brief Check event status |
1134 |
|
* |
1135 |
|
* Check the event status, according to a flag-mask given as input. |
1136 |
|
* Return true if the view passes the check. |
1137 |
|
* |
1138 |
|
* @param view View number (0-11) |
1139 |
|
* @param flagmask Mask of flags to check (eg. flagmask=0x111 no missing packet, |
1140 |
|
* no crc error, no software alarm) |
1141 |
|
* |
1142 |
|
* @see TrkLevel2 class definition to know how the status flag is defined |
1143 |
|
* |
1144 |
|
*/ |
1145 |
|
Bool_t TrkLevel2::StatusCheck(int view, int flagmask){ |
1146 |
|
|
1147 |
|
if( view<0 || view >= 12)return false; |
1148 |
|
return !(good[view]&flagmask); |
1149 |
|
|
1150 |
|
}; |
1151 |
|
|
1152 |
|
|
1153 |
//-------------------------------------- |
//-------------------------------------- |
1154 |
// |
// |
1155 |
// |
// |
1265 |
t_track->ayv[ip] = l2->ayv_nt[i][ip]; |
t_track->ayv[ip] = l2->ayv_nt[i][ip]; |
1266 |
t_track->dedx_x[ip] = l2->dedx_x[i][ip]; |
t_track->dedx_x[ip] = l2->dedx_x[i][ip]; |
1267 |
t_track->dedx_y[ip] = l2->dedx_y[i][ip]; |
t_track->dedx_y[ip] = l2->dedx_y[i][ip]; |
1268 |
|
t_track->multmaxx[ip] = l2->multmaxx[i][ip]; |
1269 |
|
t_track->multmaxy[ip] = l2->multmaxy[i][ip]; |
1270 |
|
t_track->seedx[ip] = l2->seedx[i][ip]; |
1271 |
|
t_track->seedy[ip] = l2->seedy[i][ip]; |
1272 |
|
t_track->xpu[ip] = l2->xpu[i][ip]; |
1273 |
|
t_track->ypu[ip] = l2->ypu[i][ip]; |
1274 |
//----------------------------------------------------- |
//----------------------------------------------------- |
1275 |
//----------------------------------------------------- |
//----------------------------------------------------- |
1276 |
//----------------------------------------------------- |
//----------------------------------------------------- |
1623 |
// path_.error = 0; |
// path_.error = 0; |
1624 |
// readb_(); |
// readb_(); |
1625 |
|
|
1626 |
|
// TrkParams::SetTrackingMode(); |
1627 |
|
// TrkParams::SetPrecisionFactor(); |
1628 |
|
// TrkParams::SetStepMin(); |
1629 |
|
TrkParams::SetMiniDefault(); |
1630 |
|
|
1631 |
TrkParams::Set(path,1); |
TrkParams::Set(path,1); |
1632 |
TrkParams::Load(1); |
TrkParams::Load(1); |
1633 |
|
|
1634 |
// |
// |
1635 |
}; |
}; |
1636 |
/** |
// /** |
1637 |
* Get BY (kGauss) |
// * Get BY (kGauss) |
1638 |
* @param v (x,y,z) coordinates in cm |
// * @param v (x,y,z) coordinates in cm |
1639 |
*/ |
// */ |
1640 |
float TrkLevel2::GetBX(float* v){ |
// float TrkLevel2::GetBX(float* v){ |
1641 |
float b[3]; |
// float b[3]; |
1642 |
gufld_(v,b); |
// gufld_(v,b); |
1643 |
return b[0]/10.; |
// return b[0]/10.; |
1644 |
} |
// } |
1645 |
/** |
// /** |
1646 |
* Get BY (kGauss) |
// * Get BY (kGauss) |
1647 |
* @param v (x,y,z) coordinates in cm |
// * @param v (x,y,z) coordinates in cm |
1648 |
*/ |
// */ |
1649 |
float TrkLevel2::GetBY(float* v){ |
// float TrkLevel2::GetBY(float* v){ |
1650 |
float b[3]; |
// float b[3]; |
1651 |
gufld_(v,b); |
// gufld_(v,b); |
1652 |
return b[1]/10.; |
// return b[1]/10.; |
1653 |
} |
// } |
1654 |
/** |
// /** |
1655 |
* Get BY (kGauss) |
// * Get BY (kGauss) |
1656 |
* @param v (x,y,z) coordinates in cm |
// * @param v (x,y,z) coordinates in cm |
1657 |
*/ |
// */ |
1658 |
float TrkLevel2::GetBZ(float* v){ |
// float TrkLevel2::GetBZ(float* v){ |
1659 |
float b[3]; |
// float b[3]; |
1660 |
gufld_(v,b); |
// gufld_(v,b); |
1661 |
return b[2]/10.; |
// return b[2]/10.; |
1662 |
} |
// } |
1663 |
//-------------------------------------- |
//-------------------------------------- |
1664 |
// |
// |
1665 |
// |
// |