File indexing completed on 2025-09-17 08:55:16
0001
0002
0003 #ifndef EDM4HEP_Vector3d_H
0004 #define EDM4HEP_Vector3d_H
0005
0006 #include <edm4hep/Vector3f.h>
0007 #include <cstddef>
0008 #include <ostream>
0009
0010 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0011 #include "nlohmann/json_fwd.hpp"
0012 #endif
0013
0014 namespace edm4hep {
0015
0016
0017
0018
0019
0020 class Vector3d {
0021 public:
0022 double x{};
0023 double y{};
0024 double z{};
0025
0026 constexpr Vector3d() : x(0),y(0),z(0) {}
0027 constexpr Vector3d(double xx, double yy, double zz) : x(xx),y(yy),z(zz) {}
0028 constexpr Vector3d(const double* v) : x(v[0]),y(v[1]),z(v[2]) {}
0029 constexpr Vector3d(const float* v) : x(v[0]),y(v[1]),z(v[2]) {}
0030 [[ deprecated("This constructor will be removed again it is mainly here for an easier transition") ]]
0031 constexpr Vector3d(const Vector3f& v) : x(v.x), y(v.y), z(v.z) {}
0032 constexpr bool operator==(const Vector3d& v) const { return (x==v.x&&y==v.y&&z==v.z) ; }
0033 constexpr bool operator!=(const Vector3d& v) const { return !(*this == v) ; }
0034 constexpr double operator[](unsigned i) const {
0035 static_assert(
0036 (offsetof(Vector3d,x)+sizeof(Vector3d::x) == offsetof(Vector3d,y)) &&
0037 (offsetof(Vector3d,y)+sizeof(Vector3d::y) == offsetof(Vector3d,z)),
0038 "operator[] requires no padding");
0039 return *( &x + i ) ; }
0040
0041
0042 };
0043
0044 std::ostream& operator<<(std::ostream& o, const edm4hep::Vector3d& value);
0045
0046 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0047 void to_json(nlohmann::json& j, const Vector3d& value);
0048 #endif
0049
0050 }
0051
0052
0053 #endif