19#ifndef BDSFOURVECTOR_H
20#define BDSFOURVECTOR_H
21#include "BDSException.hh"
34template<
typename Type>
49 for (
const auto& i : indices)
58 for (
const G4int& i : indices)
66 if (index > (G4int)indices.size()-1)
67 {
throw BDSException(
"BDSFourVector::operator[]> index outside array");}
74 if (index > (G4int)indices.size()-1)
75 {
throw BDSException(
"BDSFourVector::operator[]> index outside array");}
80 inline const Type&
x()
const {
return values[0];}
81 inline const Type&
y()
const {
return values[1];}
82 inline const Type&
z()
const {
return values[2];}
83 inline const Type&
t()
const {
return values[3];}
102 std::vector<G4int> indices = {0,1,2,3};
General exception with possible name of object and message.
A simple templated four vector class.
const Type & y() const
Accessor by name.
const Type & z() const
Accessor by name.
BDSFourVector(Type xIn, Type yIn, Type zIn, Type tIn)
Alternate constructor.
friend std::ostream & operator<<(std::ostream &out, BDSFourVector const &v)
Output stream.
Type & operator[](const G4int index)
Access / set a single element.
const Type & x() const
Accessor by name.
const Type & operator[](const G4int index) const
Access a single element.
BDSFourVector()
Default constructor.
BDSFourVector & operator=(const BDSFourVector &rhs)
Assignment operator.
Type values[4]
Member data x,y,z,t.
const Type & t() const
Accessor by name.
BDSFourVector(const BDSFourVector &other)
Copy constructor.