150 for (Int_t i=0; i<
fNv; i++)
206 for (Int_t i=0; i<
fNv; i++)
251 fV=
new Double32_t[
fNv];
253 Double_t pi=acos(-1.);
254 Double_t twopi=2.*pi;
257 if (u ==
"deg") fu=pi/180.;
260 if (f ==
"car") frame=1;
261 if (f ==
"sph") frame=2;
262 if (f ==
"cyl") frame=3;
264 Double_t x,y,z,r,theta,phi,rho;
279 if (fabs(z/r)<=1) theta=acos(z/r);
281 if (theta<0) theta=fabs(theta);
285 if (x || y) phi=atan2(y,x);
286 if (phi<0) phi+=twopi;
322 if (phi>twopi) phi-=twopi;
351 if (fabs(z/r)<=1) theta=acos(z/r);
353 if (theta<0) theta=fabs(theta);
361 cout <<
"*Nc3Vector::SetVector* Unsupported frame : " << f << endl
362 <<
" Possible frames are 'car', 'sph' and 'cyl'." << endl;
417 Double_t pi=acos(-1.);
420 if (u ==
"deg") fu=180./pi;
423 Double_t theta=
fV[1];
427 if (f ==
"car") frame=1;
428 if (f ==
"sph") frame=2;
429 if (f ==
"cyl") frame=3;
434 v[0]=r*sin(theta)*cos(phi);
435 v[1]=r*sin(theta)*sin(phi);
452 cout <<
"*Nc3Vector::GetVector* Unsupported frame : " << f.Data() << endl
453 <<
" Possible frames are 'car', 'sph' and 'cyl'." << endl;
454 for (Int_t i=0; i<3; i++)
479 for (Int_t i=0; i<3; i++)
503 for (Int_t i=0; i<3; i++)
531 Double_t pi=acos(-1.);
534 if (u ==
"deg") fu=pi/180.;
539 if (f ==
"car") frame=1;
540 if (f ==
"sph") frame=2;
541 if (f ==
"cyl") frame=3;
544 Double_t theta=
fV[1];
551 fV=
new Double32_t[
fNv];
557 Double_t dx2,dy2,dz2;
568 dx2=pow((cos(phi)*sin(theta)*e[0]),2)+pow((r*cos(theta)*cos(phi)*e[1]*fu),2)
569 +pow((r*sin(theta)*sin(phi)*e[2]*fu),2);
570 dy2=pow((sin(phi)*sin(theta)*e[0]),2)+pow((r*cos(theta)*sin(phi)*e[1]*fu),2)
571 +pow((r*sin(theta)*cos(phi)*e[2]*fu),2);
572 dz2=pow((cos(theta)*e[0]),2)+pow((r*sin(theta)*e[1]*fu),2);
580 dx2=pow((cos(phi)*e[0]),2)+pow((rho*sin(phi)*e[1]*fu),2);
581 dy2=pow((sin(phi)*e[0]),2)+pow((rho*cos(phi)*e[1]*fu),2);
588 cout <<
"*Nc3Vector::SetErrors* Unsupported frame : " << f.Data() << endl
589 <<
" Possible frames are 'car', 'sph' and 'cyl'." << endl;
644 Double_t pi=acos(-1.);
647 if (u ==
"deg") fu=180./pi;
650 if (f ==
"car") frame=1;
651 if (f ==
"sph") frame=2;
652 if (f ==
"cyl") frame=3;
655 Double_t theta=
fV[1];
660 Double_t dr2,dtheta2,dphi2,rho,drho2;
674 rxy2=pow(v[0],2)+pow(v[1],2);
675 if (sqrt(rxy2)<(r*1e-10)) rxy2=0;
678 dr2=(pow((v[0]*dx),2)+pow((v[1]*dy),2)+pow((v[2]*dz),2))/(r*r);
686 dtheta2=rxy2*pow(dz,2)/pow(r,4);
689 dtheta2+=rxy2*pow(v[2],2)*(pow((v[0]*dx),2)+pow((v[1]*dy),2)) /
690 pow(((pow(v[2],2)*rxy2)+pow(rxy2,2)),2);
699 dphi2=(pow((v[1]*dx),2)+pow((v[0]*dy),2))/(pow(rxy2,2));
707 if (e[1]>pi) e[1]=pi;
709 if (e[2]>(2.*pi)) e[2]=2.*pi;
716 rho=fabs(r*sin(theta));
717 if (rho<(r*1e-10)) rho=0;
720 drho2=(pow((v[0]*dx),2)+pow((v[1]*dy),2))/(rho*rho);
728 dphi2=(pow((v[1]*dx),2)+pow((v[0]*dy),2))/(pow(rho,4));
736 if (e[1]>(2.*pi)) e[1]=2.*pi;
742 cout <<
"*Nc3Vector::GetErrors* Unsupported frame : " << f.Data() << endl
743 <<
" Possible frames are 'car', 'sph' and 'cyl'." << endl;
744 for (Int_t i=0; i<3; i++)
773 for (Int_t i=0; i<3; i++)
797 for (Int_t i=0; i<3; i++)
825 if ((f==
"car" || f==
"sph" || f==
"cyl") && (u==
"rad" || u==
"deg" || u==
"dms"|| u==
"hms"))
829 cout <<
" 3-Vector not initialised." << endl;
837 printf(
" Vector in %-s coordinates : %.3e %.3e %.3e \n",f.Data(),vec[0],vec[1],vec[2]);
841 printf(
" Vector in %-s coordinates : %.3e ",f.Data(),vec[0]);
842 PrintAngle(vec[1],
"deg",u,3,kTRUE); printf(
" ");
843 PrintAngle(vec[2],
"deg",u,3,kTRUE); printf(
"\n");
847 printf(
" Vector in %-s coordinates : %.3e ",f.Data(),vec[0]);
848 PrintAngle(vec[1],
"deg",u,3,kTRUE); printf(
" ");
849 printf(
" %.3e \n",vec[2]);
858 printf(
" Err. in %-s coordinates : %.3e %.3e %.3e \n",f.Data(),err[0],err[1],err[2]);
862 printf(
" Err. in %-s coordinates : %.3e ",f.Data(),err[0]);
863 PrintAngle(err[1],
"deg",u,3,kTRUE); printf(
" ");
864 PrintAngle(err[2],
"deg",u,3,kTRUE); printf(
"\n");
868 printf(
" Err. in %-s coordinates : %.3e ",f.Data(),err[0]);
869 PrintAngle(err[1],
"deg",u,3,kTRUE); printf(
" ");
870 printf(
" %.3e \n",err[2]);
876 printf(
" *Nc3Vector::Data* Unsupported input frame=%-s format=%-s \n",f.Data(),u.Data());
943 Double_t pi=acos(-1.);
946 Double_t thetahalf=v[1]/2.;
948 if (v[1]<pi) arg=tan(thetahalf);
950 if (arg>0) eta=-log(arg);
957 Double_t prod=cos(thetahalf)*sin(thetahalf);
959 if (prod)
fDresult=fabs(e[1]/2.*prod);
986 Double_t ea[3],eb[3];
993 for (Int_t i=0; i<3; i++)
996 d2+=pow(b[i]*ea[i],2)+pow(a[i]*eb[i],2);
1025 Double_t a[3],b[3],c[3];
1030 c[0]=a[1]*b[2]-a[2]*b[1];
1031 c[1]=a[2]*b[0]-a[0]*b[2];
1032 c[2]=a[0]*b[1]-a[1]*b[0];
1039 Double_t ea[3],eb[3],ec[3],d2;
1043 d2=pow(b[2]*ea[1],2)+pow(a[1]*eb[2],2)
1044 +pow(b[1]*ea[2],2)+pow(a[2]*eb[1],2);
1047 d2=pow(b[0]*ea[2],2)+pow(a[2]*eb[0],2)
1048 +pow(b[2]*ea[0],2)+pow(a[0]*eb[2],2);
1051 d2=pow(b[1]*ea[0],2)+pow(a[0]*eb[1],2)
1052 +pow(b[0]*ea[1],2)+pow(a[1]*eb[0],2);
1075 for (Int_t i=0; i<3; i++)
1085 Double_t ea[3],eb[3];
1089 for (Int_t j=0; j<3; j++)
1091 ea[j]=sqrt(pow(ea[j],2)+pow(eb[j],2));
1114 for (Int_t i=0; i<3; i++)
1124 Double_t ea[3],eb[3];
1128 for (Int_t j=0; j<3; j++)
1130 ea[j]=sqrt(pow(ea[j],2)+pow(eb[j],2));
1151 for (Int_t i=0; i<3; i++)
1164 for (Int_t j=0; j<3; j++)
1186 cout <<
" *Nc3Vector::/* Division by 0 detected. No action taken." << endl;
1194 for (Int_t i=0; i<3; i++)
1207 for (Int_t j=0; j<3; j++)
1228 Double_t a[3],b[3],ea[3],eb[3];
1236 for (Int_t i=0; i<3; i++)
1243 if (nv==6 || q.
fNv==6)
1245 for (Int_t j=0; j<3; j++)
1247 ea[j]=sqrt(pow(ea[j],2)+pow(eb[j],2));
1264 Double_t a[3],b[3],ea[3],eb[3];
1272 for (Int_t i=0; i<3; i++)
1279 if (nv==6 || q.
fNv==6)
1281 for (Int_t j=0; j<3; j++)
1283 ea[j]=sqrt(pow(ea[j],2)+pow(eb[j],2));
1300 Double_t a[3],ea[3];
1306 for (Int_t i=0; i<3; i++)
1315 for (Int_t j=0; j<3; j++)
1336 cout <<
" *Nc3Vector::/=* Division by 0 detected. No action taken." << endl;
1341 Double_t a[3],ea[3];
1347 for (Int_t i=0; i<3; i++)
1356 for (Int_t j=0; j<3; j++)
1376 Double_t pi=acos(-1.);
1377 Double_t a[3],ea[3];
1382 Double_t vt=a[0]*sin(a[1]);
1383 Double_t dvt2=pow((sin(a[1])*ea[0]),2)+pow((a[0]*cos(a[1])*ea[1]),2);
1410 Double_t pi=acos(-1.);
1411 Double_t a[3],ea[3];
1416 Double_t vl=a[0]*cos(a[1]);
1417 Double_t dvl2=pow((cos(a[1])*ea[0]),2)+pow((a[0]*sin(a[1])*ea[1]),2);
1451 Double_t* mat=m->GetMatrix();
1453 Double_t a[3],aprim[3];
1458 aprim[0]=a[0]*mat[0]+a[1]*mat[1]+a[2]*mat[2];
1459 aprim[1]=a[0]*mat[3]+a[1]*mat[4]+a[2]*mat[5];
1460 aprim[2]=a[0]*mat[6]+a[1]*mat[7]+a[2]*mat[8];
1467 aprim[0]=sqrt(pow(a[0]*mat[0],2)+pow(a[1]*mat[1],2)+pow(a[2]*mat[2],2));
1468 aprim[1]=sqrt(pow(a[0]*mat[3],2)+pow(a[1]*mat[4],2)+pow(a[2]*mat[5],2));
1469 aprim[2]=sqrt(pow(a[0]*mat[6],2)+pow(a[1]*mat[7],2)+pow(a[2]*mat[8],2));
1492 Double_t* mat=m->GetMatrix();
1494 Double_t a[3],aprim[3];
1499 a[0]=aprim[0]*mat[0]+aprim[1]*mat[3]+aprim[2]*mat[6];
1500 a[1]=aprim[0]*mat[1]+aprim[1]*mat[4]+aprim[2]*mat[7];
1501 a[2]=aprim[0]*mat[2]+aprim[1]*mat[5]+aprim[2]*mat[8];
1508 a[0]=sqrt(pow(aprim[0]*mat[0],2)+pow(aprim[1]*mat[3],2)+pow(aprim[2]*mat[6],2));
1509 a[1]=sqrt(pow(aprim[0]*mat[1],2)+pow(aprim[1]*mat[4],2)+pow(aprim[2]*mat[7],2));
1510 a[2]=sqrt(pow(aprim[0]*mat[2],2)+pow(aprim[1]*mat[5],2)+pow(aprim[2]*mat[8],2));
1539 if (!
fNv || i<1 || i>3)
return 0;
1598 Double_t x=v1.
Dot(v2);
1604 if (fabs(x)<1.-dx)
fDresult=dx/sqrt(1.-x*x);
1608 Double_t pi=acos(-1.);
1639 if (in==out)
return a;
1642 Double_t pi=acos(-1.);
1643 Double_t epsilon=1.e-12;
1644 Int_t word=0,ddd=0,hh=0,mm=0,ss=0;
1649 if (in==
"rad") b*=180./pi;
1651 if (in==
"hrs") b*=15.;
1660 s=b-Double_t(ddd*10000+mm*100+ss);
1661 b=Double_t(ddd)+Double_t(mm)/60.+(Double_t(ss)+s)/3600.;
1671 s=b-Double_t(hh*10000+mm*100+ss);
1672 b=15.*(Double_t(hh)+Double_t(mm)/60.+(Double_t(ss)+s)/3600.);
1680 if (out==
"rad") b*=pi/180.;
1682 if (out==
"hrs") b/=15.;
1713 b=Double_t(10000*ddd+100*mm+ss)+s;
1746 b=Double_t(10000*hh+100*mm+ss)+s;
1794 if (out==
"deg" || out==
"rad")
1798 printf(
"%*.*f %-s",5+ndig,ndig,b,out.Data());
1802 printf(
"%-.*f %-s",ndig,b,out.Data());
1807 Double_t epsilon=1.e-12;
1808 Int_t word=0,ddd=0,hh=0,mm=0,ss=0;
1819 s=fabs(b)-Double_t(ddd*10000+mm*100+ss);
1843 printf(
"%4dd %02d' %0*.*f\"",ddd,mm,3+ndig,ndig,s);
1847 printf(
"%-dd %-d' %-.*f\"",ddd,mm,ndig,s);
1860 s=fabs(b)-Double_t(hh*10000+mm*100+ss);
1884 printf(
"%3dh %02dm %0*.*fs",hh,mm,3+ndig,ndig,s);
1888 printf(
"%-dh %-dm %-.*fs",hh,mm,ndig,s);
Handling of 3-vectors in various reference frames.
Nc3Vector operator*(Double_t s) const
Double_t GetX(Int_t i, TString f, TString u="rad")
Double32_t fDresult
! Error on scalar result (e.g. norm or dotproduct)
void GetErrors(Double_t *e, TString f, TString u="rad") const
void SetVector(Double_t *v, TString f, TString u="rad")
Nc3Vector & operator*=(Double_t s)
virtual void Load(Nc3Vector &q)
Nc3Vector & operator+=(Nc3Vector &q)
Nc3Vector Cross(Nc3Vector &q) const
virtual void Data(TString f="car", TString u="rad") const
Nc3Vector operator/(Double_t s) const
Nc3Vector & operator/=(Double_t s)
Nc3Vector operator+(Nc3Vector &q) const
Nc3Vector GetVecTrans() const
Nc3Vector operator-(Nc3Vector &q) const
Nc3Vector & operator=(const Nc3Vector &q)
void SetErrors(Double_t *e, TString f, TString u="rad")
virtual Double_t GetOpeningAngle(Nc3Vector &q, TString u="rad")
Double_t Dot(Nc3Vector &q)
Double_t GetPseudoRapidity()
Double_t ConvertAngle(Double_t a, TString in, TString out) const
void PrintAngle(Double_t a, TString in, TString out, Int_t ndig=1, Bool_t align=kFALSE) const
Nc3Vector GetVecLong() const
Double_t GetResultError() const
void GetVector(Double_t *v, TString f, TString u="rad") const
Nc3Vector GetPrimed(TRotMatrix *m) const
Nc3Vector & operator-=(Nc3Vector &q)
Nc3Vector GetUnprimed(TRotMatrix *m) const