#ifndef ROOT_Math_GenVector_PositionVector3D
#define ROOT_Math_GenVector_PositionVector3D 1
#include "Math/GenVector/DisplacementVector3D.h"
#include "Math/GenVector/GenVectorIO.h"
#include "Math/GenVector/CoordinateSystemTags.h"
#include <cassert>
namespace ROOT {
namespace Math {
template <class CoordSystem, class Tag = DefaultCoordinateSystemTag >
class PositionVector3D {
public:
typedef typename CoordSystem::Scalar Scalar;
typedef CoordSystem CoordinateType;
typedef Tag CoordinateSystemTag;
PositionVector3D() : fCoordinates() { }
PositionVector3D(const Scalar & a, const Scalar & b, const Scalar & c) :
fCoordinates ( a , b, c) { }
template <class T>
explicit PositionVector3D( const PositionVector3D<T,Tag> & v) :
fCoordinates ( v.Coordinates() ) { }
template <class T>
explicit PositionVector3D( const DisplacementVector3D<T,Tag> & p) :
fCoordinates ( p.Coordinates() ) { }
template <class ForeignVector>
explicit PositionVector3D( const ForeignVector & v) :
fCoordinates ( Cartesian3D<Scalar>( v.x(), v.y(), v.z() ) ) { }
#ifdef LATER
template <class LAVector>
PositionVector3D(const LAVector & v, size_t index0 ) {
fCoordinates = CoordSystem ( v[index0], v[index0+1], v[index0+2] );
}
#endif
template <class OtherCoords>
PositionVector3D & operator=
( const PositionVector3D<OtherCoords,Tag> & v) {
fCoordinates = v.Coordinates();
return *this;
}
template <class OtherCoords>
PositionVector3D & operator=
( const DisplacementVector3D<OtherCoords,Tag> & v) {
fCoordinates = v.Coordinates();
return *this;
}
template <class ForeignVector>
PositionVector3D & operator= ( const ForeignVector & v) {
SetXYZ( v.x(), v.y(), v.z() );
return *this;
}
#ifdef LATER
template <class LAVector>
PositionVector3D & assignFrom(const LAVector & v, size_t index0 = 0) {
fCoordinates = CoordSystem ( v[index0], v[index0+1], v[index0+2] );
return *this;
}
#endif
const CoordSystem & Coordinates() const {
return fCoordinates;
}
void SetCoordinates( const Scalar src[] )
{ fCoordinates.SetCoordinates(src); }
void SetCoordinates( Scalar a, Scalar b, Scalar c )
{ fCoordinates.SetCoordinates(a, b, c); }
template <class IT>
void SetCoordinates( IT begin, IT end )
{ IT a = begin; IT b = ++begin; IT c = ++begin;
assert (++begin==end);
SetCoordinates (*a,*b,*c);
}
void GetCoordinates( Scalar& a, Scalar& b, Scalar& c ) const
{ fCoordinates.GetCoordinates(a, b, c); }
void GetCoordinates( Scalar dest[] ) const
{ fCoordinates.GetCoordinates(dest); }
template <class IT>
void GetCoordinates( IT begin, IT end ) const
{ IT a = begin; IT b = ++begin; IT c = ++begin;
assert (++begin==end);
GetCoordinates (*a,*b,*c);
}
template <class IT>
void GetCoordinates( IT begin ) const {
Scalar a,b,c = 0;
GetCoordinates (a,b,c);
*begin++ = a;
*begin++ = b;
*begin = c;
}
void SetXYZ (Scalar x, Scalar y, Scalar z) {
fCoordinates = Cartesian3D<Scalar> (x,y,z);
}
bool operator==(const PositionVector3D & rhs) const {
return fCoordinates==rhs.fCoordinates;
}
bool operator!= (const PositionVector3D & rhs) const {
return !(operator==(rhs));
}
Scalar X() const { return fCoordinates.X(); }
Scalar Y() const { return fCoordinates.Y(); }
Scalar Z() const { return fCoordinates.Z(); }
Scalar R() const { return fCoordinates.R(); }
Scalar Theta() const { return fCoordinates.Theta(); }
Scalar Phi() const { return fCoordinates.Phi(); }
Scalar Eta() const { return fCoordinates.Eta(); }
Scalar Rho() const { return fCoordinates.Rho(); }
Scalar Mag2() const { return fCoordinates.Mag2();}
Scalar Perp2() const { return fCoordinates.Perp2();}
void SetX (Scalar x) { fCoordinates.SetX(x); }
void SetY (Scalar y) { fCoordinates.SetY(y); }
void SetZ (Scalar z) { fCoordinates.SetZ(z); }
void SetR (Scalar r) { fCoordinates.SetR(r); }
void SetTheta (Scalar theta) { fCoordinates.SetTheta(theta); }
void SetPhi (Scalar phi) { fCoordinates.SetPhi(phi); }
void SetRho (Scalar rho) { fCoordinates.SetRho(rho); }
void SetEta (Scalar eta) { fCoordinates.SetEta(eta); }
template< class OtherCoords >
Scalar Dot( const DisplacementVector3D<OtherCoords,Tag> & v) const {
return X()*v.x() + Y()*v.y() + Z()*v.z();
}
template< class OtherCoords >
PositionVector3D Cross( const DisplacementVector3D<OtherCoords,Tag> & v) const {
PositionVector3D result;
result.SetXYZ ( Y()*v.z() - v.y()*Z(),
Z()*v.x() - v.z()*X(),
X()*v.y() - v.x()*Y() );
return result;
}
template <class OtherCoords>
PositionVector3D & operator+= (const DisplacementVector3D<OtherCoords,Tag> & v)
{
SetXYZ( X() + v.X(), Y() + v.Y(), Z() + v.Z() );
return *this;
}
template <class OtherCoords>
PositionVector3D & operator-= (const DisplacementVector3D<OtherCoords,Tag> & v)
{
SetXYZ( X() - v.X(), Y() - v.Y(), Z() - v.Z() );
return *this;
}
PositionVector3D & operator *= (Scalar a) {
fCoordinates.Scale(a);
return *this;
}
PositionVector3D & operator /= (Scalar a) {
fCoordinates.Scale(1/a);
return *this;
}
PositionVector3D operator * ( Scalar a ) const {
PositionVector3D tmp(*this);
tmp *= a;
return tmp;
}
PositionVector3D operator / (Scalar a) const {
PositionVector3D tmp(*this);
tmp /= a;
return tmp;
}
Scalar x() const { return X(); }
Scalar y() const { return Y(); }
Scalar z() const { return Z(); }
Scalar r() const { return R(); }
Scalar theta() const { return Theta(); }
Scalar phi() const { return Phi(); }
Scalar eta() const { return Eta(); }
Scalar rho() const { return Rho(); }
Scalar mag2() const { return Mag2(); }
Scalar perp2() const { return Perp2(); }
private:
CoordSystem fCoordinates;
template <class OtherCoords, class OtherTag>
explicit PositionVector3D( const PositionVector3D<OtherCoords, OtherTag> & );
template <class OtherCoords, class OtherTag>
explicit PositionVector3D( const DisplacementVector3D<OtherCoords, OtherTag> & );
template <class OtherCoords, class OtherTag>
PositionVector3D & operator=( const PositionVector3D<OtherCoords, OtherTag> & );
template <class OtherCoords, class OtherTag>
PositionVector3D & operator=( const DisplacementVector3D<OtherCoords, OtherTag> & );
template <class OtherCoords, class OtherTag>
PositionVector3D & operator+=(const DisplacementVector3D<OtherCoords, OtherTag> & );
template <class OtherCoords, class OtherTag>
PositionVector3D & operator-=(const DisplacementVector3D<OtherCoords, OtherTag> & );
};
template <class CoordSystem, class U>
inline
PositionVector3D<CoordSystem>
operator * ( typename PositionVector3D<CoordSystem,U>::Scalar a,
PositionVector3D<CoordSystem,U> v) {
return v *= a;
}
template <class CoordSystem1, class CoordSystem2, class U>
inline
DisplacementVector3D<CoordSystem1,U>
operator-( const PositionVector3D<CoordSystem1,U> & v1,
const PositionVector3D<CoordSystem2,U> & v2) {
return DisplacementVector3D<CoordSystem1,U>( Cartesian3D<typename CoordSystem1::Scalar>(
v1.X()-v2.X(), v1.Y()-v2.Y(),v1.Z()-v2.Z() )
);
}
template <class CoordSystem1, class CoordSystem2, class U>
inline
PositionVector3D<CoordSystem2,U>
operator+( PositionVector3D<CoordSystem2,U> p1,
const DisplacementVector3D<CoordSystem1,U> & v2) {
return p1 += v2;
}
template <class CoordSystem1, class CoordSystem2, class U>
inline
PositionVector3D<CoordSystem2,U>
operator+( DisplacementVector3D<CoordSystem1,U> const & v1,
PositionVector3D<CoordSystem2,U> p2) {
return p2 += v1;
}
template <class CoordSystem1, class CoordSystem2, class U>
inline
PositionVector3D<CoordSystem2,U>
operator-( PositionVector3D<CoordSystem2,U> p1,
DisplacementVector3D<CoordSystem1,U> const & v2) {
return p1 -= v2;
}
template< class char_t, class traits_t, class T, class U >
inline
std::basic_ostream<char_t,traits_t> &
operator << ( std::basic_ostream<char_t,traits_t> & os
, PositionVector3D<T,U> const & v
)
{
if( !os ) return os;
typename T::Scalar a, b, c;
v.GetCoordinates(a, b, c);
if( detail::get_manip( os, detail::bitforbit ) ) {
detail::set_manip( os, detail::bitforbit, '\00' );
typedef GenVector_detail::BitReproducible BR;
BR::Output(os, a);
BR::Output(os, b);
BR::Output(os, c);
}
else {
os << detail::get_manip( os, detail::open ) << a
<< detail::get_manip( os, detail::sep ) << b
<< detail::get_manip( os, detail::sep ) << c
<< detail::get_manip( os, detail::close );
}
return os;
}
template< class char_t, class traits_t, class T, class U >
inline
std::basic_istream<char_t,traits_t> &
operator >> ( std::basic_istream<char_t,traits_t> & is
, PositionVector3D<T,U> & v
)
{
if( !is ) return is;
typename T::Scalar a, b, c;
if( detail::get_manip( is, detail::bitforbit ) ) {
detail::set_manip( is, detail::bitforbit, '\00' );
typedef GenVector_detail::BitReproducible BR;
BR::Input(is, a);
BR::Input(is, b);
BR::Input(is, c);
}
else {
detail::require_delim( is, detail::open ); is >> a;
detail::require_delim( is, detail::sep ); is >> b;
detail::require_delim( is, detail::sep ); is >> c;
detail::require_delim( is, detail::close );
}
if( is )
v.SetCoordinates(a, b, c);
return is;
}
}
}
#endif /* ROOT_Math_GenVector_PositionVector3D */
ROOT page - Class index - Class Hierarchy - Top of the page
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.