]>
Commit | Line | Data |
---|---|---|
da7cd221 | 1 | |
2 | // Author: ruben.shahoyan@cern.ch 20/03/2007 | |
3 | ||
4 | /////////////////////////////////////////////////////////////////////////////////// | |
5 | // // | |
6 | // Wrapper for the set of mag.field parameterizations by Chebyshev polinomials // | |
7 | // To obtain the field in cartesian coordinates/components use // | |
db83d72f | 8 | // Field(double* xyz, double* bxyz); // |
da7cd221 | 9 | // For cylindrical coordinates/components: // |
db83d72f | 10 | // FieldCyl(double* rphiz, double* brphiz) // |
da7cd221 | 11 | // // |
12 | // The solenoid part is parameterized in the volume R<500, -550<Z<550 cm // | |
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 | // // | |
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. // | |
25 | // // | |
26 | // To obtain the field integral in the TPC region from given point to nearest // | |
27 | // cathod plane (+- 250 cm) use: // | |
db83d72f | 28 | // GetTPCInt(double* xyz, double* bxyz); for Cartesian frame // |
da7cd221 | 29 | // or // |
db83d72f | 30 | // GetTPCIntCyl(Double_t *rphiz, Double_t *b); for Cylindrical frame // |
da7cd221 | 31 | // // |
32 | // // | |
33 | // The units are kiloGauss and cm. // | |
34 | // // | |
35 | /////////////////////////////////////////////////////////////////////////////////// | |
36 | ||
a1dde210 | 37 | #ifndef ALIMAGWRAPCHEB_H |
38 | #define ALIMAGWRAPCHEB_H | |
a1dde210 | 39 | |
da7cd221 | 40 | #include <TMath.h> |
41 | #include <TNamed.h> | |
42 | #include "AliCheb3D.h" | |
a1dde210 | 43 | |
da7cd221 | 44 | class TSystem; |
45 | class TArrayF; | |
46 | class TArrayI; | |
a1dde210 | 47 | |
da7cd221 | 48 | class AliMagWrapCheb: public TNamed |
a1dde210 | 49 | { |
da7cd221 | 50 | public: |
a1dde210 | 51 | AliMagWrapCheb(); |
da7cd221 | 52 | AliMagWrapCheb(const AliMagWrapCheb& src); |
53 | ~AliMagWrapCheb() {Clear();} | |
54 | // | |
55 | void CopyFrom(const AliMagWrapCheb& src); | |
56 | AliMagWrapCheb& operator=(const AliMagWrapCheb& rhs); | |
57 | virtual void Clear(const Option_t * = ""); | |
58 | // | |
59 | Int_t GetNParamsSol() const {return fNParamsSol;} | |
1d18ebe0 | 60 | Int_t GetNSegZSol() const {return fNZSegSol;} |
61 | Float_t* GetSegZSol() const {return fSegZSol;} | |
da7cd221 | 62 | // |
1d18ebe0 | 63 | Int_t GetNParamsTPCInt() const {return fNParamsTPC;} |
64 | Int_t GetNSegZTPCInt() const {return fNZSegTPC;} | |
da7cd221 | 65 | // |
66 | Int_t GetNParamsDip() const {return fNParamsDip;} | |
67 | Int_t GetNSegZDip() const {return fNZSegDip;} | |
68 | // | |
9251fceb | 69 | Float_t GetMaxZ() const {return GetMaxZSol();} |
70 | Float_t GetMinZ() const {return fParamsDip ? GetMinZDip() : GetMinZSol();} | |
da7cd221 | 71 | // |
72 | Float_t GetMinZSol() const {return fMinZSol;} | |
73 | Float_t GetMaxZSol() const {return fMaxZSol;} | |
74 | Float_t GetMaxRSol() const {return fMaxRSol;} | |
75 | // | |
76 | Float_t GetMinZDip() const {return fMinZDip;} | |
77 | Float_t GetMaxZDip() const {return fMaxZDip;} | |
78 | // | |
1d18ebe0 | 79 | Float_t GetMinZTPCInt() const {return fMinZTPC;} |
80 | Float_t GetMaxZTPCInt() const {return fMaxZTPC;} | |
81 | Float_t GetMaxRTPCInt() const {return fMaxRTPC;} | |
da7cd221 | 82 | // |
83 | AliCheb3D* GetParamSol(Int_t ipar) const {return (AliCheb3D*)fParamsSol->UncheckedAt(ipar);} | |
1d18ebe0 | 84 | AliCheb3D* GetParamTPCInt(Int_t ipar) const {return (AliCheb3D*)fParamsTPC->UncheckedAt(ipar);} |
da7cd221 | 85 | AliCheb3D* GetParamDip(Int_t ipar) const {return (AliCheb3D*)fParamsDip->UncheckedAt(ipar);} |
86 | // | |
87 | virtual void Print(Option_t * = "") const; | |
88 | // | |
db83d72f | 89 | virtual void Field(const Double_t *xyz, Double_t *b) const; |
90 | Double_t GetBz(const Double_t *xyz) const; | |
da7cd221 | 91 | // |
db83d72f | 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; | |
da7cd221 | 95 | // |
1d18ebe0 | 96 | Int_t FindSolSegment(const Double_t *xyz) const; |
97 | Int_t FindTPCSegment(const Double_t *xyz) const; | |
db83d72f | 98 | Int_t FindDipSegment(const Double_t *xyz) const; |
99 | static void CylToCartCylB(const Double_t *rphiz, const Double_t *brphiz,Double_t *bxyz); | |
100 | static void CylToCartCartB(const Double_t *xyz, const Double_t *brphiz,Double_t *bxyz); | |
101 | static void CartToCylCartB(const Double_t *xyz, const Double_t *bxyz, Double_t *brphiz); | |
102 | static void CartToCylCylB(const Double_t *rphiz, const Double_t *bxyz, Double_t *brphiz); | |
103 | static void CartToCyl(const Double_t *xyz, Double_t *rphiz); | |
104 | static void CylToCart(const Double_t *rphiz,Double_t *xyz); | |
da7cd221 | 105 | // |
106 | #ifdef _INC_CREATION_ALICHEB3D_ // see AliCheb3D.h for explanation | |
107 | void LoadData(const char* inpfile); | |
108 | // | |
109 | AliMagWrapCheb(const char* inputFile); | |
db83d72f | 110 | void SaveData(const char* outfile) const; |
1d18ebe0 | 111 | Int_t SegmentDimension(Float_t** seg,const TObjArray* par,int npar, int dim, |
112 | Float_t xmn,Float_t xmx,Float_t ymn,Float_t ymx,Float_t zmn,Float_t zmx); | |
da7cd221 | 113 | // |
114 | void AddParamSol(const AliCheb3D* param); | |
115 | void AddParamTPCInt(const AliCheb3D* param); | |
116 | void AddParamDip(const AliCheb3D* param); | |
1d18ebe0 | 117 | void BuildTable(Int_t npar,TObjArray *parArr, Int_t &nZSeg, Int_t &nYSeg, Int_t &nXSeg, |
118 | Float_t &minZ,Float_t &maxZ,Float_t **segZ,Float_t **segY,Float_t **segX, | |
119 | Int_t **begSegY,Int_t **nSegY,Int_t **begSegX,Int_t **nSegX,Int_t **segID); | |
da7cd221 | 120 | void BuildTableSol(); |
1d18ebe0 | 121 | void BuildTableDip(); |
da7cd221 | 122 | void BuildTableTPCInt(); |
123 | void ResetTPCInt(); | |
124 | // | |
125 | // | |
126 | #endif | |
a1dde210 | 127 | // |
128 | protected: | |
db83d72f | 129 | void FieldCylSol(const Double_t *rphiz, Double_t *b) const; |
130 | Double_t FieldCylSolBz(const Double_t *rphiz) const; | |
da7cd221 | 131 | // |
132 | protected: | |
133 | // | |
1d18ebe0 | 134 | Int_t fNParamsSol; // Total number of parameterization pieces for solenoid |
135 | Int_t fNZSegSol; // number of distinct Z segments in Solenoid | |
136 | Int_t fNPSegSol; // number of distinct P segments in Solenoid | |
137 | Int_t fNRSegSol; // number of distinct R segments in Solenoid | |
138 | Float_t* fSegZSol; //[fNZSegSol] coordinates of distinct Z segments in Solenoid | |
139 | Float_t* fSegPSol; //[fNPSegSol] coordinated of P segments for each Zsegment in Solenoid | |
140 | Float_t* fSegRSol; //[fNRSegSol] coordinated of R segments for each Psegment in Solenoid | |
141 | Int_t* fBegSegPSol; //[fNPSegSol] beginning of P segments array for each Z segment | |
142 | Int_t* fNSegPSol; //[fNZSegSol] number of P segments for each Z segment | |
143 | Int_t* fBegSegRSol; //[fNPSegSol] beginning of R segments array for each P segment | |
144 | Int_t* fNSegRSol; //[fNPSegSol] number of R segments for each P segment | |
145 | Int_t* fSegIDSol; //[fNRSegSol] ID of the solenoid parameterization for given RPZ segment | |
146 | Float_t fMinZSol; // Min Z of Solenoid parameterization | |
147 | Float_t fMaxZSol; // Max Z of Solenoid parameterization | |
148 | TObjArray* fParamsSol; // Parameterization pieces for Solenoid field | |
149 | Float_t fMaxRSol; // max raduis for Solenoid field | |
150 | // | |
151 | Int_t fNParamsTPC; // Total number of parameterization pieces for TPCint | |
152 | Int_t fNZSegTPC; // number of distinct Z segments in TPCint | |
153 | Int_t fNPSegTPC; // number of distinct P segments in TPCint | |
154 | Int_t fNRSegTPC; // number of distinct R segments in TPCint | |
155 | Float_t* fSegZTPC; //[fNZSegTPC] coordinates of distinct Z segments in TPCint | |
156 | Float_t* fSegPTPC; //[fNPSegTPC] coordinated of P segments for each Zsegment in TPCint | |
157 | Float_t* fSegRTPC; //[fNRSegTPC] coordinated of R segments for each Psegment in TPCint | |
158 | Int_t* fBegSegPTPC; //[fNPSegTPC] beginning of P segments array for each Z segment | |
159 | Int_t* fNSegPTPC; //[fNZSegTPC] number of P segments for each Z segment | |
160 | Int_t* fBegSegRTPC; //[fNPSegTPC] beginning of R segments array for each P segment | |
161 | Int_t* fNSegRTPC; //[fNPSegTPC] number of R segments for each P segment | |
162 | Int_t* fSegIDTPC; //[fNRSegTPC] ID of the TPCint parameterization for given RPZ segment | |
163 | Float_t fMinZTPC; // Min Z of TPCint parameterization | |
164 | Float_t fMaxZTPC; // Max Z of TPCint parameterization | |
165 | TObjArray* fParamsTPC; // Parameterization pieces for TPCint field | |
166 | Float_t fMaxRTPC; // max raduis for Solenoid field integral in TPC | |
da7cd221 | 167 | // |
168 | Int_t fNParamsDip; // Total number of parameterization pieces for dipole | |
169 | Int_t fNZSegDip; // number of distinct Z segments in Dipole | |
170 | Int_t fNYSegDip; // number of distinct Y segments in Dipole | |
171 | Int_t fNXSegDip; // number of distinct X segments in Dipole | |
da7cd221 | 172 | Float_t* fSegZDip; //[fNZSegDip] coordinates of distinct Z segments in Dipole |
173 | Float_t* fSegYDip; //[fNYSegDip] coordinated of Y segments for each Zsegment in Dipole | |
174 | Float_t* fSegXDip; //[fNXSegDip] coordinated of X segments for each Ysegment in Dipole | |
da7cd221 | 175 | Int_t* fBegSegYDip; //[fNZSegDip] beginning of Y segments array for each Z segment |
176 | Int_t* fNSegYDip; //[fNZSegDip] number of Y segments for each Z segment | |
177 | Int_t* fBegSegXDip; //[fNYSegDip] beginning of X segments array for each Y segment | |
178 | Int_t* fNSegXDip; //[fNYSegDip] number of X segments for each Y segment | |
179 | Int_t* fSegIDDip; //[fNXSegDip] ID of the dipole parameterization for given XYZ segment | |
da7cd221 | 180 | Float_t fMinZDip; // Min Z of Dipole parameterization |
181 | Float_t fMaxZDip; // Max Z of Dipole parameterization | |
da7cd221 | 182 | TObjArray* fParamsDip; // Parameterization pieces for Dipole field |
da7cd221 | 183 | // |
1d18ebe0 | 184 | ClassDef(AliMagWrapCheb,5) // Wrapper class for the set of Chebishev parameterizations of Alice mag.field |
da7cd221 | 185 | // |
186 | }; | |
187 | ||
188 | ||
da7cd221 | 189 | //__________________________________________________________________________________________ |
190 | inline void AliMagWrapCheb::FieldCyl(const Double_t *rphiz, Double_t *b) const | |
191 | { | |
192 | // compute field in Cylindircal coordinates | |
193 | // if (rphiz[2]<GetMinZSol() || rphiz[2]>GetMaxZSol() || rphiz[0]>GetMaxRSol()) {for (int i=3;i--;) b[i]=0; return;} | |
1d18ebe0 | 194 | b[0] = b[1] = b[2] = 0; |
da7cd221 | 195 | FieldCylSol(rphiz,b); |
196 | } | |
197 | ||
198 | //__________________________________________________________________________________________________ | |
db83d72f | 199 | inline void AliMagWrapCheb::CylToCartCylB(const Double_t *rphiz, const Double_t *brphiz,Double_t *bxyz) |
da7cd221 | 200 | { |
201 | // convert field in cylindrical coordinates to cartesian system, point is in cyl.system | |
db83d72f | 202 | Double_t btr = TMath::Sqrt(brphiz[0]*brphiz[0]+brphiz[1]*brphiz[1]); |
203 | Double_t psiPLUSphi = TMath::ATan2(brphiz[1],brphiz[0]) + rphiz[1]; | |
da7cd221 | 204 | bxyz[0] = btr*TMath::Cos(psiPLUSphi); |
205 | bxyz[1] = btr*TMath::Sin(psiPLUSphi); | |
206 | bxyz[2] = brphiz[2]; | |
207 | // | |
208 | } | |
209 | ||
210 | //__________________________________________________________________________________________________ | |
db83d72f | 211 | inline void AliMagWrapCheb::CylToCartCartB(const Double_t* xyz, const Double_t *brphiz, Double_t *bxyz) |
da7cd221 | 212 | { |
213 | // convert field in cylindrical coordinates to cartesian system, point is in cart.system | |
db83d72f | 214 | Double_t btr = TMath::Sqrt(brphiz[0]*brphiz[0]+brphiz[1]*brphiz[1]); |
215 | Double_t phiPLUSpsi = TMath::ATan2(xyz[1],xyz[0]) + TMath::ATan2(brphiz[1],brphiz[0]); | |
da7cd221 | 216 | bxyz[0] = btr*TMath::Cos(phiPLUSpsi); |
217 | bxyz[1] = btr*TMath::Sin(phiPLUSpsi); | |
218 | bxyz[2] = brphiz[2]; | |
219 | // | |
220 | } | |
221 | ||
222 | //__________________________________________________________________________________________________ | |
db83d72f | 223 | inline void AliMagWrapCheb::CartToCylCartB(const Double_t *xyz, const Double_t *bxyz, Double_t *brphiz) |
da7cd221 | 224 | { |
225 | // convert field in cylindrical coordinates to cartesian system, poin is in cart.system | |
db83d72f | 226 | Double_t btr = TMath::Sqrt(bxyz[0]*bxyz[0]+bxyz[1]*bxyz[1]); |
227 | Double_t psiMINphi = TMath::ATan2(bxyz[1],bxyz[0]) - TMath::ATan2(xyz[1],xyz[0]); | |
da7cd221 | 228 | // |
229 | brphiz[0] = btr*TMath::Cos(psiMINphi); | |
230 | brphiz[1] = btr*TMath::Sin(psiMINphi); | |
231 | brphiz[2] = bxyz[2]; | |
232 | // | |
233 | } | |
234 | ||
235 | //__________________________________________________________________________________________________ | |
db83d72f | 236 | inline void AliMagWrapCheb::CartToCylCylB(const Double_t *rphiz, const Double_t *bxyz, Double_t *brphiz) |
da7cd221 | 237 | { |
238 | // convert field in cylindrical coordinates to cartesian system, point is in cyl.system | |
db83d72f | 239 | Double_t btr = TMath::Sqrt(bxyz[0]*bxyz[0]+bxyz[1]*bxyz[1]); |
240 | Double_t psiMINphi = TMath::ATan2(bxyz[1],bxyz[0]) - rphiz[1]; | |
da7cd221 | 241 | brphiz[0] = btr*TMath::Cos(psiMINphi); |
242 | brphiz[1] = btr*TMath::Sin(psiMINphi); | |
243 | brphiz[2] = bxyz[2]; | |
244 | // | |
245 | } | |
a1dde210 | 246 | |
da7cd221 | 247 | //__________________________________________________________________________________________________ |
db83d72f | 248 | inline void AliMagWrapCheb::CartToCyl(const Double_t *xyz, Double_t *rphiz) |
da7cd221 | 249 | { |
250 | rphiz[0] = TMath::Sqrt(xyz[0]*xyz[0]+xyz[1]*xyz[1]); | |
251 | rphiz[1] = TMath::ATan2(xyz[1],xyz[0]); | |
252 | rphiz[2] = xyz[2]; | |
253 | } | |
254 | ||
255 | //__________________________________________________________________________________________________ | |
db83d72f | 256 | inline void AliMagWrapCheb::CylToCart(const Double_t *rphiz, Double_t *xyz) |
da7cd221 | 257 | { |
258 | xyz[0] = rphiz[0]*TMath::Cos(rphiz[1]); | |
259 | xyz[1] = rphiz[0]*TMath::Sin(rphiz[1]); | |
260 | xyz[2] = rphiz[2]; | |
261 | } | |
262 | ||
a1dde210 | 263 | #endif |