20 #ifndef ROOT_Math_GenVector_CylindricalEta3D
21 #define ROOT_Math_GenVector_CylindricalEta3D 1
48 class CylindricalEta3D {
57 CylindricalEta3D() : fRho(0), fEta(0), fPhi(0) { }
62 CylindricalEta3D(Scalar rho, Scalar eta, Scalar phi) :
63 fRho(rho), fEta(eta), fPhi(phi) { Restrict(); }
69 template <
class CoordSystem >
70 explicit CylindricalEta3D(
const CoordSystem & v ) :
71 fRho(v.Rho() ), fEta(v.Eta() ), fPhi(v.Phi() )
73 static Scalar bigEta = Scalar(-0.3) * log(std::numeric_limits<Scalar>::epsilon());
74 if (std::fabs(fEta) > bigEta) {
88 CylindricalEta3D(
const CylindricalEta3D & v) :
89 fRho(v.Rho() ), fEta(v.Eta() ), fPhi(v.Phi() ) { }
94 CylindricalEta3D & operator= (
const CylindricalEta3D & v) {
104 void SetCoordinates(
const Scalar src[] )
105 { fRho=src[0]; fEta=src[1]; fPhi=src[2]; Restrict(); }
110 void GetCoordinates( Scalar dest[] )
const
111 { dest[0] = fRho; dest[1] = fEta; dest[2] = fPhi; }
116 void SetCoordinates(Scalar rho, Scalar eta, Scalar phi)
117 { fRho=rho; fEta=eta; fPhi=phi; Restrict(); }
122 void GetCoordinates(Scalar& rho, Scalar& eta, Scalar& phi)
const
123 {rho=fRho; eta=fEta; phi=fPhi;}
126 inline static Scalar pi() {
return M_PI; }
127 inline void Restrict() {
128 if (fPhi <= -pi() || fPhi > pi()) fPhi = fPhi - floor(fPhi / (2 * pi()) + .5) * 2 * pi();
135 T Rho()
const {
return fRho; }
136 T Eta()
const {
return fEta; }
137 T Phi()
const {
return fPhi; }
138 T X()
const {
return fRho * cos(fPhi); }
139 T Y()
const {
return fRho * sin(fPhi); }
142 return fRho > 0 ? fRho * sinh(fEta) : fEta == 0 ? 0 : fEta > 0 ? fEta - etaMax<T>() : fEta + etaMax<T>();
146 return fRho > 0 ? fRho * cosh(fEta)
147 : fEta > etaMax<T>() ? fEta - etaMax<T>() : fEta < -etaMax<T>() ? -fEta - etaMax<T>() : 0;
151 const Scalar r = R();
154 T Perp2()
const {
return fRho*fRho; }
155 T Theta()
const {
return fRho > 0 ? 2 * atan(exp(-fEta)) : (fEta >= 0 ? 0 : pi()); }
185 void SetXYZ(Scalar x, Scalar y, Scalar z);
200 }
else if ( fEta > etaMax<T>() ) {
201 fEta = ( fEta-etaMax<T>())*a + etaMax<T>();
202 }
else if ( fEta < -etaMax<T>() ) {
203 fEta = ( fEta+etaMax<T>())*a - etaMax<T>();
212 fPhi = ( fPhi > 0 ? fPhi - pi() : fPhi + pi() );
220 template <
class CoordSystem >
221 CylindricalEta3D & operator= (
const CoordSystem & c ) {
233 bool operator==(
const CylindricalEta3D & rhs)
const {
234 return fRho == rhs.fRho && fEta == rhs.fEta && fPhi == rhs.fPhi;
236 bool operator!= (
const CylindricalEta3D & rhs)
const
237 {
return !(operator==(rhs));}
244 T x()
const {
return X();}
245 T y()
const {
return Y();}
246 T z()
const {
return Z(); }
252 #if defined(__MAKECINT__) || defined(G__DICTIONARY)
264 void SetTheta(Scalar theta);
286 #if defined(__MAKECINT__) || defined(G__DICTIONARY)
296 void CylindricalEta3D<T>::SetXYZ(Scalar xx, Scalar yy, Scalar zz) {
297 *
this = Cartesian3D<Scalar>(xx, yy, zz);
300 #if defined(__MAKECINT__) || defined(G__DICTIONARY)
307 void CylindricalEta3D<T>::SetX(Scalar xx) {
308 GenVector_exception e(
"CylindricalEta3D::SetX() is not supposed to be called");
310 Cartesian3D<Scalar> v(*
this); v.SetX(xx);
311 *
this = CylindricalEta3D<Scalar>(v);
314 void CylindricalEta3D<T>::SetY(Scalar yy) {
315 GenVector_exception e(
"CylindricalEta3D::SetY() is not supposed to be called");
317 Cartesian3D<Scalar> v(*
this); v.SetY(yy);
318 *
this = CylindricalEta3D<Scalar>(v);
321 void CylindricalEta3D<T>::SetZ(Scalar zz) {
322 GenVector_exception e(
"CylindricalEta3D::SetZ() is not supposed to be called");
324 Cartesian3D<Scalar> v(*
this); v.SetZ(zz);
325 *
this = CylindricalEta3D<Scalar>(v);
328 void CylindricalEta3D<T>::SetR(Scalar r) {
329 GenVector_exception e(
"CylindricalEta3D::SetR() is not supposed to be called");
331 Polar3D<Scalar> v(*
this); v.SetR(r);
332 *
this = CylindricalEta3D<Scalar>(v);
335 void CylindricalEta3D<T>::SetTheta(Scalar theta) {
336 GenVector_exception e(
"CylindricalEta3D::SetTheta() is not supposed to be called");
338 Polar3D<Scalar> v(*
this); v.SetTheta(theta);
339 *
this = CylindricalEta3D<Scalar>(v);