File indexing completed on 2025-06-30 08:34:26
0001
0002
0003 #ifndef EDM4HEP_Vector3d_H
0004 #define EDM4HEP_Vector3d_H
0005
0006 #include <cstddef>
0007 #include <edm4hep/Vector3f.h>
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 }
0028 constexpr Vector3d(double xx, double yy, double zz) : x(xx), y(yy), z(zz) {
0029 }
0030 constexpr Vector3d(const double* v) : x(v[0]), y(v[1]), z(v[2]) {
0031 }
0032 constexpr Vector3d(const float* v) : x(v[0]), y(v[1]), z(v[2]) {
0033 }
0034 [[deprecated("This constructor will be removed again it is mainly here for an easier "
0035 "transition")]] constexpr Vector3d(const Vector3f& v) :
0036 x(v.x), y(v.y), z(v.z) {
0037 }
0038 constexpr bool operator==(const Vector3d& v) const {
0039 return (x == v.x && y == v.y && z == v.z);
0040 }
0041 constexpr bool operator!=(const Vector3d& v) const {
0042 return !(*this == v);
0043 }
0044 constexpr double operator[](unsigned i) const {
0045 static_assert((offsetof(Vector3d, x) + sizeof(Vector3d::x) == offsetof(Vector3d, y)) &&
0046 (offsetof(Vector3d, y) + sizeof(Vector3d::y) == offsetof(Vector3d, z)),
0047 "operator[] requires no padding");
0048 return *(&x + i);
0049 }
0050 };
0051
0052 std::ostream& operator<<(std::ostream& o, const edm4hep::Vector3d& value);
0053
0054 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0055 void to_json(nlohmann::json& j, const Vector3d& value);
0056 #endif
0057
0058 }
0059
0060 #endif