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;
35class FieldOriginBiasParam;
36}
37} // namespace o2
38namespace o2
39{
40namespace field
41{
42
47{
48
49 public:
53 enum { kOverrideGRP = BIT(14) }; // don't recreate from GRP if set
54
57
61 MagneticField(const char* name, const char* title, Double_t factorSol = 1., Double_t factorDip = 1.,
63 MagFieldParam::BeamType_t btype = MagFieldParam::kBeamTypepp, Double_t benergy = -1, Int_t integ = 2,
64 Double_t fmax = 15, const std::string path = "$(O2_ROOT)/share/Common/maps/mfchebKGI_sym.root");
65
67
69
71 ~MagneticField() override = default;
72
74 static MagneticField* createNominalField(int fld, bool uniform = false);
75
77 void CreateField();
78
80 void AllowFastField(bool v = true);
81
82 bool fastFieldExists() const
83 {
84 return !(mMapType == MagFieldParam::k5kGUniform || mDipoleOnOffFlag == true);
85 }
86
87 void rescaleField(float l3Cur, float diCur, bool uniform, int convention = 0);
88
90
92 Double_t GetBx(Double_t x, Double_t y, Double_t z) override
93 {
94 double xyz[3] = {x, y, z}, b[3];
96 return b[0];
97 }
98
100 Double_t GetBy(Double_t x, Double_t y, Double_t z) override
101 {
102 double xyz[3] = {x, y, z}, b[3];
104 return b[1];
105 }
106
108 Double_t GetBz(Double_t x, Double_t y, Double_t z) override
109 {
110 double xyz[3] = {x, y, z};
111 return getBz(xyz);
112 }
113
116 void Field(const Double_t* __restrict__ point, Double_t* __restrict__ bField) override;
117
118 void field(const math_utils::Point3D<float> xyz, float bxyz[3])
119 {
120 double xyzd[3] = {xyz.X(), xyz.Y(), xyz.Z()}, bxyzd[3] = {0};
121 Field(xyzd, bxyzd);
122 bxyz[0] = bxyzd[0];
123 bxyz[1] = bxyzd[1];
124 bxyz[2] = bxyzd[2];
125 }
126
127 void field(const math_utils::Point3D<double> xyz, double bxyz[3])
128 {
129 double xyzd[3] = {xyz.X(), xyz.Y(), xyz.Z()};
130 Field(xyzd, bxyz);
131 }
132
133 void field(const double* __restrict__ point, double* __restrict__ bField)
134 {
135 Field(point, bField);
136 }
137
138 void field(const float* __restrict__ point, float* __restrict__ bField)
139 {
140 double xyz[3] = {point[0], point[1], point[2]}, bxyz[3] = {0};
141 Field(xyz, bxyz);
142 bField[0] = bxyz[0];
143 bField[1] = bxyz[1];
144 bField[2] = bxyz[2];
145 }
146
148 void GetBxyz(const Double_t p[3], Double_t* b) override { MagneticField::Field(p, b); }
149
151 void FillParContainer() override;
152
154 void getTPCIntegral(const Double_t* xyz, Double_t* b) const;
155
157 void getTPCRatIntegral(const Double_t* xyz, Double_t* b) const;
158
160 void getTPCIntegralCylindrical(const Double_t* rphiz, Double_t* b) const;
161
164 void getTPCRatIntegralCylindrical(const Double_t* rphiz, Double_t* b) const;
165
167 Double_t getBz(const Double_t* xyz) const;
168
169 MagneticWrapperChebyshev* getMeasuredMap() const { return mMeasuredMap.get(); }
170
172 const MagFieldFast* getFastField() const { return mFastField.get(); }
173
174 // Former MagF methods or their aliases
175
177 void setFactorSolenoid(float fc = 1.);
178
180 void setFactorDipole(float fc = 1.);
181
183 Double_t getFactorSolenoid() const;
184
186 Double_t getFactorDipole() const;
187
188 Double_t Factor() const { return getFactorSolenoid(); }
189
190 Double_t getCurrentSolenoid() const
191 {
192 return getFactorSolenoid() * (mMapType == MagFieldParam::k2kG ? 12000 : 30000);
193 }
194
195 Double_t getCurrentDipole() const { return getFactorDipole() * 6000; }
196
197 Bool_t IsUniform() const { return mMapType == MagFieldParam::k5kGUniform; }
198
199 void MachineField(const Double_t* __restrict__ x, Double_t* __restrict__ b) const;
200
201 MagFieldParam::BMap_t getMapType() const { return mMapType; }
202
203 MagFieldParam::BeamType_t getBeamType() const { return mBeamType; }
204
206 const char* getBeamTypeText() const;
207
208 Double_t getBeamEnergy() const { return mBeamEnergy; }
209
210 Double_t Max() const { return mMaxField; }
211
212 Int_t Integral() const { return mDefaultIntegration; }
213
214 Int_t precIntegral() const { return mPrecisionInteg; }
215
216 Double_t solenoidField() const { return mSolenoid; }
217
218 Char_t* getDataFileName() const { return (Char_t*)mParameterNames.GetName(); }
219
220 Char_t* getParameterName() const { return (Char_t*)mParameterNames.GetTitle(); }
221
222 void setDataFileName(const Char_t* nm) { mParameterNames.SetName(nm); }
223
224 void setParameterName(const Char_t* nm) { mParameterNames.SetTitle(nm); }
225
227 void Print(Option_t* opt) const override;
228
229 Bool_t loadParameterization();
230
231 static Int_t getPolarityConvention() { return Int_t(sPolarityConvention); }
232
233 static MagFieldParam::BMap_t getFieldMapScale(float& l3, float& dip, bool uniform, int convention = 0);
234
241 static MagneticField* createFieldMap(float l3Current = -30000., float diCurrent = -6000., Int_t convention = 0,
242 Bool_t uniform = kFALSE, float beamenergy = 7000, const Char_t* btype = "pp",
243 const std::string path = std::string(gSystem->Getenv("VMCWORKDIR")) +
244 std::string("/Common/maps/mfchebKGI_sym.root"));
245
246 protected:
247 // not supposed to be changed during the run, set only at the initialization via constructor
248 void initializeMachineField(MagFieldParam::BeamType_t btype, Double_t benergy);
249
251
252 void setBeamEnergy(float energy) { mBeamEnergy = energy; }
253 void checkOriginBias();
254
255 private:
256 std::unique_ptr<MagneticWrapperChebyshev> mMeasuredMap;
257 std::unique_ptr<MagFieldFast> mFastField; // ! optional fast parametrization
258 MagFieldParam::BMap_t mMapType;
259 Double_t mSolenoid;
260 MagFieldParam::BeamType_t mBeamType;
261 Double_t mBeamEnergy;
262
263 Int_t mDefaultIntegration;
264 Int_t mPrecisionInteg;
265 Double_t mMultipicativeFactorSolenoid;
266 Double_t mMultipicativeFactorDipole;
267 Double_t mMaxField;
268 Bool_t mDipoleOnOffFlag;
269
270 Double_t mQuadrupoleGradient;
271 Double_t mDipoleField;
272 Double_t mCompensatorField2C;
273 Double_t mCompensatorField1A;
274 Double_t mCompensatorField2A;
275
276 TNamed mParameterNames;
277
278 static const FieldOriginBiasParam* gOriginBias;
279
280 static const Double_t sSolenoidToDipoleZ;
281 static const UShort_t sPolarityConvention;
282
284
285 ClassDefOverride(o2::field::MagneticField,
286 3) // Class for all Alice MagField wrapper for measured data + Tosca parameterization
287};
288} // namespace field
289} // namespace o2
290
291#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 ...