BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
BmnFieldMap.h
Go to the documentation of this file.
1// ---------------------------------------------------------------------------------
2// ----- BmnFieldMap header file -------------
3// ----- Created 03/02/2015 by P. Batyuk -------------
4// ---------------------------------------------------------------------------------
5#ifndef BMNFIELDMAP_H
6#define BMNFIELDMAP_H 1
7
8#include "BmnFieldMapData.h"
9#include "BmnFieldPar.h"
10#include "FairField.h"
11#include "TArrayF.h"
12
13typedef struct
14{
15 Int_t N;
18 Double_t step;
20
21class BmnFieldMap : public FairField
22{
23 public:
25 BmnFieldMap(const char* mapFileName);
27 virtual ~BmnFieldMap();
28
29 virtual void Init();
30
31 virtual Double_t GetBx(Double_t x, Double_t y, Double_t z) = 0;
32 virtual Double_t GetBy(Double_t x, Double_t y, Double_t z) = 0;
33 virtual Double_t GetBz(Double_t x, Double_t y, Double_t z) = 0;
34
36 Double_t y,
37 Double_t z,
38 Int_t& ix,
39 Int_t& iy,
40 Int_t& iz,
41 Double_t& dx,
42 Double_t& dy,
43 Double_t& dz) = 0;
44
45 /** Write the field map to an ASCII file **/
46 void WriteAsciiFile(const char* asciiFileName);
47
48 /** Write field map data to a ROOT file **/
49 void WriteRootFile(const char* rootFileName, const char* mapFileName);
50
51 /** Set the position of the field centre **/
53
54 /** Set a global field scaling factor **/
55 void SetScale(Double_t factor)
56 {
57 fScale = factor;
58 fIsOff = (factor == 0 ? kTRUE : kFALSE);
59 }
60
61 /** Turn magnetic field off **/
62 void SetFieldOff(Bool_t is_off = kTRUE) { fIsOff = is_off; }
63
64 /** Set field map file path **/
65 void SetFileName(const char* map_file_name) { fName = map_file_name; }
66
67 /** Accessors to field parameters in local coordinate system **/
68 Double_t GetXmin() const { return fXmin; }
69 Double_t GetYmin() const { return fYmin; }
70 Double_t GetZmin() const { return fZmin; }
71
72 Double_t GetXmax() const { return fXmax; }
73 Double_t GetYmax() const { return fYmax; }
74 Double_t GetZmax() const { return fZmax; }
75
76 Double_t GetXstep() const { return fXstep; }
77 Double_t GetYstep() const { return fYstep; }
78 Double_t GetZstep() const { return fZstep; }
79
80 Int_t GetNx() const { return fNx; }
81 Int_t GetNy() const { return fNy; }
82 Int_t GetNz() const { return fNz; }
83
84 /** Accessor to field centre position in global system **/
85 Double_t GetPositionX() const { return fPosX; }
86 Double_t GetPositionY() const { return fPosY; }
87 Double_t GetPositionZ() const { return fPosZ; }
88
89 /** Accessor to global scaling factor **/
90 Double_t GetScale() const { return fScale; }
91
92 /** Whether magnetic field is off **/
93 Bool_t IsFieldOff() const { return fIsOff; }
94
95 /** Accessors to the field value arrays **/
96 TArrayF* GetBx() const { return fBx; }
97 TArrayF* GetBy() const { return fBy; }
98 TArrayF* GetBz() const { return fBz; }
99
100 /** Accessor to field map file **/
101 const char* GetFileName() { return fName.Data(); }
102
103 /** Get the expanded path to the field map file in the current installation **/
105
106 /** Screen output **/
107 virtual void Print(Option_t*) const;
108
109 virtual void FillParContainer() = 0;
110
111 /** Reset the field parameters and data **/
112 void Reset();
113
114 protected:
115 /** Reset the field parameters and data **/
116 // void Reset();
117
118 /** Read the field map from an ASCII file **/
119 void ReadAsciiFile(const char* asciiFileName);
120
121 /** Read field map from a ROOT file **/
122 void ReadRootFile(const char* rootFileName);
123 void ReadRootFileNewFormat(const char* rootFileName);
124 void ReadRootFileNewFormatExtrap(const char* rootFileName);
125
126 /** Set field parameters and data **/
127 void SetField(const BmnFieldMapData* data);
128
129 /** Get field values by interpolation of the grid.
130 ** @param dx,dy,dz Relative distance from grid point [cell units]
131 **/
133
134 /** Global scaling factor (w.r.t. map on file) **/
136
137 /** Field centre position in global coordinates **/
140
141 /** Field limits in local coordinate system **/
145
146 /** Number of grid points **/
147 Int_t fNx, fNy, fNz;
148
149 /** Arrays with the field values **/
150 TArrayF* fBx;
151 TArrayF* fBy;
152 TArrayF* fBz;
153
154 /** Variables for temporary storage
155 ** Used in the very frequently called method GetFieldValue **/
156 Double_t fHa[2][2][2]; //! Field at corners of a grid cell
157 Double_t fHb[2][2]; //! Interpolated field (2-dim)
158 Double_t fHc[2]; //! Interpolated field (1-dim)
159
161 /** Whether magnetic field is off **/
163
164 private:
165 BmnFieldMap(const BmnFieldMap&) = delete;
167
169};
170
171#endif
friend F32vec4 min(const F32vec4 &a, const F32vec4 &b)
Definition P4_F32vec4.h:30
friend F32vec4 max(const F32vec4 &a, const F32vec4 &b)
Definition P4_F32vec4.h:31
bool Bool_t
int Int_t
constexpr Bool_t kFALSE
double Double_t
constexpr Bool_t kTRUE
const char Option_t
#define ClassDef(name, id)
void ReadRootFileNewFormat(const char *rootFileName)
virtual void Init()
Double_t fHa[2][2][2]
Variables for temporary storage Used in the very frequently called method GetFieldValue.
TArrayF * fBy
BmnFieldMap(BmnFieldPar *fieldPar)
void SetField(const BmnFieldMapData *data)
Set field parameters and data.
Bool_t fIsOff
Whether magnetic field is off.
Double_t fPosZ
Int_t GetNz() const
Definition BmnFieldMap.h:82
Double_t fPosBx
virtual void FillParContainer()=0
Double_t GetPositionX() const
Accessor to field centre position in global system.
Definition BmnFieldMap.h:85
Double_t GetPositionY() const
Definition BmnFieldMap.h:86
virtual ~BmnFieldMap()
TArrayF * GetBx() const
Accessors to the field value arrays.
Definition BmnFieldMap.h:96
Bool_t IsFieldOff() const
Whether magnetic field is off.
Definition BmnFieldMap.h:93
BmnFieldMap(const BmnFieldMap &)=delete
Int_t fNx
Number of grid points.
void ReadRootFileNewFormatExtrap(const char *rootFileName)
Double_t GetPositionZ() const
Definition BmnFieldMap.h:87
virtual Double_t GetBz(Double_t x, Double_t y, Double_t z)=0
void ReadRootFile(const char *rootFileName)
Read field map from a ROOT file.
Double_t fPosY
const char * GetFileName()
Accessor to field map file.
TArrayF * GetBy() const
Definition BmnFieldMap.h:97
TArrayF * fBz
Double_t GetYstep() const
Definition BmnFieldMap.h:77
Double_t Interpolate(Double_t dx, Double_t dy, Double_t dz)
Get field values by interpolation of the grid.
Double_t fScale
Global scaling factor (w.r.t.
Double_t fPosX
Field centre position in global coordinates.
Double_t fHc[2]
Interpolated field (2-dim).
void Reset()
Reset the field parameters and data.
Double_t GetZstep() const
Definition BmnFieldMap.h:78
virtual Bool_t IsInside(Double_t x, Double_t y, Double_t z, Int_t &ix, Int_t &iy, Int_t &iz, Double_t &dx, Double_t &dy, Double_t &dz)=0
Double_t GetXstep() const
Definition BmnFieldMap.h:76
void SetFileName(const char *map_file_name)
Set field map file path.
Definition BmnFieldMap.h:65
void SetPosition(Double_t x, Double_t y, Double_t z)
Set the position of the field centre.
Double_t fZmin
virtual Double_t GetBy(Double_t x, Double_t y, Double_t z)=0
Double_t GetZmin() const
Definition BmnFieldMap.h:70
Double_t GetYmin() const
Definition BmnFieldMap.h:69
void SetScale(Double_t factor)
Set a global field scaling factor.
Definition BmnFieldMap.h:55
virtual void Print(Option_t *) const
Screen output.
TArrayF * GetBz() const
Definition BmnFieldMap.h:98
virtual Double_t GetBx(Double_t x, Double_t y, Double_t z)=0
BmnFieldMap(const char *mapFileName)
Double_t fYmax
void SetFieldOff(Bool_t is_off=kTRUE)
Turn magnetic field off.
Definition BmnFieldMap.h:62
Double_t fHb[2][2]
Field at corners of a grid cell.
Double_t GetXmax() const
Definition BmnFieldMap.h:72
Int_t GetNy() const
Definition BmnFieldMap.h:81
void WriteRootFile(const char *rootFileName, const char *mapFileName)
Write field map data to a ROOT file.
Int_t GetNx() const
Definition BmnFieldMap.h:80
Bool_t fDebugInfo
Interpolated field (1-dim).
Double_t fPosBy
Double_t fXstep
Double_t GetScale() const
Accessor to global scaling factor.
Definition BmnFieldMap.h:90
Double_t fZstep
Double_t fPosBz
Double_t fXmin
Field limits in local coordinate system.
Double_t GetXmin() const
Accessors to field parameters in local coordinate system.
Definition BmnFieldMap.h:68
TArrayF * fBx
Arrays with the field values.
void ReadAsciiFile(const char *asciiFileName)
Reset the field parameters and data.
Double_t fZmax
Double_t GetZmax() const
Definition BmnFieldMap.h:74
Double_t fYmin
Double_t fYstep
static TString GetMapFilePath(TString mapName)
Get the expanded path to the field map file in the current installation.
void WriteAsciiFile(const char *asciiFileName)
Write the field map to an ASCII file.
Double_t fXmax
Double_t GetYmax() const
Definition BmnFieldMap.h:73
BmnFieldMap & operator=(const BmnFieldMap &)=delete