GArMagneticField.h
Go to the documentation of this file.
1 /// \file MPDMagneticField.h
2 /// \brief Describe the magnetic field structure of a detector
3 ///
4 /// \version $Id: MPDMagneticField.h,v 1.3 2019-11-06 02:46:38 trj Exp $
5 /// \author trj@fnal.gov
6 //////////////////////////////////////////////////////////////////////////
7 /// \namespace mag
8 /// A namespace for simulated magnetic fields
9 //////////////////////////////////////////////////////////////////////////
10 
11 #ifndef MAG_GARMAGNETICFIELD_H
12 #define MAG_GARMAGNETICFIELD_H
13 
14 // nug4 libraries
15 #include "nug4/MagneticField/MagneticField.h"
16 
17 namespace fhicl { class ParameterSet; }
18 namespace mag
19 {
20 
21 // Specifies the magnetic field over all space
22 //
23 // The default implementation, however, uses a nearly trivial,
24 // non-physical hack.
25 class GArMagneticField: public MagneticField {
26 
27 public:
28 
29  explicit GArMagneticField(fhicl::ParameterSet const& pset);
30  GArMagneticField(GArMagneticField const&) = delete;
31  virtual ~GArMagneticField() = default;
32 
33  void reconfigure(fhicl::ParameterSet const& pset);
34 
35  //Return std::vector<MagneticFieldDescription>
36  std::vector<MagneticFieldDescription> const& Fields() const override { return fFieldDescriptions; }
37 
38  //Return std::vector<MagneticFieldDescription> size
39  size_t NumFields() const override { return fFieldDescriptions.size(); }
40 
41  //Return the field mode
42  MagFieldMode_t const& UseField(size_t f) const override { return fFieldDescriptions[f].fMode; }
43 
44  //Return the magnetized volumes
45  std::string const& MagnetizedVolume(size_t f) const override { return fFieldDescriptions[f].fVolume; }
46 
47  // return the field at a particular point
48  G4ThreeVector const FieldAtPoint(G4ThreeVector const& p = G4ThreeVector(0)) const override;
49 
50  // This method will only return a uniform field based on the input
51  // volume name. If the input volume does not have a uniform field
52  // caveat emptor
53  G4ThreeVector const UniformFieldInVolume(std::string const& volName) const override;
54 
55 private:
56  void ReadRZFile(const std::string& filename, RZFieldMap& rzmap);
57  void ReadXYZFile(const std::string& filename, XYZFieldMap& xyzmap, const float unitFactor);
58 
59  G4ThreeVector CalcRZField(G4ThreeVector const& p, RZFieldMap const& rzmap) const;
60  G4ThreeVector CalcXYZField(G4ThreeVector const& p, XYZFieldMap const& xyzmap) const;
61 
63  std::vector<MagneticFieldDescription> fFieldDescriptions; ///< Descriptions of the fields
64  float fUnitFactor; //factor to convert from map position units to mm
65 };
66 
68 {
69 public:
70  Interpolator();
71 
72  float interpolate(const float* point, const std::vector<std::vector<std::vector<float>>>& g,
73  const float* delta, const float* offset) const;
74  float interpolate(float x, float y, float z,
75  const std::vector<std::vector<std::vector<float>>>& g, float hx, float hy,
76  float hz, float xo, float yo, float zo) const;
77 
78 private:
79  float conv_kernel(float s) const;
80 };
81 
82 } // namespace mag
83 
84 #endif // MAG_GARMAGNETICFIELD_H
std::vector< MagneticFieldDescription > const & Fields() const override
std::string const & MagnetizedVolume(size_t f) const override
static constexpr double g
Definition: Units.h:144
std::string string
Definition: nybbler.cc:12
struct vector vector
string filename
Definition: train.py:213
std::vector< MagneticFieldDescription > fFieldDescriptions
Descriptions of the fields.
virtual void reconfigure(fhicl::ParameterSet const &pset)
p
Definition: test.py:223
MagFieldMode_t const & UseField(size_t f) const override
list x
Definition: train.py:276
static QCString * s
Definition: config.cpp:1042
size_t NumFields() const override