modifications to satisfy the coding conventions
[u/mrichter/AliRoot.git] / STEER / AliMagFCheb.h
CommitLineData
0eea9d4d 1
2// Author: ruben.shahoyan@cern.ch 20/03/2007
d28e407c 3
0eea9d4d 4///////////////////////////////////////////////////////////////////////////////////
5// //
6// Wrapper for the set of mag.field parameterizations by Chebyshev polinomials //
7// To obtain the field in cartesian coordinates/components use //
8// Field(float* xyz, float* bxyz); //
9// For cylindrical coordinates/components: //
10// FieldCyl(float* rphiz, float* brphiz) //
11// //
d28e407c 12// The solenoid part is parameterized in the volume R<500, -550<Z<550 cm //
0eea9d4d 13// //
14// The region R<423 cm, -343.3<Z<481.3 for 30kA and -343.3<Z<481.3 for 12kA //
15// is parameterized using measured data while outside the Tosca calculation //
16// is used (matched to data on the boundary of the measurements) //
17// //
5406439e 18// Two options are possible: //
19// 1) _BRING_TO_BOUNDARY_ is defined in the AliCheb3D: //
20// If the querried point is outside of the validity region then the field //
21// at the closest point on the fitted surface is returned. //
22// 2) _BRING_TO_BOUNDARY_ is not defined in the AliCheb3D: //
23// If the querried point is outside of the validity region the return //
24// value for the field components are set to 0. //
0eea9d4d 25// //
d28e407c 26// To obtain the field integral in the TPC region from given point to nearest //
27// cathod plane (+- 250 cm) use: //
28// GetTPCInt(float* xyz, float* bxyz); for Cartesian frame //
29// or //
30// GetTPCIntCyl(Float_t *rphiz, Float_t *b); for Cylindrical frame //
31// //
32// //
33// The units are kiloGauss and cm. //
34// //
0eea9d4d 35///////////////////////////////////////////////////////////////////////////////////
36
5406439e 37#ifndef ALIMAGFCHEB_H
38#define ALIMAGFCHEB_H
39
40#include <TMath.h>
0eea9d4d 41#include <TNamed.h>
42#include "AliCheb3D.h"
43
5406439e 44class TSystem;
45
0eea9d4d 46class AliMagFCheb: public TNamed
47{
48 public:
d28e407c 49 AliMagFCheb();
50 AliMagFCheb(const AliMagFCheb& src);
51 ~AliMagFCheb() {Clear();}
0eea9d4d 52 //
d28e407c 53 void CopyFrom(const AliMagFCheb& src);
54 AliMagFCheb& operator=(const AliMagFCheb& rhs);
5406439e 55 virtual void Clear(const Option_t * = "");
0eea9d4d 56 //
57 Int_t GetNParamsSol() const {return fNParamsSol;}
58 Int_t GetNSegZSol() const {return fNSegZSol;}
5406439e 59 float* GetSegZSol() const {return fSegZSol;}
d28e407c 60 //
61 Int_t GetNParamsTPCInt() const {return fNParamsTPCInt;}
62 Int_t GetNSegZTPCInt() const {return fNSegZTPCInt;}
63 //
64 Int_t GetNParamsDip() const {return fNParamsDip;}
65 Int_t GetNSegZDip() const {return fNZSegDip;}
66 //
0eea9d4d 67 //
68 Float_t GetMinZSol() const {return fMinZSol;}
69 Float_t GetMaxZSol() const {return fMaxZSol;}
70 Float_t GetMaxRSol() const {return fMaxRSol;}
d28e407c 71 //
72 Float_t GetMinZDip() const {return fMinZDip;}
73 Float_t GetMaxZDip() const {return fMaxZDip;}
74 //
75 Float_t GetMinZTPCInt() const {return fMinZTPCInt;}
76 Float_t GetMaxZTPCInt() const {return fMaxZTPCInt;}
77 Float_t GetMaxRTPCInt() const {return fMaxRTPCInt;}
78 //
5406439e 79 Int_t FindDipSegment(const float *xyz) const;
0eea9d4d 80 AliCheb3D* GetParamSol(Int_t ipar) const {return (AliCheb3D*)fParamsSol->UncheckedAt(ipar);}
d28e407c 81 AliCheb3D* GetParamTPCInt(Int_t ipar) const {return (AliCheb3D*)fParamsTPCInt->UncheckedAt(ipar);}
0eea9d4d 82 AliCheb3D* GetParamDip(Int_t ipar) const {return (AliCheb3D*)fParamsDip->UncheckedAt(ipar);}
83 //
0eea9d4d 84 virtual void Print(Option_t * = "") const;
85 //
86 virtual void Field(Float_t *xyz, Float_t *b) const;
5406439e 87 virtual void FieldCyl(const Float_t *rphiz, Float_t *b) const;
ae5ea910 88 //
d28e407c 89 virtual void GetTPCInt(Float_t *xyz, Float_t *b) const;
90 virtual void GetTPCIntCyl(Float_t *rphiz, Float_t *b) const;
0eea9d4d 91 //
5406439e 92 static void CylToCartCylB(const float *rphiz, const float *brphiz,float *bxyz);
93 static void CylToCartCartB(const float *xyz, const float *brphiz,float *bxyz);
94 static void CartToCylCartB(const float *xyz, const float *bxyz, float *brphiz);
95 static void CartToCylCylB(const float *rphiz, const float *bxyz, float *brphiz);
96 static void CartToCyl(const float *xyz, float *rphiz);
97 static void CylToCart(const float *rphiz,float *xyz);
0eea9d4d 98 //
99#ifdef _INC_CREATION_ALICHEB3D_ // see AliCheb3D.h for explanation
1cf34ee8 100 void LoadData(const char* inpfile);
101 //
d28e407c 102 AliMagFCheb(const char* inputFile);
103 void SaveData(const char* outfile) const;
104 Int_t SegmentDipDimension(float** seg,const TObjArray* par,int npar, int dim,
105 float xmn,float xmx,float ymn,float ymx,float zmn,float zmx);
106 //
5406439e 107 void AddParamSol(const AliCheb3D* param);
108 void AddParamTPCInt(const AliCheb3D* param);
109 void AddParamDip(const AliCheb3D* param);
d28e407c 110 void BuildTableDip();
111 void BuildTableSol();
112 void BuildTableTPCInt();
113 void ResetTPCInt();
114
0eea9d4d 115#endif
116 //
117 protected:
5406439e 118 virtual void FieldCylSol(const Float_t *rphiz, Float_t *b) const;
0eea9d4d 119 //
120 protected:
121 //
122 Int_t fNParamsSol; // Total number of parameterization pieces for Sol
d28e407c 123 Int_t fNSegZSol; // Number of segments in Z for Solenoid field
124 //
125 Int_t fNParamsTPCInt; // Total number of parameterization pieces for TPC field integral
126 Int_t fNSegZTPCInt; // Number of segments in Z for TPC field integral
0eea9d4d 127 //
128 Int_t fNParamsDip; // Total number of parameterization pieces for dipole
d28e407c 129 Int_t fNZSegDip; // number of distinct Z segments in Dipole
130 Int_t fNYSegDip; // number of distinct Y segments in Dipole
131 Int_t fNXSegDip; // number of distinct X segments in Dipole
132 //
133 Float_t* fSegZSol; //[fNSegZSol] upper boundaries of Z segments
134 Float_t* fSegRSol; //[fNParamsSol] upper boundaries of R segments
135 //
136 Float_t* fSegZTPCInt; //[fNSegZTPCInt] upper boundaries of Z segments
137 Float_t* fSegRTPCInt; //[fNParamsTPCInt] upper boundaries of R segments
0eea9d4d 138 //
d28e407c 139 Float_t* fSegZDip; //[fNZSegDip] coordinates of distinct Z segments in Dipole
140 Float_t* fSegYDip; //[fNYSegDip] coordinated of Y segments for each Zsegment in Dipole
141 Float_t* fSegXDip; //[fNXSegDip] coordinated of X segments for each Ysegment in Dipole
0eea9d4d 142 //
d28e407c 143 Int_t* fNSegRSol; //[fNSegZSol] number of R segments for each Z segment
144 Int_t* fSegZIdSol; //[fNSegZSol] Id of the first R segment of each Z segment in the fSegRSol...
145 //
146 Int_t* fNSegRTPCInt; //[fNSegZTPCInt] number of R segments for each Z segment
147 Int_t* fSegZIdTPCInt; //[fNSegZTPCInt] Id of the first R segment of each Z segment in the fSegRTPCInt...
148 //
149 Int_t* fBegSegYDip; //[fNZSegDip] beginning of Y segments array for each Z segment
150 Int_t* fNSegYDip; //[fNZSegDip] number of Y segments for each Z segment
151 Int_t* fBegSegXDip; //[fNYSegDip] beginning of X segments array for each Y segment
152 Int_t* fNSegXDip; //[fNYSegDip] number of X segments for each Y segment
153 Int_t* fSegIDDip; //[fNXSegDip] ID of the dipole parameterization for given XYZ segment
0eea9d4d 154 //
155 Float_t fMinZSol; // Min Z of Sol parameterization (in CYL. coordinates)
156 Float_t fMaxZSol; // Max Z of Sol parameterization (in CYL. coordinates)
157 Float_t fMaxRSol; // Max R of Sol parameterization (in CYL. coordinates)
158 //
d28e407c 159 Float_t fMinZDip; // Min Z of Dipole parameterization
160 Float_t fMaxZDip; // Max Z of Dipole parameterization
161 //
162 Float_t fMinZTPCInt; // Min Z of TPCInt parameterization (in CYL. coordinates)
163 Float_t fMaxZTPCInt; // Max Z of TPCInt parameterization (in CYL. coordinates)
164 Float_t fMaxRTPCInt; // Max R of TPCInt parameterization (in CYL. coordinates)
165 //
0eea9d4d 166 TObjArray* fParamsSol; // Parameterization pieces for Solenoid field
167 TObjArray* fParamsDip; // Parameterization pieces for Dipole field
d28e407c 168 TObjArray* fParamsTPCInt; // Parameterization pieces for Solenoid field integrals in TPC region
0eea9d4d 169 //
d28e407c 170 ClassDef(AliMagFCheb,3) // Wrapper class for the set of Chebishev parameterizations of Alice mag.field
0eea9d4d 171 //
172 };
173
174
175//__________________________________________________________________________________________
5406439e 176inline void AliMagFCheb::FieldCyl(const Float_t *rphiz, Float_t *b) const
0eea9d4d 177{
178 // compute field in Cylindircal coordinates
d28e407c 179 // if (rphiz[2]<GetMinZSol() || rphiz[2]>GetMaxZSol() || rphiz[0]>GetMaxRSol()) {for (int i=3;i--;) b[i]=0; return;}
0eea9d4d 180 FieldCylSol(rphiz,b);
181}
182
d28e407c 183//__________________________________________________________________________________________________
5406439e 184inline void AliMagFCheb::CylToCartCylB(const float *rphiz, const float *brphiz,float *bxyz)
d28e407c 185{
186 // convert field in cylindrical coordinates to cartesian system, point is in cyl.system
187 float btr = TMath::Sqrt(brphiz[0]*brphiz[0]+brphiz[1]*brphiz[1]);
188 float psiPLUSphi = TMath::ATan2(brphiz[1],brphiz[0]) + rphiz[1];
189 bxyz[0] = btr*TMath::Cos(psiPLUSphi);
190 bxyz[1] = btr*TMath::Sin(psiPLUSphi);
191 bxyz[2] = brphiz[2];
192 //
193}
194
195//__________________________________________________________________________________________________
5406439e 196inline void AliMagFCheb::CylToCartCartB(const float *xyz, const float *brphiz,float *bxyz)
d28e407c 197{
198 // convert field in cylindrical coordinates to cartesian system, point is in cart.system
199 float btr = TMath::Sqrt(brphiz[0]*brphiz[0]+brphiz[1]*brphiz[1]);
200 float phiPLUSpsi = TMath::ATan2(xyz[1],xyz[0]) + TMath::ATan2(brphiz[1],brphiz[0]);
201 bxyz[0] = btr*TMath::Cos(phiPLUSpsi);
202 bxyz[1] = btr*TMath::Sin(phiPLUSpsi);
203 bxyz[2] = brphiz[2];
204 //
205}
206
207//__________________________________________________________________________________________________
5406439e 208inline void AliMagFCheb::CartToCylCartB(const float *xyz, const float *bxyz, float *brphiz)
d28e407c 209{
210 // convert field in cylindrical coordinates to cartesian system, poin is in cart.system
211 float btr = TMath::Sqrt(bxyz[0]*bxyz[0]+bxyz[1]*bxyz[1]);
212 float psiMINphi = TMath::ATan2(bxyz[1],bxyz[0]) - TMath::ATan2(xyz[1],xyz[0]);
213 //
214 brphiz[0] = btr*TMath::Cos(psiMINphi);
215 brphiz[1] = btr*TMath::Sin(psiMINphi);
216 brphiz[2] = bxyz[2];
217 //
218}
219
220//__________________________________________________________________________________________________
5406439e 221inline void AliMagFCheb::CartToCylCylB(const float *rphiz, const float *bxyz, float *brphiz)
d28e407c 222{
223 // convert field in cylindrical coordinates to cartesian system, point is in cyl.system
224 float btr = TMath::Sqrt(bxyz[0]*bxyz[0]+bxyz[1]*bxyz[1]);
225 float psiMINphi = TMath::ATan2(bxyz[1],bxyz[0]) - rphiz[1];
226 brphiz[0] = btr*TMath::Cos(psiMINphi);
227 brphiz[1] = btr*TMath::Sin(psiMINphi);
228 brphiz[2] = bxyz[2];
229 //
230}
231
232//__________________________________________________________________________________________________
5406439e 233inline void AliMagFCheb::CartToCyl(const float *xyz,float *rphiz)
d28e407c 234{
235 rphiz[0] = TMath::Sqrt(xyz[0]*xyz[0]+xyz[1]*xyz[1]);
236 rphiz[1] = TMath::ATan2(xyz[1],xyz[0]);
237 rphiz[2] = xyz[2];
238}
239
240//__________________________________________________________________________________________________
5406439e 241inline void AliMagFCheb::CylToCart(const float *rphiz, float *xyz)
d28e407c 242{
243 xyz[0] = rphiz[0]*TMath::Cos(rphiz[1]);
244 xyz[1] = rphiz[0]*TMath::Sin(rphiz[1]);
245 xyz[2] = rphiz[2];
246}
247
0eea9d4d 248#endif