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
0018
0019
0020
0021 PV2DBase() : theVector() {}
0022
0023
0024 PV2DBase(const T& x, const T& y) : theVector(x, y) {}
0025
0026
0027 PV2DBase(const Polar& set) : theVector(set) {}
0028
0029
0030
0031 template <class U>
0032 explicit PV2DBase(const Basic2DVector<U>& v) : theVector(v) {}
0033
0034
0035
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
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