Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:04:16

0001 #ifndef GeometryVector_PV2DBase_h
0002 #define GeometryVector_PV2DBase_h
0003 
0004 #include "DataFormats/GeometryVector/interface/Basic2DVector.h"
0005 
0006 #include <iosfwd>
0007 #include <ostream>
0008 
0009 template <class T, class PVType, class FrameType>
0010 class PV2DBase {
0011 public:
0012   typedef T ScalarType;
0013   typedef Basic2DVector<T> BasicVectorType;
0014   typedef typename BasicVectorType::Polar Polar;
0015   typedef typename BasicVectorType::MathVector MathVector;
0016 
0017   /** default constructor uses default constructor of T to initialize the 
0018    *  components. For built-in floating-point types this means initialization 
0019    * to zero
0020    */
0021   PV2DBase() : theVector() {}
0022 
0023   /// construct from cartesian coordinates
0024   PV2DBase(const T& x, const T& y) : theVector(x, y) {}
0025 
0026   /// construct from polar coordinates
0027   PV2DBase(const Polar& set) : theVector(set) {}
0028 
0029   /** Explicit constructor from BasicVectorType, possibly of different precision
0030    */
0031   template <class U>
0032   explicit PV2DBase(const Basic2DVector<U>& v) : theVector(v) {}
0033 
0034   /** Access to the basic vector, use only when the operations on Point and Vector
0035    *  are too restrictive (preferably never). 
0036    */
0037   const BasicVectorType& basicVector() const { return theVector; }
0038 #ifndef __REFLEX__
0039   MathVector const& mathVector() const { return theVector.v; }
0040   MathVector& mathVector() { return theVector.v; }
0041 #endif
0042 
0043   T x() const { return basicVector().x(); }
0044   T y() const { return basicVector().y(); }
0045   T mag2() const { return basicVector().mag2(); }
0046   T r() const { return basicVector().r(); }
0047   T mag() const { return basicVector().mag(); }
0048   T barePhi() const { return basicVector().barePhi(); }
0049   Geom::Phi<T> phi() const { return basicVector().phi(); }
0050 
0051 protected:
0052   // required in the implementation of inherited types...
0053   BasicVectorType& basicVector() { return theVector; }
0054 
0055   BasicVectorType theVector;
0056 };
0057 
0058 template <class T, class PV, class F>
0059 inline std::ostream& operator<<(std::ostream& s, const PV2DBase<T, PV, F>& v) {
0060   return s << " (" << v.x() << ',' << v.y() << ") ";
0061 }
0062 #endif  // GeometryVector_PV2DBase_h