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"
21 ClassImp(AliMagWrapCheb)
23 //__________________________________________________________________________________________
24 AliMagWrapCheb::AliMagWrapCheb() :
25 fNParamsSol(0),fNZSegSol(0),fNPSegSol(0),fNRSegSol(0),
26 fSegZSol(0),fSegPSol(0),fSegRSol(0),
27 fBegSegPSol(0),fNSegPSol(0),fBegSegRSol(0),fNSegRSol(0),fSegIDSol(0),fMinZSol(1.e6),fMaxZSol(-1.e6),fParamsSol(0),fMaxRSol(0),
29 fNParamsTPC(0),fNZSegTPC(0),fNPSegTPC(0),fNRSegTPC(0),
30 fSegZTPC(0),fSegPTPC(0),fSegRTPC(0),
31 fBegSegPTPC(0),fNSegPTPC(0),fBegSegRTPC(0),fNSegRTPC(0),fSegIDTPC(0),fMinZTPC(1.e6),fMaxZTPC(-1.e6),fParamsTPC(0),fMaxRTPC(0),
33 fNParamsTPCRat(0),fNZSegTPCRat(0),fNPSegTPCRat(0),fNRSegTPCRat(0),
34 fSegZTPCRat(0),fSegPTPCRat(0),fSegRTPCRat(0),
35 fBegSegPTPCRat(0),fNSegPTPCRat(0),fBegSegRTPCRat(0),fNSegRTPCRat(0),fSegIDTPCRat(0),fMinZTPCRat(1.e6),fMaxZTPCRat(-1.e6),fParamsTPCRat(0),fMaxRTPCRat(0),
37 fNParamsDip(0),fNZSegDip(0),fNYSegDip(0),fNXSegDip(0),
38 fSegZDip(0),fSegYDip(0),fSegXDip(0),
39 fBegSegYDip(0),fNSegYDip(0),fBegSegXDip(0),fNSegXDip(0),fSegIDDip(0),fMinZDip(1.e6),fMaxZDip(-1.e6),fParamsDip(0)
42 // default constructor
45 //__________________________________________________________________________________________
46 AliMagWrapCheb::AliMagWrapCheb(const AliMagWrapCheb& src) :
48 fNParamsSol(0),fNZSegSol(0),fNPSegSol(0),fNRSegSol(0),
49 fSegZSol(0),fSegPSol(0),fSegRSol(0),
50 fBegSegPSol(0),fNSegPSol(0),fBegSegRSol(0),fNSegRSol(0),fSegIDSol(0),fMinZSol(1.e6),fMaxZSol(-1.e6),fParamsSol(0),fMaxRSol(0),
52 fNParamsTPC(0),fNZSegTPC(0),fNPSegTPC(0),fNRSegTPC(0),
53 fSegZTPC(0),fSegPTPC(0),fSegRTPC(0),
54 fBegSegPTPC(0),fNSegPTPC(0),fBegSegRTPC(0),fNSegRTPC(0),fSegIDTPC(0),fMinZTPC(1.e6),fMaxZTPC(-1.e6),fParamsTPC(0),fMaxRTPC(0),
56 fNParamsTPCRat(0),fNZSegTPCRat(0),fNPSegTPCRat(0),fNRSegTPCRat(0),
57 fSegZTPCRat(0),fSegPTPCRat(0),fSegRTPCRat(0),
58 fBegSegPTPCRat(0),fNSegPTPCRat(0),fBegSegRTPCRat(0),fNSegRTPCRat(0),fSegIDTPCRat(0),fMinZTPCRat(1.e6),fMaxZTPCRat(-1.e6),fParamsTPCRat(0),fMaxRTPCRat(0),
60 fNParamsDip(0),fNZSegDip(0),fNYSegDip(0),fNXSegDip(0),
61 fSegZDip(0),fSegYDip(0),fSegXDip(0),
62 fBegSegYDip(0),fNSegYDip(0),fBegSegXDip(0),fNSegXDip(0),fSegIDDip(0),fMinZDip(1.e6),fMaxZDip(-1.e6),fParamsDip(0)
68 //__________________________________________________________________________________________
69 void AliMagWrapCheb::CopyFrom(const AliMagWrapCheb& src)
73 SetName(src.GetName());
74 SetTitle(src.GetTitle());
76 fNParamsSol = src.fNParamsSol;
77 fNZSegSol = src.fNZSegSol;
78 fNPSegSol = src.fNPSegSol;
79 fNRSegSol = src.fNRSegSol;
80 fMinZSol = src.fMinZSol;
81 fMaxZSol = src.fMaxZSol;
82 fMaxRSol = src.fMaxRSol;
83 if (src.fNParamsSol) {
84 memcpy(fSegZSol = new Float_t[fNZSegSol], src.fSegZSol, sizeof(Float_t)*fNZSegSol);
85 memcpy(fSegPSol = new Float_t[fNPSegSol], src.fSegPSol, sizeof(Float_t)*fNPSegSol);
86 memcpy(fSegRSol = new Float_t[fNRSegSol], src.fSegRSol, sizeof(Float_t)*fNRSegSol);
87 memcpy(fBegSegPSol= new Int_t[fNZSegSol], src.fBegSegPSol, sizeof(Int_t)*fNZSegSol);
88 memcpy(fNSegPSol = new Int_t[fNZSegSol], src.fNSegPSol, sizeof(Int_t)*fNZSegSol);
89 memcpy(fBegSegRSol= new Int_t[fNPSegSol], src.fBegSegRSol, sizeof(Int_t)*fNPSegSol);
90 memcpy(fNSegRSol = new Int_t[fNPSegSol], src.fNSegRSol, sizeof(Int_t)*fNPSegSol);
91 memcpy(fSegIDSol = new Int_t[fNRSegSol], src.fSegIDSol, sizeof(Int_t)*fNRSegSol);
92 fParamsSol = new TObjArray(fNParamsSol);
93 for (int i=0;i<fNParamsSol;i++) fParamsSol->AddAtAndExpand(new AliCheb3D(*src.GetParamSol(i)),i);
96 fNParamsTPC = src.fNParamsTPC;
97 fNZSegTPC = src.fNZSegTPC;
98 fNPSegTPC = src.fNPSegTPC;
99 fNRSegTPC = src.fNRSegTPC;
100 fMinZTPC = src.fMinZTPC;
101 fMaxZTPC = src.fMaxZTPC;
102 fMaxRTPC = src.fMaxRTPC;
103 if (src.fNParamsTPC) {
104 memcpy(fSegZTPC = new Float_t[fNZSegTPC], src.fSegZTPC, sizeof(Float_t)*fNZSegTPC);
105 memcpy(fSegPTPC = new Float_t[fNPSegTPC], src.fSegPTPC, sizeof(Float_t)*fNPSegTPC);
106 memcpy(fSegRTPC = new Float_t[fNRSegTPC], src.fSegRTPC, sizeof(Float_t)*fNRSegTPC);
107 memcpy(fBegSegPTPC= new Int_t[fNZSegTPC], src.fBegSegPTPC, sizeof(Int_t)*fNZSegTPC);
108 memcpy(fNSegPTPC = new Int_t[fNZSegTPC], src.fNSegPTPC, sizeof(Int_t)*fNZSegTPC);
109 memcpy(fBegSegRTPC= new Int_t[fNPSegTPC], src.fBegSegRTPC, sizeof(Int_t)*fNPSegTPC);
110 memcpy(fNSegRTPC = new Int_t[fNPSegTPC], src.fNSegRTPC, sizeof(Int_t)*fNPSegTPC);
111 memcpy(fSegIDTPC = new Int_t[fNRSegTPC], src.fSegIDTPC, sizeof(Int_t)*fNRSegTPC);
112 fParamsTPC = new TObjArray(fNParamsTPC);
113 for (int i=0;i<fNParamsTPC;i++) fParamsTPC->AddAtAndExpand(new AliCheb3D(*src.GetParamTPCInt(i)),i);
116 fNParamsTPCRat = src.fNParamsTPCRat;
117 fNZSegTPCRat = src.fNZSegTPCRat;
118 fNPSegTPCRat = src.fNPSegTPCRat;
119 fNRSegTPCRat = src.fNRSegTPCRat;
120 fMinZTPCRat = src.fMinZTPCRat;
121 fMaxZTPCRat = src.fMaxZTPCRat;
122 fMaxRTPCRat = src.fMaxRTPCRat;
123 if (src.fNParamsTPCRat) {
124 memcpy(fSegZTPCRat = new Float_t[fNZSegTPCRat], src.fSegZTPCRat, sizeof(Float_t)*fNZSegTPCRat);
125 memcpy(fSegPTPCRat = new Float_t[fNPSegTPCRat], src.fSegPTPCRat, sizeof(Float_t)*fNPSegTPCRat);
126 memcpy(fSegRTPCRat = new Float_t[fNRSegTPCRat], src.fSegRTPCRat, sizeof(Float_t)*fNRSegTPCRat);
127 memcpy(fBegSegPTPCRat= new Int_t[fNZSegTPCRat], src.fBegSegPTPCRat, sizeof(Int_t)*fNZSegTPCRat);
128 memcpy(fNSegPTPCRat = new Int_t[fNZSegTPCRat], src.fNSegPTPCRat, sizeof(Int_t)*fNZSegTPCRat);
129 memcpy(fBegSegRTPCRat= new Int_t[fNPSegTPCRat], src.fBegSegRTPCRat, sizeof(Int_t)*fNPSegTPCRat);
130 memcpy(fNSegRTPCRat = new Int_t[fNPSegTPCRat], src.fNSegRTPCRat, sizeof(Int_t)*fNPSegTPCRat);
131 memcpy(fSegIDTPCRat = new Int_t[fNRSegTPCRat], src.fSegIDTPCRat, sizeof(Int_t)*fNRSegTPCRat);
132 fParamsTPCRat = new TObjArray(fNParamsTPCRat);
133 for (int i=0;i<fNParamsTPCRat;i++) fParamsTPCRat->AddAtAndExpand(new AliCheb3D(*src.GetParamTPCRatInt(i)),i);
136 fNParamsDip = src.fNParamsDip;
137 fNZSegDip = src.fNZSegDip;
138 fNYSegDip = src.fNYSegDip;
139 fNXSegDip = src.fNXSegDip;
140 fMinZDip = src.fMinZDip;
141 fMaxZDip = src.fMaxZDip;
142 if (src.fNParamsDip) {
143 memcpy(fSegZDip = new Float_t[fNZSegDip], src.fSegZDip, sizeof(Float_t)*fNZSegDip);
144 memcpy(fSegYDip = new Float_t[fNYSegDip], src.fSegYDip, sizeof(Float_t)*fNYSegDip);
145 memcpy(fSegXDip = new Float_t[fNXSegDip], src.fSegXDip, sizeof(Float_t)*fNXSegDip);
146 memcpy(fBegSegYDip= new Int_t[fNZSegDip], src.fBegSegYDip, sizeof(Int_t)*fNZSegDip);
147 memcpy(fNSegYDip = new Int_t[fNZSegDip], src.fNSegYDip, sizeof(Int_t)*fNZSegDip);
148 memcpy(fBegSegXDip= new Int_t[fNYSegDip], src.fBegSegXDip, sizeof(Int_t)*fNYSegDip);
149 memcpy(fNSegXDip = new Int_t[fNYSegDip], src.fNSegXDip, sizeof(Int_t)*fNYSegDip);
150 memcpy(fSegIDDip = new Int_t[fNXSegDip], src.fSegIDDip, sizeof(Int_t)*fNXSegDip);
151 fParamsDip = new TObjArray(fNParamsDip);
152 for (int i=0;i<fNParamsDip;i++) fParamsDip->AddAtAndExpand(new AliCheb3D(*src.GetParamDip(i)),i);
157 //__________________________________________________________________________________________
158 AliMagWrapCheb& AliMagWrapCheb::operator=(const AliMagWrapCheb& rhs)
169 //__________________________________________________________________________________________
170 void AliMagWrapCheb::Clear(const Option_t *)
172 // clear all dynamic parts
174 delete fParamsSol; fParamsSol = 0;
175 delete[] fSegZSol; fSegZSol = 0;
176 delete[] fSegPSol; fSegPSol = 0;
177 delete[] fSegRSol; fSegRSol = 0;
178 delete[] fBegSegPSol; fBegSegPSol = 0;
179 delete[] fNSegPSol; fNSegPSol = 0;
180 delete[] fBegSegRSol; fBegSegRSol = 0;
181 delete[] fNSegRSol; fNSegRSol = 0;
182 delete[] fSegIDSol; fSegIDSol = 0;
184 fNParamsSol = fNZSegSol = fNPSegSol = fNRSegSol = 0;
190 delete fParamsTPC; fParamsTPC = 0;
191 delete[] fSegZTPC; fSegZTPC = 0;
192 delete[] fSegPTPC; fSegPTPC = 0;
193 delete[] fSegRTPC; fSegRTPC = 0;
194 delete[] fBegSegPTPC; fBegSegPTPC = 0;
195 delete[] fNSegPTPC; fNSegPTPC = 0;
196 delete[] fBegSegRTPC; fBegSegRTPC = 0;
197 delete[] fNSegRTPC; fNSegRTPC = 0;
198 delete[] fSegIDTPC; fSegIDTPC = 0;
200 fNParamsTPC = fNZSegTPC = fNPSegTPC = fNRSegTPC = 0;
205 if (fNParamsTPCRat) {
206 delete fParamsTPCRat; fParamsTPCRat = 0;
207 delete[] fSegZTPCRat; fSegZTPCRat = 0;
208 delete[] fSegPTPCRat; fSegPTPCRat = 0;
209 delete[] fSegRTPCRat; fSegRTPCRat = 0;
210 delete[] fBegSegPTPCRat; fBegSegPTPCRat = 0;
211 delete[] fNSegPTPCRat; fNSegPTPCRat = 0;
212 delete[] fBegSegRTPCRat; fBegSegRTPCRat = 0;
213 delete[] fNSegRTPCRat; fNSegRTPCRat = 0;
214 delete[] fSegIDTPCRat; fSegIDTPCRat = 0;
216 fNParamsTPCRat = fNZSegTPCRat = fNPSegTPCRat = fNRSegTPCRat = 0;
222 delete fParamsDip; fParamsDip = 0;
223 delete[] fSegZDip; fSegZDip = 0;
224 delete[] fSegYDip; fSegYDip = 0;
225 delete[] fSegXDip; fSegXDip = 0;
226 delete[] fBegSegYDip; fBegSegYDip = 0;
227 delete[] fNSegYDip; fNSegYDip = 0;
228 delete[] fBegSegXDip; fBegSegXDip = 0;
229 delete[] fNSegXDip; fNSegXDip = 0;
230 delete[] fSegIDDip; fSegIDDip = 0;
232 fNParamsDip = fNZSegDip = fNYSegDip = fNXSegDip = 0;
238 //__________________________________________________________________________________________
239 void AliMagWrapCheb::Field(const Double_t *xyz, Double_t *b) const
241 // compute field in cartesian coordinates. If point is outside of the parameterized region
242 // get it at closest valid point
245 #ifndef _BRING_TO_BOUNDARY_ // exact matching to fitted volume is requested
246 b[0] = b[1] = b[2] = 0;
249 if (xyz[2]>fMinZSol) {
250 CartToCyl(xyz,rphiz);
251 FieldCylSol(rphiz,b);
252 // convert field to cartesian system
253 CylToCartCylB(rphiz, b,b);
257 int iddip = FindDipSegment(xyz);
259 AliCheb3D* par = GetParamDip(iddip);
260 #ifndef _BRING_TO_BOUNDARY_
261 if (!par->IsInside(xyz)) return;
267 //__________________________________________________________________________________________
268 Double_t AliMagWrapCheb::GetBz(const Double_t *xyz) const
270 // compute Bz for the point in cartesian coordinates. If point is outside of the parameterized region
271 // get it at closest valid point
274 if (xyz[2]>fMinZSol) {
275 CartToCyl(xyz,rphiz);
276 return FieldCylSolBz(rphiz);
279 int iddip = FindDipSegment(xyz);
280 if (iddip<0) return 0.;
281 AliCheb3D* par = GetParamDip(iddip);
282 #ifndef _BRING_TO_BOUNDARY_
283 if (!par->IsInside(xyz)) return 0.;
285 return par->Eval(xyz,2);
289 //__________________________________________________________________________________________
290 void AliMagWrapCheb::Print(Option_t *) const
293 printf("Alice magnetic field parameterized by Chebyshev polynomials\n");
294 printf("Segmentation for Solenoid (%+.2f<Z<%+.2f cm | R<%.2f cm)\n",fMinZSol,fMaxZSol,fMaxRSol);
297 for (int i=0;i<fNParamsSol;i++) {
299 GetParamSol(i)->Print();
303 printf("Segmentation for TPC field integral (%+.2f<Z<%+.2f cm | R<%.2f cm)\n",fMinZTPC,fMaxZTPC,fMaxRTPC);
306 for (int i=0;i<fNParamsTPC;i++) {
308 GetParamTPCInt(i)->Print();
312 printf("Segmentation for TPC field ratios integral (%+.2f<Z<%+.2f cm | R<%.2f cm)\n",fMinZTPCRat,fMaxZTPCRat,fMaxRTPCRat);
315 for (int i=0;i<fNParamsTPCRat;i++) {
316 printf("TPCRat%4d ",i);
317 GetParamTPCRatInt(i)->Print();
321 printf("Segmentation for Dipole (%+.2f<Z<%+.2f cm)\n",fMinZDip,fMaxZDip);
323 for (int i=0;i<fNParamsDip;i++) {
325 GetParamDip(i)->Print();
331 //__________________________________________________________________________________________________
332 Int_t AliMagWrapCheb::FindDipSegment(const Double_t *xyz) const
334 // find the segment containing point xyz. If it is outside find the closest segment
335 if (!fNParamsDip) return -1;
336 int xid,yid,zid = TMath::BinarySearch(fNZSegDip,fSegZDip,(Float_t)xyz[2]); // find zsegment
338 Bool_t reCheck = kFALSE;
340 int ysegBeg = fBegSegYDip[zid];
342 for (yid=0;yid<fNSegYDip[zid];yid++) if (xyz[1]<fSegYDip[ysegBeg+yid]) break;
343 if ( --yid < 0 ) yid = 0;
346 int xsegBeg = fBegSegXDip[yid];
347 for (xid=0;xid<fNSegXDip[yid];xid++) if (xyz[0]<fSegXDip[xsegBeg+xid]) break;
349 if ( --xid < 0) xid = 0;
352 // to make sure that due to the precision problems we did not pick the next Zbin
353 if (!reCheck && (xyz[2] - fSegZDip[zid] < 3.e-5) && zid &&
354 !GetParamDip(fSegIDDip[xid])->IsInside(xyz)) { // check the previous Z bin
361 return fSegIDDip[xid];
364 //__________________________________________________________________________________________________
365 Int_t AliMagWrapCheb::FindSolSegment(const Double_t *rpz) const
367 // find the segment containing point xyz. If it is outside find the closest segment
368 if (!fNParamsSol) return -1;
369 int rid,pid,zid = TMath::BinarySearch(fNZSegSol,fSegZSol,(Float_t)rpz[2]); // find zsegment
371 Bool_t reCheck = kFALSE;
373 int psegBeg = fBegSegPSol[zid];
374 for (pid=0;pid<fNSegPSol[zid];pid++) if (rpz[1]<fSegPSol[psegBeg+pid]) break;
375 if ( --pid < 0 ) pid = 0;
378 int rsegBeg = fBegSegRSol[pid];
379 for (rid=0;rid<fNSegRSol[pid];rid++) if (rpz[0]<fSegRSol[rsegBeg+rid]) break;
380 if ( --rid < 0) rid = 0;
383 // to make sure that due to the precision problems we did not pick the next Zbin
384 if (!reCheck && (rpz[2] - fSegZSol[zid] < 3.e-5) && zid &&
385 !GetParamSol(fSegIDSol[rid])->IsInside(rpz)) { // check the previous Z bin
392 return fSegIDSol[rid];
395 //__________________________________________________________________________________________________
396 Int_t AliMagWrapCheb::FindTPCSegment(const Double_t *rpz) const
398 // find the segment containing point xyz. If it is outside find the closest segment
399 if (!fNParamsTPC) return -1;
400 int rid,pid,zid = TMath::BinarySearch(fNZSegTPC,fSegZTPC,(Float_t)rpz[2]); // find zsegment
402 Bool_t reCheck = kFALSE;
404 int psegBeg = fBegSegPTPC[zid];
406 for (pid=0;pid<fNSegPTPC[zid];pid++) if (rpz[1]<fSegPTPC[psegBeg+pid]) break;
407 if ( --pid < 0 ) pid = 0;
410 int rsegBeg = fBegSegRTPC[pid];
411 for (rid=0;rid<fNSegRTPC[pid];rid++) if (rpz[0]<fSegRTPC[rsegBeg+rid]) break;
412 if ( --rid < 0) rid = 0;
415 // to make sure that due to the precision problems we did not pick the next Zbin
416 if (!reCheck && (rpz[2] - fSegZSol[zid] < 3.e-5) && zid &&
417 !GetParamSol(fSegIDSol[rid])->IsInside(rpz)) { // check the previous Z bin
424 return fSegIDTPC[rid];
427 //__________________________________________________________________________________________________
428 Int_t AliMagWrapCheb::FindTPCRatSegment(const Double_t *rpz) const
430 // find the segment containing point xyz. If it is outside find the closest segment
431 if (!fNParamsTPCRat) return -1;
432 int rid,pid,zid = TMath::BinarySearch(fNZSegTPCRat,fSegZTPCRat,(Float_t)rpz[2]); // find zsegment
434 Bool_t reCheck = kFALSE;
436 int psegBeg = fBegSegPTPCRat[zid];
438 for (pid=0;pid<fNSegPTPCRat[zid];pid++) if (rpz[1]<fSegPTPCRat[psegBeg+pid]) break;
439 if ( --pid < 0 ) pid = 0;
442 int rsegBeg = fBegSegRTPCRat[pid];
443 for (rid=0;rid<fNSegRTPCRat[pid];rid++) if (rpz[0]<fSegRTPCRat[rsegBeg+rid]) break;
444 if ( --rid < 0) rid = 0;
447 // to make sure that due to the precision problems we did not pick the next Zbin
448 if (!reCheck && (rpz[2] - fSegZSol[zid] < 3.e-5) && zid &&
449 !GetParamSol(fSegIDSol[rid])->IsInside(rpz)) { // check the previous Z bin
456 return fSegIDTPCRat[rid];
460 //__________________________________________________________________________________________
461 void AliMagWrapCheb::GetTPCInt(const Double_t *xyz, Double_t *b) const
463 // compute TPC region field integral in cartesian coordinates.
464 // If point is outside of the parameterized region get it at closeset valid point
465 static Double_t rphiz[3];
468 // convert coordinates to cyl system
469 CartToCyl(xyz,rphiz);
470 #ifndef _BRING_TO_BOUNDARY_
471 if ( (rphiz[2]>GetMaxZTPCInt()||rphiz[2]<GetMinZTPCInt()) ||
472 rphiz[0]>GetMaxRTPCInt()) {for (int i=3;i--;) b[i]=0; return;}
475 GetTPCIntCyl(rphiz,b);
477 // convert field to cartesian system
478 CylToCartCylB(rphiz, b,b);
482 //__________________________________________________________________________________________
483 void AliMagWrapCheb::GetTPCRatInt(const Double_t *xyz, Double_t *b) const
485 // compute TPCRat region field integral in cartesian coordinates.
486 // If point is outside of the parameterized region get it at closeset valid point
487 static Double_t rphiz[3];
490 // convert coordinates to cyl system
491 CartToCyl(xyz,rphiz);
492 #ifndef _BRING_TO_BOUNDARY_
493 if ( (rphiz[2]>GetMaxZTPCRatInt()||rphiz[2]<GetMinZTPCRatInt()) ||
494 rphiz[0]>GetMaxRTPCRatInt()) {for (int i=3;i--;) b[i]=0; return;}
497 GetTPCRatIntCyl(rphiz,b);
499 // convert field to cartesian system
500 CylToCartCylB(rphiz, b,b);
504 //__________________________________________________________________________________________
505 void AliMagWrapCheb::FieldCylSol(const Double_t *rphiz, Double_t *b) const
507 // compute Solenoid field in Cylindircal coordinates
508 // note: if the point is outside the volume get the field in closest parameterized point
509 int id = FindSolSegment(rphiz);
511 AliCheb3D* par = GetParamSol(id);
512 #ifndef _BRING_TO_BOUNDARY_ // exact matching to fitted volume is requested
513 if (!par->IsInside(rphiz)) return;
520 //__________________________________________________________________________________________
521 Double_t AliMagWrapCheb::FieldCylSolBz(const Double_t *rphiz) const
523 // compute Solenoid field in Cylindircal coordinates
524 // note: if the point is outside the volume get the field in closest parameterized point
525 int id = FindSolSegment(rphiz);
527 AliCheb3D* par = GetParamSol(id);
528 #ifndef _BRING_TO_BOUNDARY_
529 return par->IsInside(rphiz) ? par->Eval(rphiz,2) : 0;
531 return par->Eval(rphiz,2);
535 //__________________________________________________________________________________________
536 void AliMagWrapCheb::GetTPCIntCyl(const Double_t *rphiz, Double_t *b) const
538 // compute field integral in TPC region in Cylindircal coordinates
539 // note: the check for the point being inside the parameterized region is done outside
540 int id = FindTPCSegment(rphiz);
542 b[0] = b[1] = b[2] = 0;
545 AliCheb3D* par = GetParamTPCInt(id);
546 if (par->IsInside(rphiz)) {
550 b[0] = b[1] = b[2] = 0;
555 //__________________________________________________________________________________________
556 void AliMagWrapCheb::GetTPCRatIntCyl(const Double_t *rphiz, Double_t *b) const
558 // compute field integral in TPCRat region in Cylindircal coordinates
559 // note: the check for the point being inside the parameterized region is done outside
560 int id = FindTPCRatSegment(rphiz);
562 b[0] = b[1] = b[2] = 0;
565 AliCheb3D* par = GetParamTPCRatInt(id);
566 if (par->IsInside(rphiz)) {
570 b[0] = b[1] = b[2] = 0;
576 #ifdef _INC_CREATION_ALICHEB3D_
577 //_______________________________________________
578 void AliMagWrapCheb::LoadData(const char* inpfile)
580 // read coefficients data from the text file
582 TString strf = inpfile;
583 gSystem->ExpandPathName(strf);
584 FILE* stream = fopen(strf,"r");
586 printf("Did not find input file %s\n",strf.Data());
591 AliCheb3DCalc::ReadLine(buffs,stream);
592 if (!buffs.BeginsWith("START")) {
593 Error("LoadData","Expected: \"START <name>\", found \"%s\"\nStop\n",buffs.Data());
596 if (buffs.First(' ')>0) SetName(buffs.Data()+buffs.First(' ')+1);
598 // Solenoid part -----------------------------------------------------------
599 AliCheb3DCalc::ReadLine(buffs,stream);
600 if (!buffs.BeginsWith("START SOLENOID")) {
601 Error("LoadData","Expected: \"START SOLENOID\", found \"%s\"\nStop\n",buffs.Data());
604 AliCheb3DCalc::ReadLine(buffs,stream); // nparam
605 int nparSol = buffs.Atoi();
607 for (int ip=0;ip<nparSol;ip++) {
608 AliCheb3D* cheb = new AliCheb3D();
609 cheb->LoadData(stream);
613 AliCheb3DCalc::ReadLine(buffs,stream);
614 if (!buffs.BeginsWith("END SOLENOID")) {
615 Error("LoadData","Expected \"END SOLENOID\", found \"%s\"\nStop\n",buffs.Data());
619 // TPCInt part -----------------------------------------------------------
620 AliCheb3DCalc::ReadLine(buffs,stream);
621 if (!buffs.BeginsWith("START TPCINT")) {
622 Error("LoadData","Expected: \"START TPCINT\", found \"%s\"\nStop\n",buffs.Data());
625 AliCheb3DCalc::ReadLine(buffs,stream); // nparam
626 int nparTPCInt = buffs.Atoi();
628 for (int ip=0;ip<nparTPCInt;ip++) {
629 AliCheb3D* cheb = new AliCheb3D();
630 cheb->LoadData(stream);
631 AddParamTPCInt(cheb);
634 AliCheb3DCalc::ReadLine(buffs,stream);
635 if (!buffs.BeginsWith("END TPCINT")) {
636 Error("LoadData","Expected \"END TPCINT\", found \"%s\"\nStop\n",buffs.Data());
640 // TPCRatInt part -----------------------------------------------------------
641 AliCheb3DCalc::ReadLine(buffs,stream);
642 if (!buffs.BeginsWith("START TPCRatINT")) {
643 Error("LoadData","Expected: \"START TPCRatINT\", found \"%s\"\nStop\n",buffs.Data());
646 AliCheb3DCalc::ReadLine(buffs,stream); // nparam
647 int nparTPCRatInt = buffs.Atoi();
649 for (int ip=0;ip<nparTPCRatInt;ip++) {
650 AliCheb3D* cheb = new AliCheb3D();
651 cheb->LoadData(stream);
652 AddParamTPCRatInt(cheb);
655 AliCheb3DCalc::ReadLine(buffs,stream);
656 if (!buffs.BeginsWith("END TPCRatINT")) {
657 Error("LoadData","Expected \"END TPCRatINT\", found \"%s\"\nStop\n",buffs.Data());
661 // Dipole part -----------------------------------------------------------
662 AliCheb3DCalc::ReadLine(buffs,stream);
663 if (!buffs.BeginsWith("START DIPOLE")) {
664 Error("LoadData","Expected: \"START DIPOLE\", found \"%s\"\nStop\n",buffs.Data());
667 AliCheb3DCalc::ReadLine(buffs,stream); // nparam
668 int nparDip = buffs.Atoi();
670 for (int ip=0;ip<nparDip;ip++) {
671 AliCheb3D* cheb = new AliCheb3D();
672 cheb->LoadData(stream);
676 AliCheb3DCalc::ReadLine(buffs,stream);
677 if (!buffs.BeginsWith("END DIPOLE")) {
678 Error("LoadData","Expected \"END DIPOLE\", found \"%s\"\nStop\n",GetName(),buffs.Data());
682 AliCheb3DCalc::ReadLine(buffs,stream);
683 if (!buffs.BeginsWith("END") || !buffs.Contains(GetName())) {
684 Error("LoadData","Expected: \"END %s\", found \"%s\"\nStop\n",GetName(),buffs.Data());
688 // ---------------------------------------------------------------------------
693 BuildTableTPCRatInt();
695 printf("Loaded magnetic field \"%s\" from %s\n",GetName(),strf.Data());
699 //__________________________________________________________________________________________
700 void AliMagWrapCheb::BuildTableSol()
702 BuildTable(fNParamsSol,fParamsSol,
703 fNZSegSol,fNPSegSol,fNRSegSol,
705 &fSegZSol,&fSegPSol,&fSegRSol,
706 &fBegSegPSol,&fNSegPSol,
707 &fBegSegRSol,&fNSegRSol,
711 //__________________________________________________________________________________________
712 void AliMagWrapCheb::BuildTableDip()
714 BuildTable(fNParamsDip,fParamsDip,
715 fNZSegDip,fNYSegDip,fNXSegDip,
717 &fSegZDip,&fSegYDip,&fSegXDip,
718 &fBegSegYDip,&fNSegYDip,
719 &fBegSegXDip,&fNSegXDip,
723 //__________________________________________________________________________________________
724 void AliMagWrapCheb::BuildTableTPCInt()
726 BuildTable(fNParamsTPC,fParamsTPC,
727 fNZSegTPC,fNPSegTPC,fNRSegTPC,
729 &fSegZTPC,&fSegPTPC,&fSegRTPC,
730 &fBegSegPTPC,&fNSegPTPC,
731 &fBegSegRTPC,&fNSegRTPC,
735 //__________________________________________________________________________________________
736 void AliMagWrapCheb::BuildTableTPCRatInt()
738 BuildTable(fNParamsTPCRat,fParamsTPCRat,
739 fNZSegTPCRat,fNPSegTPCRat,fNRSegTPCRat,
740 fMinZTPCRat,fMaxZTPCRat,
741 &fSegZTPCRat,&fSegPTPCRat,&fSegRTPCRat,
742 &fBegSegPTPCRat,&fNSegPTPCRat,
743 &fBegSegRTPCRat,&fNSegRTPCRat,
749 //_______________________________________________
750 #ifdef _INC_CREATION_ALICHEB3D_
752 //__________________________________________________________________________________________
753 AliMagWrapCheb::AliMagWrapCheb(const char* inputFile) :
754 fNParamsSol(0),fNZSegSol(0),fNPSegSol(0),fNRSegSol(0),
755 fSegZSol(0),fSegPSol(0),fSegRSol(0),
756 fBegSegPSol(0),fNSegPSol(0),fBegSegRSol(0),fNSegRSol(0),fSegIDSol(0),fMinZSol(1.e6),fMaxZSol(-1.e6),fParamsSol(0),fMaxRSol(0),
758 fNParamsTPC(0),fNZSegTPC(0),fNPSegTPC(0),fNRSegTPC(0),
759 fSegZTPC(0),fSegPTPC(0),fSegRTPC(0),
760 fBegSegPTPC(0),fNSegPTPC(0),fBegSegRTPC(0),fNSegRTPC(0),fSegIDTPC(0),fMinZTPC(1.e6),fMaxZTPC(-1.e6),fParamsTPC(0),fMaxRTPC(0),
762 fNParamsTPCRat(0),fNZSegTPCRat(0),fNPSegTPCRat(0),fNRSegTPCRat(0),
763 fSegZTPCRat(0),fSegPTPCRat(0),fSegRTPCRat(0),
764 fBegSegPTPCRat(0),fNSegPTPCRat(0),fBegSegRTPCRat(0),fNSegRTPCRat(0),fSegIDTPCRat(0),fMinZTPCRat(1.e6),fMaxZTPCRat(-1.e6),fParamsTPCRat(0),fMaxRTPCRat(0),
766 fNParamsDip(0),fNZSegDip(0),fNYSegDip(0),fNXSegDip(0),
767 fSegZDip(0),fSegYDip(0),fSegXDip(0),
768 fBegSegYDip(0),fNSegYDip(0),fBegSegXDip(0),fNSegXDip(0),fSegIDDip(0),fMinZDip(1.e6),fMaxZDip(-1.e6),fParamsDip(0)
771 // construct from coeffs from the text file
775 //__________________________________________________________________________________________
776 void AliMagWrapCheb::AddParamSol(const AliCheb3D* param)
778 // adds new parameterization piece for Sol
779 // NOTE: pieces must be added strictly in increasing R then increasing Z order
781 if (!fParamsSol) fParamsSol = new TObjArray();
782 fParamsSol->Add( (AliCheb3D*)param );
784 if (fMaxRSol<param->GetBoundMax(0)) fMaxRSol = param->GetBoundMax(0);
788 //__________________________________________________________________________________________
789 void AliMagWrapCheb::AddParamTPCInt(const AliCheb3D* param)
791 // adds new parameterization piece for TPCInt
792 // NOTE: pieces must be added strictly in increasing R then increasing Z order
794 if (!fParamsTPC) fParamsTPC = new TObjArray();
795 fParamsTPC->Add( (AliCheb3D*)param);
797 if (fMaxRTPC<param->GetBoundMax(0)) fMaxRTPC = param->GetBoundMax(0);
801 //__________________________________________________________________________________________
802 void AliMagWrapCheb::AddParamTPCRatInt(const AliCheb3D* param)
804 // adds new parameterization piece for TPCRatInt
805 // NOTE: pieces must be added strictly in increasing R then increasing Z order
807 if (!fParamsTPCRat) fParamsTPCRat = new TObjArray();
808 fParamsTPCRat->Add( (AliCheb3D*)param);
810 if (fMaxRTPCRat<param->GetBoundMax(0)) fMaxRTPCRat = param->GetBoundMax(0);
814 //__________________________________________________________________________________________
815 void AliMagWrapCheb::AddParamDip(const AliCheb3D* param)
817 // adds new parameterization piece for Dipole
819 if (!fParamsDip) fParamsDip = new TObjArray();
820 fParamsDip->Add( (AliCheb3D*)param);
825 //__________________________________________________________________________________________
826 void AliMagWrapCheb::ResetTPCInt()
828 // clean TPC field integral (used for update)
830 delete fParamsTPC; fParamsTPC = 0;
831 delete[] fSegZTPC; fSegZTPC = 0;
832 delete[] fSegPTPC; fSegPTPC = 0;
833 delete[] fSegRTPC; fSegRTPC = 0;
834 delete[] fBegSegPTPC; fBegSegPTPC = 0;
835 delete[] fNSegPTPC; fNSegPTPC = 0;
836 delete[] fBegSegRTPC; fBegSegRTPC = 0;
837 delete[] fNSegRTPC; fNSegRTPC = 0;
838 delete[] fSegIDTPC; fSegIDTPC = 0;
840 fNParamsTPC = fNZSegTPC = fNPSegTPC = fNRSegTPC = 0;
847 //__________________________________________________________________________________________
848 void AliMagWrapCheb::ResetTPCRatInt()
850 // clean TPCRat field integral (used for update)
851 if (fNParamsTPCRat) {
852 delete fParamsTPCRat; fParamsTPCRat = 0;
853 delete[] fSegZTPCRat; fSegZTPCRat = 0;
854 delete[] fSegPTPCRat; fSegPTPCRat = 0;
855 delete[] fSegRTPCRat; fSegRTPCRat = 0;
856 delete[] fBegSegPTPCRat; fBegSegPTPCRat = 0;
857 delete[] fNSegPTPCRat; fNSegPTPCRat = 0;
858 delete[] fBegSegRTPCRat; fBegSegRTPCRat = 0;
859 delete[] fNSegRTPCRat; fNSegRTPCRat = 0;
860 delete[] fSegIDTPCRat; fSegIDTPCRat = 0;
862 fNParamsTPCRat = fNZSegTPCRat = fNPSegTPCRat = fNRSegTPCRat = 0;
870 //__________________________________________________
871 void AliMagWrapCheb::BuildTable(Int_t npar,TObjArray *parArr, Int_t &nZSeg, Int_t &nYSeg, Int_t &nXSeg,
872 Float_t &minZ,Float_t &maxZ,
873 Float_t **segZ,Float_t **segY,Float_t **segX,
874 Int_t **begSegY,Int_t **nSegY,
875 Int_t **begSegX,Int_t **nSegX,
878 // build lookup table for dipole
881 TArrayF segYArr,segXArr;
882 TArrayI begSegYDipArr,begSegXDipArr;
883 TArrayI nSegYDipArr,nSegXDipArr;
885 float *tmpSegZ,*tmpSegY,*tmpSegX;
887 // create segmentation in Z
888 nZSeg = SegmentDimension(&tmpSegZ, parArr, npar, 2, 1,-1, 1,-1, 1,-1) - 1;
892 // for each Z slice create segmentation in Y
893 begSegYDipArr.Set(nZSeg);
894 nSegYDipArr.Set(nZSeg);
896 for (int iz=0;iz<nZSeg;iz++) {
897 printf("\nZSegment#%d %+e : %+e\n",iz,tmpSegZ[iz],tmpSegZ[iz+1]);
898 int ny = SegmentDimension(&tmpSegY, parArr, npar, 1,
899 1,-1, 1,-1, tmpSegZ[iz],tmpSegZ[iz+1]) - 1;
900 segYArr.Set(ny + nYSeg);
901 for (int iy=0;iy<ny;iy++) segYArr[nYSeg+iy] = tmpSegY[iy];
902 begSegYDipArr[iz] = nYSeg;
903 nSegYDipArr[iz] = ny;
904 printf(" Found %d YSegments, to start from %d\n",ny, begSegYDipArr[iz]);
906 // for each slice in Z and Y create segmentation in X
907 begSegXDipArr.Set(nYSeg+ny);
908 nSegXDipArr.Set(nYSeg+ny);
909 xyz[2] = (tmpSegZ[iz]+tmpSegZ[iz+1])/2.; // mean Z of this segment
911 for (int iy=0;iy<ny;iy++) {
913 printf("\n YSegment#%d %+e : %+e\n",iy, tmpSegY[iy],tmpSegY[iy+1]);
914 int nx = SegmentDimension(&tmpSegX, parArr, npar, 0,
915 1,-1, tmpSegY[iy],tmpSegY[iy+1], tmpSegZ[iz],tmpSegZ[iz+1]) - 1;
917 segXArr.Set(nx + nXSeg);
918 for (int ix=0;ix<nx;ix++) segXArr[nXSeg+ix] = tmpSegX[ix];
919 begSegXDipArr[isg] = nXSeg;
920 nSegXDipArr[isg] = nx;
921 printf(" Found %d XSegments, to start from %d\n",nx, begSegXDipArr[isg]);
923 segIDArr.Set(nXSeg+nx);
925 // find corresponding params
926 xyz[1] = (tmpSegY[iy]+tmpSegY[iy+1])/2.; // mean Y of this segment
928 for (int ix=0;ix<nx;ix++) {
929 xyz[0] = (tmpSegX[ix]+tmpSegX[ix+1])/2.; // mean X of this segment
930 for (int ipar=0;ipar<npar;ipar++) {
931 AliCheb3D* cheb = (AliCheb3D*) parArr->At(ipar);
932 if (!cheb->IsInside(xyz)) continue;
933 segIDArr[nXSeg+ix] = ipar;
946 maxZ = tmpSegZ[nZSeg];
947 (*segZ) = new Float_t[nZSeg];
948 for (int i=nZSeg;i--;) (*segZ)[i] = tmpSegZ[i];
951 (*segY) = new Float_t[nYSeg];
952 (*segX) = new Float_t[nXSeg];
953 (*begSegY) = new Int_t[nZSeg];
954 (*nSegY) = new Int_t[nZSeg];
955 (*begSegX) = new Int_t[nYSeg];
956 (*nSegX) = new Int_t[nYSeg];
957 (*segID) = new Int_t[nXSeg];
959 for (int i=nYSeg;i--;) (*segY)[i] = segYArr[i];
960 for (int i=nXSeg;i--;) (*segX)[i] = segXArr[i];
961 for (int i=nZSeg;i--;) {(*begSegY)[i] = begSegYDipArr[i]; (*nSegY)[i] = nSegYDipArr[i];}
962 for (int i=nYSeg;i--;) {(*begSegX)[i] = begSegXDipArr[i]; (*nSegX)[i] = nSegXDipArr[i];}
963 for (int i=nXSeg;i--;) {(*segID)[i] = segIDArr[i];}
968 //__________________________________________________
969 void AliMagWrapCheb::BuildTableDip()
971 // build lookup table for dipole
973 if (fNParamsDip<1) return;
975 TArrayI begSegYDip,begSegXDip;
976 TArrayI nsegYDip,nsegXDip;
978 float *tmpSegZ,*tmpSegY,*tmpSegX;
980 // create segmentation in Z
981 fNZSegDip = SegmentDimension(&tmpSegZ, fParamsDip, fNParamsDip, 2, 1,-1, 1,-1, 1,-1) - 1;
985 // for each Z slice create segmentation in Y
986 begSegYDip.Set(fNZSegDip);
987 nsegYDip.Set(fNZSegDip);
989 for (int iz=0;iz<fNZSegDip;iz++) {
990 printf("\nZSegment#%d %+e : %+e\n",iz,tmpSegZ[iz],tmpSegZ[iz+1]);
991 int ny = SegmentDimension(&tmpSegY, fParamsDip, fNParamsDip, 1,
992 1,-1, 1,-1, tmpSegZ[iz],tmpSegZ[iz+1]) - 1;
993 segY.Set(ny + fNYSegDip);
994 for (int iy=0;iy<ny;iy++) segY[fNYSegDip+iy] = tmpSegY[iy];
995 begSegYDip[iz] = fNYSegDip;
997 printf(" Found %d YSegments, to start from %d\n",ny, begSegYDip[iz]);
999 // for each slice in Z and Y create segmentation in X
1000 begSegXDip.Set(fNYSegDip+ny);
1001 nsegXDip.Set(fNYSegDip+ny);
1002 xyz[2] = (tmpSegZ[iz]+tmpSegZ[iz+1])/2.; // mean Z of this segment
1004 for (int iy=0;iy<ny;iy++) {
1005 int isg = fNYSegDip+iy;
1006 printf("\n YSegment#%d %+e : %+e\n",iy, tmpSegY[iy],tmpSegY[iy+1]);
1007 int nx = SegmentDimension(&tmpSegX, fParamsDip, fNParamsDip, 0,
1008 1,-1, tmpSegY[iy],tmpSegY[iy+1], tmpSegZ[iz],tmpSegZ[iz+1]) - 1;
1010 segX.Set(nx + fNXSegDip);
1011 for (int ix=0;ix<nx;ix++) segX[fNXSegDip+ix] = tmpSegX[ix];
1012 begSegXDip[isg] = fNXSegDip;
1014 printf(" Found %d XSegments, to start from %d\n",nx, begSegXDip[isg]);
1016 segID.Set(fNXSegDip+nx);
1018 // find corresponding params
1019 xyz[1] = (tmpSegY[iy]+tmpSegY[iy+1])/2.; // mean Y of this segment
1021 for (int ix=0;ix<nx;ix++) {
1022 xyz[0] = (tmpSegX[ix]+tmpSegX[ix+1])/2.; // mean X of this segment
1023 for (int ipar=0;ipar<fNParamsDip;ipar++) {
1024 AliCheb3D* cheb = (AliCheb3D*) fParamsDip->At(ipar);
1025 if (!cheb->IsInside(xyz)) continue;
1026 segID[fNXSegDip+ix] = ipar;
1038 fMinZDip = tmpSegZ[0];
1039 fMaxZDip = tmpSegZ[fNZSegDip];
1040 fSegZDip = new Float_t[fNZSegDip];
1041 for (int i=fNZSegDip;i--;) fSegZDip[i] = tmpSegZ[i];
1044 fSegYDip = new Float_t[fNYSegDip];
1045 fSegXDip = new Float_t[fNXSegDip];
1046 fBegSegYDip = new Int_t[fNZSegDip];
1047 fNSegYDip = new Int_t[fNZSegDip];
1048 fBegSegXDip = new Int_t[fNYSegDip];
1049 fNSegXDip = new Int_t[fNYSegDip];
1050 fSegIDDip = new Int_t[fNXSegDip];
1052 for (int i=fNYSegDip;i--;) fSegYDip[i] = segY[i];
1053 for (int i=fNXSegDip;i--;) fSegXDip[i] = segX[i];
1054 for (int i=fNZSegDip;i--;) {fBegSegYDip[i] = begSegYDip[i]; fNSegYDip[i] = nsegYDip[i];}
1055 for (int i=fNYSegDip;i--;) {fBegSegXDip[i] = begSegXDip[i]; fNSegXDip[i] = nsegXDip[i];}
1056 for (int i=fNXSegDip;i--;) {fSegIDDip[i] = segID[i];}
1061 //________________________________________________________________
1062 void AliMagWrapCheb::SaveData(const char* outfile) const
1064 // writes coefficients data to output text file
1065 TString strf = outfile;
1066 gSystem->ExpandPathName(strf);
1067 FILE* stream = fopen(strf,"w+");
1069 // Sol part ---------------------------------------------------------
1070 fprintf(stream,"# Set of Chebyshev parameterizations for ALICE magnetic field\nSTART %s\n",GetName());
1071 fprintf(stream,"START SOLENOID\n#Number of pieces\n%d\n",fNParamsSol);
1072 for (int ip=0;ip<fNParamsSol;ip++) GetParamSol(ip)->SaveData(stream);
1073 fprintf(stream,"#\nEND SOLENOID\n");
1075 // TPCInt part ---------------------------------------------------------
1076 fprintf(stream,"# Set of Chebyshev parameterizations for ALICE magnetic field\nSTART %s\n",GetName());
1077 fprintf(stream,"START TPCINT\n#Number of pieces\n%d\n",fNParamsTPC);
1078 for (int ip=0;ip<fNParamsTPC;ip++) GetParamTPCInt(ip)->SaveData(stream);
1079 fprintf(stream,"#\nEND TPCINT\n");
1081 // TPCRatInt part ---------------------------------------------------------
1082 fprintf(stream,"# Set of Chebyshev parameterizations for ALICE magnetic field\nSTART %s\n",GetName());
1083 fprintf(stream,"START TPCRatINT\n#Number of pieces\n%d\n",fNParamsTPCRat);
1084 for (int ip=0;ip<fNParamsTPCRat;ip++) GetParamTPCRatInt(ip)->SaveData(stream);
1085 fprintf(stream,"#\nEND TPCRatINT\n");
1087 // Dip part ---------------------------------------------------------
1088 fprintf(stream,"START DIPOLE\n#Number of pieces\n%d\n",fNParamsDip);
1089 for (int ip=0;ip<fNParamsDip;ip++) GetParamDip(ip)->SaveData(stream);
1090 fprintf(stream,"#\nEND DIPOLE\n");
1092 fprintf(stream,"#\nEND %s\n",GetName());
1098 Int_t AliMagWrapCheb::SegmentDimension(float** seg,const TObjArray* par,int npar, int dim,
1099 float xmn,float xmx,float ymn,float ymx,float zmn,float zmx)
1101 // find all boundaries in deimension dim for boxes in given region.
1102 // if mn>mx for given projection the check is not done for it.
1103 float *tmpC = new float[2*npar];
1104 int *tmpInd = new int[2*npar];
1106 for (int ip=0;ip<npar;ip++) {
1107 AliCheb3D* cheb = (AliCheb3D*) par->At(ip);
1108 if (xmn<xmx && (cheb->GetBoundMin(0)>(xmx+xmn)/2 || cheb->GetBoundMax(0)<(xmn+xmx)/2)) continue;
1109 if (ymn<ymx && (cheb->GetBoundMin(1)>(ymx+ymn)/2 || cheb->GetBoundMax(1)<(ymn+ymx)/2)) continue;
1110 if (zmn<zmx && (cheb->GetBoundMin(2)>(zmx+zmn)/2 || cheb->GetBoundMax(2)<(zmn+zmx)/2)) continue;
1112 tmpC[nseg0++] = cheb->GetBoundMin(dim);
1113 tmpC[nseg0++] = cheb->GetBoundMax(dim);
1115 // range Dim's boundaries in increasing order
1116 TMath::Sort(nseg0,tmpC,tmpInd,kFALSE);
1117 // count number of really different Z's
1120 for (int ip=0;ip<nseg0;ip++) {
1121 if (TMath::Abs(cprev-tmpC[ tmpInd[ip] ])>1e-4) {
1122 cprev = tmpC[ tmpInd[ip] ];
1125 else tmpInd[ip] = -1; // supress redundant Z
1128 *seg = new float[nseg]; // create final Z segmenations
1130 for (int ip=0;ip<nseg0;ip++) if (tmpInd[ip]>=0) (*seg)[nseg++] = tmpC[ tmpInd[ip] ];