ATLAS Offline Software
Loading...
Searching...
No Matches
BFieldVector.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
5//
6// BFieldVector.h
7// Magnetic field value stored in the map.
8// We allow short (usual case) double (special case)
9//
10// Masahiro Morii, Harvard University
11//
12// Athena MT RD Schaffer , C Anastopoulos
13//
14#ifndef BFIELDVECTOR_H
15#define BFIELDVECTOR_H
16
17#include <array>
18#include <cstdlib>
19
20template<class T>
22{
23public:
24 static_assert(
25 (std::is_same<T, short>::value || std::is_same<T, double>::value),
26 "Type for the BField Vector must be one of short or double");
27
28 // Default
29 BFieldVector() = default; // cppcheck-suppress uninitMemberVar; m_B uninit on purpose
30 BFieldVector(const BFieldVector&) = default;
34 ~BFieldVector() = default;
35
36 BFieldVector(T Bz, T Br, T Bphi)
37 : m_B{ Bz, Br, Bphi }
38 {}
39 // setter
40 void set(T Bz, T Br, T Bphi) { m_B = { Bz, Br, Bphi }; }
41
42 // accessors
43 T z() const { return m_B[0]; }
44 T r() const { return m_B[1]; }
45 T phi() const { return m_B[2]; }
46 // array-like accessor
47 T operator[](size_t i) const { return m_B[i]; }
48
49private:
50 std::array<T, 3> m_B;
51};
52
53#endif
BFieldVector & operator=(BFieldVector &&)=default
T operator[](size_t i) const
BFieldVector(const BFieldVector &)=default
BFieldVector(T Bz, T Br, T Bphi)
std::array< T, 3 > m_B
T r() const
BFieldVector & operator=(const BFieldVector &)=default
T phi() const
~BFieldVector()=default
T z() const
BFieldVector()=default
void set(T Bz, T Br, T Bphi)
BFieldVector(BFieldVector &&)=default