Project
Loading...
Searching...
No Matches
MagneticField.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
15
16#ifndef ALICEO2_FIELD_MAGNETICFIELD_H_
17#define ALICEO2_FIELD_MAGNETICFIELD_H_
18
19#include "FairField.h" // for FairField
20#include "Field/MagFieldParam.h"
21#include "Field/MagneticWrapperChebyshev.h" // for MagneticWrapperChebyshev
22#include "Field/MagFieldFast.h"
23#include "TSystem.h"
24#include "Rtypes.h" // for Double_t, Char_t, Int_t, Float_t, etc
25#include "TNamed.h" // for TNamed
26#include <memory> // for str::unique_ptr
27
28class FairParamList;
29
30namespace o2
31{
32namespace field
33{
34class MagneticWrapperChebyshev;
35}
36} // namespace o2
37namespace o2
38{
39namespace field
40{
41
46{
47
48 public:
52 enum { kOverrideGRP = BIT(14) }; // don't recreate from GRP if set
53
56
60 MagneticField(const char* name, const char* title, Double_t factorSol = 1., Double_t factorDip = 1.,
62 MagFieldParam::BeamType_t btype = MagFieldParam::kBeamTypepp, Double_t benergy = -1, Int_t integ = 2,
63 Double_t fmax = 15, const std::string path = "$(O2_ROOT)/share/Common/maps/mfchebKGI_sym.root");
64
66
68
70 ~MagneticField() override = default;
71
73 static MagneticField* createNominalField(int fld, bool uniform = false);
74
76 void CreateField();
77
79 void AllowFastField(bool v = true);
80
81 bool fastFieldExists() const
82 {
83 return !(mMapType == MagFieldParam::k5kGUniform || mDipoleOnOffFlag == true);
84 }
85
86 void rescaleField(float l3Cur, float diCur, bool uniform, int convention = 0);
87
89
91 Double_t GetBx(Double_t x, Double_t y, Double_t z) override
92 {
93 double xyz[3] = {x, y, z}, b[3];
95 return b[0];
96 }
97
99 Double_t GetBy(Double_t x, Double_t y, Double_t z) override
100 {
101 double xyz[3] = {x, y, z}, b[3];
103 return b[1];
104 }
105
107 Double_t GetBz(Double_t x, Double_t y, Double_t z) override
108 {
109 double xyz[3] = {x, y, z};
110 return getBz(xyz);
111 }
112
115 void Field(const Double_t* __restrict__ point, Double_t* __restrict__ bField) override;
116
117 void field(const math_utils::Point3D<float> xyz, float bxyz[3])
118 {
119 double xyzd[3] = {xyz.X(), xyz.Y(), xyz.Z()}, bxyzd[3] = {0};
120 Field(xyzd, bxyzd);
121 bxyz[0] = bxyzd[0];
122 bxyz[1] = bxyzd[1];
123 bxyz[2] = bxyzd[2];
124 }
125
126 void field(const math_utils::Point3D<double> xyz, double bxyz[3])
127 {
128 double xyzd[3] = {xyz.X(), xyz.Y(), xyz.Z()};
129 Field(xyzd, bxyz);
130 }
131
132 void field(const double* __restrict__ point, double* __restrict__ bField)
133 {
134 Field(point, bField);
135 }
136
137 void field(const float* __restrict__ point, float* __restrict__ bField)
138 {
139 double xyz[3] = {point[0], point[1], point[2]}, bxyz[3] = {0};
140 Field(xyz, bxyz);
141 bField[0] = bxyz[0];
142 bField[1] = bxyz[1];
143 bField[2] = bxyz[2];
144 }
145
147 void GetBxyz(const Double_t p[3], Double_t* b) override { MagneticField::Field(p, b); }
148
150 void FillParContainer() override;
151
153 void getTPCIntegral(const Double_t* xyz, Double_t* b) const;
154
156 void getTPCRatIntegral(const Double_t* xyz, Double_t* b) const;
157
159 void getTPCIntegralCylindrical(const Double_t* rphiz, Double_t* b) const;
160
163 void getTPCRatIntegralCylindrical(const Double_t* rphiz, Double_t* b) const;
164
166 Double_t getBz(const Double_t* xyz) const;
167
168 MagneticWrapperChebyshev* getMeasuredMap() const { return mMeasuredMap.get(); }
169
171 const MagFieldFast* getFastField() const { return mFastField.get(); }
172
173 // Former MagF methods or their aliases
174
176 void setFactorSolenoid(float fc = 1.);
177
179 void setFactorDipole(float fc = 1.);
180
182 Double_t getFactorSolenoid() const;
183
185 Double_t getFactorDipole() const;
186
187 Double_t Factor() const { return getFactorSolenoid(); }
188
189 Double_t getCurrentSolenoid() const
190 {
191 return getFactorSolenoid() * (mMapType == MagFieldParam::k2kG ? 12000 : 30000);
192 }
193
194 Double_t getCurrentDipole() const { return getFactorDipole() * 6000; }
195
196 Bool_t IsUniform() const { return mMapType == MagFieldParam::k5kGUniform; }
197
198 void MachineField(const Double_t* __restrict__ x, Double_t* __restrict__ b) const;
199
200 MagFieldParam::BMap_t getMapType() const { return mMapType; }
201
202 MagFieldParam::BeamType_t getBeamType() const { return mBeamType; }
203
205 const char* getBeamTypeText() const;
206
207 Double_t getBeamEnergy() const { return mBeamEnergy; }
208
209 Double_t Max() const { return mMaxField; }
210
211 Int_t Integral() const { return mDefaultIntegration; }
212
213 Int_t precIntegral() const { return mPrecisionInteg; }
214
215 Double_t solenoidField() const { return mSolenoid; }
216
217 Char_t* getDataFileName() const { return (Char_t*)mParameterNames.GetName(); }
218
219 Char_t* getParameterName() const { return (Char_t*)mParameterNames.GetTitle(); }
220
221 void setDataFileName(const Char_t* nm) { mParameterNames.SetName(nm); }
222
223 void setParameterName(const Char_t* nm) { mParameterNames.SetTitle(nm); }
224
226 void Print(Option_t* opt) const override;
227
228 Bool_t loadParameterization();
229
230 static Int_t getPolarityConvention() { return Int_t(sPolarityConvention); }
231
232 static MagFieldParam::BMap_t getFieldMapScale(float& l3, float& dip, bool uniform, int convention = 0);
233
240 static MagneticField* createFieldMap(float l3Current = -30000., float diCurrent = -6000., Int_t convention = 0,
241 Bool_t uniform = kFALSE, float beamenergy = 7000, const Char_t* btype = "pp",
242 const std::string path = std::string(gSystem->Getenv("VMCWORKDIR")) +
243 std::string("/Common/maps/mfchebKGI_sym.root"));
244
245 protected:
246 // not supposed to be changed during the run, set only at the initialization via constructor
247 void initializeMachineField(MagFieldParam::BeamType_t btype, Double_t benergy);
248
250
251 void setBeamEnergy(float energy) { mBeamEnergy = energy; }
252
253 private:
254 std::unique_ptr<MagneticWrapperChebyshev> mMeasuredMap;
255 std::unique_ptr<MagFieldFast> mFastField; // ! optional fast parametrization
256 MagFieldParam::BMap_t mMapType;
257 Double_t mSolenoid;
258 MagFieldParam::BeamType_t mBeamType;
259 Double_t mBeamEnergy;
260
261 Int_t mDefaultIntegration;
262 Int_t mPrecisionInteg;
263 Double_t mMultipicativeFactorSolenoid;
264 Double_t mMultipicativeFactorDipole;
265 Double_t mMaxField;
266 Bool_t mDipoleOnOffFlag;
267
268 Double_t mQuadrupoleGradient;
269 Double_t mDipoleField;
270 Double_t mCompensatorField2C;
271 Double_t mCompensatorField1A;
272 Double_t mCompensatorField2A;
273
274 TNamed mParameterNames;
275
276 static const Double_t sSolenoidToDipoleZ;
277 static const UShort_t sPolarityConvention;
278
280
281 ClassDefOverride(o2::field::MagneticField,
282 3) // Class for all Alice MagField wrapper for measured data + Tosca parameterization
283};
284} // namespace field
285} // namespace o2
286
287#endif
Definition of the fast magnetic field parametrization MagFieldFast.
Definition of the MagFieldParam: container for ALICE mag. field parameters.
void setBeamType(MagFieldParam::BeamType_t type)
const MagFieldFast * getFastField() const
get fast field direct pointer
static MagFieldParam::BMap_t getFieldMapScale(float &l3, float &dip, bool uniform, int convention=0)
Double_t getBz(const Double_t *xyz) const
Method to calculate the field at point xyz.
Double_t getFactorDipole() const
Return the sign*scale of the current in the Dipole according to sPolarityConventionthe.
Double_t GetBz(Double_t x, Double_t y, Double_t z) override
Z component.
Double_t GetBx(Double_t x, Double_t y, Double_t z) override
Virtual methods from FairField.
void getTPCRatIntegralCylindrical(const Double_t *rphiz, Double_t *b) const
void field(const math_utils::Point3D< double > xyz, double bxyz[3])
void MachineField(const Double_t *__restrict__ x, Double_t *__restrict__ b) const
const char * getBeamTypeText() const
Returns beam type in text form.
void field(const math_utils::Point3D< float > xyz, float bxyz[3])
void getTPCRatIntegral(const Double_t *xyz, Double_t *b) const
Method to calculate the integral_0^z of br,bt,bz.
void rescaleField(float l3Cur, float diCur, bool uniform, int convention=0)
void getTPCIntegralCylindrical(const Double_t *rphiz, Double_t *b) const
Method to calculate the integral_0^z of br,bt,bz in cylindrical coordinates ( -pi<phi<pi convention )
Char_t * getDataFileName() const
void setDataFileName(const Char_t *nm)
static MagneticField * createFieldMap(float l3Current=-30000., float diCurrent=-6000., Int_t convention=0, Bool_t uniform=kFALSE, float beamenergy=7000, const Char_t *btype="pp", const std::string path=std::string(gSystem->Getenv("VMCWORKDIR"))+std::string("/Common/maps/mfchebKGI_sym.root"))
void setFactorDipole(float fc=1.)
Sets the sign*scale of the current in the Dipole according to sPolarityConvention.
MagneticField & operator=(const MagneticField &src)
void AllowFastField(bool v=true)
allow fast field param
Double_t GetBy(Double_t x, Double_t y, Double_t z) override
Y component, avoid using since slow.
Double_t getBeamEnergy() const
void setBeamEnergy(float energy)
Double_t getCurrentDipole() const
void field(const float *__restrict__ point, float *__restrict__ bField)
void FillParContainer() override
Fill Paramater.
Double_t getFactorSolenoid() const
Returns the sign*scale of the current in the Dipole according to sPolarityConventionthe.
Double_t getCurrentSolenoid() const
static Int_t getPolarityConvention()
void Field(const Double_t *__restrict__ point, Double_t *__restrict__ bField) override
MagFieldParam::BeamType_t getBeamType() const
MagFieldParam::BMap_t getMapType() const
void getTPCIntegral(const Double_t *xyz, Double_t *b) const
Method to calculate the integral_0^z of br,bt,bz.
void setParameterName(const Char_t *nm)
~MagneticField() override=default
Default destructor.
void Print(Option_t *opt) const override
Prints short or long info.
Char_t * getParameterName() const
MagneticField()
Default constructor.
void GetBxyz(const Double_t p[3], Double_t *b) override
3d field query alias for Alias Method to calculate the field at point xyz
void setFactorSolenoid(float fc=1.)
Sets the sign/scale of the current in the L3 according to sPolarityConvention.
void field(const double *__restrict__ point, double *__restrict__ bField)
MagneticWrapperChebyshev * getMeasuredMap() const
void CreateField()
real field creation is here
static MagneticField * createNominalField(int fld, bool uniform=false)
create field from rounded value, i.e. +-5 or +-2 kGauss
Double_t solenoidField() const
void initializeMachineField(MagFieldParam::BeamType_t btype, Double_t benergy)
Double_t Factor() const
GLint GLenum GLint x
Definition glcorearb.h:403
GLenum src
Definition glcorearb.h:1767
const GLdouble * v
Definition glcorearb.h:832
GLuint const GLchar * name
Definition glcorearb.h:781
GLboolean GLboolean GLboolean b
Definition glcorearb.h:1233
GLint y
Definition glcorearb.h:270
GLint GLint GLsizei GLint GLenum GLenum type
Definition glcorearb.h:275
GLsizei const GLchar *const * path
Definition glcorearb.h:3591
GLenum GLfloat param
Definition glcorearb.h:271
GLdouble GLdouble GLdouble z
Definition glcorearb.h:843
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...