SND@LHC Software
Loading...
Searching...
No Matches
ShipBFieldMap.h
Go to the documentation of this file.
1
6#ifndef ShipBFieldMap_H
7#define ShipBFieldMap_H
8
9#include "TGeoMatrix.h"
10#include "TVirtualMagField.h"
11
12#include <string>
13#include <utility>
14#include <vector>
15
16class ShipBFieldMap : public TVirtualMagField
17{
18
19 public:
20
22
34 ShipBFieldMap(const std::string& label, const std::string& mapFileName,
35 Float_t xOffset = 0.0, Float_t yOffset = 0.0, Float_t zOffset = 0.0,
36 Float_t phi = 0.0, Float_t theta = 0.0, Float_t psi = 0.0,
37 Float_t scale = 1.0, Bool_t isSymmetric = kFALSE);
38
41
53 ShipBFieldMap(const std::string& newName, const ShipBFieldMap& rhs,
54 Float_t newXOffset, Float_t newYOffset, Float_t newZOffset,
55 Float_t newPhi = 0.0, Float_t newTheta = 0.0, Float_t newPsi = 0.0,
56 Float_t newScale = 1.0);
57
59 virtual ~ShipBFieldMap();
60
62
66 virtual void Field(const Double_t* position, Double_t* B);
67
69 typedef std::vector< std::vector<Float_t> > floatArray;
70
72
75 floatArray* getFieldMap() const {return fieldMap_;}
76
78
81 void SetXOffset(Float_t xValue) {xOffset_ = xValue;}
82
84
87 void SetYOffset(Float_t yValue) {yOffset_ = yValue;}
88
90
93 void SetZOffset(Float_t zValue) {zOffset_ = zValue;}
94
96
99 void SetPhi(Float_t phi) {phi_ = phi;}
100
102
105 void SetTheta(Float_t theta) {theta_ = theta;}
106
108
111 void SetPsi(Float_t psi) {psi_ = psi;}
112
114
117 void SetScale(Float_t scale) {scale_ = scale;}
118
120
123 void UseSymmetry(Bool_t flag) {isSymmetric_ = flag;}
124
125
127
130 std::string GetMapFileName() const {return mapFileName_;}
131
133
136 Int_t GetNx() const {return Nx_;}
137
139
142 Int_t GetNy() const {return Ny_;}
143
145
148 Int_t GetNz() const {return Nz_;}
149
151
154 Int_t GetNBins() const {return N_;}
155
157
160 Float_t GetXMin() const {return xMin_;}
161
163
166 Float_t GetXMax() const {return xMax_;}
167
169
172 Float_t GetdX() const {return dx_;}
173
175
178 Float_t GetXRange() const {return xRange_;}
179
181
184 Float_t GetYMin() const {return yMin_;}
185
187
190 Float_t GetYMax() const {return yMax_;}
191
193
196 Float_t GetdY() const {return dy_;}
197
199
202 Float_t GetYRange() const {return yRange_;}
203
205
208 Float_t GetZMin() const {return zMin_;}
209
211
214 Float_t GetZMax() const {return zMax_;}
215
217
220 Float_t GetdZ() const {return dz_;}
221
223
226 Float_t GetZRange() const {return zRange_;}
227
229
232 Float_t GetXOffset() const {return xOffset_;}
233
235
238 Float_t GetYOffset() const {return yOffset_;}
239
241
244 Float_t GetZOffset() const {return zOffset_;}
245
247
250 Float_t GetPhi() const {return phi_;}
251
253
256 Float_t GetTheta() const {return theta_;}
257
259
262 Float_t GetPsi() const {return psi_;}
263
265
268 Float_t GetScale() const {return scale_;}
269
271
274 Bool_t HasSymmetry() const {return isSymmetric_;}
275
277
280 Bool_t IsACopy() const {return isCopy_;}
281
284
285
286 protected:
287
288 private:
289
292
295
298
300 void initialise();
301
303 void readMapFile();
304
306 void readRootFile();
307
309 void readTextFile();
310
311 // ! Set the coordinate limits from information stored in the datafile
312 void setLimits();
313
315
321 Bool_t insideRange(Float_t x, Float_t y, Float_t z);
322
324 typedef std::pair<Int_t, Float_t> binPair;
325
327
332 binPair getBinInfo(Float_t x, CoordAxis theAxis);
333
335
341 Int_t getMapBin(Int_t iX, Int_t iY, Int_t iZ);
342
345
349 Float_t BInterCalc(CoordAxis theAxis);
350
354
356 std::string mapFileName_;
357
360
362 Bool_t isCopy_;
363
365 Int_t Nx_;
366
368 Int_t Ny_;
369
371 Int_t Nz_;
372
374 Int_t N_;
375
377 Float_t xMin_;
378
380 Float_t xMax_;
381
383 Float_t dx_;
384
386 Float_t xRange_;
387
389 Float_t yMin_;
390
392 Float_t yMax_;
393
395 Float_t dy_;
396
398 Float_t yRange_;
399
401 Float_t zMin_;
402
404 Float_t zMax_;
405
407 Float_t dz_;
408
410 Float_t zRange_;
411
413 Float_t xOffset_;
414
416 Float_t yOffset_;
417
419 Float_t zOffset_;
420
422 Float_t phi_;
423
425 Float_t theta_;
426
428 Float_t psi_;
429
431 Float_t scale_;
432
435
437 TGeoMatrix* theTrans_;
438
440 Float_t Tesla_;
441
443 Int_t binA_;
444
446 Int_t binB_;
447
449 Int_t binC_;
450
452 Int_t binD_;
453
455 Int_t binE_;
456
458 Int_t binF_;
459
461 Int_t binG_;
462
464 Int_t binH_;
465
467 Float_t xFrac_;
468
470 Float_t yFrac_;
471
473 Float_t zFrac_;
474
476 Float_t xFrac1_;
477
479 Float_t yFrac1_;
480
482 Float_t zFrac1_;
483
484};
485
486#endif
Class that defines a (3d) magnetic field map (distances in cm, fields in tesla)
Float_t zFrac_
Fractional bin distance along z.
Float_t xMax_
The maximum value of x for the map.
void SetZOffset(Float_t zValue)
Set the z global co-ordinate shift.
void SetScale(Float_t scale)
Set the field magnitude scaling factor.
ShipBFieldMap & operator=(const ShipBFieldMap &rhs)
Copy assignment operator not implemented.
Int_t binD_
Bin D for the trilinear interpolation.
Float_t GetZMin() const
Get the minimum value of z for the map.
Float_t dy_
The bin width along y.
Float_t GetXMax() const
Get the maximum value of x for the map.
Float_t psi_
The third Euler rotation angle about the new z axis.
Int_t GetNBins() const
Get the total numer of bins.
Float_t dz_
The bin width along z.
Float_t zRange_
The co-ordinate range along z.
std::pair< Int_t, Float_t > binPair
Typedef for an int-double pair.
std::vector< std::vector< Float_t > > floatArray
Typedef for a vector containing a vector of floats.
Bool_t HasSymmetry() const
Get the boolean flag to specify if we have quadrant symmetry.
Float_t GetYOffset() const
Get the y offset co-ordinate of the map for global positioning.
Float_t zFrac1_
Complimentary fractional bin distance along z.
Int_t binE_
Bin E for the trilinear interpolation.
Float_t BInterCalc(CoordAxis theAxis)
Int_t Nz_
The number of bins along z.
Float_t Tesla_
Double converting Tesla to kiloGauss (for VMC/FairRoot B field units)
Float_t GetXRange() const
Get the x co-ordinate range for the map.
Int_t N_
The total number of bins.
Float_t GetTheta() const
Get the second Euler rotation angle about the new x axis for global positioning.
floatArray * fieldMap_
Float_t yFrac1_
Complimentary fractional bin distance along y.
Float_t xFrac_
Fractional bin distance along x.
Int_t GetNy() const
Get the number of bins along y.
Float_t yMin_
The minimum value of y for the map.
Float_t zOffset_
The z value of the positional offset for the map.
std::string mapFileName_
The name of the map file.
Bool_t initialised_
Initialisation boolean.
void SetPhi(Float_t phi)
Set the first Euler rotation angle phi about the z axis.
Int_t Ny_
The number of bins along y.
Float_t GetdX() const
Get the bin width along x for the map.
std::string GetMapFileName() const
Get the name of the map file.
Float_t theta_
The second Euler rotation angle about the new x axis.
Float_t yFrac_
Fractional bin distance along y.
Bool_t isCopy_
Flag to specify if we are a copy of the field map (just a change of global offsets)
Int_t binC_
Bin C for the trilinear interpolation.
Bool_t IsACopy() const
Get the boolean flag to specify if we are a "copy".
virtual void Field(const Double_t *position, Double_t *B)
Implementation of evaluating the B field.
Int_t binG_
Bin G for the trilinear interpolation.
Int_t binH_
Bin H for the trilinear interpolation.
Float_t xMin_
The minimum value of x for the map.
void initialise()
Initialisation.
void SetYOffset(Float_t yValue)
Set the y global co-ordinate shift.
Int_t GetNz() const
Get the number of bins along z.
Int_t binB_
Bin B for the trilinear interpolation.
Int_t binF_
Bin F for the trilinear interpolation.
CoordAxis
Enumeration to specify the co-ordinate type.
void SetXOffset(Float_t xValue)
Set the x global co-ordinate shift.
Float_t GetYRange() const
Get the y co-ordinate range for the map.
Float_t GetScale() const
Get the field magnitude scaling factor.
void SetPsi(Float_t psi)
Set the third Euler rotation angle psi about the new z axis.
floatArray * getFieldMap() const
Retrieve the field map.
void UseSymmetry(Bool_t flag)
Set the boolean to specify if we have quadrant symmetry.
Float_t GetPsi() const
Get the third Euler rotation angle about the new z axis for global positioning.
ClassDef(ShipBFieldMap, 1)
ClassDef for ROOT.
Int_t Nx_
The number of bins along x.
Float_t GetdY() const
Get the bin width along y for the map.
Float_t xRange_
The co-ordinate range along x.
Float_t yOffset_
The y value of the positional offset for the map.
void readTextFile()
Process the text file containing the field map data.
Float_t scale_
The B field magnitude scaling factor.
TGeoMatrix * theTrans_
The combined translation and rotation transformation.
binPair getBinInfo(Float_t x, CoordAxis theAxis)
Get the bin number and fractional distance from the leftmost bin edge.
Float_t GetPhi() const
Get the first Euler rotation angle about the z axis for global positioning.
Bool_t insideRange(Float_t x, Float_t y, Float_t z)
Check to see if a point is within the map validity range.
void SetTheta(Float_t theta)
Set the second Euler rotation angle theta about the new x axis.
virtual ~ShipBFieldMap()
Destructor.
void readRootFile()
Process the ROOT file containing the field map data.
Float_t GetdZ() const
Get the bin width along z for the map.
Float_t xFrac1_
Complimentary fractional bin distance along x.
Int_t binA_
Bin A for the trilinear interpolation.
void readMapFile()
Read the field map data and store the information internally.
Float_t GetXOffset() const
Get the x offset co-ordinate of the map for global positioning.
Int_t getMapBin(Int_t iX, Int_t iY, Int_t iZ)
Find the vector entry of the field map data given the bins iX, iY and iZ.
Float_t yMax_
The maximum value of y for the map.
Float_t yRange_
The co-ordinate range along y.
Float_t zMax_
The maximum value of z for the map.
Float_t phi_
The first Euler rotation angle about the z axis.
Float_t GetZMax() const
Get the maximum value of z for the map.
Float_t GetYMax() const
Get the maximum value of y for the map.
Float_t zMin_
The minimum value of z for the map.
Float_t GetYMin() const
Get the minimum value of y for the map.
Float_t dx_
The bin width along x.
ShipBFieldMap(const ShipBFieldMap &rhs)
Copy constructor not implemented.
Float_t GetXMin() const
Get the minimum value of x for the map.
Bool_t isSymmetric_
The boolean specifying if we have quadrant symmetry.
Int_t GetNx() const
Get the number of bins along x.
Float_t xOffset_
The x value of the positional offset for the map.
Float_t GetZRange() const
Get the z co-ordinate range for the map.
Float_t GetZOffset() const
Get the z offset co-ordinate of the map for global positioning.