Project
Loading...
Searching...
No Matches
MagneticWrapperChebyshev.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_MAGNETICWRAPPERCHEBYSHEV_H_
17#define ALICEO2_FIELD_MAGNETICWRAPPERCHEBYSHEV_H_
18
19#include <TMath.h> // for ATan2, Cos, Sin, Sqrt
20#include <TNamed.h> // for TNamed
21#include <TObjArray.h> // for TObjArray
22#include "MathUtils/Chebyshev3D.h" // for Chebyshev3D
23#include "MathUtils/Chebyshev3DCalc.h" // for _INC_CREATION_Chebyshev3D_
24#include "Rtypes.h" // for Double_t, Int_t, Float_t, etc
25
26namespace o2
27{
28namespace field
29{
30
52class MagneticWrapperChebyshev : public TNamed
53{
54
55 public:
58
61
63 {
64 Clear();
65 }
66
69
72
74 void Clear(const Option_t* = "") override;
75
77 {
78 return mNumberOfParameterizationSolenoid;
79 }
80
82 {
83 return mNumberOfDistinctZSegmentsSolenoid;
84 }
85
87 {
88 return mCoordinatesSegmentsZSolenoid;
89 }
90
92 {
93 return mNumberOfParameterizationTPC;
94 }
95
97 {
98 return mNumberOfDistinctZSegmentsTPC;
99 }
100
102 {
103 return mNumberOfParameterizationTPCRat;
104 }
105
107 {
108 return mNumberOfDistinctZSegmentsTPCRat;
109 }
110
112 {
113 return mNumberOfParameterizationDipole;
114 }
115
117 {
118 return mNumberOfDistinctZSegmentsDipole;
119 }
120
122 {
123 return getMaxZSol();
124 }
125
127 {
128 return mParameterizationDipole ? getMinZDip() : getMinZSol();
129 }
130
132 {
133 return mMinZSolenoid;
134 }
135
137 {
138 return mMaxZSolenoid;
139 }
140
142 {
143 return mMaxRadiusSolenoid;
144 }
145
147 {
148 return mMinDipoleZ;
149 }
150
152 {
153 return mMaxDipoleZ;
154 }
155
157 {
158 return mMinZTPC;
159 }
160
162 {
163 return mMaxZTPC;
164 }
165
167 {
168 return mMaxRadiusTPC;
169 }
170
172 {
173 return mMinZTPCRat;
174 }
175
177 {
178 return mMaxZTPCRat;
179 }
180
182 {
183 return mMaxRadiusTPCRat;
184 }
185
187 {
188 return (o2::math_utils::Chebyshev3D*)mParameterizationSolenoid->UncheckedAt(ipar);
189 }
190
192 {
193 return (o2::math_utils::Chebyshev3D*)mParameterizationTPCRat->UncheckedAt(ipar);
194 }
195
197 {
198 return (o2::math_utils::Chebyshev3D*)mParameterizationTPC->UncheckedAt(ipar);
199 }
200
202 {
203 return (o2::math_utils::Chebyshev3D*)mParameterizationDipole->UncheckedAt(ipar);
204 }
205
207 void Print(Option_t* = "") const override;
208
211 virtual void Field(const Double_t* xyz, Double_t* b) const;
212
215 Double_t getBz(const Double_t* xyz) const;
216
217 void fieldCylindrical(const Double_t* rphiz, Double_t* b) const;
218
221 void getTPCIntegral(const Double_t* xyz, Double_t* b) const;
222
223 // Computes field integral in TPC region in Cylindircal coordinates
224 // note: the check for the point being inside the parameterized region is done outside
225 void getTPCIntegralCylindrical(const Double_t* rphiz, Double_t* b) const;
226
229 void getTPCRatIntegral(const Double_t* xyz, Double_t* b) const;
230
231 // Computes field integral in TPCRat region in Cylindircal coordinates
232 // note: the check for the point being inside the parameterized region is done outside
233 void getTPCRatIntegralCylindrical(const Double_t* rphiz, Double_t* b) const;
234
236 Int_t findSolenoidSegment(const Double_t* xyz) const;
237
239 Int_t findTPCSegment(const Double_t* xyz) const;
240
242 Int_t findTPCRatSegment(const Double_t* xyz) const;
243
245 Int_t findDipoleSegment(const Double_t* xyz) const;
246
247 static void cylindricalToCartesianCylB(const Double_t* rphiz, const Double_t* brphiz, Double_t* bxyz);
248
249 static void cylindricalToCartesianCartB(const Double_t* xyz, const Double_t* brphiz, Double_t* bxyz);
250
251 static void cartesianToCylindricalCartB(const Double_t* xyz, const Double_t* bxyz, Double_t* brphiz);
252
253 static void cartesianToCylindricalCylB(const Double_t* rphiz, const Double_t* bxyz, Double_t* brphiz);
254
255 static void cartesianToCylindrical(const Double_t* xyz, Double_t* rphiz);
256
257 static void cylindricalToCartesian(const Double_t* rphiz, Double_t* xyz);
258
259#ifdef _INC_CREATION_Chebyshev3D_ // see Cheb3D.h for explanation
261 void loadData(const char* inpfile);
262
264 MagneticWrapperChebyshev(const char* inputFile);
265
267 void saveData(const char* outfile) const;
268
271 Int_t segmentDimension(Float_t** seg, const TObjArray* par, int npar, int dim, Float_t xmn, Float_t xmx, Float_t ymn,
272 Float_t ymx, Float_t zmn, Float_t zmx);
273
276 void addParameterSolenoid(const o2::math_utils::Chebyshev3D* param);
277
278 // Adds new parameterization piece for TPCIntegral
279 // NOTE: pieces must be added strictly in increasing R then increasing Z order
280
281 void addParameterTPCIntegral(const o2::math_utils::Chebyshev3D* param);
283 // NOTE: pieces must be added strictly in increasing R then increasing Z order
284 void addParameterTPCRatIntegral(const o2::math_utils::Chebyshev3D* param);
285
287 void addParameterDipole(const o2::math_utils::Chebyshev3D* param);
288
290 void buildTable(Int_t npar, TObjArray* parArr, Int_t& nZSeg, Int_t& nYSeg, Int_t& nXSeg, Float_t& minZ, Float_t& maxZ,
291 Float_t** segZ, Float_t** segY, Float_t** segX, Int_t** begSegY, Int_t** nSegY, Int_t** begSegX,
292 Int_t** nSegX, Int_t** segID);
293
295 void buildTableSolenoid();
296
298 void buildTableDipole();
299
301 void buildTableTPCIntegral();
302
304 void buildTableTPCRatIntegral();
305
307 void resetTPCIntegral();
308
310 void resetTPCRatIntegral();
311
313 void resetSolenoid();
314
316 void resetDipole();
317#endif
318
319 protected:
322 void fieldCylindricalSolenoid(const Double_t* rphiz, Double_t* b) const;
323
326 Double_t fieldCylindricalSolenoidBz(const Double_t* rphiz) const;
327
328 private:
329 Int_t mNumberOfParameterizationSolenoid;
330 Int_t mNumberOfDistinctZSegmentsSolenoid;
331 Int_t mNumberOfDistinctPSegmentsSolenoid;
332 Int_t mNumberOfDistinctRSegmentsSolenoid;
333 Float_t*
334 mCoordinatesSegmentsZSolenoid; //[mNumberOfDistinctZSegmentsSolenoid] coordinates of distinct Z segments in Solenoid
335 Float_t* mCoordinatesSegmentsPSolenoid; //[mNumberOfDistinctPSegmentsSolenoid] coordinates of P segments for each
336 // Zsegment in Solenoid
337 Float_t* mCoordinatesSegmentsRSolenoid; //[mNumberOfDistinctRSegmentsSolenoid] coordinates of R segments for each
338 // Psegment in Solenoid
339 Int_t* mBeginningOfSegmentsPSolenoid; //[mNumberOfDistinctPSegmentsSolenoid] beginning of P segments array for each Z
340 // segment
341 Int_t* mNumberOfSegmentsPSolenoid; //[mNumberOfDistinctZSegmentsSolenoid] number of P segments for each Z segment
342 Int_t* mBeginningOfSegmentsRSolenoid; //[mNumberOfDistinctPSegmentsSolenoid] beginning of R segments array for each P
343 // segment
344 Int_t* mNumberOfRSegmentsSolenoid; //[mNumberOfDistinctPSegmentsSolenoid] number of R segments for each P segment
345 Int_t*
346 mSegmentIdSolenoid; //[mNumberOfDistinctRSegmentsSolenoid] ID of the solenoid parameterization for given RPZ segment
347 Float_t mMinZSolenoid;
348 Float_t mMaxZSolenoid;
349 TObjArray* mParameterizationSolenoid;
350 Float_t mMaxRadiusSolenoid;
351
352 Int_t mNumberOfParameterizationTPC;
353 Int_t mNumberOfDistinctZSegmentsTPC;
354 Int_t mNumberOfDistinctPSegmentsTPC;
355 Int_t mNumberOfDistinctRSegmentsTPC;
356 Float_t* mCoordinatesSegmentsZTPC; //[mNumberOfDistinctZSegmentsTPC] coordinates of distinct Z segments in TPCint
357 Float_t*
358 mCoordinatesSegmentsPTPC; //[mNumberOfDistinctPSegmentsTPC] coordinates of P segments for each Zsegment in TPCint
359 Float_t*
360 mCoordinatesSegmentsRTPC; //[mNumberOfDistinctRSegmentsTPC] coordinates of R segments for each Psegment in TPCint
361 Int_t* mBeginningOfSegmentsPTPC; //[mNumberOfDistinctPSegmentsTPC] beginning of P segments array for each Z segment
362 Int_t* mNumberOfSegmentsPTPC; //[mNumberOfDistinctZSegmentsTPC] number of P segments for each Z segment
363 Int_t* mBeginningOfSegmentsRTPC; //[mNumberOfDistinctPSegmentsTPC] beginning of R segments array for each P segment
364 Int_t* mNumberOfRSegmentsTPC; //[mNumberOfDistinctPSegmentsTPC] number of R segments for each P segment
365 Int_t* mSegmentIdTPC; //[mNumberOfDistinctRSegmentsTPC] ID of the TPCint parameterization for given RPZ segment
366 Float_t mMinZTPC;
367 Float_t mMaxZTPC;
368 TObjArray* mParameterizationTPC;
369 Float_t mMaxRadiusTPC;
370
371 Int_t
372 mNumberOfParameterizationTPCRat;
374 Int_t mNumberOfDistinctZSegmentsTPCRat;
375 Int_t mNumberOfDistinctPSegmentsTPCRat;
376 Int_t mNumberOfDistinctRSegmentsTPCRat;
377 Float_t*
378 mCoordinatesSegmentsZTPCRat; //[mNumberOfDistinctZSegmentsTPCRat] coordinates of distinct Z segments in TpcRatInt
379 Float_t* mCoordinatesSegmentsPTPCRat; //[mNumberOfDistinctPSegmentsTPCRat] coordinates of P segments for each Zsegment
380 // in TpcRatInt
381 Float_t* mCoordinatesSegmentsRTPCRat; //[mNumberOfDistinctRSegmentsTPCRat] coordinates of R segments for each Psegment
382 // in TpcRatInt
383 Int_t*
384 mBeginningOfSegmentsPTPCRat; //[mNumberOfDistinctPSegmentsTPCRat] beginning of P segments array for each Z segment
385 Int_t* mNumberOfSegmentsPTPCRat; //[mNumberOfDistinctZSegmentsTPCRat] number of P segments for each Z segment
386 Int_t*
387 mBeginningOfSegmentsRTPCRat; //[mNumberOfDistinctPSegmentsTPCRat] beginning of R segments array for each P segment
388 Int_t* mNumberOfRSegmentsTPCRat; //[mNumberOfDistinctPSegmentsTPCRat] number of R segments for each P segment
389 Int_t*
390 mSegmentIdTPCRat; //[mNumberOfDistinctRSegmentsTPCRat] ID of the TpcRatInt parameterization for given RPZ segment
391 Float_t mMinZTPCRat;
392 Float_t mMaxZTPCRat;
393 TObjArray* mParameterizationTPCRat;
394 Float_t mMaxRadiusTPCRat;
395
396 Int_t mNumberOfParameterizationDipole;
397 Int_t mNumberOfDistinctZSegmentsDipole;
398 Int_t mNumberOfDistinctYSegmentsDipole;
399 Int_t mNumberOfDistinctXSegmentsDipole;
400 Float_t*
401 mCoordinatesSegmentsZDipole; //[mNumberOfDistinctZSegmentsDipole] coordinates of distinct Z segments in Dipole
402 Float_t* mCoordinatesSegmentsYDipole; //[mNumberOfDistinctYSegmentsDipole] coordinates of Y segments for each Zsegment
403 // in Dipole
404 Float_t* mCoordinatesSegmentsXDipole; //[mNumberOfDistinctXSegmentsDipole] coordinates of X segments for each Ysegment
405 // in Dipole
406 Int_t*
407 mBeginningOfSegmentsYDipole; //[mNumberOfDistinctZSegmentsDipole] beginning of Y segments array for each Z segment
408 Int_t* mNumberOfSegmentsYDipole; //[mNumberOfDistinctZSegmentsDipole] number of Y segments for each Z segment
409 Int_t*
410 mBeginningOfSegmentsXDipole; //[mNumberOfDistinctYSegmentsDipole] beginning of X segments array for each Y segment
411 Int_t* mNumberOfSegmentsXDipole; //[mNumberOfDistinctYSegmentsDipole] number of X segments for each Y segment
412 Int_t* mSegmentIdDipole; //[mNumberOfDistinctXSegmentsDipole] ID of the dipole parameterization for given XYZ segment
413 Float_t mMinDipoleZ;
414 Float_t mMaxDipoleZ;
415 TObjArray* mParameterizationDipole;
416
418 2) // Wrapper class for the set of Chebishev parameterizations of Alice mag.field
419};
420
422inline void MagneticWrapperChebyshev::fieldCylindrical(const Double_t* rphiz, Double_t* b) const
423{
424 // if (rphiz[2]<GetMinZSol() || rphiz[2]>GetMaxZSol() || rphiz[0]>GetMaxRSol()) {for (int i=3;i--;) b[i]=0; return;}
425 b[0] = b[1] = b[2] = 0;
427}
428
430inline void MagneticWrapperChebyshev::cylindricalToCartesianCylB(const Double_t* rphiz, const Double_t* brphiz,
431 Double_t* bxyz)
432{
433 Double_t btr = TMath::Sqrt(brphiz[0] * brphiz[0] + brphiz[1] * brphiz[1]);
434 Double_t psiPLUSphi = TMath::ATan2(brphiz[1], brphiz[0]) + rphiz[1];
435 bxyz[0] = btr * TMath::Cos(psiPLUSphi);
436 bxyz[1] = btr * TMath::Sin(psiPLUSphi);
437 bxyz[2] = brphiz[2];
438}
439
441inline void MagneticWrapperChebyshev::cylindricalToCartesianCartB(const Double_t* xyz, const Double_t* brphiz,
442 Double_t* bxyz)
443{
444 Double_t btr = TMath::Sqrt(brphiz[0] * brphiz[0] + brphiz[1] * brphiz[1]);
445 Double_t phiPLUSpsi = TMath::ATan2(xyz[1], xyz[0]) + TMath::ATan2(brphiz[1], brphiz[0]);
446 bxyz[0] = btr * TMath::Cos(phiPLUSpsi);
447 bxyz[1] = btr * TMath::Sin(phiPLUSpsi);
448 bxyz[2] = brphiz[2];
449}
450
452inline void MagneticWrapperChebyshev::cartesianToCylindricalCartB(const Double_t* xyz, const Double_t* bxyz,
453 Double_t* brphiz)
454{
455 Double_t btr = TMath::Sqrt(bxyz[0] * bxyz[0] + bxyz[1] * bxyz[1]);
456 Double_t psiMINphi = TMath::ATan2(bxyz[1], bxyz[0]) - TMath::ATan2(xyz[1], xyz[0]);
457
458 brphiz[0] = btr * TMath::Cos(psiMINphi);
459 brphiz[1] = btr * TMath::Sin(psiMINphi);
460 brphiz[2] = bxyz[2];
461}
462
464inline void MagneticWrapperChebyshev::cartesianToCylindricalCylB(const Double_t* rphiz, const Double_t* bxyz,
465 Double_t* brphiz)
466{
467 Double_t btr = TMath::Sqrt(bxyz[0] * bxyz[0] + bxyz[1] * bxyz[1]);
468 Double_t psiMINphi = TMath::ATan2(bxyz[1], bxyz[0]) - rphiz[1];
469 brphiz[0] = btr * TMath::Cos(psiMINphi);
470 brphiz[1] = btr * TMath::Sin(psiMINphi);
471 brphiz[2] = bxyz[2];
472}
473
474inline void MagneticWrapperChebyshev::cartesianToCylindrical(const Double_t* xyz, Double_t* rphiz)
475{
476 rphiz[0] = TMath::Sqrt(xyz[0] * xyz[0] + xyz[1] * xyz[1]);
477 rphiz[1] = TMath::ATan2(xyz[1], xyz[0]);
478 rphiz[2] = xyz[2];
479}
480
481inline void MagneticWrapperChebyshev::cylindricalToCartesian(const Double_t* rphiz, Double_t* xyz)
482{
483 xyz[0] = rphiz[0] * TMath::Cos(rphiz[1]);
484 xyz[1] = rphiz[0] * TMath::Sin(rphiz[1]);
485 xyz[2] = rphiz[2];
486}
487} // namespace field
488} // namespace o2
489
490#endif
o2::mch::mapping::CathodeSegmentation seg
void fieldCylindricalSolenoid(const Double_t *rphiz, Double_t *b) const
o2::math_utils::Chebyshev3D * getParameterDipole(Int_t ipar) const
static void cartesianToCylindricalCartB(const Double_t *xyz, const Double_t *bxyz, Double_t *brphiz)
Converts field in cylindrical coordinates to cartesian system, poin is in cart.system.
MagneticWrapperChebyshev & operator=(const MagneticWrapperChebyshev &rhs)
Assignment operator.
void Print(Option_t *="") const override
Prints info.
void copyFrom(const MagneticWrapperChebyshev &src)
Copy method.
o2::math_utils::Chebyshev3D * getParameterTPCRatIntegral(Int_t ipar) const
Double_t getBz(const Double_t *xyz) const
void Clear(const Option_t *="") override
Clears all dynamic parts.
Double_t fieldCylindricalSolenoidBz(const Double_t *rphiz) const
static void cylindricalToCartesian(const Double_t *rphiz, Double_t *xyz)
static void cartesianToCylindricalCylB(const Double_t *rphiz, const Double_t *bxyz, Double_t *brphiz)
Converts field in cylindrical coordinates to cartesian system, point is in cyl.system.
Int_t findDipoleSegment(const Double_t *xyz) const
Finds the segment containing point xyz. If it is outside it finds the closest segment.
void getTPCIntegralCylindrical(const Double_t *rphiz, Double_t *b) const
static void cylindricalToCartesianCylB(const Double_t *rphiz, const Double_t *brphiz, Double_t *bxyz)
Converts field in cylindrical coordinates to cartesian system, point is in cyl.system.
o2::math_utils::Chebyshev3D * getParameterSolenoid(Int_t ipar) const
void getTPCRatIntegral(const Double_t *xyz, Double_t *b) const
Int_t findTPCRatSegment(const Double_t *xyz) const
Finds the segment containing point xyz. If it is outside it finds the closest segment.
virtual void Field(const Double_t *xyz, Double_t *b) const
static void cylindricalToCartesianCartB(const Double_t *xyz, const Double_t *brphiz, Double_t *bxyz)
Converts field in cylindrical coordinates to cartesian system, point is in cart.system.
void getTPCIntegral(const Double_t *xyz, Double_t *b) const
Int_t findTPCSegment(const Double_t *xyz) const
Finds the segment containing point xyz. If it is outside it finds the closest segment.
o2::math_utils::Chebyshev3D * getParameterTPCIntegral(Int_t ipar) const
void fieldCylindrical(const Double_t *rphiz, Double_t *b) const
Computes field in Cylindircal coordinates.
Int_t findSolenoidSegment(const Double_t *xyz) const
Finds the segment containing point xyz. If it is outside it finds the closest segment.
static void cartesianToCylindrical(const Double_t *xyz, Double_t *rphiz)
void getTPCRatIntegralCylindrical(const Double_t *rphiz, Double_t *b) const
GLenum src
Definition glcorearb.h:1767
GLboolean GLboolean GLboolean b
Definition glcorearb.h:1233
GLenum GLfloat param
Definition glcorearb.h:271
GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat maxZ
Definition glcorearb.h:2910
GLfloat GLfloat minZ
Definition glcorearb.h:2910
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...