27 #ifndef KFParticleStandalone
33 #include "TRSymMatrix.h"
41 static Bool_t first = kTRUE;
44 KFParticleBase::Class()->IgnoreTObjectStreamer();
59 std::cout << *
this << std::endl;
60 if (opt && (opt[0] ==
'a' || opt[0] ==
'A')) {
61 TRVector
P(8,
fP); std::cout <<
"par. " <<
P << std::endl;
62 TRSymMatrix
C(8,
fC); std::cout <<
"cov. " <<
C << std::endl;
68 static const Char_t *vn[14] = {
"x",
"y",
"z",
"px",
"py",
"pz",
"E",
"S",
"M",
"t",
"p",
"Q",
"Chi2",
"NDF"};
69 os << Form(
"p(%4i,%4i,%4i)",particle.
Id(),particle.GetParentID(),particle.IdParentMcVx());
70 for (Int_t
i = 0;
i < 8;
i++) {
77 os << Form(
" %s:%8.3f", vn[i], particle.
GetParameter(i));
79 float Mtp[3] = {0.f, 0.f, 0.f}, MtpErr[3] = {0.f, 0.f, 0.f};
80 particle.
GetMass(Mtp[0], MtpErr[0]);
if (MtpErr[0] < 1
e-7 || MtpErr[0] > 1e10) MtpErr[0] = -13;
81 particle.
GetLifeTime(Mtp[1], MtpErr[1]);
if (MtpErr[1] <= 0 || MtpErr[1] > 1e10) MtpErr[1] = -13;
82 particle.
GetMomentum(Mtp[2], MtpErr[2]);
if (MtpErr[2] <= 0 || MtpErr[2] > 1e10) MtpErr[2] = -13;
83 for (Int_t i = 8; i < 11; i++) {
84 if (i == 9 && Mtp[i-8] <= 0.0)
continue;
85 if (MtpErr[i-8] > 0 && MtpErr[i-8] < 9e2) os << Form(
" %s:%8.3f+/-%7.3f", vn[i],Mtp[i-8],MtpErr[i-8]);
86 else os << Form(
" %s:%8.3f", vn[i],Mtp[i-8]);
88 os << Form(
" pdg:%5i Q:%2i chi2/NDF :%8.2f/%2i",particle.
GetPDG(),particle.
GetQ(),particle.
GetChi2(),particle.
GetNDF());
89 if (particle.IdTruth()) os << Form(
" IdT:%4i/%3i",particle.IdTruth(),particle.QaTruth());
92 os <<
" ND: " << nd <<
":";
94 for (
int d = 0; d < nd; d++) {
96 if (d < nd-1) os <<
",";
137 for( Int_t i=0; i<6 ; i++ )
fP[i] = Param[i];
138 for( Int_t i=0; i<21; i++ )
fC[i] = Cov[i];
149 float energyInv = 1./
energy;
151 h0 = fP[3]*energyInv,
152 h1 = fP[4]*energyInv,
153 h2 = fP[5]*energyInv;
155 fC[21] = h0*
fC[ 6] + h1*
fC[10] + h2*
fC[15];
156 fC[22] = h0*fC[ 7] + h1*fC[11] + h2*fC[16];
157 fC[23] = h0*fC[ 8] + h1*fC[12] + h2*fC[17];
158 fC[24] = h0*fC[ 9] + h1*fC[13] + h2*fC[18];
159 fC[25] = h0*fC[13] + h1*fC[14] + h2*fC[19];
160 fC[26] = h0*fC[18] + h1*fC[19] + h2*fC[20];
161 fC[27] = ( h0*h0*fC[ 9] + h1*h1*fC[14] + h2*h2*fC[20]
162 + 2*(h0*h1*fC[13] + h0*h2*fC[18] + h1*h2*fC[19] ) );
163 for( Int_t i=28; i<36; i++ ) fC[i] = 0;
180 for( Int_t i=0; i<8; i++)
fP[i] = 0;
181 for(Int_t i=0;i<36;++
i)
fC[i]=0.;
182 fC[0] =
fC[2] =
fC[5] = 100.;
208 error = (x2*
fC[9]+y2*
fC[14]+z2*
fC[20] + 2*(x*y*
fC[13]+x*z*
fC[18]+y*z*
fC[19]) );
209 if( error>1.
e-16 && p>1.
e-4 ){
210 error = sqrt(error)/
p;
230 error = (px2*
fC[9] + py2*
fC[14] + 2*px*py*
fC[13] );
231 if( error>0 && pt>1.
e-4 ){
232 error = sqrt(error)/
pt;
249 float pt2 = px*px + py*py;
250 float p2 = pt2 + pz*pz;
257 if( c>1.
e-8 ) eta = 0.5*log(c);
262 float p2pt4 = p2*pt4;
263 error = (h3*h3*
fC[9] + h4*h4*
fC[14] + pt4*
fC[20] + 2*( h3*(h4*
fC[13] +
fC[18]*pt2) + pt2*h4*
fC[19] ) );
265 if( error>0 && p2pt4>1.
e-10 ){
266 error = sqrt(error/p2pt4);
285 float pt2 = px2 + py2;
287 error = (py2*
fC[9] + px2*
fC[14] - 2*px*py*
fC[13] );
288 if( error>0 && pt2>1.
e-4 ){
289 error = sqrt(error)/pt2;
308 error = (x2*
fC[0] + y2*
fC[2] - 2*x*y*
fC[1] );
309 if( error>0 && r>1.
e-4 ){
310 error = sqrt(error)/
r;
376 error = p2*
fC[35] + t*t/p2*(x2*
fC[9]+y2*
fC[14]+z2*
fC[20]
377 + 2*(x*y*
fC[13]+x*z*
fC[18]+y*z*
fC[19]) )
378 + 2*t*(x*
fC[31]+y*
fC[32]+z*
fC[33]);
379 error = sqrt(fabs(error));
403 error = pt2*
fC[35] + t*t/pt2*(x2*
fC[9]+y2*
fC[14] + 2*x*y*
fC[13] )
404 + 2*t*(x*
fC[31]+y*
fC[32]);
405 error = sqrt(fabs(error));
426 error = m*m*
fC[35] + 2*
fP[7]*cTM +
fP[7]*
fP[7]*dm*dm;
428 error = sqrt( error );
462 float ds[2] = {0.f,0.f};
464 float F1[36],
F2[36],
F3[36],
F4[36];
465 for(
int i1=0; i1<36; i1++)
474 if( fabs(ds[0]*
fP[5]) > 1000.
f || fabs(ds[1]*daughter.
fP[5]) > 1000.f)
477 float V0Tmp[36] = {0.};
478 float V1Tmp[36] = {0.};
481 for(
int iC=0; iC<36; iC++)
484 Transport(ds[0], dsdr[0], fP,
fC, dsdr[1], F1, F2);
485 daughter.
Transport(ds[1], dsdr[3], m, V, dsdr[2], F4, F3);
490 for(
int iC=0; iC<21; iC++)
497 for(
int i=0; i<6; i++)
498 for(
int j=0;
j<6;
j++)
501 for(
int k=0;
k<6;
k++)
503 C1F1T[
i][
j] += C[
IJ(i,
k)] * F1[
j*6+
k];
507 for(
int i=0; i<6; i++)
508 for(
int j=0;
j<6;
j++)
511 for(
int k=0;
k<6;
k++)
513 F3C1F1T[
i][
j] += F3[i*6+
k] * C1F1T[
k][
j];
517 for(
int i=0; i<6; i++)
518 for(
int j=0;
j<6;
j++)
521 for(
int k=0;
k<6;
k++)
523 C2F2T[
i][
j] += daughter.
fC[
IJ(i,
k)] * F2[
j*6+
k];
526 for(
int i=0; i<3; i++)
527 for(
int j=0;
j<3;
j++)
529 D[
i][
j] = F3C1F1T[
i][
j];
530 for(
int k=0;
k<6;
k++)
532 D[
i][
j] += F4[i*6+
k] * C2F2T[
k][
j];
541 float dsdp[6] = {-dsdr[0], -dsdr[1], -dsdr[2], 0, 0, 0};
544 for(
int i2=0; i2<36; i2++)
549 daughter.
Transport(dS, dsdr, m, V, dsdp, F, F1);
558 for(
int i=0; i<3; i++)
559 for(
int j=0;
j<6;
j++)
562 for(
int k=0;
k<3;
k++)
569 for(
int i=0; i<6; i++)
570 for(
int j=0;
j<6;
j++)
573 for(
int k=0;
k<3;
k++)
575 FVFT[
i][
j] += F1[i*6+
k] * VFT[
k][
j];
579 for(
int i=0; i<3; i++)
580 for(
int j=0;
j<3;
j++)
583 for(
int k=0;
k<3;
k++)
634 for( Int_t i=0; i<7; i++)
fP[i] = Daughter.
fP[i];
635 for( Int_t i=0; i<28; i++)
fC[
i] = Daughter.
fC[
i];
663 for( Int_t iter=0; iter<maxIter; iter++ ){
671 float mS[6]= {
fC[0]+mV[0],
672 fC[1]+mV[1],
fC[2]+mV[2],
673 fC[3]+mV[3],
fC[4]+mV[4],
fC[5]+mV[5] };
679 float zeta[3] = { m[0]-
fP[0], m[1]-fP[1], m[2]-fP[2] };
681 float dChi2 = (mS[0]*zeta[0] + mS[1]*zeta[1] + mS[3]*zeta[2])*zeta[0]
682 + (mS[1]*zeta[0] + mS[2]*zeta[1] + mS[4]*zeta[2])*zeta[1]
683 + (mS[3]*zeta[0] + mS[4]*zeta[1] + mS[5]*zeta[2])*zeta[2];
684 if (dChi2 > 1e9)
return;
688 for(
int i=0; i<3; i++)
689 for(
int j=0;
j<3;
j++)
692 for(
int k=0;
k<3;
k++)
697 float mCHt0[7], mCHt1[7], mCHt2[7];
699 mCHt0[0]=
fC[ 0] ; mCHt1[0]=
fC[ 1] ; mCHt2[0]=
fC[ 3] ;
700 mCHt0[1]=
fC[ 1] ; mCHt1[1]=
fC[ 2] ; mCHt2[1]=
fC[ 4] ;
701 mCHt0[2]=
fC[ 3] ; mCHt1[2]=
fC[ 4] ; mCHt2[2]=
fC[ 5] ;
702 mCHt0[3]=
fC[ 6]-mV[ 6]; mCHt1[3]=
fC[ 7]-mV[ 7]; mCHt2[3]=
fC[ 8]-mV[ 8];
703 mCHt0[4]=
fC[10]-mV[10]; mCHt1[4]=
fC[11]-mV[11]; mCHt2[4]=
fC[12]-mV[12];
704 mCHt0[5]=
fC[15]-mV[15]; mCHt1[5]=
fC[16]-mV[16]; mCHt2[5]=
fC[17]-mV[17];
705 mCHt0[6]=
fC[21]-mV[21]; mCHt1[6]=
fC[22]-mV[22]; mCHt2[6]=
fC[23]-mV[23];
709 float k0[7], k1[7], k2[7];
711 for(Int_t i=0;i<7;++
i){
712 k0[
i] = mCHt0[
i]*mS[0] + mCHt1[
i]*mS[1] + mCHt2[
i]*mS[3];
713 k1[
i] = mCHt0[
i]*mS[1] + mCHt1[
i]*mS[2] + mCHt2[
i]*mS[4];
714 k2[
i] = mCHt0[
i]*mS[3] + mCHt1[
i]*mS[4] + mCHt2[
i]*mS[5];
738 for(Int_t i=0;i<7;++
i)
739 fP[i] =
fP[i] + k0[i]*zeta[0] + k1[i]*zeta[1] + k2[i]*zeta[2];
743 for(Int_t i=0,
k=0;i<7;++
i){
744 for(Int_t
j=0;
j<=
i;++
j,++
k){
745 fC[
k] =
fC[
k] - (k0[
i]*mCHt0[
j] + k1[
i]*mCHt1[
j] + k2[
i]*mCHt2[
j] );
750 for(
int i=0; i<3; i++)
752 for(
int j=0;
j<3;
j++)
758 for(
int i=0; i<3; i++)
759 for(
int j=0;
j<3;
j++)
762 for(
int k=0;
k<3;
k++)
764 A[
i][
j] += D[
i][
k] * K2[
k][
j];
769 for(
int i=0; i<3; i++)
770 for(
int j=0;
j<3;
j++)
773 for(
int k=0;
k<3;
k++)
775 M[
i][
j] += K[
i][
k] * A[
k][
j];
780 fC[1] += M[0][1] + M[1][0];
782 fC[3] += M[0][2] + M[2][0];
783 fC[4] += M[1][2] + M[2][1];
809 float mS[6]= {
fC[0]+mV[0],
810 fC[1]+mV[1],
fC[2]+mV[2],
811 fC[3]+mV[3],
fC[4]+mV[4],
fC[5]+mV[5] };
817 float zeta[3] = { m[0]-
fP[0], m[1]-fP[1], m[2]-fP[2] };
819 float dChi2 = (mS[0]*zeta[0] + mS[1]*zeta[1] + mS[3]*zeta[2])*zeta[0]
820 + (mS[1]*zeta[0] + mS[2]*zeta[1] + mS[4]*zeta[2])*zeta[1]
821 + (mS[3]*zeta[0] + mS[4]*zeta[1] + mS[5]*zeta[2])*zeta[2];
824 for(
int i=0; i<3; i++)
825 for(
int j=0;
j<3;
j++)
828 for(
int k=0;
k<3;
k++)
833 float mCHt0[7], mCHt1[7], mCHt2[7];
835 mCHt0[0]=
fC[ 0] ; mCHt1[0]=
fC[ 1] ; mCHt2[0]=
fC[ 3] ;
836 mCHt0[1]=
fC[ 1] ; mCHt1[1]=
fC[ 2] ; mCHt2[1]=
fC[ 4] ;
837 mCHt0[2]=
fC[ 3] ; mCHt1[2]=
fC[ 4] ; mCHt2[2]=
fC[ 5] ;
838 mCHt0[3]=
fC[ 6]+mV[ 6]; mCHt1[3]=
fC[ 7]+mV[ 7]; mCHt2[3]=
fC[ 8]+mV[ 8];
839 mCHt0[4]=
fC[10]+mV[10]; mCHt1[4]=
fC[11]+mV[11]; mCHt2[4]=
fC[12]+mV[12];
840 mCHt0[5]=
fC[15]+mV[15]; mCHt1[5]=
fC[16]+mV[16]; mCHt2[5]=
fC[17]+mV[17];
841 mCHt0[6]=
fC[21]+mV[21]; mCHt1[6]=
fC[22]+mV[22]; mCHt2[6]=
fC[23]+mV[23];
845 float k0[7], k1[7], k2[7];
847 for(Int_t i=0;i<7;++
i){
848 k0[
i] = mCHt0[
i]*mS[0] + mCHt1[
i]*mS[1] + mCHt2[
i]*mS[3];
849 k1[
i] = mCHt0[
i]*mS[1] + mCHt1[
i]*mS[2] + mCHt2[
i]*mS[4];
850 k2[
i] = mCHt0[
i]*mS[3] + mCHt1[
i]*mS[4] + mCHt2[
i]*mS[5];
874 for(Int_t i=0;i<7;++
i)
875 fP[i] =
fP[i] + k0[i]*zeta[0] + k1[i]*zeta[1] + k2[i]*zeta[2];
879 for(Int_t i=0,
k=0;i<7;++
i){
880 for(Int_t
j=0;
j<=
i;++
j,++
k){
881 fC[
k] =
fC[
k] - (k0[
i]*mCHt0[
j] + k1[
i]*mCHt1[
j] + k2[
i]*mCHt2[
j] );
886 for(
int i=0; i<3; i++)
888 for(
int j=0;
j<3;
j++)
894 for(
int i=0; i<3; i++)
895 for(
int j=0;
j<3;
j++)
898 for(
int k=0;
k<3;
k++)
900 A[
i][
j] += D[
i][
k] * K2[
k][
j];
905 for(
int i=0; i<3; i++)
906 for(
int j=0;
j<3;
j++)
909 for(
int k=0;
k<3;
k++)
911 M[
i][
j] += K[
i][
k] * A[
k][
j];
916 fC[1] += M[0][1] + M[1][0];
918 fC[3] += M[0][2] + M[2][0];
919 fC[4] += M[1][2] + M[2][1];
941 for( Int_t iter=0; iter<maxIter; iter++ ){
948 float mS[6]= {
fC[0]+mV[0],
949 fC[1]+mV[1],
fC[2]+mV[2],
950 fC[3]+mV[3],
fC[4]+mV[4],
fC[5]+mV[5] };
954 float zeta[3] = { m[0]-
fP[0], m[1]-fP[1], m[2]-fP[2] };
957 for(
int i=0; i<3; i++)
958 for(
int j=0;
j<3;
j++)
961 for(
int k=0;
k<3;
k++)
968 float mCHt0[7], mCHt1[7], mCHt2[7];
970 mCHt0[0]=
fC[ 0] ; mCHt1[0]=
fC[ 1] ; mCHt2[0]=
fC[ 3] ;
971 mCHt0[1]=
fC[ 1] ; mCHt1[1]=
fC[ 2] ; mCHt2[1]=
fC[ 4] ;
972 mCHt0[2]=
fC[ 3] ; mCHt1[2]=
fC[ 4] ; mCHt2[2]=
fC[ 5] ;
973 mCHt0[3]=
fC[ 6] ; mCHt1[3]=
fC[ 7] ; mCHt2[3]=
fC[ 8] ;
974 mCHt0[4]=
fC[10] ; mCHt1[4]=
fC[11] ; mCHt2[4]=
fC[12] ;
975 mCHt0[5]=
fC[15] ; mCHt1[5]=
fC[16] ; mCHt2[5]=
fC[17] ;
976 mCHt0[6]=
fC[21] ; mCHt1[6]=
fC[22] ; mCHt2[6]=
fC[23] ;
980 float k0[7], k1[7], k2[7];
982 for(Int_t i=0;i<7;++
i){
983 k0[
i] = mCHt0[
i]*mS[0] + mCHt1[
i]*mS[1] + mCHt2[
i]*mS[3];
984 k1[
i] = mCHt0[
i]*mS[1] + mCHt1[
i]*mS[2] + mCHt2[
i]*mS[4];
985 k2[
i] = mCHt0[
i]*mS[3] + mCHt1[
i]*mS[4] + mCHt2[
i]*mS[5];
992 float mVHt0[7], mVHt1[7], mVHt2[7];
994 mVHt0[0]=mV[ 0] ; mVHt1[0]=mV[ 1] ; mVHt2[0]=mV[ 3] ;
995 mVHt0[1]=mV[ 1] ; mVHt1[1]=mV[ 2] ; mVHt2[1]=mV[ 4] ;
996 mVHt0[2]=mV[ 3] ; mVHt1[2]=mV[ 4] ; mVHt2[2]=mV[ 5] ;
997 mVHt0[3]=mV[ 6] ; mVHt1[3]=mV[ 7] ; mVHt2[3]=mV[ 8] ;
998 mVHt0[4]=mV[10] ; mVHt1[4]=mV[11] ; mVHt2[4]=mV[12] ;
999 mVHt0[5]=mV[15] ; mVHt1[5]=mV[16] ; mVHt2[5]=mV[17] ;
1000 mVHt0[6]=mV[21] ; mVHt1[6]=mV[22] ; mVHt2[6]=mV[23] ;
1004 float km0[7], km1[7], km2[7];
1006 for(Int_t i=0;i<7;++
i){
1007 km0[
i] = mVHt0[
i]*mS[0] + mVHt1[
i]*mS[1] + mVHt2[
i]*mS[3];
1008 km1[
i] = mVHt0[
i]*mS[1] + mVHt1[
i]*mS[2] + mVHt2[
i]*mS[4];
1009 km2[
i] = mVHt0[
i]*mS[3] + mVHt1[
i]*mS[4] + mVHt2[
i]*mS[5];
1012 for(Int_t i=0;i<7;++
i)
1013 fP[i] =
fP[i] + k0[i]*zeta[0] + k1[i]*zeta[1] + k2[i]*zeta[2];
1015 for(Int_t i=0;i<7;++
i)
1016 m[i] = m[i] - km0[i]*zeta[0] - km1[i]*zeta[1] - km2[i]*zeta[2];
1018 for(Int_t i=0,
k=0;i<7;++
i){
1019 for(Int_t
j=0;
j<=
i;++
j,++
k){
1020 fC[
k] =
fC[
k] - (k0[
i]*mCHt0[
j] + k1[
i]*mCHt1[
j] + k2[
i]*mCHt2[
j] );
1024 for(Int_t i=0,
k=0;i<7;++
i){
1025 for(Int_t
j=0;
j<=
i;++
j,++
k){
1026 mV[
k] = mV[
k] - (km0[
i]*mVHt0[
j] + km1[
i]*mVHt1[
j] + km2[
i]*mVHt2[
j] );
1032 for(Int_t i=0;i<7;++
i){
1033 for(Int_t
j=0;
j<7;++
j){
1034 mDf[
i][
j] = (km0[
i]*mCHt0[
j] + km1[
i]*mCHt1[
j] + km2[
i]*mCHt2[
j] );
1038 float mJ1[7][7], mJ2[7][7];
1039 for(Int_t iPar1=0; iPar1<7; iPar1++)
1041 for(Int_t iPar2=0; iPar2<7; iPar2++)
1043 mJ1[iPar1][iPar2] = 0;
1044 mJ2[iPar1][iPar2] = 0;
1048 float mMassParticle =
fP[6]*
fP[6] - (
fP[3]*
fP[3] +
fP[4]*
fP[4] +
fP[5]*
fP[5]);
1049 float mMassDaughter = m[6]*m[6] - (m[3]*m[3] + m[4]*m[4] + m[5]*m[5]);
1050 if(mMassParticle > 0) mMassParticle = sqrt(mMassParticle);
1051 if(mMassDaughter > 0) mMassDaughter = sqrt(mMassDaughter);
1065 for(Int_t i=0; i<7; i++) {
1066 for(Int_t
j=0;
j<7;
j++) {
1068 for(Int_t
k=0;
k<7;
k++) {
1069 mDJ[
i][
j] += mDf[
i][
k]*mJ1[
j][
k];
1074 for(Int_t i=0; i<7; ++
i){
1075 for(Int_t
j=0;
j<7; ++
j){
1077 for(Int_t l=0; l<7; l++){
1078 mDf[
i][
j] += mJ2[
i][l]*mDJ[l][
j];
1101 fC[6 ] += mDf[3][0];
fC[7 ] += mDf[3][1];
fC[8 ] += mDf[3][2];
1102 fC[10] += mDf[4][0];
fC[11] += mDf[4][1];
fC[12] += mDf[4][2];
1103 fC[15] += mDf[5][0];
fC[16] += mDf[5][1];
fC[17] += mDf[5][2];
1104 fC[21] += mDf[6][0];
fC[22] += mDf[6][1];
fC[23] += mDf[6][2];
1106 fC[9 ] += mDf[3][3] + mDf[3][3];
1107 fC[13] += mDf[4][3] + mDf[3][4];
fC[14] += mDf[4][4] + mDf[4][4];
1108 fC[18] += mDf[5][3] + mDf[3][5];
fC[19] += mDf[5][4] + mDf[4][5];
fC[20] += mDf[5][5] + mDf[5][5];
1109 fC[24] += mDf[6][3] + mDf[3][6];
fC[25] += mDf[6][4] + mDf[4][6];
fC[26] += mDf[6][5] + mDf[5][6];
fC[27] += mDf[6][6] + mDf[6][6];
1113 for(
int i=0; i<3; i++)
1115 for(
int j=0;
j<3;
j++)
1116 K2[i][
j] = -K[
j][i];
1121 for(
int i=0; i<3; i++)
1122 for(
int j=0;
j<3;
j++)
1125 for(
int k=0;
k<3;
k++)
1127 A[
i][
j] += D[
i][
k] * K2[
k][
j];
1132 for(
int i=0; i<3; i++)
1133 for(
int j=0;
j<3;
j++)
1136 for(
int k=0;
k<3;
k++)
1138 M[
i][
j] += K[
i][
k] * A[
k][
j];
1143 fC[1] += M[0][1] + M[1][0];
1145 fC[3] += M[0][2] + M[2][0];
1146 fC[4] += M[1][2] + M[2][1];
1154 fChi2 += (mS[0]*zeta[0] + mS[1]*zeta[1] + mS[3]*zeta[2])*zeta[0]
1155 + (mS[1]*zeta[0] + mS[2]*zeta[1] + mS[4]*zeta[2])*zeta[1]
1156 + (mS[3]*zeta[0] + mS[4]*zeta[1] + mS[5]*zeta[2])*zeta[2];
1170 const float *
m = Vtx.
fP, *mV = Vtx.
fC;
1172 float decayPoint[3] = {
fP[0],
fP[1], fP[2]};
1173 float decayPointCov[6] = {
fC[0],
fC[1], fC[2], fC[3], fC[4], fC[5] };
1176 for(
int iD1=0; iD1<6; iD1++)
1177 for(
int iD2=0; iD2<6; iD2++)
1180 Bool_t noS = (
fC[35]<=0 );
1189 float dsdr[6] = {0.f, 0.f, 0.f, 0.f, 0.f, 0.f};
1192 float dsdp[6] = {-dsdr[0], -dsdr[1], -dsdr[2], 0, 0, 0};
1194 float F[36],
F1[36];
1195 for(
int i2=0; i2<36; i2++)
1202 float CTmp[36] = {0.};
1205 for(
int iC=0; iC<6; iC++)
1208 for(
int i=0; i<6; i++)
1209 for(
int j=0;
j<3;
j++)
1212 for(
int k=0;
k<3;
k++)
1214 D[
i][
j] += mV[
IJ(
j,
k)] * F1[i*6+
k];
1219 float mS[6] = {
fC[0] + mV[0],
1220 fC[1] + mV[1],
fC[2] + mV[2],
1221 fC[3] + mV[3],
fC[4] + mV[4],
fC[5] + mV[5] };
1224 float res[3] = { m[0] -
X(), m[1] -
Y(), m[2] -
Z() };
1227 for(
int i=0; i<3; i++)
1228 for(
int j=0;
j<3;
j++)
1231 for(
int k=0;
k<3;
k++)
1235 float mCHt0[7], mCHt1[7], mCHt2[7];
1236 mCHt0[0]=
fC[ 0]; mCHt1[0]=
fC[ 1]; mCHt2[0]=
fC[ 3];
1237 mCHt0[1]=
fC[ 1]; mCHt1[1]=
fC[ 2]; mCHt2[1]=
fC[ 4];
1238 mCHt0[2]=
fC[ 3]; mCHt1[2]=
fC[ 4]; mCHt2[2]=
fC[ 5];
1239 mCHt0[3]=
fC[ 6]; mCHt1[3]=
fC[ 7]; mCHt2[3]=
fC[ 8];
1240 mCHt0[4]=
fC[10]; mCHt1[4]=
fC[11]; mCHt2[4]=
fC[12];
1241 mCHt0[5]=
fC[15]; mCHt1[5]=
fC[16]; mCHt2[5]=
fC[17];
1242 mCHt0[6]=
fC[21]; mCHt1[6]=
fC[22]; mCHt2[6]=
fC[23];
1244 float k0[7], k1[7], k2[7];
1245 for(Int_t i=0;i<7;++
i){
1246 k0[
i] = mCHt0[
i]*mS[0] + mCHt1[
i]*mS[1] + mCHt2[
i]*mS[3];
1247 k1[
i] = mCHt0[
i]*mS[1] + mCHt1[
i]*mS[2] + mCHt2[
i]*mS[4];
1248 k2[
i] = mCHt0[
i]*mS[3] + mCHt1[
i]*mS[4] + mCHt2[
i]*mS[5];
1251 for(Int_t i=0;i<7;++
i)
1252 fP[i] =
fP[i] + k0[i]*res[0] + k1[i]*res[1] + k2[i]*res[2];
1254 for(Int_t i=0,
k=0;i<7;++
i){
1255 for(Int_t
j=0;
j<=
i;++
j,++
k){
1256 fC[
k] =
fC[
k] - (k0[
i]*mCHt0[
j] + k1[
i]*mCHt1[
j] + k2[
i]*mCHt2[
j] );
1261 for(
int i=0; i<3; i++)
1263 for(
int j=0;
j<3;
j++)
1264 K2[i][
j] = -K[
j][i];
1269 for(
int i=0; i<3; i++)
1270 for(
int j=0;
j<3;
j++)
1273 for(
int k=0;
k<3;
k++)
1275 A[
i][
j] += D[
k][
i] * K2[
k][
j];
1280 for(
int i=0; i<3; i++)
1281 for(
int j=0;
j<3;
j++)
1284 for(
int k=0;
k<3;
k++)
1286 M[
i][
j] += K[
i][
k] * A[
k][
j];
1291 fC[1] += M[0][1] + M[1][0];
1293 fC[3] += M[0][2] + M[2][0];
1294 fC[4] += M[1][2] + M[2][1];
1297 fChi2 += (mS[0]*res[0] + mS[1]*res[1] + mS[3]*res[2])*res[0]
1298 + (mS[1]*res[0] + mS[2]*res[1] + mS[4]*res[2])*res[1]
1299 + (mS[3]*res[0] + mS[4]*res[1] + mS[5]*res[2])*res[2];
1309 float dsdr[6] = {0.f, 0.f, 0.f, 0.f, 0.f, 0.f};
1312 float dsdp[6] = {-dsdr[0], -dsdr[1], -dsdr[2], 0, 0, 0};
1314 float F[36],
F1[36];
1315 for(
int i2=0; i2<36; i2++)
1320 float tmpP[8], tmpC[36];
1321 Transport(
fP[7], dsdr, tmpP, tmpC, dsdp, F, F1 );
1324 for(
int iDsDr=0; iDsDr<6; iDsDr++)
1326 float dsdrC = 0, dsdpV = 0;
1328 for(
int k=0;
k<6;
k++)
1329 dsdrC += dsdr[
k] *
fC[
IJ(
k,iDsDr)];
1331 fC[iDsDr+28] = dsdrC;
1332 fC[35] += dsdrC*dsdr[iDsDr] ;
1335 for(
int k=0;
k<3;
k++)
1336 dsdpV -= dsdr[
k] * decayPointCov[
IJ(
k,iDsDr)];
1337 fC[35] -= dsdpV*dsdr[iDsDr];
1357 const float energy2 = mP[6]*mP[6], p2 = mP[3]*mP[3]+mP[4]*mP[4]+mP[5]*mP[5], mass2 = mass*
mass;
1359 const float a = energy2 - p2 + 2.*mass2;
1360 const float b = -2.*(energy2 + p2);
1361 const float c = energy2 - p2 - mass2;
1364 if(fabs(b) > 1.e-10) lambda = -c / b;
1366 float d = 4.*energy2*p2 - mass2*(energy2-p2-2.*mass2);
1367 if(d>=0 && fabs(a) > 1.e-10) lambda = (energy2 + p2 - sqrt(d))/a;
1373 for(iIter=0; iIter<100; iIter++)
1375 float lambda2 = lambda*lambda;
1376 float lambda4 = lambda2*lambda2;
1380 float f = -mass2 * lambda4 + a*lambda2 + b*lambda +
c;
1381 float df = -4.*mass2 * lambda2*lambda + 2.*a*lambda +
b;
1382 if(fabs(df) < 1.e-10)
break;
1384 if(fabs(lambda0 - lambda) < 1.e-8)
break;
1387 const float lpi = 1./(1. + lambda);
1388 const float lmi = 1./(1. - lambda);
1389 const float lp2i = lpi*lpi;
1390 const float lm2i = lmi*lmi;
1392 float lambda2 = lambda*lambda;
1394 float dfl = -4.*mass2 * lambda2*lambda + 2.*a*lambda +
b;
1396 dfx[0] = -2.*(1. + lambda)*(1. + lambda)*mP[3];
1397 dfx[1] = -2.*(1. + lambda)*(1. + lambda)*mP[4];
1398 dfx[2] = -2.*(1. + lambda)*(1. + lambda)*mP[5];
1399 dfx[3] = 2.*(1. - lambda)*(1. - lambda)*mP[6];
1400 float dlx[4] = {1,1,1,1};
1401 if(fabs(dfl) > 1.e-10 )
1403 for(
int i=0; i<4; i++)
1404 dlx[i] = -dfx[i] / dfl;
1407 float dxx[4] = {mP[3]*lm2i, mP[4]*lm2i, mP[5]*lm2i, -mP[6]*lp2i};
1409 for(Int_t i=0; i<7; i++)
1410 for(Int_t
j=0;
j<7;
j++)
1416 for(Int_t i=3; i<7; i++)
1417 for(Int_t
j=3;
j<7;
j++)
1418 mJ[i][
j] = dlx[
j-3]*dxx[i-3];
1420 for(Int_t i=3; i<6; i++)
1426 for(Int_t i=0; i<7; i++) {
1427 for(Int_t
j=0;
j<7;
j++) {
1429 for(Int_t
k=0;
k<7;
k++) {
1430 mCJ[
i][
j] += mC[
IJ(i,
k)]*mJ[
j][
k];
1435 for(Int_t i=0; i<7; ++
i){
1436 for(Int_t
j=0;
j<=
i; ++
j){
1438 for(Int_t l=0; l<7; l++){
1439 mC[
IJ(i,
j)] += mJ[
i][l]*mCJ[l][
j];
1456 const float& px =
fP[3];
1457 const float& py =
fP[4];
1458 const float& pz =
fP[5];
1461 const float residual = (energy*energy - px*px - py*py - pz*pz) - mass*mass;
1462 const float dm2 = float(4.
f) * ( px*px*
fC[9] + py*py*
fC[14] + pz*pz*
fC[20] + energy*energy*
fC[27] +
1463 float(2.
f) * ( px*py*
fC[13] + pz*(px*
fC[18]+py*
fC[19]) - energy*(px*
fC[24]+py*
fC[25]+pz*
fC[26]) ) );
1464 const float dChi2 = residual*residual / dm2;
1485 float m2 = Mass*Mass;
1486 float s2 = m2*SigmaMass*SigmaMass;
1489 float e0 = sqrt(m2+p2);
1492 mH[0] = mH[1] = mH[2] = 0.;
1499 float zeta = e0*e0 - e0*fP[6];
1500 zeta = m2 - (fP[6]*fP[6]-p2);
1502 float mCHt[8], s2_est=0;
1503 for( Int_t i=0; i<8; ++
i ){
1505 for (Int_t
j=0;
j<8;++
j) mCHt[i] +=
Cij(i,
j)*mH[
j];
1506 s2_est += mH[
i]*mCHt[
i];
1509 if( s2_est<1.
e-20 )
return;
1512 float w2 = 1./( s2 + s2_est );
1513 fChi2 += zeta*zeta*w2;
1515 for( Int_t i=0, ii=0; i<8; ++
i ){
1516 float ki = mCHt[
i]*w2;
1518 for(Int_t
j=0;
j<=
i;++
j)
fC[ii++] -= ki*mCHt[
j];
1532 h[0] = h[1] = h[2] = h[3] = h[4] = h[5] = h[6] = 0;
1535 float zeta = 0 -
fP[7];
1536 for(Int_t i=0;i<8;++
i) zeta -= h[i]*(
fP[i]-
fP[i]);
1543 for( Int_t i=0, ii=0; i<7; ++
i ){
1544 float ki =
fC[28+
i]*
s;
1546 for(Int_t
j=0;
j<=
i;++
j)
fC[ii++] -= ki*
fC[28+
j];
1568 const int maxIter = 1;
1569 for( Int_t iter=0; iter<maxIter; iter++ ){
1574 for(Int_t i=0;i<36;++
i)
fC[i]=0.;
1581 for( Int_t itr =0; itr<nDaughters; itr++ ){
1593 float dsdr[6] = {0.f};
1601 float dsdr[6] = {0.f};
1633 if( p2<1.
e-4 ) p2 = 1;
1635 const float&
a = fP[3]*(xyz[0]-fP[0]) + fP[4]*(xyz[1]-fP[1]) + fP[5]*(xyz[2]-fP[2]);
1636 dsdr[0] = -fP[3]/p2;
1637 dsdr[1] = -fP[4]/p2;
1638 dsdr[2] = -fP[5]/p2;
1639 dsdr[3] = ((xyz[0]-fP[0])*p2 - 2.
f* fP[3]*a)/(p2*p2);
1640 dsdr[4] = ((xyz[1]-fP[1])*p2 - 2.
f* fP[4]*a)/(p2*p2);
1641 dsdr[5] = ((xyz[2]-fP[2])*p2 - 2.
f* fP[5]*a)/(p2*p2);
1664 const float&
x = param[0];
1665 const float&
y = param[1];
1666 const float&
z = param[2];
1667 const float& px = param[3];
1668 const float& py = param[4];
1669 const float& pz = param[5];
1671 const float kCLight = 0.000299792458f;
1672 float bq = B*
fQ*kCLight;
1673 float pt2 = px*px + py*py;
1674 float p2 = pt2 + pz*pz;
1676 float dx = xyz[0] -
x;
1677 float dy = xyz[1] -
y;
1678 float dz = xyz[2] -
z;
1679 float a = dx*px+dy*py;
1684 const float LocalSmall = 1.e-8
f;
1685 bool mask = ( fabs(bq)<LocalSmall );
1686 if(mask && p2>1.
e-4
f)
1688 dS = (a + dz*pz)/p2;
1693 dsdr[3] = (dx*p2 - 2.f* px *(a + dz *pz))/(p2*p2);
1694 dsdr[4] = (dy*p2 - 2.f* py *(a + dz *pz))/(p2*p2);
1695 dsdr[5] = (dz*p2 - 2.f* pz *(a + dz *pz))/(p2*p2);
1702 dS = atan2( abq, pt2 + bq*(dy*px -dx*py) )/bq;
1706 float s = sin(bs),
c = cos(bs);
1708 if(fabs(bq) < LocalSmall)
1710 float bbq = bq*(dx*py - dy*px) - pt2;
1712 dsdr[0] = (px*bbq - py*abq)/(abq*abq + bbq*bbq);
1713 dsdr[1] = (px*abq + py*bbq)/(abq*abq + bbq*bbq);
1715 dsdr[3] = -(dx*bbq + dy*abq + 2.f*px*
a)/(abq*abq + bbq*bbq);
1716 dsdr[4] = (dx*abq - dy*bbq - 2.f*py*
a)/(abq*abq + bbq*bbq);
1720 float cCoeff = (bbq*
c - abq*
s) - pz*pz ;
1721 if(fabs(cCoeff) > 1.e-8
f)
1722 sz = (dS*pz - dz)*pz / cCoeff;
1724 float dcdr[6] = {0.f};
1725 dcdr[0] = -bq*py*
c - bbq*s*bq*dsdr[0] + px*bq*s - abq*
c*bq*dsdr[0];
1726 dcdr[1] = bq*px*
c - bbq*s*bq*dsdr[1] + py*bq*s - abq*
c*bq*dsdr[1];
1727 dcdr[3] = (-bq*dy-2*px)*
c - bbq*s*bq*dsdr[3] - dx*bq*s - abq*
c*bq*dsdr[3];
1728 dcdr[4] = ( bq*dx-2*py)*
c - bbq*s*bq*dsdr[4] - dy*bq*s - abq*
c*bq*dsdr[4];
1731 for(
int iP=0; iP<6; iP++)
1732 dsdr[iP] += pz*pz/cCoeff*dsdr[iP] - sz/cCoeff*dcdr[iP];
1733 dsdr[2] += pz/cCoeff;
1734 dsdr[5] += (2.f*pz*dS -
dz)/cCoeff;
1739 s = sin(bs),
c = cos(bs);
1742 const float kOvSqr6 = 1.f/sqrt(
float(6.
f));
1744 if(LocalSmall < fabs(bs))
1751 sB = (1.f-bs*kOvSqr6)*(1.
f+bs*kOvSqr6)*dS;
1756 p[0] = x + sB*px + cB*py;
1757 p[1] = y - cB*px + sB*py;
1760 p[4] = -s*px +
c*py;
1765 a = dx*p[3]+dy*p[4] + dz*pz;
1768 dS += atan2( abq, p2 + bq*(dy*p[3] -dx*p[4]) )/bq;
1788 const float param[6] = {
fP[0], -
fP[2], fP[1], fP[3], -fP[5], fP[4] };
1789 const float point[3] = { xyz[0], -xyz[2], xyz[1] };
1791 float dsdrBz[6] = {0.f};
1794 dsdr[0] = dsdrBz[0];
1795 dsdr[1] = dsdrBz[2];
1796 dsdr[2] = -dsdrBz[1];
1797 dsdr[3] = dsdrBz[3];
1798 dsdr[4] = dsdrBz[5];
1799 dsdr[5] = -dsdrBz[4];
1819 const float& Bx = B[0];
1820 const float& By = B[1];
1821 const float&
Bz = B[2];
1823 const float& Bxz = sqrt(Bx*Bx + Bz*Bz);
1824 const float& Br = sqrt(Bx*Bx + By*By + Bz*Bz);
1828 if(fabs(Bxz) > 1.
e-8
f)
1834 const float& sinP = By/Br;
1835 const float& cosP = Bxz/Br;
1837 const float param[6] = { cosA*
fP[0] - sinA*
fP[2],
1838 -sinA*sinP*fP[0] + cosP*fP[1] - cosA*sinP*fP[2],
1839 cosP*sinA*fP[0] + sinP*fP[1] + cosA*cosP*fP[2],
1840 cosA*fP[3] - sinA*fP[5],
1841 -sinA*sinP*fP[3] + cosP*fP[4] - cosA*sinP*fP[5],
1842 cosP*sinA*fP[3] + sinP*fP[4] + cosA*cosP*fP[5]};
1843 const float point[3] = { cosA*xyz[0] - sinA*xyz[2],
1844 -sinA*sinP*xyz[0] + cosP*xyz[1] - cosA*sinP*xyz[2],
1845 cosP*sinA*xyz[0] + sinP*xyz[1] + cosA*cosP*xyz[2] };
1847 float dsdrBz[6] = {0.f};
1850 dsdr[0] = dsdrBz[0]*cosA - dsdrBz[1]*sinA*sinP + dsdrBz[2]*sinA*cosP;
1851 dsdr[1] = dsdrBz[1]*cosP + dsdrBz[2]*sinP;
1852 dsdr[2] = -dsdrBz[0]*sinA - dsdrBz[1]*cosA*sinP + dsdrBz[2]*cosA*cosP;
1853 dsdr[3] = dsdrBz[3]*cosA - dsdrBz[4]*sinA*sinP + dsdrBz[5]*sinA*cosP;
1854 dsdr[4] = dsdrBz[4]*cosP + dsdrBz[5]*sinP;
1855 dsdr[5] = -dsdrBz[3]*sinA - dsdrBz[4]*cosA*sinP + dsdrBz[5]*cosA*cosP;
1913 const float kOvSqr6 = 1.f/sqrt(
float(6.
f));
1914 const float kCLight = 0.000299792458f;
1918 const float& bq1 = Bz*
fQ*kCLight;
1919 const float& bq2 = Bz*p.
fQ*kCLight;
1921 const bool& isStraight1 = fabs(bq1) < 1.e-8
f;
1922 const bool& isStraight2 = fabs(bq2) < 1.e-8
f;
1924 if( isStraight1 && isStraight2 )
1930 const float& px1 = param1[3];
1931 const float& py1 = param1[4];
1932 const float& pz1 = param1[5];
1934 const float& px2 = param2[3];
1935 const float& py2 = param2[4];
1936 const float& pz2 = param2[5];
1938 const float& pt12 = px1*px1 + py1*py1;
1939 const float& pt22 = px2*px2 + py2*py2;
1941 const float& x01 = param1[0];
1942 const float& y01 = param1[1];
1943 const float& z01 = param1[2];
1945 const float& x02 = param2[0];
1946 const float& y02 = param2[1];
1947 const float& z02 = param2[2];
1949 float dS1[2] = {0.f}, dS2[2]={0.f};
1951 const float& dx0 = (x01 - x02);
1952 const float& dy0 = (y01 - y02);
1953 const float& dr02 = dx0*dx0 + dy0*dy0;
1954 const float& drp1 = dx0*px1 + dy0*py1;
1955 const float& dxyp1 = dx0*py1 - dy0*px1;
1956 const float& drp2 = dx0*px2 + dy0*py2;
1957 const float& dxyp2 = dx0*py2 - dy0*px2;
1958 const float& p1p2 = px1*px2 + py1*py2;
1959 const float& dp1p2 = px1*py2 - px2*py1;
1961 const float& k11 = (bq2*drp1 - dp1p2);
1962 const float& k21 = (bq1*(bq2*dxyp1 - p1p2) + bq2*pt12);
1963 const float& k12 = ((bq1*drp2 - dp1p2));
1964 const float& k22 = (bq2*(bq1*dxyp2 + p1p2) - bq1*pt22);
1966 const float& kp = (dxyp1*bq2 - dxyp2*bq1 - p1p2);
1967 const float& kd = dr02/2.f*bq1*bq2 + kp;
1968 const float& c1 = -(bq1*kd + pt12*bq2);
1969 const float&
c2 = bq2*kd + pt22*bq1;
1971 float d1 = pt12*pt22 - kd*kd;
1975 float d2 = pt12*pt22 - kd*kd;
1988 float dk11dr1[6] = {bq2*px1, bq2*py1, 0, bq2*dx0 - py2, bq2*dy0 + px2, 0};
1989 float dk11dr2[6] = {-bq2*px1, -bq2*py1, 0, py1, -px1, 0};
1990 float dk12dr1[6] = {bq1*px2, bq1*py2, 0, -py2, px2, 0};
1991 float dk12dr2[6] = {-bq1*px2, -bq1*py2, 0, bq1*dx0 + py1, bq1*dy0 - px1, 0};
1992 float dk21dr1[6] = {bq1*bq2*py1, -bq1*bq2*px1, 0, 2*bq2*px1 + bq1*(-(bq2*dy0) - px2), 2*bq2*py1 + bq1*(bq2*dx0 - py2), 0};
1993 float dk21dr2[6] = {-(bq1*bq2*py1), bq1*bq2*px1, 0, -(bq1*px1), -(bq1*py1), 0};
1994 float dk22dr1[6] = {bq1*bq2*py2, -(bq1*bq2*px2), 0, bq2*px2, bq2*py2, 0};
1995 float dk22dr2[6] = {-(bq1*bq2*py2), bq1*bq2*px2, 0, bq2*(-(bq1*dy0) + px1) - 2*bq1*px2, bq2*(bq1*dx0 + py1) - 2*bq1*py2, 0};
1997 float dkddr1[6] = {bq1*bq2*dx0 + bq2*py1 - bq1*py2, bq1*bq2*dy0 - bq2*px1 + bq1*px2, 0, -bq2*dy0 - px2, bq2*dx0 - py2, 0};
1998 float dkddr2[6] = {-bq1*bq2*dx0 - bq2*py1 + bq1*py2, -bq1*bq2*dy0 + bq2*px1 - bq1*px2, 0, bq1*dy0 - px1, -bq1*dx0 - py1, 0};
2000 float dc1dr1[6] = {-(bq1*(bq1*bq2*dx0 + bq2*py1 - bq1*py2)), -(bq1*(bq1*bq2*dy0 - bq2*px1 + bq1*px2)), 0, -2*bq2*px1 - bq1*(-(bq2*dy0) - px2), -2*bq2*py1 - bq1*(bq2*dx0 - py2), 0};
2001 float dc1dr2[6] = {-(bq1*(-(bq1*bq2*dx0) - bq2*py1 + bq1*py2)), -(bq1*(-(bq1*bq2*dy0) + bq2*px1 - bq1*px2)), 0, -(bq1*(bq1*dy0 - px1)), -(bq1*(-(bq1*dx0) - py1)), 0};
2003 float dc2dr1[6] = {bq2*(bq1*bq2*dx0 + bq2*py1 - bq1*py2), bq2*(bq1*bq2*dy0 - bq2*px1 + bq1*px2), 0, bq2*(-(bq2*dy0) - px2), bq2*(bq2*dx0 - py2), 0};
2004 float dc2dr2[6] = {bq2*(-(bq1*bq2*dx0) - bq2*py1 + bq1*py2), bq2*(-(bq1*bq2*dy0) + bq2*px1 - bq1*px2), 0, bq2*(bq1*dy0 - px1) + 2*bq1*px2, bq2*(-(bq1*dx0) - py1) + 2*bq1*py2, 0};
2006 float dd1dr1[6] = {0,0,0,0,0,0};
2007 float dd1dr2[6] = {0,0,0,0,0,0};
2010 for(
int i=0; i<6; i++)
2012 dd1dr1[
i] = -kd/d1*dkddr1[
i];
2013 dd1dr2[
i] = -kd/d1*dkddr2[
i];
2015 dd1dr1[3] += px1/d1*pt22; dd1dr1[4] += py1/d1*pt22;
2016 dd1dr2[3] += px2/d1*pt12; dd1dr2[4] += py2/d1*pt12;
2021 dS1[0] = atan2( bq1*(k11*c1 + k21*d1), (bq1*k11*d1*bq1 - k21*c1) )/bq1;
2022 dS1[1] = atan2( bq1*(k11*c1 - k21*d1), (-bq1*k11*d1*bq1 - k21*c1) )/bq1;
2024 float a = bq1*(k11*c1 + k21*d1);
2025 float b = bq1*k11*d1*bq1 - k21*c1;
2026 for(
int iP=0; iP<6; iP++)
2028 if(( b*b + a*a ) > 0)
2030 const float dadr1 = bq1*( dk11dr1[iP]*c1 + k11*dc1dr1[iP] + dk21dr1[iP]*d1 + k21*dd1dr1[iP] );
2031 const float dadr2 = bq1*( dk11dr2[iP]*c1 + k11*dc1dr2[iP] + dk21dr2[iP]*d1 + k21*dd1dr2[iP] );
2032 const float dbdr1 = bq1*bq1*( dk11dr1[iP]*d1 + k11*dd1dr1[iP] ) - ( dk21dr1[iP]*c1 + k21*dc1dr1[iP] );
2033 const float dbdr2 = bq1*bq1*( dk11dr2[iP]*d1 + k11*dd1dr2[iP] ) - ( dk21dr2[iP]*c1 + k21*dc1dr2[iP] );
2035 dS1dR1[0][iP] = 1/bq1 * 1/( b*b + a*
a ) * ( dadr1*b - dbdr1*a );
2036 dS1dR2[0][iP] = 1/bq1 * 1/( b*b + a*
a ) * ( dadr2*b - dbdr2*a );
2045 a = bq1*(k11*c1 - k21*d1);
2046 b = -bq1*k11*d1*bq1 - k21*c1;
2047 for(
int iP=0; iP<6; iP++)
2049 if(( b*b + a*a ) > 0)
2051 const float dadr1 = bq1*( dk11dr1[iP]*c1 + k11*dc1dr1[iP] - (dk21dr1[iP]*d1 + k21*dd1dr1[iP]) );
2052 const float dadr2 = bq1*( dk11dr2[iP]*c1 + k11*dc1dr2[iP] - (dk21dr2[iP]*d1 + k21*dd1dr2[iP]) );
2053 const float dbdr1 = -bq1*bq1*( dk11dr1[iP]*d1 + k11*dd1dr1[iP] ) - ( dk21dr1[iP]*c1 + k21*dc1dr1[iP] );
2054 const float dbdr2 = -bq1*bq1*( dk11dr2[iP]*d1 + k11*dd1dr2[iP] ) - ( dk21dr2[iP]*c1 + k21*dc1dr2[iP] );
2056 dS1dR1[1][iP] = 1/bq1 * 1/( b*b + a*
a ) * ( dadr1*b - dbdr1*a );
2057 dS1dR2[1][iP] = 1/bq1 * 1/( b*b + a*
a ) * ( dadr2*b - dbdr2*a );
2068 dS2[0] = atan2( (bq2*k12*c2 + k22*d2*bq2), (bq2*k12*d2*bq2 - k22*c2) )/bq2;
2069 dS2[1] = atan2( (bq2*k12*c2 - k22*d2*bq2), (-bq2*k12*d2*bq2 - k22*c2) )/bq2;
2071 float a = bq2*(k12*c2 + k22*d2);
2072 float b = bq2*k12*d2*bq2 - k22*
c2;
2073 for(
int iP=0; iP<6; iP++)
2075 if(( b*b + a*a ) > 0)
2077 const float dadr1 = bq2*( dk12dr1[iP]*c2 + k12*dc2dr1[iP] + dk22dr1[iP]*d1 + k22*dd1dr1[iP] );
2078 const float dadr2 = bq2*( dk12dr2[iP]*c2 + k12*dc2dr2[iP] + dk22dr2[iP]*d1 + k22*dd1dr2[iP] );
2079 const float dbdr1 = bq2*bq2*( dk12dr1[iP]*d1 + k12*dd1dr1[iP] ) - (dk22dr1[iP]*c2 + k22*dc2dr1[iP]);
2080 const float dbdr2 = bq2*bq2*( dk12dr2[iP]*d1 + k12*dd1dr2[iP] ) - (dk22dr2[iP]*c2 + k22*dc2dr2[iP]);
2082 dS2dR1[0][iP] = 1/bq2 * 1/( b*b + a*
a ) * ( dadr1*b - dbdr1*a );
2083 dS2dR2[0][iP] = 1/bq2 * 1/( b*b + a*
a ) * ( dadr2*b - dbdr2*a );
2092 a = bq2*(k12*c2 - k22*d2);
2093 b = -bq2*k12*d2*bq2 - k22*
c2;
2094 for(
int iP=0; iP<6; iP++)
2096 if(( b*b + a*a ) > 0)
2098 const float dadr1 = bq2*( dk12dr1[iP]*c2 + k12*dc2dr1[iP] - (dk22dr1[iP]*d1 + k22*dd1dr1[iP]) );
2099 const float dadr2 = bq2*( dk12dr2[iP]*c2 + k12*dc2dr2[iP] - (dk22dr2[iP]*d1 + k22*dd1dr2[iP]) );
2100 const float dbdr1 = -bq2*bq2*( dk12dr1[iP]*d1 + k12*dd1dr1[iP] ) - (dk22dr1[iP]*c2 + k22*dc2dr1[iP]);
2101 const float dbdr2 = -bq2*bq2*( dk12dr2[iP]*d1 + k12*dd1dr2[iP] ) - (dk22dr2[iP]*c2 + k22*dc2dr2[iP]);
2103 dS2dR1[1][iP] = 1/bq2 * 1/( b*b + a*
a ) * ( dadr1*b - dbdr1*a );
2104 dS2dR2[1][iP] = 1/bq2 * 1/( b*b + a*
a ) * ( dadr2*b - dbdr2*a );
2113 if(isStraight1 && (pt12>0.
f) )
2115 dS1[0] = (k11*c1 + k21*d1)/(- k21*c1);
2116 dS1[1] = (k11*c1 - k21*d1)/(- k21*c1);
2118 float a = k11*c1 + k21*d1;
2121 for(
int iP=0; iP<6; iP++)
2125 const float dadr1 = ( dk11dr1[iP]*c1 + k11*dc1dr1[iP] + dk21dr1[iP]*d1 + k21*dd1dr1[iP] );
2126 const float dadr2 = ( dk11dr2[iP]*c1 + k11*dc1dr2[iP] + dk21dr2[iP]*d1 + k21*dd1dr2[iP] );
2127 const float dbdr1 = -( dk21dr1[iP]*c1 + k21*dc1dr1[iP] );
2128 const float dbdr2 = -( dk21dr2[iP]*c1 + k21*dc1dr2[iP] );
2130 dS1dR1[0][iP] = dadr1/b - dbdr1*a/(b*
b) ;
2131 dS1dR2[0][iP] = dadr2/b - dbdr2*a/(b*
b) ;
2140 a = k11*c1 - k21*d1;
2141 for(
int iP=0; iP<6; iP++)
2145 const float dadr1 = ( dk11dr1[iP]*c1 + k11*dc1dr1[iP] - dk21dr1[iP]*d1 - k21*dd1dr1[iP] );
2146 const float dadr2 = ( dk11dr2[iP]*c1 + k11*dc1dr2[iP] - dk21dr2[iP]*d1 - k21*dd1dr2[iP] );
2147 const float dbdr1 = -( dk21dr1[iP]*c1 + k21*dc1dr1[iP] );
2148 const float dbdr2 = -( dk21dr2[iP]*c1 + k21*dc1dr2[iP] );
2150 dS1dR1[1][iP] = dadr1/b - dbdr1*a/(b*
b) ;
2151 dS1dR2[1][iP] = dadr2/b - dbdr2*a/(b*
b) ;
2160 if(isStraight2 && (pt22>0.
f) )
2162 dS2[0] = (k12*c2 + k22*d2)/(- k22*c2);
2163 dS2[1] = (k12*c2 - k22*d2)/(- k22*c2);
2165 float a = k12*c2 + k22*d1;
2168 for(
int iP=0; iP<6; iP++)
2172 const float dadr1 = ( dk12dr1[iP]*c2 + k12*dc2dr1[iP] + dk22dr1[iP]*d1 + k22*dd1dr1[iP] );
2173 const float dadr2 = ( dk12dr2[iP]*c2 + k12*dc2dr2[iP] + dk22dr2[iP]*d1 + k22*dd1dr2[iP] );
2174 const float dbdr1 = -( dk22dr1[iP]*c2 + k22*dc2dr1[iP] );
2175 const float dbdr2 = -( dk22dr2[iP]*c2 + k22*dc2dr2[iP] );
2177 dS2dR1[0][iP] = dadr1/b - dbdr1*a/(b*
b) ;
2178 dS2dR2[0][iP] = dadr2/b - dbdr2*a/(b*
b) ;
2187 a = k12*c2 - k22*d1;
2188 for(
int iP=0; iP<6; iP++)
2192 const float dadr1 = ( dk12dr1[iP]*c2 + k12*dc2dr1[iP] - dk22dr1[iP]*d1 - k22*dd1dr1[iP] );
2193 const float dadr2 = ( dk12dr2[iP]*c2 + k12*dc2dr2[iP] - dk22dr2[iP]*d1 - k22*dd1dr2[iP] );
2194 const float dbdr1 = -( dk22dr1[iP]*c2 + k22*dc2dr1[iP] );
2195 const float dbdr2 = -( dk22dr2[iP]*c2 + k22*dc2dr2[iP] );
2197 dS2dR1[1][iP] = dadr1/b - dbdr1*a/(b*
b) ;
2198 dS2dR2[1][iP] = dadr2/b - dbdr2*a/(b*
b) ;
2211 for(
int iP = 0; iP<2; iP++)
2213 const float& bs1 = bq1*dS1[iP];
2214 const float& bs2 = bq2*dS2[iP];
2215 float sss = sin(bs1), ccc = cos(bs1);
2217 const bool& bs1Big = fabs(bs1) > 1.e-8
f;
2218 const bool& bs2Big = fabs(bs2) > 1.e-8
f;
2220 float sB(0.
f), cB(0.
f);
2228 sB = ((1.f-bs1*kOvSqr6)*(1.
f+bs1*kOvSqr6)*dS1[iP]);
2232 const float& x1 = param1[0] + sB*px1 + cB*py1;
2233 const float& y1 = param1[1] - cB*px1 + sB*py1;
2234 const float& z1 = param1[2] + dS1[iP]*param1[5];
2236 sss = sin(bs2), ccc = cos(bs2);
2245 sB = ((1.f-bs2*kOvSqr6)*(1.
f+bs2*kOvSqr6)*dS2[iP]);
2249 const float& x2 = param2[0] + sB*px2 + cB*py2;
2250 const float& y2 = param2[1] - cB*px2 + sB*py2;
2251 const float& z2 = param2[2] + dS2[iP]*param2[5];
2257 dr2[iP] = dx*dx + dy*dy + dz*
dz;
2260 const bool isFirstRoot = dr2[0] < dr2[1];
2266 for(
int iP=0; iP<6; iP++)
2268 dsdr[0][iP] = dS1dR1[0][iP];
2269 dsdr[1][iP] = dS1dR2[0][iP];
2270 dsdr[2][iP] = dS2dR1[0][iP];
2271 dsdr[3][iP] = dS2dR2[0][iP];
2279 for(
int iP=0; iP<6; iP++)
2281 dsdr[0][iP] = dS1dR1[1][iP];
2282 dsdr[1][iP] = dS1dR2[1][iP];
2283 dsdr[2][iP] = dS2dR1[1][iP];
2284 dsdr[3][iP] = dS2dR2[1][iP];
2329 const float& bs1 = bq1*dS[0];
2330 const float& bs2 = bq2*dS[1];
2331 float sss = sin(bs1), ccc = cos(bs1);
2333 const bool& bs1Big = fabs(bs1) > 1.e-8
f;
2334 const bool& bs2Big = fabs(bs2) > 1.e-8
f;
2336 float sB(0.
f), cB(0.
f);
2344 sB = ((1.f-bs1*kOvSqr6)*(1.
f+bs1*kOvSqr6)*dS[0]);
2348 const float& x1 = x01 + sB*px1 + cB*py1;
2349 const float& y1 = y01 - cB*px1 + sB*py1;
2350 const float& z1 = z01 + dS[0]*pz1;
2351 const float& ppx1 = ccc*px1 + sss*py1;
2352 const float& ppy1 = -sss*px1 + ccc*py1;
2353 const float& ppz1 = pz1;
2355 float sss1 = sin(bs2), ccc1 = cos(bs2);
2357 float sB1(0.
f), cB1(0.
f);
2361 cB1 = (1.f-ccc1)/bq2;
2365 sB1 = ((1.f-bs2*kOvSqr6)*(1.
f+bs2*kOvSqr6)*dS[1]);
2369 const float& x2 = x02 + sB1*px2 + cB1*py2;
2370 const float& y2 = y02 - cB1*px2 + sB1*py2;
2371 const float& z2 = z02 + dS[1]*pz2;
2372 const float& ppx2 = ccc1*px2 + sss1*py2;
2373 const float& ppy2 = -sss1*px2 + ccc1*py2;
2374 const float& ppz2 = pz2;
2376 const float& p12 = ppx1*ppx1 + ppy1*ppy1 + ppz1*ppz1;
2377 const float& p22 = ppx2*ppx2 + ppy2*ppy2 + ppz2*ppz2;
2378 const float& lp1p2 = ppx1*ppx2 + ppy1*ppy2 + ppz1*ppz2;
2380 const float& dx = (x2 - x1);
2381 const float&
dy = (y2 - y1);
2382 const float&
dz = (z2 - z1);
2384 const float& ldrp1 = ppx1*dx + ppy1*dy + ppz1*
dz;
2385 const float& ldrp2 = ppx2*dx + ppy2*dy + ppz2*
dz;
2387 float detp = lp1p2*lp1p2 - p12*p22;
2388 if( fabs(detp)<1.e-4 ) detp = 1;
2391 const float a1 = ldrp2*lp1p2 - ldrp1*p22;
2392 const float a2 = ldrp2*p12 - ldrp1*lp1p2;
2393 const float lp1p2_ds0 = bq1*( ppx2*ppy1 - ppy2*ppx1);
2394 const float lp1p2_ds1 = bq2*( ppx1*ppy2 - ppy1*ppx2);
2395 const float ldrp1_ds0 = -p12 + bq1*(ppy1*dx - ppx1*
dy);
2396 const float ldrp1_ds1 = lp1p2;
2397 const float ldrp2_ds0 = -lp1p2;
2398 const float ldrp2_ds1 = p22 + bq2*(ppy2*dx - ppx2*
dy);
2399 const float detp_ds0 = 2*lp1p2*lp1p2_ds0;
2400 const float detp_ds1 = 2*lp1p2*lp1p2_ds1;
2401 const float a1_ds0 = ldrp2_ds0*lp1p2 + ldrp2*lp1p2_ds0 - ldrp1_ds0*p22;
2402 const float a1_ds1 = ldrp2_ds1*lp1p2 + ldrp2*lp1p2_ds1 - ldrp1_ds1*p22;
2403 const float a2_ds0 = ldrp2_ds0*p12 - ldrp1_ds0*lp1p2 - ldrp1*lp1p2_ds0;
2404 const float a2_ds1 = ldrp2_ds1*p12 - ldrp1_ds1*lp1p2 - ldrp1*lp1p2_ds1;
2406 const float dsl1ds0 = a1_ds0/detp - a1*detp_ds0/(detp*detp);
2407 const float dsl1ds1 = a1_ds1/detp - a1*detp_ds1/(detp*detp);
2408 const float dsl2ds0 = a2_ds0/detp - a2*detp_ds0/(detp*detp);
2409 const float dsl2ds1 = a2_ds1/detp - a2*detp_ds1/(detp*detp);
2412 for(
int iP=0; iP<6; iP++)
2414 dsldr[0][iP] = dsl1ds0*dsdr[0][iP] + dsl1ds1*dsdr[2][iP];
2415 dsldr[1][iP] = dsl1ds0*dsdr[1][iP] + dsl1ds1*dsdr[3][iP];
2416 dsldr[2][iP] = dsl2ds0*dsdr[0][iP] + dsl2ds1*dsdr[2][iP];
2417 dsldr[3][iP] = dsl2ds0*dsdr[1][iP] + dsl2ds1*dsdr[3][iP];
2420 for(
int iDS=0; iDS<4; iDS++)
2421 for(
int iP=0; iP<6; iP++)
2422 dsdr[iDS][iP] += dsldr[iDS][iP];
2424 const float lp1p2_dr0[6] = {0, 0, 0, ccc*ppx2 - ppy2*sss, ccc*ppy2 + ppx2*sss, pz2};
2425 const float lp1p2_dr1[6] = {0, 0, 0, ccc1*ppx1 - ppy1*sss1, ccc1*ppy1 + ppx1*sss1, pz1};
2426 const float ldrp1_dr0[6] = {-ppx1, -ppy1, -pz1, cB*ppy1 - ppx1*sB + ccc*dx - sss*
dy, -cB*ppx1-ppy1*sB + sss*dx + ccc*
dy, -dS[0]*pz1 + dz};
2427 const float ldrp1_dr1[6] = { ppx1, ppy1, pz1, -cB1*ppy1 + ppx1*sB1, cB1*ppx1 + ppy1*sB1, dS[1]*pz1};
2428 const float ldrp2_dr0[6] = {-ppx2, -ppy2, -pz2, cB*ppy2 - ppx2*sB, -cB*ppx2-ppy2*sB, -dS[0]*pz2};
2429 const float ldrp2_dr1[6] = {ppx2, ppy2, pz2, -cB1*ppy2 + ppx2*sB1 + ccc1*dx- sss1*
dy, cB1*ppx2 + ppy2*sB1 + sss1*dx + ccc1*
dy, dz + dS[1]*pz2};
2430 const float p12_dr0[6] = {0, 0, 0, 2*px1, 2*py1, 2*pz1};
2431 const float p22_dr1[6] = {0, 0, 0, 2*px2, 2*py2, 2*pz2};
2432 float a1_dr0[6], a1_dr1[6], a2_dr0[6], a2_dr1[6], detp_dr0[6], detp_dr1[6];
2433 for(
int iP=0; iP<6; iP++)
2435 a1_dr0[iP] = ldrp2_dr0[iP]*lp1p2 + ldrp2*lp1p2_dr0[iP] - ldrp1_dr0[iP]*p22;
2436 a1_dr1[iP] = ldrp2_dr1[iP]*lp1p2 + ldrp2*lp1p2_dr1[iP] - ldrp1_dr1[iP]*p22 - ldrp1*p22_dr1[iP];
2437 a2_dr0[iP] = ldrp2_dr0[iP]*p12 + ldrp2*p12_dr0[iP] - ldrp1_dr0[iP]*lp1p2 - ldrp1*lp1p2_dr0[iP];
2438 a2_dr1[iP] = ldrp2_dr1[iP]*p12 - ldrp1_dr1[iP]*lp1p2 - ldrp1*lp1p2_dr1[iP];
2439 detp_dr0[iP] = 2*lp1p2*lp1p2_dr0[iP] - p12_dr0[iP]*p22;
2440 detp_dr1[iP] = 2*lp1p2*lp1p2_dr1[iP] - p12*p22_dr1[iP];
2442 dsdr[0][iP] += a1_dr0[iP]/detp - a1*detp_dr0[iP]/(detp*detp);
2443 dsdr[1][iP] += a1_dr1[iP]/detp - a1*detp_dr1[iP]/(detp*detp);
2444 dsdr[2][iP] += a2_dr0[iP]/detp - a2*detp_dr0[iP]/(detp*detp);
2445 dsdr[3][iP] += a2_dr1[iP]/detp - a2*detp_dr1[iP]/(detp*detp);
2448 dS[0] += (ldrp2*lp1p2 - ldrp1*p22) /detp;
2449 dS[1] += (ldrp2*p12 - ldrp1*lp1p2)/detp;
2476 const float param1[6] = {
fP[0], -
fP[2], fP[1], fP[3], -fP[5], fP[4] };
2477 const float param2[6] = { p.
fP[0], -p.
fP[2], p.
fP[1], p.
fP[3], -p.
fP[5], p.
fP[4] };
2480 for(
int i1=0; i1<4; i1++)
2481 for(
int i2=0; i2<6; i2++)
2486 for(
int iDs=0; iDs<4; iDs++)
2488 dsdr[iDs][0] = dsdrBz[iDs][0];
2489 dsdr[iDs][1] = dsdrBz[iDs][2];
2490 dsdr[iDs][2] = -dsdrBz[iDs][1];
2491 dsdr[iDs][3] = dsdrBz[iDs][3];
2492 dsdr[iDs][4] = dsdrBz[iDs][5];
2493 dsdr[iDs][5] = -dsdrBz[iDs][4];
2517 float p22 = p.
fP[3]*p.
fP[3] + p.
fP[4]*p.
fP[4] + p.
fP[5]*p.
fP[5];
2518 float p1p2 = fP[3]*p.
fP[3] + fP[4]*p.
fP[4] + fP[5]*p.
fP[5];
2520 float drp1 = fP[3]*(p.
fP[0]-fP[0]) + fP[4]*(p.
fP[1]-fP[1]) + fP[5]*(p.
fP[2]-fP[2]);
2521 float drp2 = p.
fP[3]*(p.
fP[0]-fP[0]) + p.
fP[4]*(p.
fP[1]-fP[1]) + p.
fP[5]*(p.
fP[2]-fP[2]);
2523 float detp = p1p2*p1p2 - p12*p22;
2524 if( fabs(detp)<1.e-4 ) detp = 1;
2526 dS[0] = (drp2*p1p2 - drp1*p22) /detp;
2527 dS[1] = (drp2*p12 - drp1*p1p2)/detp;
2529 const float x01 = fP[0];
2530 const float y01 = fP[1];
2531 const float z01 = fP[2];
2532 const float px1 = fP[3];
2533 const float py1 = fP[4];
2534 const float pz1 = fP[5];
2536 const float x02 = p.
fP[0];
2537 const float y02 = p.
fP[1];
2538 const float z02 = p.
fP[2];
2539 const float px2 = p.
fP[3];
2540 const float py2 = p.
fP[4];
2541 const float pz2 = p.
fP[5];
2543 const float drp1_dr1[6] = {-px1, -py1, -pz1, -x01 + x02, -y01 + y02, -z01 + z02};
2544 const float drp1_dr2[6] = {px1, py1, pz1, 0, 0, 0};
2545 const float drp2_dr1[6] = {-px2, -py2, -pz2, 0, 0, 0};
2546 const float drp2_dr2[6] = {px2, py2, pz2, -x01 + x02, -y01 + y02, -z01 + z02};
2547 const float dp1p2_dr1[6] = {0, 0, 0, px2, py2, pz2};
2548 const float dp1p2_dr2[6] = {0, 0, 0, px1, py1, pz1};
2549 const float dp12_dr1[6] = {0, 0, 0, 2*px1, 2*py1, 2*pz1};
2550 const float dp12_dr2[6] = {0, 0, 0, 0, 0, 0};
2551 const float dp22_dr1[6] = {0, 0, 0, 0, 0, 0};
2552 const float dp22_dr2[6] = {0, 0, 0, 2*px2, 2*py2, 2*pz2};
2553 const float ddetp_dr1[6] = {0, 0, 0, -2*p22*px1 + 2*p1p2*px2, -2*p22*py1 + 2*p1p2*py2, -2*p22*pz1 + 2*p1p2*pz2};
2554 const float ddetp_dr2[6] = {0, 0, 0, 2*p1p2*px1 - 2*p12*px2, 2*p1p2*py1 - 2*p12*py2, 2*p1p2*pz1 - 2*p12*pz2};
2557 float da1_dr1[6], da1_dr2[6], da2_dr1[6], da2_dr2[6];
2559 const float a1 = drp2*p1p2 - drp1*p22;
2560 const float a2 = drp2*p12 - drp1*p1p2;
2561 for(
int i=0; i<6; i++)
2563 da1_dr1[
i] = drp2_dr1[
i]*p1p2 + drp2*dp1p2_dr1[
i] - drp1_dr1[
i]*p22 - drp1*dp22_dr1[
i];
2564 da1_dr2[
i] = drp2_dr2[
i]*p1p2 + drp2*dp1p2_dr2[
i] - drp1_dr2[
i]*p22 - drp1*dp22_dr2[
i];
2566 da2_dr1[
i] = drp2_dr1[
i]*p12 + drp2*dp12_dr1[
i] - drp1_dr1[
i]*p1p2 - drp1*dp1p2_dr1[
i];
2567 da2_dr2[
i] = drp2_dr2[
i]*p12 + drp2*dp12_dr2[
i] - drp1_dr2[
i]*p1p2 - drp1*dp1p2_dr2[
i];
2569 dsdr[0][
i] = da1_dr1[
i]/detp - a1/(detp*detp)*ddetp_dr1[i];
2570 dsdr[1][
i] = da1_dr2[
i]/detp - a1/(detp*detp)*ddetp_dr2[i];
2572 dsdr[2][
i] = da2_dr1[
i]/detp - a2/(detp*detp)*ddetp_dr1[i];
2573 dsdr[3][
i] = da2_dr2[
i]/detp - a2/(detp*detp)*ddetp_dr2[i];
2603 const float& bq1 = fld[1]*
fQ;
2604 const float& bq2 = fld[1]*p.
fQ;
2605 const bool& isStraight1 = fabs(bq1) < 1.e-8
f;
2606 const bool& isStraight2 = fabs(bq2) < 1.e-8
f;
2608 if( isStraight1 && isStraight2 )
2642 if( fabs(dS*
fP[5]) > 1000.
f ) dS = 0;
2644 const float kCLight = 0.000299792458;
2646 float c =
fQ*kCLight;
2655 float sx=0, sy=0, sz=0, syy=0, syz=0, syyy=0, ssx=0, ssy=0, ssz=0, ssyy=0, ssyz=0, ssyyy=0;
2660 float p0[3], p1[3], p2[3];
2668 p2[0] = fP[0] + px*dS;
2669 p2[1] = fP[1] + py*dS;
2670 p2[2] = fP[2] + pz*dS;
2672 p1[0] = 0.5*(p0[0]+p2[0]);
2673 p1[1] = 0.5*(p0[1]+p2[1]);
2674 p1[2] = 0.5*(p0[2]+p2[2]);
2682 float ssy1 = ( 7*fld[0][1] + 6*fld[1][1]-fld[2][1] )*c*dS*dS/96.;
2683 float ssy2 = ( fld[0][1] + 2*fld[1][1] )*c*dS*dS/6.;
2695 sx = c*( fld[0][0] + 4*fld[1][0] + fld[2][0] )*dS/6.;
2696 sy = c*( fld[0][1] + 4*fld[1][1] + fld[2][1] )*dS/6.;
2697 sz = c*( fld[0][2] + 4*fld[1][2] + fld[2][2] )*dS/6.;
2699 ssx = c*( fld[0][0] + 2*fld[1][0])*dS*dS/6.;
2700 ssy = c*( fld[0][1] + 2*fld[1][1])*dS*dS/6.;
2701 ssz = c*( fld[0][2] + 2*fld[1][2])*dS*dS/6.;
2703 float c2[3][3] = { { 5, -4, -1},{ 44, 80, -4},{ 11, 44, 5} };
2704 float cc2[3][3] = { { 38, 8, -4},{ 148, 208, -20},{ 3, 36, 3} };
2705 for(Int_t
n=0;
n<3;
n++)
2706 for(Int_t
m=0;
m<3;
m++)
2708 syz += c2[
n][
m]*fld[
n][1]*fld[
m][2];
2709 ssyz += cc2[
n][
m]*fld[
n][1]*fld[
m][2];
2712 syz *= c*c*dS*dS/360.;
2713 ssyz *= c*c*dS*dS*dS/2520.;
2715 syy = c*( fld[0][1] + 4*fld[1][1] + fld[2][1] )*dS;
2716 syyy = syy*syy*syy / 1296;
2719 ssyy = ( fld[0][1]*( 38*fld[0][1] + 156*fld[1][1] - fld[2][1] )+
2720 fld[1][1]*( 208*fld[1][1] +16*fld[2][1] )+
2721 fld[2][1]*( 3*fld[2][1] )
2722 )*dS*dS*dS*c*c/2520.;
2725 fld[0][1]*( fld[0][1]*( 85*fld[0][1] + 526*fld[1][1] - 7*fld[2][1] )+
2726 fld[1][1]*( 1376*fld[1][1] +84*fld[2][1] )+
2727 fld[2][1]*( 19*fld[2][1] ) )+
2728 fld[1][1]*( fld[1][1]*( 1376*fld[1][1] +256*fld[2][1] )+
2729 fld[2][1]*( 62*fld[2][1] ) )+
2730 fld[2][1]*fld[2][1] *( 3*fld[2][1] )
2731 )*dS*dS*dS*dS*c*c*c/90720.;
2736 for( Int_t i=0; i<8; i++ )
for( Int_t
j=0;
j<8;
j++) mJ[i][
j]=0;
2738 mJ[0][0]=1; mJ[0][1]=0; mJ[0][2]=0; mJ[0][3]=dS-ssyy; mJ[0][4]=ssx; mJ[0][5]=ssyyy-ssy;
2739 mJ[1][0]=0; mJ[1][1]=1; mJ[1][2]=0; mJ[1][3]=-ssz; mJ[1][4]=dS; mJ[1][5]=ssx+ssyz;
2740 mJ[2][0]=0; mJ[2][1]=0; mJ[2][2]=1; mJ[2][3]=ssy-ssyyy; mJ[2][4]=-ssx; mJ[2][5]=dS-ssyy;
2742 mJ[3][0]=0; mJ[3][1]=0; mJ[3][2]=0; mJ[3][3]=1-syy; mJ[3][4]=sx; mJ[3][5]=syyy-sy;
2743 mJ[4][0]=0; mJ[4][1]=0; mJ[4][2]=0; mJ[4][3]=-sz; mJ[4][4]=1; mJ[4][5]=sx+syz;
2744 mJ[5][0]=0; mJ[5][1]=0; mJ[5][2]=0; mJ[5][3]=sy-syyy; mJ[5][4]=-sx; mJ[5][5]=1-syy;
2745 mJ[6][6] = mJ[7][7] = 1;
2747 P[0] = fP[0] + mJ[0][3]*px + mJ[0][4]*py + mJ[0][5]*pz;
2748 P[1] = fP[1] + mJ[1][3]*px + mJ[1][4]*py + mJ[1][5]*pz;
2749 P[2] = fP[2] + mJ[2][3]*px + mJ[2][4]*py + mJ[2][5]*pz;
2750 P[3] = mJ[3][3]*px + mJ[3][4]*py + mJ[3][5]*pz;
2751 P[4] = mJ[4][3]*px + mJ[4][4]*py + mJ[4][5]*pz;
2752 P[5] = mJ[5][3]*px + mJ[5][4]*py + mJ[5][5]*pz;
2757 for( Int_t i=0; i<6; i++ )
for( Int_t
j=0;
j<6;
j++) mJds[i][
j]=0;
2761 mJds[0][3]= 1 - 3*ssyy/dS; mJds[0][4]= 2*ssx/dS; mJds[0][5]= (4.f*ssyyy-2*ssy)/dS;
2762 mJds[1][3]= -2.f*ssz/dS; mJds[1][4]= 1; mJds[1][5]= (2.f*ssx + 3.*ssyz)/dS;
2763 mJds[2][3]= (2.f*ssy-4.f*ssyyy)/dS; mJds[2][4]=-2*ssx/dS; mJds[2][5]= 1 - 3.f*ssyy/dS;
2765 mJds[3][3]= -2.f*syy/dS; mJds[3][4]= sx/dS; mJds[3][5]= 3.f*syyy/dS - sy/dS;
2766 mJds[4][3]= -sz/dS; mJds[4][4]=0; mJds[4][5] = sx/dS + 2.f*syz/dS;
2767 mJds[5][3]= sy/dS - 3.f*syyy/dS; mJds[5][4]=-sx/dS; mJds[5][5]= -2.f*syy/dS;
2770 for(
int i1=0; i1<6; i1++)
2771 for(
int i2=0; i2<6; i2++)
2772 mJ[i1][i2] += mJds[i1][3]*px*dsdr[i2] + mJds[i1][4]*py*dsdr[i2] + mJds[i1][5]*pz*dsdr[i2];
2778 for(
int i=0; i<6; i++)
2779 for(
int j=0;
j<6;
j++)
2780 F[i*6+
j] = mJ[i][
j];
2782 for(
int i1=0; i1<6; i1++)
2783 for(
int i2=0; i2<6; i2++)
2784 F1[i1*6 + i2] = mJds[i1][3]*px*dsdr1[i2] + mJds[i1][4]*py*dsdr1[i2] + mJds[i1][5]*pz*dsdr1[i2];
2813 const float kCLight = 0.000299792458;
2816 float s = sin(bs),
c = cos(bs);
2818 if( fabs(bs)>1.
e-10){
2822 const float kOvSqr6 = 1./sqrt(6.);
2823 sB = (1.-bs*kOvSqr6)*(1.+bs*kOvSqr6)*dS;
2831 P[0] =
fP[0] + sB*px + cB*py;
2832 P[1] =
fP[1] - cB*px + sB*py;
2833 P[2] =
fP[2] + dS*pz;
2835 P[4] = -s*px +
c*py;
2841 for( Int_t i=0; i<8; i++ )
for( Int_t
j=0;
j<8;
j++) mJ[i][
j]=0;
2843 for(
int i=0; i<8; i++) mJ[i][i]=1;
2844 mJ[0][3] = sB; mJ[0][4] = cB;
2845 mJ[1][3] = -cB; mJ[1][4] = sB;
2847 mJ[3][3] =
c; mJ[3][4] =
s;
2848 mJ[4][3] = -
s; mJ[4][4] =
c;
2852 for( Int_t i=0; i<6; i++ )
for( Int_t
j=0;
j<6;
j++) mJds[i][
j]=0;
2853 mJds[0][3] =
c; mJds[0][4] =
s;
2854 mJds[1][3] = -
s; mJds[1][4] =
c;
2856 mJds[3][3] = -Bz*
s; mJds[3][4] = Bz*
c;
2857 mJds[4][3] = -Bz*
c; mJds[4][4] = -Bz*
s;
2859 for(
int i1=0; i1<6; i1++)
2860 for(
int i2=0; i2<6; i2++)
2861 mJ[i1][i2] += mJds[i1][3]*px*dsdr[i2] + mJds[i1][4]*py*dsdr[i2] + mJds[i1][5]*pz*dsdr[i2];
2867 for(
int i=0; i<6; i++)
2868 for(
int j=0;
j<6;
j++)
2869 F[i*6+
j] = mJ[i][
j];
2871 for(
int i1=0; i1<6; i1++)
2872 for(
int i2=0; i2<6; i2++)
2873 F1[i1*6 + i2] = mJds[i1][3]*px*dsdr1[i2] + mJds[i1][4]*py*dsdr1[i2] + mJds[i1][5]*pz*dsdr1[i2];
2893 float mP[8], mC[36];
2895 float dsdr[6] = {0.f};
2899 float d[3]={ vtx[0]-mP[0], vtx[1]-mP[1], vtx[2]-mP[2]};
2900 return sqrt( d[0]*d[0]+d[1]*d[1]+d[2]*d[2] );
2913 float mP[8], mC[36], mP1[8], mC1[36];
2915 p.
Transport( dS[1], dsdr[3], mP1, mC1 );
2916 float dx = mP[0]-mP1[0];
2917 float dy = mP[1]-mP1[1];
2918 float dz = mP[2]-mP1[2];
2919 return sqrt(dx*dx+dy*dy+dz*dz);
2941 float dsdr[6] = {0.f,0.f,0.f,0.f,0.f,0.f};
2943 float dsdp[6] = {-dsdr[0], -dsdr[1], -dsdr[2], 0, 0, 0};
2944 float F[36],
F1[36];
2945 for(
int i2=0; i2<36; i2++)
2950 Transport( dS, dsdr, mP, mC, dsdp, F, F1 );
2955 for(
int i=0; i<3; i++)
2956 for(
int j=0;
j<6;
j++)
2959 for(
int k=0;
k<3;
k++)
2961 VFT[
i][
j] += Cv[
IJ(i,
k)] * F1[
j*6+
k];
2966 for(
int i=0; i<6; i++)
2967 for(
int j=0;
j<6;
j++)
2970 for(
int k=0;
k<3;
k++)
2972 FVFT[
i][
j] += F1[i*6+
k] * VFT[
k][
j];
2975 mC[0] += FVFT[0][0] + Cv[0];
2976 mC[1] += FVFT[1][0] + Cv[1];
2977 mC[2] += FVFT[1][1] + Cv[2];
2978 mC[3] += FVFT[2][0] + Cv[3];
2979 mC[4] += FVFT[2][1] + Cv[4];
2980 mC[5] += FVFT[2][2] + Cv[5];
2985 float d[3]={ v[0]-mP[0], v[1]-mP[1], v[2]-mP[2]};
2987 return ( ( mC[0]*d[0] + mC[1]*d[1] + mC[3]*d[2])*d[0]
2988 +(mC[1]*d[0] + mC[2]*d[1] + mC[4]*d[2])*d[1]
2989 +(mC[3]*d[0] + mC[4]*d[1] + mC[5]*d[2])*d[2] );
2999 float ds[2] = {0.f,0.f};
3001 float F1[36],
F2[36],
F3[36],
F4[36];
3002 for(
int i1=0; i1<36; i1++)
3011 float V0Tmp[36] = {0.};
3012 float V1Tmp[36] = {0.};
3015 float mP1[8], mC1[36];
3016 float mP2[8], mC2[36];
3018 Transport(ds[0], dsdr[0], mP1, mC1, dsdr[1], F1, F2);
3019 p.
Transport(ds[1], dsdr[3], mP2, mC2, dsdr[2], F4, F3);
3024 for(
int iC=0; iC<6; iC++)
3025 mC1[iC] += V0Tmp[iC] + mC2[iC] + V1Tmp[iC];
3027 float d[3]={ mP2[0]-mP1[0], mP2[1]-mP1[1], mP2[2]-mP1[2]};
3029 return ( ( mC1[0]*d[0] + mC1[1]*d[1] + mC1[3]*d[2])*d[0]
3030 +(mC1[1]*d[0] + mC1[2]*d[1] + mC1[4]*d[2])*d[1]
3031 +(mC1[3]*d[0] + mC1[4]*d[1] + mC1[5]*d[2])*d[2] );
3048 float mS[6] = { mCm[0] - Vtx.
fC[0] + (D[0][0] + D[0][0]),
3049 mCm[1] - Vtx.
fC[1] + (D[1][0] + D[0][1]), mCm[2] - Vtx.
fC[2] + (D[1][1] + D[1][1]),
3050 mCm[3] - Vtx.
fC[3] + (D[2][0] + D[0][2]), mCm[4] - Vtx.
fC[4] + (D[1][2] + D[2][1]), mCm[5] - Vtx.
fC[5] + (D[2][2] + D[2][2]) };
3055 float zeta[3] = { m[0]-Vtx.
fP[0], m[1]-Vtx.
fP[1], m[2]-Vtx.
fP[2] };
3059 float mCHt0[3], mCHt1[3], mCHt2[3];
3061 mCHt0[0]=Vtx.
fC[ 0] ; mCHt1[0]=Vtx.
fC[ 1] ; mCHt2[0]=Vtx.
fC[ 3] ;
3062 mCHt0[1]=Vtx.
fC[ 1] ; mCHt1[1]=Vtx.
fC[ 2] ; mCHt2[1]=Vtx.
fC[ 4] ;
3063 mCHt0[2]=Vtx.
fC[ 3] ; mCHt1[2]=Vtx.
fC[ 4] ; mCHt2[2]=Vtx.
fC[ 5] ;
3067 float k0[3], k1[3], k2[3];
3069 for(Int_t i=0;i<3;++
i){
3070 k0[
i] = mCHt0[
i]*mS[0] + mCHt1[
i]*mS[1] + mCHt2[
i]*mS[3];
3071 k1[
i] = mCHt0[
i]*mS[1] + mCHt1[
i]*mS[2] + mCHt2[
i]*mS[4];
3072 k2[
i] = mCHt0[
i]*mS[3] + mCHt1[
i]*mS[4] + mCHt2[
i]*mS[5];
3077 float dChi2 = ((mS[0]*zeta[0] + mS[1]*zeta[1] + mS[3]*zeta[2])*zeta[0]
3078 + (mS[1]*zeta[0] + mS[2]*zeta[1] + mS[4]*zeta[2])*zeta[1]
3079 + (mS[3]*zeta[0] + mS[4]*zeta[1] + mS[5]*zeta[2])*zeta[2]);
3081 for(Int_t i=0;i<3;++
i)
3082 Vtx.
fP[i] -= k0[i]*zeta[0] + k1[i]*zeta[1] + k2[i]*zeta[2];
3086 for(Int_t i=0,
k=0;i<3;++i){
3087 for(Int_t
j=0;
j<=
i;++
j,++
k)
3088 Vtx.
fC[
k] += k0[i]*mCHt0[
j] + k1[i]*mCHt1[
j] + k2[i]*mCHt2[
j];
3110 float mS[6] = { mV[0] - Vtx.
fC[0] + (D[0][0] + D[0][0]),
3111 mV[1] - Vtx.
fC[1] + (D[1][0] + D[0][1]), mV[2] - Vtx.
fC[2] + (D[1][1] + D[1][1]),
3112 mV[3] - Vtx.
fC[3] + (D[2][0] + D[0][2]), mV[4] - Vtx.
fC[4] + (D[1][2] + D[2][1]), mV[5] - Vtx.
fC[5] + (D[2][2] + D[2][2]) };
3117 float zeta[3] = { m[0]-Vtx.
fP[0], m[1]-Vtx.
fP[1], m[2]-Vtx.
fP[2] };
3121 float mCHt0[7], mCHt1[7], mCHt2[7];
3123 mCHt0[0]=mV[ 0] ; mCHt1[0]=mV[ 1] ; mCHt2[0]=mV[ 3] ;
3124 mCHt0[1]=mV[ 1] ; mCHt1[1]=mV[ 2] ; mCHt2[1]=mV[ 4] ;
3125 mCHt0[2]=mV[ 3] ; mCHt1[2]=mV[ 4] ; mCHt2[2]=mV[ 5] ;
3126 mCHt0[3]=Vtx.
fC[ 6]-mV[ 6]; mCHt1[3]=Vtx.
fC[ 7]-mV[ 7]; mCHt2[3]=Vtx.
fC[ 8]-mV[ 8];
3127 mCHt0[4]=Vtx.
fC[10]-mV[10]; mCHt1[4]=Vtx.
fC[11]-mV[11]; mCHt2[4]=Vtx.
fC[12]-mV[12];
3128 mCHt0[5]=Vtx.
fC[15]-mV[15]; mCHt1[5]=Vtx.
fC[16]-mV[16]; mCHt2[5]=Vtx.
fC[17]-mV[17];
3129 mCHt0[6]=Vtx.
fC[21]-mV[21]; mCHt1[6]=Vtx.
fC[22]-mV[22]; mCHt2[6]=Vtx.
fC[23]-mV[23];
3133 float k0[7], k1[7], k2[7];
3135 for(Int_t i=0;i<7;++
i){
3136 k0[
i] = mCHt0[
i]*mS[0] + mCHt1[
i]*mS[1] + mCHt2[
i]*mS[3];
3137 k1[
i] = mCHt0[
i]*mS[1] + mCHt1[
i]*mS[2] + mCHt2[
i]*mS[4];
3138 k2[
i] = mCHt0[
i]*mS[3] + mCHt1[
i]*mS[4] + mCHt2[
i]*mS[5];
3143 Vtx.
fP[ 3] -= m[ 3];
3144 Vtx.
fP[ 4] -= m[ 4];
3145 Vtx.
fP[ 5] -= m[ 5];
3146 Vtx.
fP[ 6] -= m[ 6];
3148 Vtx.
fC[ 9] -= mV[ 9];
3149 Vtx.
fC[13] -= mV[13];
3150 Vtx.
fC[14] -= mV[14];
3151 Vtx.
fC[18] -= mV[18];
3152 Vtx.
fC[19] -= mV[19];
3153 Vtx.
fC[20] -= mV[20];
3154 Vtx.
fC[24] -= mV[24];
3155 Vtx.
fC[25] -= mV[25];
3156 Vtx.
fC[26] -= mV[26];
3157 Vtx.
fC[27] -= mV[27];
3161 for(Int_t i=0;i<3;++
i)
3162 Vtx.
fP[i] = m[i] - (k0[i]*zeta[0] + k1[i]*zeta[1] + k2[i]*zeta[2]);
3163 for(Int_t i=3;i<7;++
i)
3164 Vtx.
fP[i] = Vtx.
fP[i] - (k0[i]*zeta[0] + k1[i]*zeta[1] + k2[i]*zeta[2]);
3168 float ffC[28] = {-mV[ 0],
3170 -mV[ 3], -mV[ 4], -mV[ 5],
3171 mV[ 6], mV[ 7], mV[ 8], Vtx.
fC[ 9],
3172 mV[10], mV[11], mV[12], Vtx.
fC[13], Vtx.
fC[14],
3173 mV[15], mV[16], mV[17], Vtx.
fC[18], Vtx.
fC[19], Vtx.
fC[20],
3174 mV[21], mV[22], mV[23], Vtx.
fC[24], Vtx.
fC[25], Vtx.
fC[26], Vtx.
fC[27] };
3176 for(Int_t i=0,
k=0;i<7;++
i){
3177 for(Int_t
j=0;
j<=
i;++
j,++
k){
3178 Vtx.
fC[
k] = ffC[
k] + (k0[
i]*mCHt0[
j] + k1[
i]*mCHt1[
j] + k2[
i]*mCHt2[
j] );
3186 Vtx.
fChi2 -= ((mS[0]*zeta[0] + mS[1]*zeta[1] + mS[3]*zeta[2])*zeta[0]
3187 + (mS[1]*zeta[0] + mS[2]*zeta[1] + mS[4]*zeta[2])*zeta[1]
3188 + (mS[3]*zeta[0] + mS[4]*zeta[1] + mS[5]*zeta[2])*zeta[2]);
3215 for( Int_t i=0; i<8; i++ )
for( Int_t
j=0;
j<8;
j++) mJ[i][
j]=0;
3217 mJ[0][0]=1; mJ[0][1]=0; mJ[0][2]=0; mJ[0][3]=dS; mJ[0][4]=0; mJ[0][5]=0;
3218 mJ[1][0]=0; mJ[1][1]=1; mJ[1][2]=0; mJ[1][3]=0; mJ[1][4]=dS; mJ[1][5]=0;
3219 mJ[2][0]=0; mJ[2][1]=0; mJ[2][2]=1; mJ[2][3]=0; mJ[2][4]=0; mJ[2][5]=dS;
3221 mJ[3][0]=0; mJ[3][1]=0; mJ[3][2]=0; mJ[3][3]=1; mJ[3][4]=0; mJ[3][5]=0;
3222 mJ[4][0]=0; mJ[4][1]=0; mJ[4][2]=0; mJ[4][3]=0; mJ[4][4]=1; mJ[4][5]=0;
3223 mJ[5][0]=0; mJ[5][1]=0; mJ[5][2]=0; mJ[5][3]=0; mJ[5][4]=0; mJ[5][5]=1;
3224 mJ[6][6] = mJ[7][7] = 1;
3226 float px =
fP[3], py =
fP[4], pz =
fP[5];
3228 P[0] =
fP[0] + dS*
fP[3];
3229 P[1] = fP[1] + dS*fP[4];
3230 P[2] = fP[2] + dS*fP[5];
3238 for( Int_t i=0; i<6; i++ )
for( Int_t
j=0;
j<6;
j++) mJds[i][
j]=0;
3244 for(
int i1=0; i1<6; i1++)
3245 for(
int i2=0; i2<6; i2++)
3246 mJ[i1][i2] += mJds[i1][3]*px*dsdr[i2] + mJds[i1][4]*py*dsdr[i2] + mJds[i1][5]*pz*dsdr[i2];
3251 for(
int i=0; i<6; i++)
3252 for(
int j=0;
j<6;
j++)
3253 F[i*6+
j] = mJ[i][
j];
3255 for(
int i1=0; i1<6; i1++)
3256 for(
int i2=0; i2<6; i2++)
3257 F1[i1*6 + i2] = mJds[i1][3]*px*dsdr1[i2] + mJds[i1][4]*py*dsdr1[i2] + mJds[i1][5]*pz*dsdr1[i2];
3280 float alpha = 0., qt = 0.;
3281 float spx = positive.
GetPx() + negative.
GetPx();
3282 float spy = positive.
GetPy() + negative.
GetPy();
3283 float spz = positive.
GetPz() + negative.
GetPz();
3284 float sp = sqrt(spx*spx + spy*spy + spz*spz);
3285 if( sp == 0.0)
return;
3290 pln = (negative.
GetPx()*spx+negative.
GetPy()*spy+negative.
GetPz()*spz)/sp;
3291 plp = (positive.
GetPx()*spx+positive.
GetPy()*spy+positive.
GetPz()*spz)/sp;
3293 if( pn == 0.0)
return;
3294 float ptm = (1.-((pln/pn)*(pln/pn)));
3295 qt= (ptm>=0.)? pn*sqrt(ptm) :0;
3296 alpha = (plp-pln)/(plp+pln);
3315 float c = cos(angle);
3316 float s = sin(angle);
3319 for( Int_t i=0; i<8; i++ ){
3320 for( Int_t
j=0;
j<8;
j++){
3324 for(
int i=0; i<8; i++ ){
3327 mA[0][0] =
c; mA[0][1] =
s;
3328 mA[1][0] = -
s; mA[1][1] =
c;
3329 mA[3][3] =
c; mA[3][4] =
s;
3330 mA[4][3] = -
s; mA[4][4] =
c;
3335 for( Int_t i=0; i<8; i++ ){
3337 for( Int_t
k=0;
k<8;
k++){
3338 mAp[
i]+=mA[
i][
k] *
fP[
k];
3342 for( Int_t i=0; i<8; i++){
3346 for( Int_t i=0; i<8; i++ ){
3347 for( Int_t
j=0;
j<8;
j++ ){
3349 for( Int_t
k=0;
k<8;
k++ ){
3355 for( Int_t i=0; i<8; i++ ){
3356 for( Int_t
j=0;
j<=
i;
j++ ){
3358 for( Int_t
k=0;
k<8;
k++){
3359 xx+= mAC[
i][
k]*mA[
j][
k];
3365 X() =
GetX() + Vtx[0];
3366 Y() =
GetY() + Vtx[1];
3367 Z() =
GetZ() + Vtx[2];
3376 float d[3], uud,
u[3][3];
3377 for(
int i=0; i<3; i++)
3380 for(
int j=0;
j<3;
j++)
3384 for(
int i=0; i<3 ; i++)
3387 for(
int j=0;
j<
i;
j++)
3388 uud += u[
j][i]*u[
j][i]*d[
j];
3389 uud = a[i*(i+3)/2] - uud;
3391 if(fabs(uud)<1.e-12
f) uud = 1.
e-12
f;
3393 d[
i] = uud/fabs(uud);
3394 u[
i][
i] = sqrt(fabs(uud));
3396 for(
int j=i+1;
j<3;
j++)
3399 for(
int k=0;
k<
i;
k++)
3400 uud += u[
k][i]*u[
k][
j]*d[
k];
3401 uud = a[
j*(
j+1)/2+i] - uud;
3402 u[
i][
j] = d[
i]/u[
i][
i]*uud;
3408 for(
int i=0; i<3; i++)
3411 u[
i][
i] = 1/u[
i][
i];
3413 for(
int i=0; i<2; i++)
3415 u[
i][i+1] = - u[
i][i+1]*u[
i][
i]*u[i+1][i+1];
3417 for(
int i=0; i<1; i++)
3419 u[
i][i+2] = u[
i][i+1]*u1[i+1]*u[i+1][i+2]-u[
i][i+2]*u[
i][
i]*u[i+2][i+2];
3422 for(
int i=0; i<3; i++)
3423 a[i+3] = u[i][2]*u[2][2]*d[2];
3424 for(
int i=0; i<2; i++)
3425 a[i+1] = u[i][1]*u[1][1]*d[1] + u[i][2]*u[1][2]*d[2];
3426 a[0] = u[0][0]*u[0][0]*d[0] + u[0][1]*u[0][1]*d[1] + u[0][2]*u[0][2]*d[2];
3438 float* mA =
new float[kN*kN];
3440 for( Int_t i=0, ij=0; i<kN; i++ ){
3441 for( Int_t
j=0;
j<kN;
j++, ++ij ){
3443 for( Int_t
k=0;
k<kN; ++
k ) mA[ij]+= S[(
k<=i ) ? i*(i+1)/2+
k :
k*(
k+1)/2+
i] * Q[
j*kN+
k];
3447 for( Int_t i=0; i<kN; i++ ){
3448 for( Int_t
j=0;
j<=
i;
j++ ){
3449 Int_t ij = (
j<=
i ) ? i*(i+1)/2+
j :
j*(
j+1)/2+i;
3451 for( Int_t
k=0;
k<kN;
k++ ) SOut[ij] += Q[ i*kN+
k ] * mA[
k*kN+
j ];
3455 if(mA)
delete [] mA;