EDepSimArbMagField.hh
Go to the documentation of this file.
1 // License and Disclaimer
2 //
3 // For use with software authored by the Geant4 Collaboration
4 //
5 // MIT License
6 //
7 // Copyright (c) 2020 Andrew Cudd
8 //
9 // Permission is hereby granted, free of charge, to any person obtaining a
10 // copy of this software and associated documentation files (the "Software"),
11 // to deal in the Software without restriction, including without limitation
12 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 // and/or sell copies of the Software, and to permit persons to whom the
14 // Software is furnished to do so, subject to the following conditions:
15 //
16 // The above copyright notice and this permission notice shall be included in
17 // all copies or substantial portions of the Software.
18 //
19 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25 // DEALINGS IN THE SOFTWARE.
26 //
27 //
28 // class EDepSim::ArbMagField
29 //
30 // Class description:
31 //
32 // Class for storing and handling an arbitrary magnetic field.
33 //
34 // History:
35 // - 2020.04.14 A.Cudd created
36 // - 2020.07.28 C.McGrew updated license with permission of A.Cudd
37 //
38 // -------------------------------------------------------------------
39 
40 #ifndef EDEPSIMARBMAGFIELD_H
41 #define EDEPSIMARBMAGFIELD_H
42 
43 #include <array>
44 #include <cmath>
45 #include <fstream>
46 #include <iostream>
47 #include <sstream>
48 #include <string>
49 #include <vector>
50 
51 #include "G4Types.hh"
52 #include "G4MagneticField.hh"
53 #include <G4SystemOfUnits.hh>
54 
55 #include "EDepSimLog.hh"
56 #include "EDepSimInterpolator.hh"
57 
58 namespace EDepSim { class ArbMagField; }
59 
60 class EDepSim::ArbMagField : public G4MagneticField
61 {
62  public:
63  ArbMagField();
64 
65  bool ReadFile(const std::string& fname);
66  void PrintInfo() const;
67  virtual void GetFieldValue(const G4double pos[4], G4double* field) const;
68 
69  private:
71  std::array<double, 3> m_offset;
72  std::array<double, 3> m_delta;
73  std::vector<std::vector<std::vector<double>>> m_field_x;
74  std::vector<std::vector<std::vector<double>>> m_field_y;
75  std::vector<std::vector<std::vector<double>>> m_field_z;
76 };
77 
78 #endif
std::vector< std::vector< std::vector< double > > > m_field_x
std::string string
Definition: nybbler.cc:12
std::vector< std::vector< std::vector< double > > > m_field_y
std::array< double, 3 > m_delta
Construct a module from components.
Definition: TG4HitSegment.h:10
bool ReadFile(const std::string &fname)
std::array< double, 3 > m_offset
virtual void GetFieldValue(const G4double pos[4], G4double *field) const
std::vector< std::vector< std::vector< double > > > m_field_z