1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
16 #include "AliMagWrapCheb.h"
22 ClassImp(AliMagWrapCheb)
24 //__________________________________________________________________________________________
25 AliMagWrapCheb::AliMagWrapCheb() :
26 fNParamsSol(0),fNZSegSol(0),fNPSegSol(0),fNRSegSol(0),
27 fSegZSol(0),fSegPSol(0),fSegRSol(0),
28 fBegSegPSol(0),fNSegPSol(0),fBegSegRSol(0),fNSegRSol(0),fSegIDSol(0),fMinZSol(1.e6),fMaxZSol(-1.e6),fParamsSol(0),fMaxRSol(0),
30 fNParamsTPC(0),fNZSegTPC(0),fNPSegTPC(0),fNRSegTPC(0),
31 fSegZTPC(0),fSegPTPC(0),fSegRTPC(0),
32 fBegSegPTPC(0),fNSegPTPC(0),fBegSegRTPC(0),fNSegRTPC(0),fSegIDTPC(0),fMinZTPC(1.e6),fMaxZTPC(-1.e6),fParamsTPC(0),fMaxRTPC(0),
34 fNParamsTPCRat(0),fNZSegTPCRat(0),fNPSegTPCRat(0),fNRSegTPCRat(0),
35 fSegZTPCRat(0),fSegPTPCRat(0),fSegRTPCRat(0),
36 fBegSegPTPCRat(0),fNSegPTPCRat(0),fBegSegRTPCRat(0),fNSegRTPCRat(0),fSegIDTPCRat(0),fMinZTPCRat(1.e6),fMaxZTPCRat(-1.e6),fParamsTPCRat(0),fMaxRTPCRat(0),
38 fNParamsDip(0),fNZSegDip(0),fNYSegDip(0),fNXSegDip(0),
39 fSegZDip(0),fSegYDip(0),fSegXDip(0),
40 fBegSegYDip(0),fNSegYDip(0),fBegSegXDip(0),fNSegXDip(0),fSegIDDip(0),fMinZDip(1.e6),fMaxZDip(-1.e6),fParamsDip(0)
43 // default constructor
46 //__________________________________________________________________________________________
47 AliMagWrapCheb::AliMagWrapCheb(const AliMagWrapCheb& src) :
49 fNParamsSol(0),fNZSegSol(0),fNPSegSol(0),fNRSegSol(0),
50 fSegZSol(0),fSegPSol(0),fSegRSol(0),
51 fBegSegPSol(0),fNSegPSol(0),fBegSegRSol(0),fNSegRSol(0),fSegIDSol(0),fMinZSol(1.e6),fMaxZSol(-1.e6),fParamsSol(0),fMaxRSol(0),
53 fNParamsTPC(0),fNZSegTPC(0),fNPSegTPC(0),fNRSegTPC(0),
54 fSegZTPC(0),fSegPTPC(0),fSegRTPC(0),
55 fBegSegPTPC(0),fNSegPTPC(0),fBegSegRTPC(0),fNSegRTPC(0),fSegIDTPC(0),fMinZTPC(1.e6),fMaxZTPC(-1.e6),fParamsTPC(0),fMaxRTPC(0),
57 fNParamsTPCRat(0),fNZSegTPCRat(0),fNPSegTPCRat(0),fNRSegTPCRat(0),
58 fSegZTPCRat(0),fSegPTPCRat(0),fSegRTPCRat(0),
59 fBegSegPTPCRat(0),fNSegPTPCRat(0),fBegSegRTPCRat(0),fNSegRTPCRat(0),fSegIDTPCRat(0),fMinZTPCRat(1.e6),fMaxZTPCRat(-1.e6),fParamsTPCRat(0),fMaxRTPCRat(0),
61 fNParamsDip(0),fNZSegDip(0),fNYSegDip(0),fNXSegDip(0),
62 fSegZDip(0),fSegYDip(0),fSegXDip(0),
63 fBegSegYDip(0),fNSegYDip(0),fBegSegXDip(0),fNSegXDip(0),fSegIDDip(0),fMinZDip(1.e6),fMaxZDip(-1.e6),fParamsDip(0)
69 //__________________________________________________________________________________________
70 void AliMagWrapCheb::CopyFrom(const AliMagWrapCheb& src)
74 SetName(src.GetName());
75 SetTitle(src.GetTitle());
77 fNParamsSol = src.fNParamsSol;
78 fNZSegSol = src.fNZSegSol;
79 fNPSegSol = src.fNPSegSol;
80 fNRSegSol = src.fNRSegSol;
81 fMinZSol = src.fMinZSol;
82 fMaxZSol = src.fMaxZSol;
83 fMaxRSol = src.fMaxRSol;
84 if (src.fNParamsSol) {
85 memcpy(fSegZSol = new Float_t[fNZSegSol], src.fSegZSol, sizeof(Float_t)*fNZSegSol);
86 memcpy(fSegPSol = new Float_t[fNPSegSol], src.fSegPSol, sizeof(Float_t)*fNPSegSol);
87 memcpy(fSegRSol = new Float_t[fNRSegSol], src.fSegRSol, sizeof(Float_t)*fNRSegSol);
88 memcpy(fBegSegPSol= new Int_t[fNZSegSol], src.fBegSegPSol, sizeof(Int_t)*fNZSegSol);
89 memcpy(fNSegPSol = new Int_t[fNZSegSol], src.fNSegPSol, sizeof(Int_t)*fNZSegSol);
90 memcpy(fBegSegRSol= new Int_t[fNPSegSol], src.fBegSegRSol, sizeof(Int_t)*fNPSegSol);
91 memcpy(fNSegRSol = new Int_t[fNPSegSol], src.fNSegRSol, sizeof(Int_t)*fNPSegSol);
92 memcpy(fSegIDSol = new Int_t[fNRSegSol], src.fSegIDSol, sizeof(Int_t)*fNRSegSol);
93 fParamsSol = new TObjArray(fNParamsSol);
94 for (int i=0;i<fNParamsSol;i++) fParamsSol->AddAtAndExpand(new AliCheb3D(*src.GetParamSol(i)),i);
97 fNParamsTPC = src.fNParamsTPC;
98 fNZSegTPC = src.fNZSegTPC;
99 fNPSegTPC = src.fNPSegTPC;
100 fNRSegTPC = src.fNRSegTPC;
101 fMinZTPC = src.fMinZTPC;
102 fMaxZTPC = src.fMaxZTPC;
103 fMaxRTPC = src.fMaxRTPC;
104 if (src.fNParamsTPC) {
105 memcpy(fSegZTPC = new Float_t[fNZSegTPC], src.fSegZTPC, sizeof(Float_t)*fNZSegTPC);
106 memcpy(fSegPTPC = new Float_t[fNPSegTPC], src.fSegPTPC, sizeof(Float_t)*fNPSegTPC);
107 memcpy(fSegRTPC = new Float_t[fNRSegTPC], src.fSegRTPC, sizeof(Float_t)*fNRSegTPC);
108 memcpy(fBegSegPTPC= new Int_t[fNZSegTPC], src.fBegSegPTPC, sizeof(Int_t)*fNZSegTPC);
109 memcpy(fNSegPTPC = new Int_t[fNZSegTPC], src.fNSegPTPC, sizeof(Int_t)*fNZSegTPC);
110 memcpy(fBegSegRTPC= new Int_t[fNPSegTPC], src.fBegSegRTPC, sizeof(Int_t)*fNPSegTPC);
111 memcpy(fNSegRTPC = new Int_t[fNPSegTPC], src.fNSegRTPC, sizeof(Int_t)*fNPSegTPC);
112 memcpy(fSegIDTPC = new Int_t[fNRSegTPC], src.fSegIDTPC, sizeof(Int_t)*fNRSegTPC);
113 fParamsTPC = new TObjArray(fNParamsTPC);
114 for (int i=0;i<fNParamsTPC;i++) fParamsTPC->AddAtAndExpand(new AliCheb3D(*src.GetParamTPCInt(i)),i);
117 fNParamsTPCRat = src.fNParamsTPCRat;
118 fNZSegTPCRat = src.fNZSegTPCRat;
119 fNPSegTPCRat = src.fNPSegTPCRat;
120 fNRSegTPCRat = src.fNRSegTPCRat;
121 fMinZTPCRat = src.fMinZTPCRat;
122 fMaxZTPCRat = src.fMaxZTPCRat;
123 fMaxRTPCRat = src.fMaxRTPCRat;
124 if (src.fNParamsTPCRat) {
125 memcpy(fSegZTPCRat = new Float_t[fNZSegTPCRat], src.fSegZTPCRat, sizeof(Float_t)*fNZSegTPCRat);
126 memcpy(fSegPTPCRat = new Float_t[fNPSegTPCRat], src.fSegPTPCRat, sizeof(Float_t)*fNPSegTPCRat);
127 memcpy(fSegRTPCRat = new Float_t[fNRSegTPCRat], src.fSegRTPCRat, sizeof(Float_t)*fNRSegTPCRat);
128 memcpy(fBegSegPTPCRat= new Int_t[fNZSegTPCRat], src.fBegSegPTPCRat, sizeof(Int_t)*fNZSegTPCRat);
129 memcpy(fNSegPTPCRat = new Int_t[fNZSegTPCRat], src.fNSegPTPCRat, sizeof(Int_t)*fNZSegTPCRat);
130 memcpy(fBegSegRTPCRat= new Int_t[fNPSegTPCRat], src.fBegSegRTPCRat, sizeof(Int_t)*fNPSegTPCRat);
131 memcpy(fNSegRTPCRat = new Int_t[fNPSegTPCRat], src.fNSegRTPCRat, sizeof(Int_t)*fNPSegTPCRat);
132 memcpy(fSegIDTPCRat = new Int_t[fNRSegTPCRat], src.fSegIDTPCRat, sizeof(Int_t)*fNRSegTPCRat);
133 fParamsTPCRat = new TObjArray(fNParamsTPCRat);
134 for (int i=0;i<fNParamsTPCRat;i++) fParamsTPCRat->AddAtAndExpand(new AliCheb3D(*src.GetParamTPCRatInt(i)),i);
137 fNParamsDip = src.fNParamsDip;
138 fNZSegDip = src.fNZSegDip;
139 fNYSegDip = src.fNYSegDip;
140 fNXSegDip = src.fNXSegDip;
141 fMinZDip = src.fMinZDip;
142 fMaxZDip = src.fMaxZDip;
143 if (src.fNParamsDip) {
144 memcpy(fSegZDip = new Float_t[fNZSegDip], src.fSegZDip, sizeof(Float_t)*fNZSegDip);
145 memcpy(fSegYDip = new Float_t[fNYSegDip], src.fSegYDip, sizeof(Float_t)*fNYSegDip);
146 memcpy(fSegXDip = new Float_t[fNXSegDip], src.fSegXDip, sizeof(Float_t)*fNXSegDip);
147 memcpy(fBegSegYDip= new Int_t[fNZSegDip], src.fBegSegYDip, sizeof(Int_t)*fNZSegDip);
148 memcpy(fNSegYDip = new Int_t[fNZSegDip], src.fNSegYDip, sizeof(Int_t)*fNZSegDip);
149 memcpy(fBegSegXDip= new Int_t[fNYSegDip], src.fBegSegXDip, sizeof(Int_t)*fNYSegDip);
150 memcpy(fNSegXDip = new Int_t[fNYSegDip], src.fNSegXDip, sizeof(Int_t)*fNYSegDip);
151 memcpy(fSegIDDip = new Int_t[fNXSegDip], src.fSegIDDip, sizeof(Int_t)*fNXSegDip);
152 fParamsDip = new TObjArray(fNParamsDip);
153 for (int i=0;i<fNParamsDip;i++) fParamsDip->AddAtAndExpand(new AliCheb3D(*src.GetParamDip(i)),i);
158 //__________________________________________________________________________________________
159 AliMagWrapCheb& AliMagWrapCheb::operator=(const AliMagWrapCheb& rhs)
170 //__________________________________________________________________________________________
171 void AliMagWrapCheb::Clear(const Option_t *)
173 // clear all dynamic parts
175 fParamsSol->SetOwner(kTRUE);
176 delete fParamsSol; fParamsSol = 0;
177 delete[] fSegZSol; fSegZSol = 0;
178 delete[] fSegPSol; fSegPSol = 0;
179 delete[] fSegRSol; fSegRSol = 0;
180 delete[] fBegSegPSol; fBegSegPSol = 0;
181 delete[] fNSegPSol; fNSegPSol = 0;
182 delete[] fBegSegRSol; fBegSegRSol = 0;
183 delete[] fNSegRSol; fNSegRSol = 0;
184 delete[] fSegIDSol; fSegIDSol = 0;
186 fNParamsSol = fNZSegSol = fNPSegSol = fNRSegSol = 0;
192 fParamsTPC->SetOwner(kTRUE);
193 delete fParamsTPC; fParamsTPC = 0;
194 delete[] fSegZTPC; fSegZTPC = 0;
195 delete[] fSegPTPC; fSegPTPC = 0;
196 delete[] fSegRTPC; fSegRTPC = 0;
197 delete[] fBegSegPTPC; fBegSegPTPC = 0;
198 delete[] fNSegPTPC; fNSegPTPC = 0;
199 delete[] fBegSegRTPC; fBegSegRTPC = 0;
200 delete[] fNSegRTPC; fNSegRTPC = 0;
201 delete[] fSegIDTPC; fSegIDTPC = 0;
203 fNParamsTPC = fNZSegTPC = fNPSegTPC = fNRSegTPC = 0;
208 if (fNParamsTPCRat) {
209 fParamsTPCRat->SetOwner(kTRUE);
210 delete fParamsTPCRat; fParamsTPCRat = 0;
211 delete[] fSegZTPCRat; fSegZTPCRat = 0;
212 delete[] fSegPTPCRat; fSegPTPCRat = 0;
213 delete[] fSegRTPCRat; fSegRTPCRat = 0;
214 delete[] fBegSegPTPCRat; fBegSegPTPCRat = 0;
215 delete[] fNSegPTPCRat; fNSegPTPCRat = 0;
216 delete[] fBegSegRTPCRat; fBegSegRTPCRat = 0;
217 delete[] fNSegRTPCRat; fNSegRTPCRat = 0;
218 delete[] fSegIDTPCRat; fSegIDTPCRat = 0;
220 fNParamsTPCRat = fNZSegTPCRat = fNPSegTPCRat = fNRSegTPCRat = 0;
226 fParamsDip->SetOwner(kTRUE);
227 delete fParamsDip; fParamsDip = 0;
228 delete[] fSegZDip; fSegZDip = 0;
229 delete[] fSegYDip; fSegYDip = 0;
230 delete[] fSegXDip; fSegXDip = 0;
231 delete[] fBegSegYDip; fBegSegYDip = 0;
232 delete[] fNSegYDip; fNSegYDip = 0;
233 delete[] fBegSegXDip; fBegSegXDip = 0;
234 delete[] fNSegXDip; fNSegXDip = 0;
235 delete[] fSegIDDip; fSegIDDip = 0;
237 fNParamsDip = fNZSegDip = fNYSegDip = fNXSegDip = 0;
243 //__________________________________________________________________________________________
244 void AliMagWrapCheb::Field(const Double_t *xyz, Double_t *b) const
246 // compute field in cartesian coordinates. If point is outside of the parameterized region
247 // get it at closest valid point
250 #ifndef _BRING_TO_BOUNDARY_ // exact matching to fitted volume is requested
251 b[0] = b[1] = b[2] = 0;
254 if (xyz[2]>fMinZSol) {
255 CartToCyl(xyz,rphiz);
256 FieldCylSol(rphiz,b);
257 // convert field to cartesian system
258 CylToCartCylB(rphiz, b,b);
262 int iddip = FindDipSegment(xyz);
264 AliCheb3D* par = GetParamDip(iddip);
265 #ifndef _BRING_TO_BOUNDARY_
266 if (!par->IsInside(xyz)) return;
272 //__________________________________________________________________________________________
273 Double_t AliMagWrapCheb::GetBz(const Double_t *xyz) const
275 // compute Bz for the point in cartesian coordinates. If point is outside of the parameterized region
276 // get it at closest valid point
279 if (xyz[2]>fMinZSol) {
280 CartToCyl(xyz,rphiz);
281 return FieldCylSolBz(rphiz);
284 int iddip = FindDipSegment(xyz);
285 if (iddip<0) return 0.;
286 AliCheb3D* par = GetParamDip(iddip);
287 #ifndef _BRING_TO_BOUNDARY_
288 if (!par->IsInside(xyz)) return 0.;
290 return par->Eval(xyz,2);
294 //__________________________________________________________________________________________
295 void AliMagWrapCheb::Print(Option_t *) const
298 printf("Alice magnetic field parameterized by Chebyshev polynomials\n");
299 printf("Segmentation for Solenoid (%+.2f<Z<%+.2f cm | R<%.2f cm)\n",fMinZSol,fMaxZSol,fMaxRSol);
302 for (int i=0;i<fNParamsSol;i++) {
304 GetParamSol(i)->Print();
308 printf("Segmentation for TPC field integral (%+.2f<Z<%+.2f cm | R<%.2f cm)\n",fMinZTPC,fMaxZTPC,fMaxRTPC);
311 for (int i=0;i<fNParamsTPC;i++) {
313 GetParamTPCInt(i)->Print();
317 printf("Segmentation for TPC field ratios integral (%+.2f<Z<%+.2f cm | R<%.2f cm)\n",fMinZTPCRat,fMaxZTPCRat,fMaxRTPCRat);
320 for (int i=0;i<fNParamsTPCRat;i++) {
321 printf("TPCRat%4d ",i);
322 GetParamTPCRatInt(i)->Print();
326 printf("Segmentation for Dipole (%+.2f<Z<%+.2f cm)\n",fMinZDip,fMaxZDip);
328 for (int i=0;i<fNParamsDip;i++) {
330 GetParamDip(i)->Print();
336 //__________________________________________________________________________________________________
337 Int_t AliMagWrapCheb::FindDipSegment(const Double_t *xyz) const
339 // find the segment containing point xyz. If it is outside find the closest segment
340 if (!fNParamsDip) return -1;
341 int xid,yid,zid = TMath::BinarySearch(fNZSegDip,fSegZDip,(Float_t)xyz[2]); // find zsegment
343 Bool_t reCheck = kFALSE;
345 int ysegBeg = fBegSegYDip[zid];
347 for (yid=0;yid<fNSegYDip[zid];yid++) if (xyz[1]<fSegYDip[ysegBeg+yid]) break;
348 if ( --yid < 0 ) yid = 0;
351 int xsegBeg = fBegSegXDip[yid];
352 for (xid=0;xid<fNSegXDip[yid];xid++) if (xyz[0]<fSegXDip[xsegBeg+xid]) break;
354 if ( --xid < 0) xid = 0;
357 // to make sure that due to the precision problems we did not pick the next Zbin
358 if (!reCheck && (xyz[2] - fSegZDip[zid] < 3.e-5) && zid &&
359 !GetParamDip(fSegIDDip[xid])->IsInside(xyz)) { // check the previous Z bin
366 return fSegIDDip[xid];
369 //__________________________________________________________________________________________________
370 Int_t AliMagWrapCheb::FindSolSegment(const Double_t *rpz) const
372 // find the segment containing point xyz. If it is outside find the closest segment
373 if (!fNParamsSol) return -1;
374 int rid,pid,zid = TMath::BinarySearch(fNZSegSol,fSegZSol,(Float_t)rpz[2]); // find zsegment
376 Bool_t reCheck = kFALSE;
378 int psegBeg = fBegSegPSol[zid];
379 for (pid=0;pid<fNSegPSol[zid];pid++) if (rpz[1]<fSegPSol[psegBeg+pid]) break;
380 if ( --pid < 0 ) pid = 0;
383 int rsegBeg = fBegSegRSol[pid];
384 for (rid=0;rid<fNSegRSol[pid];rid++) if (rpz[0]<fSegRSol[rsegBeg+rid]) break;
385 if ( --rid < 0) rid = 0;
388 // to make sure that due to the precision problems we did not pick the next Zbin
389 if (!reCheck && (rpz[2] - fSegZSol[zid] < 3.e-5) && zid &&
390 !GetParamSol(fSegIDSol[rid])->IsInside(rpz)) { // check the previous Z bin
397 return fSegIDSol[rid];
400 //__________________________________________________________________________________________________
401 Int_t AliMagWrapCheb::FindTPCSegment(const Double_t *rpz) const
403 // find the segment containing point xyz. If it is outside find the closest segment
404 if (!fNParamsTPC) return -1;
405 int rid,pid,zid = TMath::BinarySearch(fNZSegTPC,fSegZTPC,(Float_t)rpz[2]); // find zsegment
407 Bool_t reCheck = kFALSE;
409 int psegBeg = fBegSegPTPC[zid];
411 for (pid=0;pid<fNSegPTPC[zid];pid++) if (rpz[1]<fSegPTPC[psegBeg+pid]) break;
412 if ( --pid < 0 ) pid = 0;
415 int rsegBeg = fBegSegRTPC[pid];
416 for (rid=0;rid<fNSegRTPC[pid];rid++) if (rpz[0]<fSegRTPC[rsegBeg+rid]) break;
417 if ( --rid < 0) rid = 0;
420 // to make sure that due to the precision problems we did not pick the next Zbin
421 if (!reCheck && (rpz[2] - fSegZTPC[zid] < 3.e-5) && zid &&
422 !GetParamTPCInt(fSegIDTPC[rid])->IsInside(rpz)) { // check the previous Z bin
429 return fSegIDTPC[rid];
432 //__________________________________________________________________________________________________
433 Int_t AliMagWrapCheb::FindTPCRatSegment(const Double_t *rpz) const
435 // find the segment containing point xyz. If it is outside find the closest segment
436 if (!fNParamsTPCRat) return -1;
437 int rid,pid,zid = TMath::BinarySearch(fNZSegTPCRat,fSegZTPCRat,(Float_t)rpz[2]); // find zsegment
439 Bool_t reCheck = kFALSE;
441 int psegBeg = fBegSegPTPCRat[zid];
443 for (pid=0;pid<fNSegPTPCRat[zid];pid++) if (rpz[1]<fSegPTPCRat[psegBeg+pid]) break;
444 if ( --pid < 0 ) pid = 0;
447 int rsegBeg = fBegSegRTPCRat[pid];
448 for (rid=0;rid<fNSegRTPCRat[pid];rid++) if (rpz[0]<fSegRTPCRat[rsegBeg+rid]) break;
449 if ( --rid < 0) rid = 0;
452 // to make sure that due to the precision problems we did not pick the next Zbin
453 if (!reCheck && (rpz[2] - fSegZTPCRat[zid] < 3.e-5) && zid &&
454 !GetParamTPCRatInt(fSegIDTPCRat[rid])->IsInside(rpz)) { // check the previous Z bin
461 return fSegIDTPCRat[rid];
465 //__________________________________________________________________________________________
466 void AliMagWrapCheb::GetTPCInt(const Double_t *xyz, Double_t *b) const
468 // compute TPC region field integral in cartesian coordinates.
469 // If point is outside of the parameterized region get it at closeset valid point
470 static Double_t rphiz[3];
473 // convert coordinates to cyl system
474 CartToCyl(xyz,rphiz);
475 #ifndef _BRING_TO_BOUNDARY_
476 if ( (rphiz[2]>GetMaxZTPCInt()||rphiz[2]<GetMinZTPCInt()) ||
477 rphiz[0]>GetMaxRTPCInt()) {for (int i=3;i--;) b[i]=0; return;}
480 GetTPCIntCyl(rphiz,b);
482 // convert field to cartesian system
483 CylToCartCylB(rphiz, b,b);
487 //__________________________________________________________________________________________
488 void AliMagWrapCheb::GetTPCRatInt(const Double_t *xyz, Double_t *b) const
490 // compute TPCRat region field integral in cartesian coordinates.
491 // If point is outside of the parameterized region get it at closeset valid point
492 static Double_t rphiz[3];
495 // convert coordinates to cyl system
496 CartToCyl(xyz,rphiz);
497 #ifndef _BRING_TO_BOUNDARY_
498 if ( (rphiz[2]>GetMaxZTPCRatInt()||rphiz[2]<GetMinZTPCRatInt()) ||
499 rphiz[0]>GetMaxRTPCRatInt()) {for (int i=3;i--;) b[i]=0; return;}
502 GetTPCRatIntCyl(rphiz,b);
504 // convert field to cartesian system
505 CylToCartCylB(rphiz, b,b);
509 //__________________________________________________________________________________________
510 void AliMagWrapCheb::FieldCylSol(const Double_t *rphiz, Double_t *b) const
512 // compute Solenoid field in Cylindircal coordinates
513 // note: if the point is outside the volume get the field in closest parameterized point
514 int id = FindSolSegment(rphiz);
516 AliCheb3D* par = GetParamSol(id);
517 #ifndef _BRING_TO_BOUNDARY_ // exact matching to fitted volume is requested
518 if (!par->IsInside(rphiz)) return;
525 //__________________________________________________________________________________________
526 Double_t AliMagWrapCheb::FieldCylSolBz(const Double_t *rphiz) const
528 // compute Solenoid field in Cylindircal coordinates
529 // note: if the point is outside the volume get the field in closest parameterized point
530 int id = FindSolSegment(rphiz);
532 AliCheb3D* par = GetParamSol(id);
533 #ifndef _BRING_TO_BOUNDARY_
534 return par->IsInside(rphiz) ? par->Eval(rphiz,2) : 0;
536 return par->Eval(rphiz,2);
541 //__________________________________________________________________________________________
542 void AliMagWrapCheb::GetTPCIntCyl(const Double_t *rphiz, Double_t *b) const
544 // compute field integral in TPC region in Cylindircal coordinates
545 // note: the check for the point being inside the parameterized region is done outside
546 int id = FindTPCSegment(rphiz);
548 b[0] = b[1] = b[2] = 0;
551 if (id>=fNParamsTPC) {
552 AliError(Form("Wrong TPCParam segment %d",id));
553 b[0] = b[1] = b[2] = 0;
556 AliCheb3D* par = GetParamTPCInt(id);
557 if (par->IsInside(rphiz)) {
561 b[0] = b[1] = b[2] = 0;
566 //__________________________________________________________________________________________
567 void AliMagWrapCheb::GetTPCRatIntCyl(const Double_t *rphiz, Double_t *b) const
569 // compute field integral in TPCRat region in Cylindircal coordinates
570 // note: the check for the point being inside the parameterized region is done outside
571 int id = FindTPCRatSegment(rphiz);
573 b[0] = b[1] = b[2] = 0;
576 if (id>=fNParamsTPCRat) {
577 AliError(Form("Wrong TPCRatParam segment %d",id));
578 b[0] = b[1] = b[2] = 0;
581 AliCheb3D* par = GetParamTPCRatInt(id);
582 if (par->IsInside(rphiz)) {
586 b[0] = b[1] = b[2] = 0;
592 #ifdef _INC_CREATION_ALICHEB3D_
593 //_______________________________________________
594 void AliMagWrapCheb::LoadData(const char* inpfile)
596 // read coefficients data from the text file
598 TString strf = inpfile;
599 gSystem->ExpandPathName(strf);
600 FILE* stream = fopen(strf,"r");
602 printf("Did not find input file %s\n",strf.Data());
607 AliCheb3DCalc::ReadLine(buffs,stream);
608 if (!buffs.BeginsWith("START")) {
609 Error("LoadData","Expected: \"START <name>\", found \"%s\"\nStop\n",buffs.Data());
612 if (buffs.First(' ')>0) SetName(buffs.Data()+buffs.First(' ')+1);
614 // Solenoid part -----------------------------------------------------------
615 AliCheb3DCalc::ReadLine(buffs,stream);
616 if (!buffs.BeginsWith("START SOLENOID")) {
617 Error("LoadData","Expected: \"START SOLENOID\", found \"%s\"\nStop\n",buffs.Data());
620 AliCheb3DCalc::ReadLine(buffs,stream); // nparam
621 int nparSol = buffs.Atoi();
623 for (int ip=0;ip<nparSol;ip++) {
624 AliCheb3D* cheb = new AliCheb3D();
625 cheb->LoadData(stream);
629 AliCheb3DCalc::ReadLine(buffs,stream);
630 if (!buffs.BeginsWith("END SOLENOID")) {
631 Error("LoadData","Expected \"END SOLENOID\", found \"%s\"\nStop\n",buffs.Data());
635 // TPCInt part -----------------------------------------------------------
636 AliCheb3DCalc::ReadLine(buffs,stream);
637 if (!buffs.BeginsWith("START TPCINT")) {
638 Error("LoadData","Expected: \"START TPCINT\", found \"%s\"\nStop\n",buffs.Data());
641 AliCheb3DCalc::ReadLine(buffs,stream); // nparam
642 int nparTPCInt = buffs.Atoi();
644 for (int ip=0;ip<nparTPCInt;ip++) {
645 AliCheb3D* cheb = new AliCheb3D();
646 cheb->LoadData(stream);
647 AddParamTPCInt(cheb);
650 AliCheb3DCalc::ReadLine(buffs,stream);
651 if (!buffs.BeginsWith("END TPCINT")) {
652 Error("LoadData","Expected \"END TPCINT\", found \"%s\"\nStop\n",buffs.Data());
656 // TPCRatInt part -----------------------------------------------------------
657 AliCheb3DCalc::ReadLine(buffs,stream);
658 if (!buffs.BeginsWith("START TPCRatINT")) {
659 Error("LoadData","Expected: \"START TPCRatINT\", found \"%s\"\nStop\n",buffs.Data());
662 AliCheb3DCalc::ReadLine(buffs,stream); // nparam
663 int nparTPCRatInt = buffs.Atoi();
665 for (int ip=0;ip<nparTPCRatInt;ip++) {
666 AliCheb3D* cheb = new AliCheb3D();
667 cheb->LoadData(stream);
668 AddParamTPCRatInt(cheb);
671 AliCheb3DCalc::ReadLine(buffs,stream);
672 if (!buffs.BeginsWith("END TPCRatINT")) {
673 Error("LoadData","Expected \"END TPCRatINT\", found \"%s\"\nStop\n",buffs.Data());
677 // Dipole part -----------------------------------------------------------
678 AliCheb3DCalc::ReadLine(buffs,stream);
679 if (!buffs.BeginsWith("START DIPOLE")) {
680 Error("LoadData","Expected: \"START DIPOLE\", found \"%s\"\nStop\n",buffs.Data());
683 AliCheb3DCalc::ReadLine(buffs,stream); // nparam
684 int nparDip = buffs.Atoi();
686 for (int ip=0;ip<nparDip;ip++) {
687 AliCheb3D* cheb = new AliCheb3D();
688 cheb->LoadData(stream);
692 AliCheb3DCalc::ReadLine(buffs,stream);
693 if (!buffs.BeginsWith("END DIPOLE")) {
694 Error("LoadData","Expected \"END DIPOLE\", found \"%s\"\nStop\n",buffs.Data());
698 AliCheb3DCalc::ReadLine(buffs,stream);
699 if (!buffs.BeginsWith("END DIPOLE") || !buffs.Contains(GetName())) {
700 Error("LoadData","Expected: \"END DIPOLE\", found \"%s\"\nStop\n",buffs.Data());
704 // ---------------------------------------------------------------------------
709 BuildTableTPCRatInt();
711 printf("Loaded magnetic field \"%s\" from %s\n",GetName(),strf.Data());
715 //__________________________________________________________________________________________
716 void AliMagWrapCheb::BuildTableSol()
718 // build lookup table
719 BuildTable(fNParamsSol,fParamsSol,
720 fNZSegSol,fNPSegSol,fNRSegSol,
722 &fSegZSol,&fSegPSol,&fSegRSol,
723 &fBegSegPSol,&fNSegPSol,
724 &fBegSegRSol,&fNSegRSol,
728 //__________________________________________________________________________________________
729 void AliMagWrapCheb::BuildTableDip()
731 // build lookup table
732 BuildTable(fNParamsDip,fParamsDip,
733 fNZSegDip,fNYSegDip,fNXSegDip,
735 &fSegZDip,&fSegYDip,&fSegXDip,
736 &fBegSegYDip,&fNSegYDip,
737 &fBegSegXDip,&fNSegXDip,
741 //__________________________________________________________________________________________
742 void AliMagWrapCheb::BuildTableTPCInt()
744 // build lookup table
745 BuildTable(fNParamsTPC,fParamsTPC,
746 fNZSegTPC,fNPSegTPC,fNRSegTPC,
748 &fSegZTPC,&fSegPTPC,&fSegRTPC,
749 &fBegSegPTPC,&fNSegPTPC,
750 &fBegSegRTPC,&fNSegRTPC,
754 //__________________________________________________________________________________________
755 void AliMagWrapCheb::BuildTableTPCRatInt()
757 // build lookup table
758 BuildTable(fNParamsTPCRat,fParamsTPCRat,
759 fNZSegTPCRat,fNPSegTPCRat,fNRSegTPCRat,
760 fMinZTPCRat,fMaxZTPCRat,
761 &fSegZTPCRat,&fSegPTPCRat,&fSegRTPCRat,
762 &fBegSegPTPCRat,&fNSegPTPCRat,
763 &fBegSegRTPCRat,&fNSegRTPCRat,
769 //_______________________________________________
770 #ifdef _INC_CREATION_ALICHEB3D_
772 //__________________________________________________________________________________________
773 AliMagWrapCheb::AliMagWrapCheb(const char* inputFile) :
774 fNParamsSol(0),fNZSegSol(0),fNPSegSol(0),fNRSegSol(0),
775 fSegZSol(0),fSegPSol(0),fSegRSol(0),
776 fBegSegPSol(0),fNSegPSol(0),fBegSegRSol(0),fNSegRSol(0),fSegIDSol(0),fMinZSol(1.e6),fMaxZSol(-1.e6),fParamsSol(0),fMaxRSol(0),
778 fNParamsTPC(0),fNZSegTPC(0),fNPSegTPC(0),fNRSegTPC(0),
779 fSegZTPC(0),fSegPTPC(0),fSegRTPC(0),
780 fBegSegPTPC(0),fNSegPTPC(0),fBegSegRTPC(0),fNSegRTPC(0),fSegIDTPC(0),fMinZTPC(1.e6),fMaxZTPC(-1.e6),fParamsTPC(0),fMaxRTPC(0),
782 fNParamsTPCRat(0),fNZSegTPCRat(0),fNPSegTPCRat(0),fNRSegTPCRat(0),
783 fSegZTPCRat(0),fSegPTPCRat(0),fSegRTPCRat(0),
784 fBegSegPTPCRat(0),fNSegPTPCRat(0),fBegSegRTPCRat(0),fNSegRTPCRat(0),fSegIDTPCRat(0),fMinZTPCRat(1.e6),fMaxZTPCRat(-1.e6),fParamsTPCRat(0),fMaxRTPCRat(0),
786 fNParamsDip(0),fNZSegDip(0),fNYSegDip(0),fNXSegDip(0),
787 fSegZDip(0),fSegYDip(0),fSegXDip(0),
788 fBegSegYDip(0),fNSegYDip(0),fBegSegXDip(0),fNSegXDip(0),fSegIDDip(0),fMinZDip(1.e6),fMaxZDip(-1.e6),fParamsDip(0)
791 // construct from coeffs from the text file
795 //__________________________________________________________________________________________
796 void AliMagWrapCheb::AddParamSol(const AliCheb3D* param)
798 // adds new parameterization piece for Sol
799 // NOTE: pieces must be added strictly in increasing R then increasing Z order
801 if (!fParamsSol) fParamsSol = new TObjArray();
802 fParamsSol->Add( (AliCheb3D*)param );
804 if (fMaxRSol<param->GetBoundMax(0)) fMaxRSol = param->GetBoundMax(0);
808 //__________________________________________________________________________________________
809 void AliMagWrapCheb::AddParamTPCInt(const AliCheb3D* param)
811 // adds new parameterization piece for TPCInt
812 // NOTE: pieces must be added strictly in increasing R then increasing Z order
814 if (!fParamsTPC) fParamsTPC = new TObjArray();
815 fParamsTPC->Add( (AliCheb3D*)param);
817 if (fMaxRTPC<param->GetBoundMax(0)) fMaxRTPC = param->GetBoundMax(0);
821 //__________________________________________________________________________________________
822 void AliMagWrapCheb::AddParamTPCRatInt(const AliCheb3D* param)
824 // adds new parameterization piece for TPCRatInt
825 // NOTE: pieces must be added strictly in increasing R then increasing Z order
827 if (!fParamsTPCRat) fParamsTPCRat = new TObjArray();
828 fParamsTPCRat->Add( (AliCheb3D*)param);
830 if (fMaxRTPCRat<param->GetBoundMax(0)) fMaxRTPCRat = param->GetBoundMax(0);
834 //__________________________________________________________________________________________
835 void AliMagWrapCheb::AddParamDip(const AliCheb3D* param)
837 // adds new parameterization piece for Dipole
839 if (!fParamsDip) fParamsDip = new TObjArray();
840 fParamsDip->Add( (AliCheb3D*)param);
845 //__________________________________________________________________________________________
846 void AliMagWrapCheb::ResetDip()
848 // clean Dip field (used for update)
850 delete fParamsDip; fParamsDip = 0;
851 delete[] fSegZDip; fSegZDip = 0;
852 delete[] fSegXDip; fSegXDip = 0;
853 delete[] fSegYDip; fSegYDip = 0;
854 delete[] fBegSegYDip; fBegSegYDip = 0;
855 delete[] fNSegYDip; fNSegYDip = 0;
856 delete[] fBegSegXDip; fBegSegXDip = 0;
857 delete[] fNSegXDip; fNSegXDip = 0;
858 delete[] fSegIDDip; fSegIDDip = 0;
860 fNParamsDip = fNZSegDip = fNXSegDip = fNYSegDip = 0;
866 //__________________________________________________________________________________________
867 void AliMagWrapCheb::ResetSol()
869 // clean Sol field (used for update)
871 delete fParamsSol; fParamsSol = 0;
872 delete[] fSegZSol; fSegZSol = 0;
873 delete[] fSegPSol; fSegPSol = 0;
874 delete[] fSegRSol; fSegRSol = 0;
875 delete[] fBegSegPSol; fBegSegPSol = 0;
876 delete[] fNSegPSol; fNSegPSol = 0;
877 delete[] fBegSegRSol; fBegSegRSol = 0;
878 delete[] fNSegRSol; fNSegRSol = 0;
879 delete[] fSegIDSol; fSegIDSol = 0;
881 fNParamsSol = fNZSegSol = fNPSegSol = fNRSegSol = 0;
888 //__________________________________________________________________________________________
889 void AliMagWrapCheb::ResetTPCInt()
891 // clean TPC field integral (used for update)
893 delete fParamsTPC; fParamsTPC = 0;
894 delete[] fSegZTPC; fSegZTPC = 0;
895 delete[] fSegPTPC; fSegPTPC = 0;
896 delete[] fSegRTPC; fSegRTPC = 0;
897 delete[] fBegSegPTPC; fBegSegPTPC = 0;
898 delete[] fNSegPTPC; fNSegPTPC = 0;
899 delete[] fBegSegRTPC; fBegSegRTPC = 0;
900 delete[] fNSegRTPC; fNSegRTPC = 0;
901 delete[] fSegIDTPC; fSegIDTPC = 0;
903 fNParamsTPC = fNZSegTPC = fNPSegTPC = fNRSegTPC = 0;
910 //__________________________________________________________________________________________
911 void AliMagWrapCheb::ResetTPCRatInt()
913 // clean TPCRat field integral (used for update)
914 if (fNParamsTPCRat) {
915 delete fParamsTPCRat; fParamsTPCRat = 0;
916 delete[] fSegZTPCRat; fSegZTPCRat = 0;
917 delete[] fSegPTPCRat; fSegPTPCRat = 0;
918 delete[] fSegRTPCRat; fSegRTPCRat = 0;
919 delete[] fBegSegPTPCRat; fBegSegPTPCRat = 0;
920 delete[] fNSegPTPCRat; fNSegPTPCRat = 0;
921 delete[] fBegSegRTPCRat; fBegSegRTPCRat = 0;
922 delete[] fNSegRTPCRat; fNSegRTPCRat = 0;
923 delete[] fSegIDTPCRat; fSegIDTPCRat = 0;
925 fNParamsTPCRat = fNZSegTPCRat = fNPSegTPCRat = fNRSegTPCRat = 0;
933 //__________________________________________________
934 void AliMagWrapCheb::BuildTable(Int_t npar,TObjArray *parArr, Int_t &nZSeg, Int_t &nYSeg, Int_t &nXSeg,
935 Float_t &minZ,Float_t &maxZ,
936 Float_t **segZ,Float_t **segY,Float_t **segX,
937 Int_t **begSegY,Int_t **nSegY,
938 Int_t **begSegX,Int_t **nSegX,
941 // build lookup table for dipole
944 TArrayF segYArr,segXArr;
945 TArrayI begSegYDipArr,begSegXDipArr;
946 TArrayI nSegYDipArr,nSegXDipArr;
948 float *tmpSegZ,*tmpSegY,*tmpSegX;
950 // create segmentation in Z
951 nZSeg = SegmentDimension(&tmpSegZ, parArr, npar, 2, 1,-1, 1,-1, 1,-1) - 1;
955 // for each Z slice create segmentation in Y
956 begSegYDipArr.Set(nZSeg);
957 nSegYDipArr.Set(nZSeg);
959 for (int iz=0;iz<nZSeg;iz++) {
960 printf("\nZSegment#%d %+e : %+e\n",iz,tmpSegZ[iz],tmpSegZ[iz+1]);
961 int ny = SegmentDimension(&tmpSegY, parArr, npar, 1,
962 1,-1, 1,-1, tmpSegZ[iz],tmpSegZ[iz+1]) - 1;
963 segYArr.Set(ny + nYSeg);
964 for (int iy=0;iy<ny;iy++) segYArr[nYSeg+iy] = tmpSegY[iy];
965 begSegYDipArr[iz] = nYSeg;
966 nSegYDipArr[iz] = ny;
967 printf(" Found %d YSegments, to start from %d\n",ny, begSegYDipArr[iz]);
969 // for each slice in Z and Y create segmentation in X
970 begSegXDipArr.Set(nYSeg+ny);
971 nSegXDipArr.Set(nYSeg+ny);
972 xyz[2] = (tmpSegZ[iz]+tmpSegZ[iz+1])/2.; // mean Z of this segment
974 for (int iy=0;iy<ny;iy++) {
976 printf("\n YSegment#%d %+e : %+e\n",iy, tmpSegY[iy],tmpSegY[iy+1]);
977 int nx = SegmentDimension(&tmpSegX, parArr, npar, 0,
978 1,-1, tmpSegY[iy],tmpSegY[iy+1], tmpSegZ[iz],tmpSegZ[iz+1]) - 1;
980 segXArr.Set(nx + nXSeg);
981 for (int ix=0;ix<nx;ix++) segXArr[nXSeg+ix] = tmpSegX[ix];
982 begSegXDipArr[isg] = nXSeg;
983 nSegXDipArr[isg] = nx;
984 printf(" Found %d XSegments, to start from %d\n",nx, begSegXDipArr[isg]);
986 segIDArr.Set(nXSeg+nx);
988 // find corresponding params
989 xyz[1] = (tmpSegY[iy]+tmpSegY[iy+1])/2.; // mean Y of this segment
991 for (int ix=0;ix<nx;ix++) {
992 xyz[0] = (tmpSegX[ix]+tmpSegX[ix+1])/2.; // mean X of this segment
993 for (int ipar=0;ipar<npar;ipar++) {
994 AliCheb3D* cheb = (AliCheb3D*) parArr->At(ipar);
995 if (!cheb->IsInside(xyz)) continue;
996 segIDArr[nXSeg+ix] = ipar;
1009 maxZ = tmpSegZ[nZSeg];
1010 (*segZ) = new Float_t[nZSeg];
1011 for (int i=nZSeg;i--;) (*segZ)[i] = tmpSegZ[i];
1014 (*segY) = new Float_t[nYSeg];
1015 (*segX) = new Float_t[nXSeg];
1016 (*begSegY) = new Int_t[nZSeg];
1017 (*nSegY) = new Int_t[nZSeg];
1018 (*begSegX) = new Int_t[nYSeg];
1019 (*nSegX) = new Int_t[nYSeg];
1020 (*segID) = new Int_t[nXSeg];
1022 for (int i=nYSeg;i--;) (*segY)[i] = segYArr[i];
1023 for (int i=nXSeg;i--;) (*segX)[i] = segXArr[i];
1024 for (int i=nZSeg;i--;) {(*begSegY)[i] = begSegYDipArr[i]; (*nSegY)[i] = nSegYDipArr[i];}
1025 for (int i=nYSeg;i--;) {(*begSegX)[i] = begSegXDipArr[i]; (*nSegX)[i] = nSegXDipArr[i];}
1026 for (int i=nXSeg;i--;) {(*segID)[i] = segIDArr[i];}
1031 //__________________________________________________
1032 void AliMagWrapCheb::BuildTableDip()
1034 // build lookup table for dipole
1036 if (fNParamsDip<1) return;
1038 TArrayI begSegYDip,begSegXDip;
1039 TArrayI nsegYDip,nsegXDip;
1041 float *tmpSegZ,*tmpSegY,*tmpSegX;
1043 // create segmentation in Z
1044 fNZSegDip = SegmentDimension(&tmpSegZ, fParamsDip, fNParamsDip, 2, 1,-1, 1,-1, 1,-1) - 1;
1048 // for each Z slice create segmentation in Y
1049 begSegYDip.Set(fNZSegDip);
1050 nsegYDip.Set(fNZSegDip);
1052 for (int iz=0;iz<fNZSegDip;iz++) {
1053 printf("\nZSegment#%d %+e : %+e\n",iz,tmpSegZ[iz],tmpSegZ[iz+1]);
1054 int ny = SegmentDimension(&tmpSegY, fParamsDip, fNParamsDip, 1,
1055 1,-1, 1,-1, tmpSegZ[iz],tmpSegZ[iz+1]) - 1;
1056 segY.Set(ny + fNYSegDip);
1057 for (int iy=0;iy<ny;iy++) segY[fNYSegDip+iy] = tmpSegY[iy];
1058 begSegYDip[iz] = fNYSegDip;
1060 printf(" Found %d YSegments, to start from %d\n",ny, begSegYDip[iz]);
1062 // for each slice in Z and Y create segmentation in X
1063 begSegXDip.Set(fNYSegDip+ny);
1064 nsegXDip.Set(fNYSegDip+ny);
1065 xyz[2] = (tmpSegZ[iz]+tmpSegZ[iz+1])/2.; // mean Z of this segment
1067 for (int iy=0;iy<ny;iy++) {
1068 int isg = fNYSegDip+iy;
1069 printf("\n YSegment#%d %+e : %+e\n",iy, tmpSegY[iy],tmpSegY[iy+1]);
1070 int nx = SegmentDimension(&tmpSegX, fParamsDip, fNParamsDip, 0,
1071 1,-1, tmpSegY[iy],tmpSegY[iy+1], tmpSegZ[iz],tmpSegZ[iz+1]) - 1;
1073 segX.Set(nx + fNXSegDip);
1074 for (int ix=0;ix<nx;ix++) segX[fNXSegDip+ix] = tmpSegX[ix];
1075 begSegXDip[isg] = fNXSegDip;
1077 printf(" Found %d XSegments, to start from %d\n",nx, begSegXDip[isg]);
1079 segID.Set(fNXSegDip+nx);
1081 // find corresponding params
1082 xyz[1] = (tmpSegY[iy]+tmpSegY[iy+1])/2.; // mean Y of this segment
1084 for (int ix=0;ix<nx;ix++) {
1085 xyz[0] = (tmpSegX[ix]+tmpSegX[ix+1])/2.; // mean X of this segment
1086 for (int ipar=0;ipar<fNParamsDip;ipar++) {
1087 AliCheb3D* cheb = (AliCheb3D*) fParamsDip->At(ipar);
1088 if (!cheb->IsInside(xyz)) continue;
1089 segID[fNXSegDip+ix] = ipar;
1101 fMinZDip = tmpSegZ[0];
1102 fMaxZDip = tmpSegZ[fNZSegDip];
1103 fSegZDip = new Float_t[fNZSegDip];
1104 for (int i=fNZSegDip;i--;) fSegZDip[i] = tmpSegZ[i];
1107 fSegYDip = new Float_t[fNYSegDip];
1108 fSegXDip = new Float_t[fNXSegDip];
1109 fBegSegYDip = new Int_t[fNZSegDip];
1110 fNSegYDip = new Int_t[fNZSegDip];
1111 fBegSegXDip = new Int_t[fNYSegDip];
1112 fNSegXDip = new Int_t[fNYSegDip];
1113 fSegIDDip = new Int_t[fNXSegDip];
1115 for (int i=fNYSegDip;i--;) fSegYDip[i] = segY[i];
1116 for (int i=fNXSegDip;i--;) fSegXDip[i] = segX[i];
1117 for (int i=fNZSegDip;i--;) {fBegSegYDip[i] = begSegYDip[i]; fNSegYDip[i] = nsegYDip[i];}
1118 for (int i=fNYSegDip;i--;) {fBegSegXDip[i] = begSegXDip[i]; fNSegXDip[i] = nsegXDip[i];}
1119 for (int i=fNXSegDip;i--;) {fSegIDDip[i] = segID[i];}
1124 //________________________________________________________________
1125 void AliMagWrapCheb::SaveData(const char* outfile) const
1127 // writes coefficients data to output text file
1128 TString strf = outfile;
1129 gSystem->ExpandPathName(strf);
1130 FILE* stream = fopen(strf,"w+");
1132 // Sol part ---------------------------------------------------------
1133 fprintf(stream,"# Set of Chebyshev parameterizations for ALICE magnetic field\nSTART %s\n",GetName());
1134 fprintf(stream,"START SOLENOID\n#Number of pieces\n%d\n",fNParamsSol);
1135 for (int ip=0;ip<fNParamsSol;ip++) GetParamSol(ip)->SaveData(stream);
1136 fprintf(stream,"#\nEND SOLENOID\n");
1138 // TPCInt part ---------------------------------------------------------
1139 fprintf(stream,"# Set of Chebyshev parameterizations for ALICE magnetic field\nSTART %s\n",GetName());
1140 fprintf(stream,"START TPCINT\n#Number of pieces\n%d\n",fNParamsTPC);
1141 for (int ip=0;ip<fNParamsTPC;ip++) GetParamTPCInt(ip)->SaveData(stream);
1142 fprintf(stream,"#\nEND TPCINT\n");
1144 // TPCRatInt part ---------------------------------------------------------
1145 fprintf(stream,"# Set of Chebyshev parameterizations for ALICE magnetic field\nSTART %s\n",GetName());
1146 fprintf(stream,"START TPCRatINT\n#Number of pieces\n%d\n",fNParamsTPCRat);
1147 for (int ip=0;ip<fNParamsTPCRat;ip++) GetParamTPCRatInt(ip)->SaveData(stream);
1148 fprintf(stream,"#\nEND TPCRatINT\n");
1150 // Dip part ---------------------------------------------------------
1151 fprintf(stream,"START DIPOLE\n#Number of pieces\n%d\n",fNParamsDip);
1152 for (int ip=0;ip<fNParamsDip;ip++) GetParamDip(ip)->SaveData(stream);
1153 fprintf(stream,"#\nEND DIPOLE\n");
1155 fprintf(stream,"#\nEND %s\n",GetName());
1161 Int_t AliMagWrapCheb::SegmentDimension(float** seg,const TObjArray* par,int npar, int dim,
1162 float xmn,float xmx,float ymn,float ymx,float zmn,float zmx)
1164 // find all boundaries in deimension dim for boxes in given region.
1165 // if mn>mx for given projection the check is not done for it.
1166 float *tmpC = new float[2*npar];
1167 int *tmpInd = new int[2*npar];
1169 for (int ip=0;ip<npar;ip++) {
1170 AliCheb3D* cheb = (AliCheb3D*) par->At(ip);
1171 if (xmn<xmx && (cheb->GetBoundMin(0)>(xmx+xmn)/2 || cheb->GetBoundMax(0)<(xmn+xmx)/2)) continue;
1172 if (ymn<ymx && (cheb->GetBoundMin(1)>(ymx+ymn)/2 || cheb->GetBoundMax(1)<(ymn+ymx)/2)) continue;
1173 if (zmn<zmx && (cheb->GetBoundMin(2)>(zmx+zmn)/2 || cheb->GetBoundMax(2)<(zmn+zmx)/2)) continue;
1175 tmpC[nseg0++] = cheb->GetBoundMin(dim);
1176 tmpC[nseg0++] = cheb->GetBoundMax(dim);
1178 // range Dim's boundaries in increasing order
1179 TMath::Sort(nseg0,tmpC,tmpInd,kFALSE);
1180 // count number of really different Z's
1183 for (int ip=0;ip<nseg0;ip++) {
1184 if (TMath::Abs(cprev-tmpC[ tmpInd[ip] ])>1e-4) {
1185 cprev = tmpC[ tmpInd[ip] ];
1188 else tmpInd[ip] = -1; // supress redundant Z
1191 *seg = new float[nseg]; // create final Z segmenations
1193 for (int ip=0;ip<nseg0;ip++) if (tmpInd[ip]>=0) (*seg)[nseg++] = tmpC[ tmpInd[ip] ];