#ifndef ROOT_Math_GenVector_PositionVector3D
#define ROOT_Math_GenVector_PositionVector3D 1
#ifndef ROOT_Math_GenVector_DisplacementVector3Dfwd
#include "Math/GenVector/DisplacementVector3Dfwd.h"
#endif
#ifndef ROOT_Math_GenVector_Cartesian3D
#include "Math/GenVector/Cartesian3D.h"
#endif
#ifndef ROOT_Math_GenVector_GenVectorIO
#include "Math/GenVector/GenVectorIO.h"
#endif
#ifndef ROOT_Math_GenVector_BitReproducible
#include "Math/GenVector/BitReproducible.h"
#endif
#ifndef ROOT_Math_GenVector_CoordinateSystemTags
#include "Math/GenVector/CoordinateSystemTags.h"
#endif
#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;
}
PositionVector3D<CoordSystem, Tag>& SetCoordinates( const Scalar src[] )
{ fCoordinates.SetCoordinates(src); return *this; }
PositionVector3D<CoordSystem, Tag>& SetCoordinates( Scalar a, Scalar b, Scalar c )
{ fCoordinates.SetCoordinates(a, b, c); return *this; }
template <class IT>
PositionVector3D<CoordSystem, Tag>& SetCoordinates( IT begin, IT end )
{ IT a = begin; IT b = ++begin; IT c = ++begin;
assert (++begin==end);
SetCoordinates (*a,*b,*c);
return *this;
}
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;
}
PositionVector3D<CoordSystem, Tag>& SetXYZ (Scalar a, Scalar b, Scalar c) {
fCoordinates.SetXYZ(a,b,c);
return *this;
}
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();}
PositionVector3D<CoordSystem, Tag>& SetX (Scalar xx) { fCoordinates.SetX(xx); return *this;}
PositionVector3D<CoordSystem, Tag>& SetY (Scalar yy) { fCoordinates.SetY(yy); return *this;}
PositionVector3D<CoordSystem, Tag>& SetZ (Scalar zz) { fCoordinates.SetZ(zz); return *this;}
PositionVector3D<CoordSystem, Tag>& SetR (Scalar rr) { fCoordinates.SetR(rr); return *this;}
PositionVector3D<CoordSystem, Tag>& SetTheta (Scalar ang) { fCoordinates.SetTheta(ang); return *this;}
PositionVector3D<CoordSystem, Tag>& SetPhi (Scalar ang) { fCoordinates.SetPhi(ang); return *this;}
PositionVector3D<CoordSystem, Tag>& SetRho (Scalar rr) { fCoordinates.SetRho(rr); return *this;}
PositionVector3D<CoordSystem, Tag>& SetEta (Scalar etaval) { fCoordinates.SetEta(etaval); return *this;}
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 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(); }
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 */
Last change: Mon Dec 1 17:06:28 2008
Last generated: 2008-12-01 17:06
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.