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 delete fParamsSol; fParamsSol = 0;
176 delete[] fSegZSol; fSegZSol = 0;
177 delete[] fSegPSol; fSegPSol = 0;
178 delete[] fSegRSol; fSegRSol = 0;
179 delete[] fBegSegPSol; fBegSegPSol = 0;
180 delete[] fNSegPSol; fNSegPSol = 0;
181 delete[] fBegSegRSol; fBegSegRSol = 0;
182 delete[] fNSegRSol; fNSegRSol = 0;
183 delete[] fSegIDSol; fSegIDSol = 0;
185 fNParamsSol = fNZSegSol = fNPSegSol = fNRSegSol = 0;
191 delete fParamsTPC; fParamsTPC = 0;
192 delete[] fSegZTPC; fSegZTPC = 0;
193 delete[] fSegPTPC; fSegPTPC = 0;
194 delete[] fSegRTPC; fSegRTPC = 0;
195 delete[] fBegSegPTPC; fBegSegPTPC = 0;
196 delete[] fNSegPTPC; fNSegPTPC = 0;
197 delete[] fBegSegRTPC; fBegSegRTPC = 0;
198 delete[] fNSegRTPC; fNSegRTPC = 0;
199 delete[] fSegIDTPC; fSegIDTPC = 0;
201 fNParamsTPC = fNZSegTPC = fNPSegTPC = fNRSegTPC = 0;
206 if (fNParamsTPCRat) {
207 delete fParamsTPCRat; fParamsTPCRat = 0;
208 delete[] fSegZTPCRat; fSegZTPCRat = 0;
209 delete[] fSegPTPCRat; fSegPTPCRat = 0;
210 delete[] fSegRTPCRat; fSegRTPCRat = 0;
211 delete[] fBegSegPTPCRat; fBegSegPTPCRat = 0;
212 delete[] fNSegPTPCRat; fNSegPTPCRat = 0;
213 delete[] fBegSegRTPCRat; fBegSegRTPCRat = 0;
214 delete[] fNSegRTPCRat; fNSegRTPCRat = 0;
215 delete[] fSegIDTPCRat; fSegIDTPCRat = 0;
217 fNParamsTPCRat = fNZSegTPCRat = fNPSegTPCRat = fNRSegTPCRat = 0;
223 delete fParamsDip; fParamsDip = 0;
224 delete[] fSegZDip; fSegZDip = 0;
225 delete[] fSegYDip; fSegYDip = 0;
226 delete[] fSegXDip; fSegXDip = 0;
227 delete[] fBegSegYDip; fBegSegYDip = 0;
228 delete[] fNSegYDip; fNSegYDip = 0;
229 delete[] fBegSegXDip; fBegSegXDip = 0;
230 delete[] fNSegXDip; fNSegXDip = 0;
231 delete[] fSegIDDip; fSegIDDip = 0;
233 fNParamsDip = fNZSegDip = fNYSegDip = fNXSegDip = 0;
239 //__________________________________________________________________________________________
240 void AliMagWrapCheb::Field(const Double_t *xyz, Double_t *b) const
242 // compute field in cartesian coordinates. If point is outside of the parameterized region
243 // get it at closest valid point
246 #ifndef _BRING_TO_BOUNDARY_ // exact matching to fitted volume is requested
247 b[0] = b[1] = b[2] = 0;
250 if (xyz[2]>fMinZSol) {
251 CartToCyl(xyz,rphiz);
252 FieldCylSol(rphiz,b);
253 // convert field to cartesian system
254 CylToCartCylB(rphiz, b,b);
258 int iddip = FindDipSegment(xyz);
260 AliCheb3D* par = GetParamDip(iddip);
261 #ifndef _BRING_TO_BOUNDARY_
262 if (!par->IsInside(xyz)) return;
268 //__________________________________________________________________________________________
269 Double_t AliMagWrapCheb::GetBz(const Double_t *xyz) const
271 // compute Bz for the point in cartesian coordinates. If point is outside of the parameterized region
272 // get it at closest valid point
275 if (xyz[2]>fMinZSol) {
276 CartToCyl(xyz,rphiz);
277 return FieldCylSolBz(rphiz);
280 int iddip = FindDipSegment(xyz);
281 if (iddip<0) return 0.;
282 AliCheb3D* par = GetParamDip(iddip);
283 #ifndef _BRING_TO_BOUNDARY_
284 if (!par->IsInside(xyz)) return 0.;
286 return par->Eval(xyz,2);
290 //__________________________________________________________________________________________
291 void AliMagWrapCheb::Print(Option_t *) const
294 printf("Alice magnetic field parameterized by Chebyshev polynomials\n");
295 printf("Segmentation for Solenoid (%+.2f<Z<%+.2f cm | R<%.2f cm)\n",fMinZSol,fMaxZSol,fMaxRSol);
298 for (int i=0;i<fNParamsSol;i++) {
300 GetParamSol(i)->Print();
304 printf("Segmentation for TPC field integral (%+.2f<Z<%+.2f cm | R<%.2f cm)\n",fMinZTPC,fMaxZTPC,fMaxRTPC);
307 for (int i=0;i<fNParamsTPC;i++) {
309 GetParamTPCInt(i)->Print();
313 printf("Segmentation for TPC field ratios integral (%+.2f<Z<%+.2f cm | R<%.2f cm)\n",fMinZTPCRat,fMaxZTPCRat,fMaxRTPCRat);
316 for (int i=0;i<fNParamsTPCRat;i++) {
317 printf("TPCRat%4d ",i);
318 GetParamTPCRatInt(i)->Print();
322 printf("Segmentation for Dipole (%+.2f<Z<%+.2f cm)\n",fMinZDip,fMaxZDip);
324 for (int i=0;i<fNParamsDip;i++) {
326 GetParamDip(i)->Print();
332 //__________________________________________________________________________________________________
333 Int_t AliMagWrapCheb::FindDipSegment(const Double_t *xyz) const
335 // find the segment containing point xyz. If it is outside find the closest segment
336 if (!fNParamsDip) return -1;
337 int xid,yid,zid = TMath::BinarySearch(fNZSegDip,fSegZDip,(Float_t)xyz[2]); // find zsegment
339 Bool_t reCheck = kFALSE;
341 int ysegBeg = fBegSegYDip[zid];
343 for (yid=0;yid<fNSegYDip[zid];yid++) if (xyz[1]<fSegYDip[ysegBeg+yid]) break;
344 if ( --yid < 0 ) yid = 0;
347 int xsegBeg = fBegSegXDip[yid];
348 for (xid=0;xid<fNSegXDip[yid];xid++) if (xyz[0]<fSegXDip[xsegBeg+xid]) break;
350 if ( --xid < 0) xid = 0;
353 // to make sure that due to the precision problems we did not pick the next Zbin
354 if (!reCheck && (xyz[2] - fSegZDip[zid] < 3.e-5) && zid &&
355 !GetParamDip(fSegIDDip[xid])->IsInside(xyz)) { // check the previous Z bin
362 return fSegIDDip[xid];
365 //__________________________________________________________________________________________________
366 Int_t AliMagWrapCheb::FindSolSegment(const Double_t *rpz) const
368 // find the segment containing point xyz. If it is outside find the closest segment
369 if (!fNParamsSol) return -1;
370 int rid,pid,zid = TMath::BinarySearch(fNZSegSol,fSegZSol,(Float_t)rpz[2]); // find zsegment
372 Bool_t reCheck = kFALSE;
374 int psegBeg = fBegSegPSol[zid];
375 for (pid=0;pid<fNSegPSol[zid];pid++) if (rpz[1]<fSegPSol[psegBeg+pid]) break;
376 if ( --pid < 0 ) pid = 0;
379 int rsegBeg = fBegSegRSol[pid];
380 for (rid=0;rid<fNSegRSol[pid];rid++) if (rpz[0]<fSegRSol[rsegBeg+rid]) break;
381 if ( --rid < 0) rid = 0;
384 // to make sure that due to the precision problems we did not pick the next Zbin
385 if (!reCheck && (rpz[2] - fSegZSol[zid] < 3.e-5) && zid &&
386 !GetParamSol(fSegIDSol[rid])->IsInside(rpz)) { // check the previous Z bin
393 return fSegIDSol[rid];
396 //__________________________________________________________________________________________________
397 Int_t AliMagWrapCheb::FindTPCSegment(const Double_t *rpz) const
399 // find the segment containing point xyz. If it is outside find the closest segment
400 if (!fNParamsTPC) return -1;
401 int rid,pid,zid = TMath::BinarySearch(fNZSegTPC,fSegZTPC,(Float_t)rpz[2]); // find zsegment
403 Bool_t reCheck = kFALSE;
405 int psegBeg = fBegSegPTPC[zid];
407 for (pid=0;pid<fNSegPTPC[zid];pid++) if (rpz[1]<fSegPTPC[psegBeg+pid]) break;
408 if ( --pid < 0 ) pid = 0;
411 int rsegBeg = fBegSegRTPC[pid];
412 for (rid=0;rid<fNSegRTPC[pid];rid++) if (rpz[0]<fSegRTPC[rsegBeg+rid]) break;
413 if ( --rid < 0) rid = 0;
416 // to make sure that due to the precision problems we did not pick the next Zbin
417 if (!reCheck && (rpz[2] - fSegZSol[zid] < 3.e-5) && zid &&
418 !GetParamSol(fSegIDSol[rid])->IsInside(rpz)) { // check the previous Z bin
425 return fSegIDTPC[rid];
428 //__________________________________________________________________________________________________
429 Int_t AliMagWrapCheb::FindTPCRatSegment(const Double_t *rpz) const
431 // find the segment containing point xyz. If it is outside find the closest segment
432 if (!fNParamsTPCRat) return -1;
433 int rid,pid,zid = TMath::BinarySearch(fNZSegTPCRat,fSegZTPCRat,(Float_t)rpz[2]); // find zsegment
435 Bool_t reCheck = kFALSE;
437 int psegBeg = fBegSegPTPCRat[zid];
439 for (pid=0;pid<fNSegPTPCRat[zid];pid++) if (rpz[1]<fSegPTPCRat[psegBeg+pid]) break;
440 if ( --pid < 0 ) pid = 0;
443 int rsegBeg = fBegSegRTPCRat[pid];
444 for (rid=0;rid<fNSegRTPCRat[pid];rid++) if (rpz[0]<fSegRTPCRat[rsegBeg+rid]) break;
445 if ( --rid < 0) rid = 0;
448 // to make sure that due to the precision problems we did not pick the next Zbin
449 if (!reCheck && (rpz[2] - fSegZSol[zid] < 3.e-5) && zid &&
450 !GetParamSol(fSegIDSol[rid])->IsInside(rpz)) { // check the previous Z bin
457 return fSegIDTPCRat[rid];
461 //__________________________________________________________________________________________
462 void AliMagWrapCheb::GetTPCInt(const Double_t *xyz, Double_t *b) const
464 // compute TPC region field integral in cartesian coordinates.
465 // If point is outside of the parameterized region get it at closeset valid point
466 static Double_t rphiz[3];
469 AliError(Form("Wrong pointers: xyz:%p b:%p",xyz,b));
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 AliError(Form("Wrong pointers: xyz:%p b:%p",xyz,b));
499 // convert coordinates to cyl system
500 CartToCyl(xyz,rphiz);
501 #ifndef _BRING_TO_BOUNDARY_
502 if ( (rphiz[2]>GetMaxZTPCRatInt()||rphiz[2]<GetMinZTPCRatInt()) ||
503 rphiz[0]>GetMaxRTPCRatInt()) {for (int i=3;i--;) b[i]=0; return;}
506 GetTPCRatIntCyl(rphiz,b);
508 // convert field to cartesian system
509 CylToCartCylB(rphiz, b,b);
513 //__________________________________________________________________________________________
514 void AliMagWrapCheb::FieldCylSol(const Double_t *rphiz, Double_t *b) const
516 // compute Solenoid field in Cylindircal coordinates
517 // note: if the point is outside the volume get the field in closest parameterized point
518 int id = FindSolSegment(rphiz);
520 AliCheb3D* par = GetParamSol(id);
521 #ifndef _BRING_TO_BOUNDARY_ // exact matching to fitted volume is requested
522 if (!par->IsInside(rphiz)) return;
529 //__________________________________________________________________________________________
530 Double_t AliMagWrapCheb::FieldCylSolBz(const Double_t *rphiz) const
532 // compute Solenoid field in Cylindircal coordinates
533 // note: if the point is outside the volume get the field in closest parameterized point
534 int id = FindSolSegment(rphiz);
536 AliCheb3D* par = GetParamSol(id);
537 #ifndef _BRING_TO_BOUNDARY_
538 return par->IsInside(rphiz) ? par->Eval(rphiz,2) : 0;
540 return par->Eval(rphiz,2);
544 //__________________________________________________________________________________________
545 void AliMagWrapCheb::GetTPCIntCyl(const Double_t *rphiz, Double_t *b) const
547 // compute field integral in TPC region in Cylindircal coordinates
548 // note: the check for the point being inside the parameterized region is done outside
549 int id = FindTPCSegment(rphiz);
551 b[0] = b[1] = b[2] = 0;
554 if (id>=fNParamsTPC) {
555 AliError(Form("Wrong TPCParam segment %d",id));
556 b[0] = b[1] = b[2] = 0;
559 AliCheb3D* par = GetParamTPCInt(id);
560 if (par->IsInside(rphiz)) {
564 b[0] = b[1] = b[2] = 0;
569 //__________________________________________________________________________________________
570 void AliMagWrapCheb::GetTPCRatIntCyl(const Double_t *rphiz, Double_t *b) const
572 // compute field integral in TPCRat region in Cylindircal coordinates
573 // note: the check for the point being inside the parameterized region is done outside
574 int id = FindTPCRatSegment(rphiz);
576 b[0] = b[1] = b[2] = 0;
579 if (id>=fNParamsTPCRat) {
580 AliError(Form("Wrong TPCRatParam segment %d",id));
581 b[0] = b[1] = b[2] = 0;
584 AliCheb3D* par = GetParamTPCRatInt(id);
585 if (par->IsInside(rphiz)) {
589 b[0] = b[1] = b[2] = 0;
595 #ifdef _INC_CREATION_ALICHEB3D_
596 //_______________________________________________
597 void AliMagWrapCheb::LoadData(const char* inpfile)
599 // read coefficients data from the text file
601 TString strf = inpfile;
602 gSystem->ExpandPathName(strf);
603 FILE* stream = fopen(strf,"r");
605 printf("Did not find input file %s\n",strf.Data());
610 AliCheb3DCalc::ReadLine(buffs,stream);
611 if (!buffs.BeginsWith("START")) {
612 Error("LoadData","Expected: \"START <name>\", found \"%s\"\nStop\n",buffs.Data());
615 if (buffs.First(' ')>0) SetName(buffs.Data()+buffs.First(' ')+1);
617 // Solenoid part -----------------------------------------------------------
618 AliCheb3DCalc::ReadLine(buffs,stream);
619 if (!buffs.BeginsWith("START SOLENOID")) {
620 Error("LoadData","Expected: \"START SOLENOID\", found \"%s\"\nStop\n",buffs.Data());
623 AliCheb3DCalc::ReadLine(buffs,stream); // nparam
624 int nparSol = buffs.Atoi();
626 for (int ip=0;ip<nparSol;ip++) {
627 AliCheb3D* cheb = new AliCheb3D();
628 cheb->LoadData(stream);
632 AliCheb3DCalc::ReadLine(buffs,stream);
633 if (!buffs.BeginsWith("END SOLENOID")) {
634 Error("LoadData","Expected \"END SOLENOID\", found \"%s\"\nStop\n",buffs.Data());
638 // TPCInt part -----------------------------------------------------------
639 AliCheb3DCalc::ReadLine(buffs,stream);
640 if (!buffs.BeginsWith("START TPCINT")) {
641 Error("LoadData","Expected: \"START TPCINT\", found \"%s\"\nStop\n",buffs.Data());
644 AliCheb3DCalc::ReadLine(buffs,stream); // nparam
645 int nparTPCInt = buffs.Atoi();
647 for (int ip=0;ip<nparTPCInt;ip++) {
648 AliCheb3D* cheb = new AliCheb3D();
649 cheb->LoadData(stream);
650 AddParamTPCInt(cheb);
653 AliCheb3DCalc::ReadLine(buffs,stream);
654 if (!buffs.BeginsWith("END TPCINT")) {
655 Error("LoadData","Expected \"END TPCINT\", found \"%s\"\nStop\n",buffs.Data());
659 // TPCRatInt part -----------------------------------------------------------
660 AliCheb3DCalc::ReadLine(buffs,stream);
661 if (!buffs.BeginsWith("START TPCRatINT")) {
662 Error("LoadData","Expected: \"START TPCRatINT\", found \"%s\"\nStop\n",buffs.Data());
665 AliCheb3DCalc::ReadLine(buffs,stream); // nparam
666 int nparTPCRatInt = buffs.Atoi();
668 for (int ip=0;ip<nparTPCRatInt;ip++) {
669 AliCheb3D* cheb = new AliCheb3D();
670 cheb->LoadData(stream);
671 AddParamTPCRatInt(cheb);
674 AliCheb3DCalc::ReadLine(buffs,stream);
675 if (!buffs.BeginsWith("END TPCRatINT")) {
676 Error("LoadData","Expected \"END TPCRatINT\", found \"%s\"\nStop\n",buffs.Data());
680 // Dipole part -----------------------------------------------------------
681 AliCheb3DCalc::ReadLine(buffs,stream);
682 if (!buffs.BeginsWith("START DIPOLE")) {
683 Error("LoadData","Expected: \"START DIPOLE\", found \"%s\"\nStop\n",buffs.Data());
686 AliCheb3DCalc::ReadLine(buffs,stream); // nparam
687 int nparDip = buffs.Atoi();
689 for (int ip=0;ip<nparDip;ip++) {
690 AliCheb3D* cheb = new AliCheb3D();
691 cheb->LoadData(stream);
695 AliCheb3DCalc::ReadLine(buffs,stream);
696 if (!buffs.BeginsWith("END DIPOLE")) {
697 Error("LoadData","Expected \"END DIPOLE\", found \"%s\"\nStop\n",GetName(),buffs.Data());
701 AliCheb3DCalc::ReadLine(buffs,stream);
702 if (!buffs.BeginsWith("END") || !buffs.Contains(GetName())) {
703 Error("LoadData","Expected: \"END %s\", found \"%s\"\nStop\n",GetName(),buffs.Data());
707 // ---------------------------------------------------------------------------
712 BuildTableTPCRatInt();
714 printf("Loaded magnetic field \"%s\" from %s\n",GetName(),strf.Data());
718 //__________________________________________________________________________________________
719 void AliMagWrapCheb::BuildTableSol()
721 BuildTable(fNParamsSol,fParamsSol,
722 fNZSegSol,fNPSegSol,fNRSegSol,
724 &fSegZSol,&fSegPSol,&fSegRSol,
725 &fBegSegPSol,&fNSegPSol,
726 &fBegSegRSol,&fNSegRSol,
730 //__________________________________________________________________________________________
731 void AliMagWrapCheb::BuildTableDip()
733 BuildTable(fNParamsDip,fParamsDip,
734 fNZSegDip,fNYSegDip,fNXSegDip,
736 &fSegZDip,&fSegYDip,&fSegXDip,
737 &fBegSegYDip,&fNSegYDip,
738 &fBegSegXDip,&fNSegXDip,
742 //__________________________________________________________________________________________
743 void AliMagWrapCheb::BuildTableTPCInt()
745 BuildTable(fNParamsTPC,fParamsTPC,
746 fNZSegTPC,fNPSegTPC,fNRSegTPC,
748 &fSegZTPC,&fSegPTPC,&fSegRTPC,
749 &fBegSegPTPC,&fNSegPTPC,
750 &fBegSegRTPC,&fNSegRTPC,
754 //__________________________________________________________________________________________
755 void AliMagWrapCheb::BuildTableTPCRatInt()
757 BuildTable(fNParamsTPCRat,fParamsTPCRat,
758 fNZSegTPCRat,fNPSegTPCRat,fNRSegTPCRat,
759 fMinZTPCRat,fMaxZTPCRat,
760 &fSegZTPCRat,&fSegPTPCRat,&fSegRTPCRat,
761 &fBegSegPTPCRat,&fNSegPTPCRat,
762 &fBegSegRTPCRat,&fNSegRTPCRat,
768 //_______________________________________________
769 #ifdef _INC_CREATION_ALICHEB3D_
771 //__________________________________________________________________________________________
772 AliMagWrapCheb::AliMagWrapCheb(const char* inputFile) :
773 fNParamsSol(0),fNZSegSol(0),fNPSegSol(0),fNRSegSol(0),
774 fSegZSol(0),fSegPSol(0),fSegRSol(0),
775 fBegSegPSol(0),fNSegPSol(0),fBegSegRSol(0),fNSegRSol(0),fSegIDSol(0),fMinZSol(1.e6),fMaxZSol(-1.e6),fParamsSol(0),fMaxRSol(0),
777 fNParamsTPC(0),fNZSegTPC(0),fNPSegTPC(0),fNRSegTPC(0),
778 fSegZTPC(0),fSegPTPC(0),fSegRTPC(0),
779 fBegSegPTPC(0),fNSegPTPC(0),fBegSegRTPC(0),fNSegRTPC(0),fSegIDTPC(0),fMinZTPC(1.e6),fMaxZTPC(-1.e6),fParamsTPC(0),fMaxRTPC(0),
781 fNParamsTPCRat(0),fNZSegTPCRat(0),fNPSegTPCRat(0),fNRSegTPCRat(0),
782 fSegZTPCRat(0),fSegPTPCRat(0),fSegRTPCRat(0),
783 fBegSegPTPCRat(0),fNSegPTPCRat(0),fBegSegRTPCRat(0),fNSegRTPCRat(0),fSegIDTPCRat(0),fMinZTPCRat(1.e6),fMaxZTPCRat(-1.e6),fParamsTPCRat(0),fMaxRTPCRat(0),
785 fNParamsDip(0),fNZSegDip(0),fNYSegDip(0),fNXSegDip(0),
786 fSegZDip(0),fSegYDip(0),fSegXDip(0),
787 fBegSegYDip(0),fNSegYDip(0),fBegSegXDip(0),fNSegXDip(0),fSegIDDip(0),fMinZDip(1.e6),fMaxZDip(-1.e6),fParamsDip(0)
790 // construct from coeffs from the text file
794 //__________________________________________________________________________________________
795 void AliMagWrapCheb::AddParamSol(const AliCheb3D* param)
797 // adds new parameterization piece for Sol
798 // NOTE: pieces must be added strictly in increasing R then increasing Z order
800 if (!fParamsSol) fParamsSol = new TObjArray();
801 fParamsSol->Add( (AliCheb3D*)param );
803 if (fMaxRSol<param->GetBoundMax(0)) fMaxRSol = param->GetBoundMax(0);
807 //__________________________________________________________________________________________
808 void AliMagWrapCheb::AddParamTPCInt(const AliCheb3D* param)
810 // adds new parameterization piece for TPCInt
811 // NOTE: pieces must be added strictly in increasing R then increasing Z order
813 if (!fParamsTPC) fParamsTPC = new TObjArray();
814 fParamsTPC->Add( (AliCheb3D*)param);
816 if (fMaxRTPC<param->GetBoundMax(0)) fMaxRTPC = param->GetBoundMax(0);
820 //__________________________________________________________________________________________
821 void AliMagWrapCheb::AddParamTPCRatInt(const AliCheb3D* param)
823 // adds new parameterization piece for TPCRatInt
824 // NOTE: pieces must be added strictly in increasing R then increasing Z order
826 if (!fParamsTPCRat) fParamsTPCRat = new TObjArray();
827 fParamsTPCRat->Add( (AliCheb3D*)param);
829 if (fMaxRTPCRat<param->GetBoundMax(0)) fMaxRTPCRat = param->GetBoundMax(0);
833 //__________________________________________________________________________________________
834 void AliMagWrapCheb::AddParamDip(const AliCheb3D* param)
836 // adds new parameterization piece for Dipole
838 if (!fParamsDip) fParamsDip = new TObjArray();
839 fParamsDip->Add( (AliCheb3D*)param);
844 //__________________________________________________________________________________________
845 void AliMagWrapCheb::ResetTPCInt()
847 // clean TPC field integral (used for update)
849 delete fParamsTPC; fParamsTPC = 0;
850 delete[] fSegZTPC; fSegZTPC = 0;
851 delete[] fSegPTPC; fSegPTPC = 0;
852 delete[] fSegRTPC; fSegRTPC = 0;
853 delete[] fBegSegPTPC; fBegSegPTPC = 0;
854 delete[] fNSegPTPC; fNSegPTPC = 0;
855 delete[] fBegSegRTPC; fBegSegRTPC = 0;
856 delete[] fNSegRTPC; fNSegRTPC = 0;
857 delete[] fSegIDTPC; fSegIDTPC = 0;
859 fNParamsTPC = fNZSegTPC = fNPSegTPC = fNRSegTPC = 0;
866 //__________________________________________________________________________________________
867 void AliMagWrapCheb::ResetTPCRatInt()
869 // clean TPCRat field integral (used for update)
870 if (fNParamsTPCRat) {
871 delete fParamsTPCRat; fParamsTPCRat = 0;
872 delete[] fSegZTPCRat; fSegZTPCRat = 0;
873 delete[] fSegPTPCRat; fSegPTPCRat = 0;
874 delete[] fSegRTPCRat; fSegRTPCRat = 0;
875 delete[] fBegSegPTPCRat; fBegSegPTPCRat = 0;
876 delete[] fNSegPTPCRat; fNSegPTPCRat = 0;
877 delete[] fBegSegRTPCRat; fBegSegRTPCRat = 0;
878 delete[] fNSegRTPCRat; fNSegRTPCRat = 0;
879 delete[] fSegIDTPCRat; fSegIDTPCRat = 0;
881 fNParamsTPCRat = fNZSegTPCRat = fNPSegTPCRat = fNRSegTPCRat = 0;
889 //__________________________________________________
890 void AliMagWrapCheb::BuildTable(Int_t npar,TObjArray *parArr, Int_t &nZSeg, Int_t &nYSeg, Int_t &nXSeg,
891 Float_t &minZ,Float_t &maxZ,
892 Float_t **segZ,Float_t **segY,Float_t **segX,
893 Int_t **begSegY,Int_t **nSegY,
894 Int_t **begSegX,Int_t **nSegX,
897 // build lookup table for dipole
900 TArrayF segYArr,segXArr;
901 TArrayI begSegYDipArr,begSegXDipArr;
902 TArrayI nSegYDipArr,nSegXDipArr;
904 float *tmpSegZ,*tmpSegY,*tmpSegX;
906 // create segmentation in Z
907 nZSeg = SegmentDimension(&tmpSegZ, parArr, npar, 2, 1,-1, 1,-1, 1,-1) - 1;
911 // for each Z slice create segmentation in Y
912 begSegYDipArr.Set(nZSeg);
913 nSegYDipArr.Set(nZSeg);
915 for (int iz=0;iz<nZSeg;iz++) {
916 printf("\nZSegment#%d %+e : %+e\n",iz,tmpSegZ[iz],tmpSegZ[iz+1]);
917 int ny = SegmentDimension(&tmpSegY, parArr, npar, 1,
918 1,-1, 1,-1, tmpSegZ[iz],tmpSegZ[iz+1]) - 1;
919 segYArr.Set(ny + nYSeg);
920 for (int iy=0;iy<ny;iy++) segYArr[nYSeg+iy] = tmpSegY[iy];
921 begSegYDipArr[iz] = nYSeg;
922 nSegYDipArr[iz] = ny;
923 printf(" Found %d YSegments, to start from %d\n",ny, begSegYDipArr[iz]);
925 // for each slice in Z and Y create segmentation in X
926 begSegXDipArr.Set(nYSeg+ny);
927 nSegXDipArr.Set(nYSeg+ny);
928 xyz[2] = (tmpSegZ[iz]+tmpSegZ[iz+1])/2.; // mean Z of this segment
930 for (int iy=0;iy<ny;iy++) {
932 printf("\n YSegment#%d %+e : %+e\n",iy, tmpSegY[iy],tmpSegY[iy+1]);
933 int nx = SegmentDimension(&tmpSegX, parArr, npar, 0,
934 1,-1, tmpSegY[iy],tmpSegY[iy+1], tmpSegZ[iz],tmpSegZ[iz+1]) - 1;
936 segXArr.Set(nx + nXSeg);
937 for (int ix=0;ix<nx;ix++) segXArr[nXSeg+ix] = tmpSegX[ix];
938 begSegXDipArr[isg] = nXSeg;
939 nSegXDipArr[isg] = nx;
940 printf(" Found %d XSegments, to start from %d\n",nx, begSegXDipArr[isg]);
942 segIDArr.Set(nXSeg+nx);
944 // find corresponding params
945 xyz[1] = (tmpSegY[iy]+tmpSegY[iy+1])/2.; // mean Y of this segment
947 for (int ix=0;ix<nx;ix++) {
948 xyz[0] = (tmpSegX[ix]+tmpSegX[ix+1])/2.; // mean X of this segment
949 for (int ipar=0;ipar<npar;ipar++) {
950 AliCheb3D* cheb = (AliCheb3D*) parArr->At(ipar);
951 if (!cheb->IsInside(xyz)) continue;
952 segIDArr[nXSeg+ix] = ipar;
965 maxZ = tmpSegZ[nZSeg];
966 (*segZ) = new Float_t[nZSeg];
967 for (int i=nZSeg;i--;) (*segZ)[i] = tmpSegZ[i];
970 (*segY) = new Float_t[nYSeg];
971 (*segX) = new Float_t[nXSeg];
972 (*begSegY) = new Int_t[nZSeg];
973 (*nSegY) = new Int_t[nZSeg];
974 (*begSegX) = new Int_t[nYSeg];
975 (*nSegX) = new Int_t[nYSeg];
976 (*segID) = new Int_t[nXSeg];
978 for (int i=nYSeg;i--;) (*segY)[i] = segYArr[i];
979 for (int i=nXSeg;i--;) (*segX)[i] = segXArr[i];
980 for (int i=nZSeg;i--;) {(*begSegY)[i] = begSegYDipArr[i]; (*nSegY)[i] = nSegYDipArr[i];}
981 for (int i=nYSeg;i--;) {(*begSegX)[i] = begSegXDipArr[i]; (*nSegX)[i] = nSegXDipArr[i];}
982 for (int i=nXSeg;i--;) {(*segID)[i] = segIDArr[i];}
987 //__________________________________________________
988 void AliMagWrapCheb::BuildTableDip()
990 // build lookup table for dipole
992 if (fNParamsDip<1) return;
994 TArrayI begSegYDip,begSegXDip;
995 TArrayI nsegYDip,nsegXDip;
997 float *tmpSegZ,*tmpSegY,*tmpSegX;
999 // create segmentation in Z
1000 fNZSegDip = SegmentDimension(&tmpSegZ, fParamsDip, fNParamsDip, 2, 1,-1, 1,-1, 1,-1) - 1;
1004 // for each Z slice create segmentation in Y
1005 begSegYDip.Set(fNZSegDip);
1006 nsegYDip.Set(fNZSegDip);
1008 for (int iz=0;iz<fNZSegDip;iz++) {
1009 printf("\nZSegment#%d %+e : %+e\n",iz,tmpSegZ[iz],tmpSegZ[iz+1]);
1010 int ny = SegmentDimension(&tmpSegY, fParamsDip, fNParamsDip, 1,
1011 1,-1, 1,-1, tmpSegZ[iz],tmpSegZ[iz+1]) - 1;
1012 segY.Set(ny + fNYSegDip);
1013 for (int iy=0;iy<ny;iy++) segY[fNYSegDip+iy] = tmpSegY[iy];
1014 begSegYDip[iz] = fNYSegDip;
1016 printf(" Found %d YSegments, to start from %d\n",ny, begSegYDip[iz]);
1018 // for each slice in Z and Y create segmentation in X
1019 begSegXDip.Set(fNYSegDip+ny);
1020 nsegXDip.Set(fNYSegDip+ny);
1021 xyz[2] = (tmpSegZ[iz]+tmpSegZ[iz+1])/2.; // mean Z of this segment
1023 for (int iy=0;iy<ny;iy++) {
1024 int isg = fNYSegDip+iy;
1025 printf("\n YSegment#%d %+e : %+e\n",iy, tmpSegY[iy],tmpSegY[iy+1]);
1026 int nx = SegmentDimension(&tmpSegX, fParamsDip, fNParamsDip, 0,
1027 1,-1, tmpSegY[iy],tmpSegY[iy+1], tmpSegZ[iz],tmpSegZ[iz+1]) - 1;
1029 segX.Set(nx + fNXSegDip);
1030 for (int ix=0;ix<nx;ix++) segX[fNXSegDip+ix] = tmpSegX[ix];
1031 begSegXDip[isg] = fNXSegDip;
1033 printf(" Found %d XSegments, to start from %d\n",nx, begSegXDip[isg]);
1035 segID.Set(fNXSegDip+nx);
1037 // find corresponding params
1038 xyz[1] = (tmpSegY[iy]+tmpSegY[iy+1])/2.; // mean Y of this segment
1040 for (int ix=0;ix<nx;ix++) {
1041 xyz[0] = (tmpSegX[ix]+tmpSegX[ix+1])/2.; // mean X of this segment
1042 for (int ipar=0;ipar<fNParamsDip;ipar++) {
1043 AliCheb3D* cheb = (AliCheb3D*) fParamsDip->At(ipar);
1044 if (!cheb->IsInside(xyz)) continue;
1045 segID[fNXSegDip+ix] = ipar;
1057 fMinZDip = tmpSegZ[0];
1058 fMaxZDip = tmpSegZ[fNZSegDip];
1059 fSegZDip = new Float_t[fNZSegDip];
1060 for (int i=fNZSegDip;i--;) fSegZDip[i] = tmpSegZ[i];
1063 fSegYDip = new Float_t[fNYSegDip];
1064 fSegXDip = new Float_t[fNXSegDip];
1065 fBegSegYDip = new Int_t[fNZSegDip];
1066 fNSegYDip = new Int_t[fNZSegDip];
1067 fBegSegXDip = new Int_t[fNYSegDip];
1068 fNSegXDip = new Int_t[fNYSegDip];
1069 fSegIDDip = new Int_t[fNXSegDip];
1071 for (int i=fNYSegDip;i--;) fSegYDip[i] = segY[i];
1072 for (int i=fNXSegDip;i--;) fSegXDip[i] = segX[i];
1073 for (int i=fNZSegDip;i--;) {fBegSegYDip[i] = begSegYDip[i]; fNSegYDip[i] = nsegYDip[i];}
1074 for (int i=fNYSegDip;i--;) {fBegSegXDip[i] = begSegXDip[i]; fNSegXDip[i] = nsegXDip[i];}
1075 for (int i=fNXSegDip;i--;) {fSegIDDip[i] = segID[i];}
1080 //________________________________________________________________
1081 void AliMagWrapCheb::SaveData(const char* outfile) const
1083 // writes coefficients data to output text file
1084 TString strf = outfile;
1085 gSystem->ExpandPathName(strf);
1086 FILE* stream = fopen(strf,"w+");
1088 // Sol part ---------------------------------------------------------
1089 fprintf(stream,"# Set of Chebyshev parameterizations for ALICE magnetic field\nSTART %s\n",GetName());
1090 fprintf(stream,"START SOLENOID\n#Number of pieces\n%d\n",fNParamsSol);
1091 for (int ip=0;ip<fNParamsSol;ip++) GetParamSol(ip)->SaveData(stream);
1092 fprintf(stream,"#\nEND SOLENOID\n");
1094 // TPCInt part ---------------------------------------------------------
1095 fprintf(stream,"# Set of Chebyshev parameterizations for ALICE magnetic field\nSTART %s\n",GetName());
1096 fprintf(stream,"START TPCINT\n#Number of pieces\n%d\n",fNParamsTPC);
1097 for (int ip=0;ip<fNParamsTPC;ip++) GetParamTPCInt(ip)->SaveData(stream);
1098 fprintf(stream,"#\nEND TPCINT\n");
1100 // TPCRatInt part ---------------------------------------------------------
1101 fprintf(stream,"# Set of Chebyshev parameterizations for ALICE magnetic field\nSTART %s\n",GetName());
1102 fprintf(stream,"START TPCRatINT\n#Number of pieces\n%d\n",fNParamsTPCRat);
1103 for (int ip=0;ip<fNParamsTPCRat;ip++) GetParamTPCRatInt(ip)->SaveData(stream);
1104 fprintf(stream,"#\nEND TPCRatINT\n");
1106 // Dip part ---------------------------------------------------------
1107 fprintf(stream,"START DIPOLE\n#Number of pieces\n%d\n",fNParamsDip);
1108 for (int ip=0;ip<fNParamsDip;ip++) GetParamDip(ip)->SaveData(stream);
1109 fprintf(stream,"#\nEND DIPOLE\n");
1111 fprintf(stream,"#\nEND %s\n",GetName());
1117 Int_t AliMagWrapCheb::SegmentDimension(float** seg,const TObjArray* par,int npar, int dim,
1118 float xmn,float xmx,float ymn,float ymx,float zmn,float zmx)
1120 // find all boundaries in deimension dim for boxes in given region.
1121 // if mn>mx for given projection the check is not done for it.
1122 float *tmpC = new float[2*npar];
1123 int *tmpInd = new int[2*npar];
1125 for (int ip=0;ip<npar;ip++) {
1126 AliCheb3D* cheb = (AliCheb3D*) par->At(ip);
1127 if (xmn<xmx && (cheb->GetBoundMin(0)>(xmx+xmn)/2 || cheb->GetBoundMax(0)<(xmn+xmx)/2)) continue;
1128 if (ymn<ymx && (cheb->GetBoundMin(1)>(ymx+ymn)/2 || cheb->GetBoundMax(1)<(ymn+ymx)/2)) continue;
1129 if (zmn<zmx && (cheb->GetBoundMin(2)>(zmx+zmn)/2 || cheb->GetBoundMax(2)<(zmn+zmx)/2)) continue;
1131 tmpC[nseg0++] = cheb->GetBoundMin(dim);
1132 tmpC[nseg0++] = cheb->GetBoundMax(dim);
1134 // range Dim's boundaries in increasing order
1135 TMath::Sort(nseg0,tmpC,tmpInd,kFALSE);
1136 // count number of really different Z's
1139 for (int ip=0;ip<nseg0;ip++) {
1140 if (TMath::Abs(cprev-tmpC[ tmpInd[ip] ])>1e-4) {
1141 cprev = tmpC[ tmpInd[ip] ];
1144 else tmpInd[ip] = -1; // supress redundant Z
1147 *seg = new float[nseg]; // create final Z segmenations
1149 for (int ip=0;ip<nseg0;ip++) if (tmpInd[ip]>=0) (*seg)[nseg++] = tmpC[ tmpInd[ip] ];