16 #ifndef ROOT_Math_GenVector_Cylindrical3D
17 #define ROOT_Math_GenVector_Cylindrical3D 1
49 Cylindrical3D() : fRho(0), fZ(0), fPhi(0) { }
54 Cylindrical3D(Scalar rho, Scalar zz, Scalar phi) :
55 fRho(rho), fZ(zz), fPhi(phi) { Restrict(); }
61 template <
class CoordSystem >
62 explicit Cylindrical3D(
const CoordSystem & v ) :
63 fRho( v.Rho() ), fZ( v.Z() ), fPhi( v.Phi() ) { Restrict(); }
71 Cylindrical3D(
const Cylindrical3D & v) :
72 fRho(v.Rho() ), fZ(v.Z() ), fPhi(v.Phi() ) { }
77 Cylindrical3D & operator= (
const Cylindrical3D & v) {
87 void SetCoordinates(
const Scalar src[] )
88 { fRho=src[0]; fZ=src[1]; fPhi=src[2]; Restrict(); }
93 void GetCoordinates( Scalar dest[] )
const
94 { dest[0] = fRho; dest[1] = fZ; dest[2] = fPhi; }
99 void SetCoordinates(Scalar rho, Scalar zz, Scalar phi)
100 { fRho=rho; fZ=zz; fPhi=phi; Restrict(); }
105 void GetCoordinates(Scalar& rho, Scalar& zz, Scalar& phi)
const
106 {rho=fRho; zz=fZ; phi=fPhi;}
109 inline static Scalar pi() {
return Scalar(M_PI); }
110 inline void Restrict()
112 if (fPhi <= -pi() || fPhi > pi()) fPhi = fPhi - floor(fPhi / (2 * pi()) + .5) * 2 * pi();
118 Scalar Rho()
const {
return fRho; }
119 Scalar Z()
const {
return fZ; }
120 Scalar Phi()
const {
return fPhi; }
122 Scalar X()
const {
return fRho * cos(fPhi); }
123 Scalar Y()
const {
return fRho * sin(fPhi); }
125 Scalar Mag2()
const {
return fRho*fRho + fZ*fZ; }
126 Scalar R()
const {
return sqrt(Mag2()); }
127 Scalar Perp2()
const {
return fRho*fRho; }
128 Scalar Theta()
const {
return (fRho == Scalar(0) && fZ == Scalar(0)) ? Scalar(0) : atan2(fRho, fZ); }
132 return Impl::Eta_FromRhoZ( fRho, fZ);
163 void SetXYZ(Scalar x, Scalar y, Scalar z);
182 fPhi = ( fPhi > 0 ? fPhi - pi() : fPhi + pi() );
190 template <
class CoordSystem >
191 Cylindrical3D & operator= (
const CoordSystem & c ) {
201 bool operator==(
const Cylindrical3D & rhs)
const {
202 return fRho == rhs.fRho && fZ == rhs.fZ && fPhi == rhs.fPhi;
204 bool operator!= (
const Cylindrical3D & rhs)
const
205 {
return !(operator==(rhs));}
212 T x()
const {
return X();}
213 T y()
const {
return Y();}
214 T z()
const {
return Z(); }
220 #if defined(__MAKECINT__) || defined(G__DICTIONARY)
228 void SetEta(Scalar eta);
232 void SetTheta(Scalar theta);
253 #if defined(__MAKECINT__) || defined(G__DICTIONARY)
264 void Cylindrical3D<T>::SetXYZ(Scalar xx, Scalar yy, Scalar zz) {
265 *
this = Cartesian3D<Scalar>(xx, yy, zz);
268 #if defined(__MAKECINT__) || defined(G__DICTIONARY)
276 void Cylindrical3D<T>::SetX(Scalar xx) {
277 GenVector_exception e(
"Cylindrical3D::SetX() is not supposed to be called");
279 Cartesian3D<Scalar> v(*
this); v.SetX(xx); *
this = Cylindrical3D<Scalar>(v);
282 void Cylindrical3D<T>::SetY(Scalar yy) {
283 GenVector_exception e(
"Cylindrical3D::SetY() is not supposed to be called");
285 Cartesian3D<Scalar> v(*
this); v.SetY(yy); *
this = Cylindrical3D<Scalar>(v);
288 void Cylindrical3D<T>::SetR(Scalar r) {
289 GenVector_exception e(
"Cylindrical3D::SetR() is not supposed to be called");
291 Polar3D<Scalar> v(*
this); v.SetR(r);
292 *
this = Cylindrical3D<Scalar>(v);
295 void Cylindrical3D<T>::SetTheta(Scalar theta) {
296 GenVector_exception e(
"Cylindrical3D::SetTheta() is not supposed to be called");
298 Polar3D<Scalar> v(*
this); v.SetTheta(theta);
299 *
this = Cylindrical3D<Scalar>(v);
302 void Cylindrical3D<T>::SetEta(Scalar eta) {
303 GenVector_exception e(
"Cylindrical3D::SetEta() is not supposed to be called");
305 CylindricalEta3D<Scalar> v(*
this); v.SetEta(eta);
306 *
this = Cylindrical3D<Scalar>(v);