2 // Author: ruben.shahoyan@cern.ch 20/03/2007
4 ///////////////////////////////////////////////////////////////////////////////////
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) //
12 // The solenoid part is parameterized in the volume R<500, -550<Z<550 cm //
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) //
18 // If the querried point is outside the validity region no the return values //
19 // for the field components are set to 0. //
21 // To obtain the field integral in the TPC region from given point to nearest //
22 // cathod plane (+- 250 cm) use: //
23 // GetTPCInt(float* xyz, float* bxyz); for Cartesian frame //
25 // GetTPCIntCyl(Float_t *rphiz, Float_t *b); for Cylindrical frame //
28 // The units are kiloGauss and cm. //
30 ///////////////////////////////////////////////////////////////////////////////////
36 #include "AliCheb3D.h"
38 class AliMagFCheb: public TNamed
42 AliMagFCheb(const AliMagFCheb& src);
43 ~AliMagFCheb() {Clear();}
45 void CopyFrom(const AliMagFCheb& src);
46 AliMagFCheb& operator=(const AliMagFCheb& rhs);
47 virtual void Clear(Option_t * = "");
49 Int_t GetNParamsSol() const {return fNParamsSol;}
50 Int_t GetNSegZSol() const {return fNSegZSol;}
52 Int_t GetNParamsTPCInt() const {return fNParamsTPCInt;}
53 Int_t GetNSegZTPCInt() const {return fNSegZTPCInt;}
55 Int_t GetNParamsDip() const {return fNParamsDip;}
56 Int_t GetNSegZDip() const {return fNZSegDip;}
59 Float_t GetMinZSol() const {return fMinZSol;}
60 Float_t GetMaxZSol() const {return fMaxZSol;}
61 Float_t GetMaxRSol() const {return fMaxRSol;}
63 Float_t GetMinZDip() const {return fMinZDip;}
64 Float_t GetMaxZDip() const {return fMaxZDip;}
66 Float_t GetMinZTPCInt() const {return fMinZTPCInt;}
67 Float_t GetMaxZTPCInt() const {return fMaxZTPCInt;}
68 Float_t GetMaxRTPCInt() const {return fMaxRTPCInt;}
70 Int_t FindDipSegment(float *xyz) const;
71 AliCheb3D* GetParamSol(Int_t ipar) const {return (AliCheb3D*)fParamsSol->UncheckedAt(ipar);}
72 AliCheb3D* GetParamTPCInt(Int_t ipar) const {return (AliCheb3D*)fParamsTPCInt->UncheckedAt(ipar);}
73 AliCheb3D* GetParamDip(Int_t ipar) const {return (AliCheb3D*)fParamsDip->UncheckedAt(ipar);}
75 virtual void Print(Option_t * = "") const;
77 virtual void Field(Float_t *xyz, Float_t *b) const;
78 virtual void FieldCyl(Float_t *rphiz, Float_t *b) const;
80 virtual void GetTPCInt(Float_t *xyz, Float_t *b) const;
81 virtual void GetTPCIntCyl(Float_t *rphiz, Float_t *b) const;
83 static void CylToCartCylB(float *rphiz, float *brphiz,float *bxyz);
84 static void CylToCartCartB(float *xyz, float *brphiz,float *bxyz);
85 static void CartToCylCartB(float *xyz, float *bxyz, float *brphiz);
86 static void CartToCylCylB(float *rphiz, float *bxyz, float *brphiz);
87 static void CartToCyl(float *xyz, float *rphiz);
88 static void CylToCart(float *rphiz,float *xyz);
90 #ifdef _INC_CREATION_ALICHEB3D_ // see AliCheb3D.h for explanation
91 void LoadData(const char* inpfile);
93 AliMagFCheb(const char* inputFile);
94 void SaveData(const char* outfile) const;
95 Int_t SegmentDipDimension(float** seg,const TObjArray* par,int npar, int dim,
96 float xmn,float xmx,float ymn,float ymx,float zmn,float zmx);
98 void AddParamSol(AliCheb3D* param);
99 void AddParamTPCInt(AliCheb3D* param);
100 void AddParamDip(AliCheb3D* param);
101 void BuildTableDip();
102 void BuildTableSol();
103 void BuildTableTPCInt();
109 virtual void FieldCylSol(Float_t *rphiz, Float_t *b) const;
113 Int_t fNParamsSol; // Total number of parameterization pieces for Sol
114 Int_t fNSegZSol; // Number of segments in Z for Solenoid field
116 Int_t fNParamsTPCInt; // Total number of parameterization pieces for TPC field integral
117 Int_t fNSegZTPCInt; // Number of segments in Z for TPC field integral
119 Int_t fNParamsDip; // Total number of parameterization pieces for dipole
120 Int_t fNZSegDip; // number of distinct Z segments in Dipole
121 Int_t fNYSegDip; // number of distinct Y segments in Dipole
122 Int_t fNXSegDip; // number of distinct X segments in Dipole
124 Float_t* fSegZSol; //[fNSegZSol] upper boundaries of Z segments
125 Float_t* fSegRSol; //[fNParamsSol] upper boundaries of R segments
127 Float_t* fSegZTPCInt; //[fNSegZTPCInt] upper boundaries of Z segments
128 Float_t* fSegRTPCInt; //[fNParamsTPCInt] upper boundaries of R segments
130 Float_t* fSegZDip; //[fNZSegDip] coordinates of distinct Z segments in Dipole
131 Float_t* fSegYDip; //[fNYSegDip] coordinated of Y segments for each Zsegment in Dipole
132 Float_t* fSegXDip; //[fNXSegDip] coordinated of X segments for each Ysegment in Dipole
134 Int_t* fNSegRSol; //[fNSegZSol] number of R segments for each Z segment
135 Int_t* fSegZIdSol; //[fNSegZSol] Id of the first R segment of each Z segment in the fSegRSol...
137 Int_t* fNSegRTPCInt; //[fNSegZTPCInt] number of R segments for each Z segment
138 Int_t* fSegZIdTPCInt; //[fNSegZTPCInt] Id of the first R segment of each Z segment in the fSegRTPCInt...
140 Int_t* fBegSegYDip; //[fNZSegDip] beginning of Y segments array for each Z segment
141 Int_t* fNSegYDip; //[fNZSegDip] number of Y segments for each Z segment
142 Int_t* fBegSegXDip; //[fNYSegDip] beginning of X segments array for each Y segment
143 Int_t* fNSegXDip; //[fNYSegDip] number of X segments for each Y segment
144 Int_t* fSegIDDip; //[fNXSegDip] ID of the dipole parameterization for given XYZ segment
146 Float_t fMinZSol; // Min Z of Sol parameterization (in CYL. coordinates)
147 Float_t fMaxZSol; // Max Z of Sol parameterization (in CYL. coordinates)
148 Float_t fMaxRSol; // Max R of Sol parameterization (in CYL. coordinates)
150 Float_t fMinZDip; // Min Z of Dipole parameterization
151 Float_t fMaxZDip; // Max Z of Dipole parameterization
153 Float_t fMinZTPCInt; // Min Z of TPCInt parameterization (in CYL. coordinates)
154 Float_t fMaxZTPCInt; // Max Z of TPCInt parameterization (in CYL. coordinates)
155 Float_t fMaxRTPCInt; // Max R of TPCInt parameterization (in CYL. coordinates)
157 TObjArray* fParamsSol; // Parameterization pieces for Solenoid field
158 TObjArray* fParamsDip; // Parameterization pieces for Dipole field
159 TObjArray* fParamsTPCInt; // Parameterization pieces for Solenoid field integrals in TPC region
161 ClassDef(AliMagFCheb,3) // Wrapper class for the set of Chebishev parameterizations of Alice mag.field
166 //__________________________________________________________________________________________
167 inline void AliMagFCheb::FieldCyl(Float_t *rphiz, Float_t *b) const
169 // compute field in Cylindircal coordinates
170 // if (rphiz[2]<GetMinZSol() || rphiz[2]>GetMaxZSol() || rphiz[0]>GetMaxRSol()) {for (int i=3;i--;) b[i]=0; return;}
171 FieldCylSol(rphiz,b);
174 //__________________________________________________________________________________________________
175 inline void AliMagFCheb::CylToCartCylB(float *rphiz, float *brphiz,float *bxyz)
177 // convert field in cylindrical coordinates to cartesian system, point is in cyl.system
178 float btr = TMath::Sqrt(brphiz[0]*brphiz[0]+brphiz[1]*brphiz[1]);
179 float psiPLUSphi = TMath::ATan2(brphiz[1],brphiz[0]) + rphiz[1];
180 bxyz[0] = btr*TMath::Cos(psiPLUSphi);
181 bxyz[1] = btr*TMath::Sin(psiPLUSphi);
186 //__________________________________________________________________________________________________
187 inline void AliMagFCheb::CylToCartCartB(float *xyz, float *brphiz,float *bxyz)
189 // convert field in cylindrical coordinates to cartesian system, point is in cart.system
190 float btr = TMath::Sqrt(brphiz[0]*brphiz[0]+brphiz[1]*brphiz[1]);
191 float phiPLUSpsi = TMath::ATan2(xyz[1],xyz[0]) + TMath::ATan2(brphiz[1],brphiz[0]);
192 bxyz[0] = btr*TMath::Cos(phiPLUSpsi);
193 bxyz[1] = btr*TMath::Sin(phiPLUSpsi);
198 //__________________________________________________________________________________________________
199 inline void AliMagFCheb::CartToCylCartB(float *xyz ,float *bxyz, float *brphiz)
201 // convert field in cylindrical coordinates to cartesian system, poin is in cart.system
202 float btr = TMath::Sqrt(bxyz[0]*bxyz[0]+bxyz[1]*bxyz[1]);
203 float psiMINphi = TMath::ATan2(bxyz[1],bxyz[0]) - TMath::ATan2(xyz[1],xyz[0]);
205 brphiz[0] = btr*TMath::Cos(psiMINphi);
206 brphiz[1] = btr*TMath::Sin(psiMINphi);
211 //__________________________________________________________________________________________________
212 inline void AliMagFCheb::CartToCylCylB(float *rphiz,float *bxyz, float *brphiz)
214 // convert field in cylindrical coordinates to cartesian system, point is in cyl.system
215 float btr = TMath::Sqrt(bxyz[0]*bxyz[0]+bxyz[1]*bxyz[1]);
216 float psiMINphi = TMath::ATan2(bxyz[1],bxyz[0]) - rphiz[1];
217 brphiz[0] = btr*TMath::Cos(psiMINphi);
218 brphiz[1] = btr*TMath::Sin(psiMINphi);
223 //__________________________________________________________________________________________________
224 inline void AliMagFCheb::CartToCyl(float *xyz,float *rphiz)
226 rphiz[0] = TMath::Sqrt(xyz[0]*xyz[0]+xyz[1]*xyz[1]);
227 rphiz[1] = TMath::ATan2(xyz[1],xyz[0]);
231 //__________________________________________________________________________________________________
232 inline void AliMagFCheb::CylToCart(float *rphiz,float *xyz)
234 xyz[0] = rphiz[0]*TMath::Cos(rphiz[1]);
235 xyz[1] = rphiz[0]*TMath::Sin(rphiz[1]);