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(double* xyz, double* bxyz); //
9 // For cylindrical coordinates/components: //
10 // FieldCyl(double* rphiz, double* 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 // 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. //
26 // To obtain the field integral in the TPC region from given point to nearest //
27 // cathod plane (+- 250 cm) use: //
28 // GetTPCInt(double* xyz, double* bxyz); for Cartesian frame //
30 // GetTPCIntCyl(Double_t *rphiz, Double_t *b); for Cylindrical frame //
33 // The units are kiloGauss and cm. //
35 ///////////////////////////////////////////////////////////////////////////////////
37 #ifndef ALIMAGWRAPCHEB_H
38 #define ALIMAGWRAPCHEB_H
42 #include "AliCheb3D.h"
48 class AliMagWrapCheb: public TNamed
52 AliMagWrapCheb(const AliMagWrapCheb& src);
53 ~AliMagWrapCheb() {Clear();}
55 void CopyFrom(const AliMagWrapCheb& src);
56 AliMagWrapCheb& operator=(const AliMagWrapCheb& rhs);
57 virtual void Clear(const Option_t * = "");
59 Int_t GetNParamsSol() const {return fNParamsSol;}
60 Int_t GetNSegZSol() const {return fNSegZSol;}
61 Float_t* GetSegZSol() const {return fSegZSol;}
63 Int_t GetNParamsTPCInt() const {return fNParamsTPCInt;}
64 Int_t GetNSegZTPCInt() const {return fNSegZTPCInt;}
66 Int_t GetNParamsDip() const {return fNParamsDip;}
67 Int_t GetNSegZDip() const {return fNZSegDip;}
69 Float_t GetMaxZ() const {return GetMaxZSol();}
70 Float_t GetMinZ() const {return fParamsDip ? GetMinZDip() : GetMinZSol();}
72 Float_t GetMinZSol() const {return fMinZSol;}
73 Float_t GetMaxZSol() const {return fMaxZSol;}
74 Float_t GetMaxRSol() const {return fMaxRSol;}
76 Float_t GetMinZDip() const {return fMinZDip;}
77 Float_t GetMaxZDip() const {return fMaxZDip;}
79 Float_t GetMinZTPCInt() const {return fMinZTPCInt;}
80 Float_t GetMaxZTPCInt() const {return fMaxZTPCInt;}
81 Float_t GetMaxRTPCInt() const {return fMaxRTPCInt;}
83 AliCheb3D* GetParamSol(Int_t ipar) const {return (AliCheb3D*)fParamsSol->UncheckedAt(ipar);}
84 AliCheb3D* GetParamTPCInt(Int_t ipar) const {return (AliCheb3D*)fParamsTPCInt->UncheckedAt(ipar);}
85 AliCheb3D* GetParamDip(Int_t ipar) const {return (AliCheb3D*)fParamsDip->UncheckedAt(ipar);}
87 virtual void Print(Option_t * = "") const;
89 virtual void Field(const Double_t *xyz, Double_t *b) const;
90 Double_t GetBz(const Double_t *xyz) const;
92 void FieldCyl(const Double_t *rphiz, Double_t *b) const;
93 void GetTPCInt(const Double_t *xyz, Double_t *b) const;
94 void GetTPCIntCyl(const Double_t *rphiz, Double_t *b) const;
96 Int_t FindDipSegment(const Double_t *xyz) const;
97 static void CylToCartCylB(const Double_t *rphiz, const Double_t *brphiz,Double_t *bxyz);
98 static void CylToCartCartB(const Double_t *xyz, const Double_t *brphiz,Double_t *bxyz);
99 static void CartToCylCartB(const Double_t *xyz, const Double_t *bxyz, Double_t *brphiz);
100 static void CartToCylCylB(const Double_t *rphiz, const Double_t *bxyz, Double_t *brphiz);
101 static void CartToCyl(const Double_t *xyz, Double_t *rphiz);
102 static void CylToCart(const Double_t *rphiz,Double_t *xyz);
104 #ifdef _INC_CREATION_ALICHEB3D_ // see AliCheb3D.h for explanation
105 void LoadData(const char* inpfile);
107 AliMagWrapCheb(const char* inputFile);
108 void SaveData(const char* outfile) const;
109 Int_t SegmentDipDimension(Float_t** seg,const TObjArray* par,int npar, int dim,
110 Float_t xmn,Float_t xmx,Float_t ymn,Float_t ymx,Float_t zmn,Float_t zmx);
112 void AddParamSol(const AliCheb3D* param);
113 void AddParamTPCInt(const AliCheb3D* param);
114 void AddParamDip(const AliCheb3D* param);
115 void BuildTableDip();
116 void BuildTableSol();
117 void BuildTableTPCInt();
124 void FieldCylSol(const Double_t *rphiz, Double_t *b) const;
125 Double_t FieldCylSolBz(const Double_t *rphiz) const;
129 Int_t fNParamsSol; // Total number of parameterization pieces for Sol
130 Int_t fNSegZSol; // Number of segments in Z for Solenoid field
132 Int_t fNParamsTPCInt; // Total number of parameterization pieces for TPC field integral
133 Int_t fNSegZTPCInt; // Number of segments in Z for TPC field integral
135 Int_t fNParamsDip; // Total number of parameterization pieces for dipole
136 Int_t fNZSegDip; // number of distinct Z segments in Dipole
137 Int_t fNYSegDip; // number of distinct Y segments in Dipole
138 Int_t fNXSegDip; // number of distinct X segments in Dipole
140 Float_t* fSegZSol; //[fNSegZSol] upper boundaries of Z segments
141 Float_t* fSegRSol; //[fNParamsSol] upper boundaries of R segments
143 Float_t* fSegZTPCInt; //[fNSegZTPCInt] upper boundaries of Z segments
144 Float_t* fSegRTPCInt; //[fNParamsTPCInt] upper boundaries of R segments
146 Float_t* fSegZDip; //[fNZSegDip] coordinates of distinct Z segments in Dipole
147 Float_t* fSegYDip; //[fNYSegDip] coordinated of Y segments for each Zsegment in Dipole
148 Float_t* fSegXDip; //[fNXSegDip] coordinated of X segments for each Ysegment in Dipole
150 Int_t* fNSegRSol; //[fNSegZSol] number of R segments for each Z segment
151 Int_t* fSegZIdSol; //[fNSegZSol] Id of the first R segment of each Z segment in the fSegRSol...
153 Int_t* fNSegRTPCInt; //[fNSegZTPCInt] number of R segments for each Z segment
154 Int_t* fSegZIdTPCInt; //[fNSegZTPCInt] Id of the first R segment of each Z segment in the fSegRTPCInt...
156 Int_t* fBegSegYDip; //[fNZSegDip] beginning of Y segments array for each Z segment
157 Int_t* fNSegYDip; //[fNZSegDip] number of Y segments for each Z segment
158 Int_t* fBegSegXDip; //[fNYSegDip] beginning of X segments array for each Y segment
159 Int_t* fNSegXDip; //[fNYSegDip] number of X segments for each Y segment
160 Int_t* fSegIDDip; //[fNXSegDip] ID of the dipole parameterization for given XYZ segment
162 Float_t fMinZSol; // Min Z of Sol parameterization (in CYL. coordinates)
163 Float_t fMaxZSol; // Max Z of Sol parameterization (in CYL. coordinates)
164 Float_t fMaxRSol; // Max R of Sol parameterization (in CYL. coordinates)
166 Float_t fMinZDip; // Min Z of Dipole parameterization
167 Float_t fMaxZDip; // Max Z of Dipole parameterization
169 Float_t fMinZTPCInt; // Min Z of TPCInt parameterization (in CYL. coordinates)
170 Float_t fMaxZTPCInt; // Max Z of TPCInt parameterization (in CYL. coordinates)
171 Float_t fMaxRTPCInt; // Max R of TPCInt parameterization (in CYL. coordinates)
173 TObjArray* fParamsSol; // Parameterization pieces for Solenoid field
174 TObjArray* fParamsDip; // Parameterization pieces for Dipole field
175 TObjArray* fParamsTPCInt; // Parameterization pieces for Solenoid field integrals in TPC region
177 ClassDef(AliMagWrapCheb,4) // Wrapper class for the set of Chebishev parameterizations of Alice mag.field
182 //__________________________________________________________________________________________
183 inline void AliMagWrapCheb::FieldCyl(const Double_t *rphiz, Double_t *b) const
185 // compute field in Cylindircal coordinates
186 // if (rphiz[2]<GetMinZSol() || rphiz[2]>GetMaxZSol() || rphiz[0]>GetMaxRSol()) {for (int i=3;i--;) b[i]=0; return;}
187 FieldCylSol(rphiz,b);
190 //__________________________________________________________________________________________________
191 inline void AliMagWrapCheb::CylToCartCylB(const Double_t *rphiz, const Double_t *brphiz,Double_t *bxyz)
193 // convert field in cylindrical coordinates to cartesian system, point is in cyl.system
194 Double_t btr = TMath::Sqrt(brphiz[0]*brphiz[0]+brphiz[1]*brphiz[1]);
195 Double_t psiPLUSphi = TMath::ATan2(brphiz[1],brphiz[0]) + rphiz[1];
196 bxyz[0] = btr*TMath::Cos(psiPLUSphi);
197 bxyz[1] = btr*TMath::Sin(psiPLUSphi);
202 //__________________________________________________________________________________________________
203 inline void AliMagWrapCheb::CylToCartCartB(const Double_t* xyz, const Double_t *brphiz, Double_t *bxyz)
205 // convert field in cylindrical coordinates to cartesian system, point is in cart.system
206 Double_t btr = TMath::Sqrt(brphiz[0]*brphiz[0]+brphiz[1]*brphiz[1]);
207 Double_t phiPLUSpsi = TMath::ATan2(xyz[1],xyz[0]) + TMath::ATan2(brphiz[1],brphiz[0]);
208 bxyz[0] = btr*TMath::Cos(phiPLUSpsi);
209 bxyz[1] = btr*TMath::Sin(phiPLUSpsi);
214 //__________________________________________________________________________________________________
215 inline void AliMagWrapCheb::CartToCylCartB(const Double_t *xyz, const Double_t *bxyz, Double_t *brphiz)
217 // convert field in cylindrical coordinates to cartesian system, poin is in cart.system
218 Double_t btr = TMath::Sqrt(bxyz[0]*bxyz[0]+bxyz[1]*bxyz[1]);
219 Double_t psiMINphi = TMath::ATan2(bxyz[1],bxyz[0]) - TMath::ATan2(xyz[1],xyz[0]);
221 brphiz[0] = btr*TMath::Cos(psiMINphi);
222 brphiz[1] = btr*TMath::Sin(psiMINphi);
227 //__________________________________________________________________________________________________
228 inline void AliMagWrapCheb::CartToCylCylB(const Double_t *rphiz, const Double_t *bxyz, Double_t *brphiz)
230 // convert field in cylindrical coordinates to cartesian system, point is in cyl.system
231 Double_t btr = TMath::Sqrt(bxyz[0]*bxyz[0]+bxyz[1]*bxyz[1]);
232 Double_t psiMINphi = TMath::ATan2(bxyz[1],bxyz[0]) - rphiz[1];
233 brphiz[0] = btr*TMath::Cos(psiMINphi);
234 brphiz[1] = btr*TMath::Sin(psiMINphi);
239 //__________________________________________________________________________________________________
240 inline void AliMagWrapCheb::CartToCyl(const Double_t *xyz, Double_t *rphiz)
242 rphiz[0] = TMath::Sqrt(xyz[0]*xyz[0]+xyz[1]*xyz[1]);
243 rphiz[1] = TMath::ATan2(xyz[1],xyz[0]);
247 //__________________________________________________________________________________________________
248 inline void AliMagWrapCheb::CylToCart(const Double_t *rphiz, Double_t *xyz)
250 xyz[0] = rphiz[0]*TMath::Cos(rphiz[1]);
251 xyz[1] = rphiz[0]*TMath::Sin(rphiz[1]);