Skip to content
Snippets Groups Projects

Draft: Resolve "VectorXYZT::mag() may be confusing since not four-vector magnitude"

1 file
+ 35
3
Compare changes
  • Side-by-side
  • Inline
+ 35
3
@@ -132,6 +132,7 @@ components:
@@ -132,6 +132,7 @@ components:
float& operator[](unsigned i) {return *(&x + i);}\n
float& operator[](unsigned i) {return *(&x + i);}\n
const float& operator[](unsigned i) const {return *(&x + i);}\n
const float& operator[](unsigned i) const {return *(&x + i);}\n
float mag() const {return std::hypot(x, y, z);}\n
float mag() const {return std::hypot(x, y, z);}\n
 
float mag2() const {return x*x + y*y + z*z;}\n
float r() const {return mag();}\n
float r() const {return mag();}\n
float theta() const {return acos(z/mag());}\n
float theta() const {return acos(z/mag());}\n
float phi() const {return atan2(y,x);}\n
float phi() const {return atan2(y,x);}\n
@@ -154,6 +155,7 @@ components:
@@ -154,6 +155,7 @@ components:
VectorPolar(double rr, double th, double ph) : r{static_cast<float>(rr)}, theta{static_cast<float>(th)}, phi{static_cast<float>(ph)} {}\n
VectorPolar(double rr, double th, double ph) : r{static_cast<float>(rr)}, theta{static_cast<float>(th)}, phi{static_cast<float>(ph)} {}\n
template<class VectorXYZType> VectorPolar(const VectorXYZType& v) : VectorPolar(v.r(), v.theta(), v.phi()) {}\n
template<class VectorXYZType> VectorPolar(const VectorXYZType& v) : VectorPolar(v.r(), v.theta(), v.phi()) {}\n
float mag() const {return r;}\n
float mag() const {return r;}\n
 
float mag2() const {return r*r;}\n
float x() const {return r * cos(phi) * sin(theta);}\n
float x() const {return r * cos(phi) * sin(theta);}\n
float y() const {return r * sin(phi) * sin(theta);}\n
float y() const {return r * sin(phi) * sin(theta);}\n
float z() const {return r * cos(theta);}\n
float z() const {return r * cos(theta);}\n
@@ -172,22 +174,52 @@ components:
@@ -172,22 +174,52 @@ components:
declaration: "
declaration: "
VectorXYZT() : x{0}, y{0}, z{0}, t{0} {}\n
VectorXYZT() : x{0}, y{0}, z{0}, t{0} {}\n
VectorXYZT(double xx, double yy, double zz, double tt) : x{xx}, y{yy}, z{zz}, t{tt} {}\n
VectorXYZT(double xx, double yy, double zz, double tt) : x{xx}, y{yy}, z{zz}, t{tt} {}\n
 
template<class VectorXYZType> VectorXYZT(const VectorXYZType& v, double tt): x{v.x()}, y{v.y()}, z{v.z()}, t{tt} {}\n
double& operator[](unsigned i) {return *(&x + i);}\n
double& operator[](unsigned i) {return *(&x + i);}\n
const double& operator[](unsigned i) const {return *(&x + i);}\n
const double& operator[](unsigned i) const {return *(&x + i);}\n
double mag() const {return std::hypot(x, y, z);}\n
double mag() const {return std::hypot(x, y, z);}\n
 
double mag2() const {return x*x + y*y + z*z;}\n
double r() const {return mag();}\n
double r() const {return mag();}\n
double theta() const {return acos(z/mag());}\n
double theta() const {return acos(z/mag());}\n
double phi() const {return atan2(y,x);}\n
double phi() const {return atan2(y,x);}\n
double eta() const {return -log(tan(0.5*theta()));}
double eta() const {return -log(tan(0.5*theta()));}
double energy() const {return t;}\n
double mass() const {return sqrt(t*t - x*x - y*y - z*z);}\n
operator std::tuple<double, double, double, double>() {return {x, y, z, t};}\n
operator std::tuple<double, double, double, double>() {return {x, y, z, t};}\n
double dot(const VectorXYZT& rhs) const {return t*rhs.t - x*rhs.x - y*rhs.y - z*rhs.z;}\n
VectorXYZT add(const VectorXYZT& rhs) const {return {x+rhs.x, y+rhs.y, z+rhs.z, t+rhs.t};}\n
VectorXYZT add(const VectorXYZT& rhs) const {return {x+rhs.x, y+rhs.y, z+rhs.z, t+rhs.t};}\n
VectorXYZT subtract(const VectorXYZT& rhs) const {return {x-rhs.x, y-rhs.y, z-rhs.z, t-rhs.t};}\n
VectorXYZT subtract(const VectorXYZT& rhs) const {return {x-rhs.x, y-rhs.y, z-rhs.z, t-rhs.t};}\n
VectorXYZT scale(double f) const {return {f*x, f*y, f*z, f*t};}\n
VectorXYZT scale(double f) const {return {f*x, f*y, f*z, f*t};}\n
"
"
 
 
eic::LorentzVectorXYZT:
 
Members:
 
- double x // [mm] or [GeV]
 
- double y //
 
- double z //
 
- double t // [ns] or [GeV]
 
ExtraCode:
 
includes: "#include <cmath>\n#include <tuple>"
 
declaration: "
 
LorentzVectorXYZT() : x{0}, y{0}, z{0}, t{0} {}\n
 
LorentzVectorXYZT(double xx, double yy, double zz, double tt) : x{xx}, y{yy}, z{zz}, t{tt} {}\n
 
template<class VectorXYZType> LorentzVectorXYZT(const VectorXYZType& v, double tt): x{v.x()}, y{v.y()}, z{v.z()}, t{tt} {}\n
 
double& operator[](unsigned i) {return *(&x + i);}\n
 
const double& operator[](unsigned i) const {return *(&x + i);}\n
 
double mag2() const {return x*x + y*y + z*z - t*t;}\n
 
double mag() const {return std::sqrt(mag2());}\n
 
double r() const {return mag();}\n
 
double theta() const {return acos(z/mag());}\n
 
double phi() const {return atan2(y,x);}\n
 
double eta() const {return -log(tan(0.5*theta()));}
 
double energy() const {return t;}\n
 
double mass2() const {return t*t - x*x - y*y - z*z;}\n
 
double mass() const {return sqrt(t*t - x*x - y*y - z*z);}\n
 
operator std::tuple<double, double, double, double>() {return {x, y, z, t};}\n
 
double dot(const LorentzVectorXYZT& rhs) const {return t*rhs.t - x*rhs.x - y*rhs.y - z*rhs.z;}\n
 
LorentzVectorXYZT add(const LorentzVectorXYZT& rhs) const {return {x+rhs.x, y+rhs.y, z+rhs.z, t+rhs.t};}\n
 
LorentzVectorXYZT subtract(const LorentzVectorXYZT& rhs) const {return {x-rhs.x, y-rhs.y, z-rhs.z, t-rhs.t};}\n
 
LorentzVectorXYZT scale(double f) const {return {f*x, f*y, f*z, f*t};}\n
 
"
 
eic::CovDiagXYZ:
eic::CovDiagXYZ:
Members:
Members:
- float xx
- float xx
Loading