**************************************************************************/
#include "AliMagWrapCheb.h"
+#include "AliLog.h"
#include <TSystem.h>
#include <TArrayF.h>
#include <TArrayI.h>
//__________________________________________________________________________________________
AliMagWrapCheb::AliMagWrapCheb() :
- fNParamsSol(0),
- fNSegZSol(0),
- fNParamsTPCInt(0),
- fNSegZTPCInt(0),
- fNParamsDip(0),
+fNParamsSol(0),fNZSegSol(0),fNPSegSol(0),fNRSegSol(0),
+ fSegZSol(0),fSegPSol(0),fSegRSol(0),
+ fBegSegPSol(0),fNSegPSol(0),fBegSegRSol(0),fNSegRSol(0),fSegIDSol(0),fMinZSol(1.e6),fMaxZSol(-1.e6),fParamsSol(0),fMaxRSol(0),
//
- fNZSegDip(0),
- fNYSegDip(0),
- fNXSegDip(0),
+ fNParamsTPC(0),fNZSegTPC(0),fNPSegTPC(0),fNRSegTPC(0),
+ fSegZTPC(0),fSegPTPC(0),fSegRTPC(0),
+ fBegSegPTPC(0),fNSegPTPC(0),fBegSegRTPC(0),fNSegRTPC(0),fSegIDTPC(0),fMinZTPC(1.e6),fMaxZTPC(-1.e6),fParamsTPC(0),fMaxRTPC(0),
//
- fSegZSol(0),
- fSegRSol(0),
+ fNParamsTPCRat(0),fNZSegTPCRat(0),fNPSegTPCRat(0),fNRSegTPCRat(0),
+ fSegZTPCRat(0),fSegPTPCRat(0),fSegRTPCRat(0),
+ fBegSegPTPCRat(0),fNSegPTPCRat(0),fBegSegRTPCRat(0),fNSegRTPCRat(0),fSegIDTPCRat(0),fMinZTPCRat(1.e6),fMaxZTPCRat(-1.e6),fParamsTPCRat(0),fMaxRTPCRat(0),
//
- fSegZTPCInt(0),
- fSegRTPCInt(0),
-//
- fSegZDip(0),
- fSegYDip(0),
- fSegXDip(0),
-//
- fNSegRSol(0),
- fSegZIdSol(0),
-//
- fNSegRTPCInt(0),
- fSegZIdTPCInt(0),
-//
- fBegSegYDip(0),
- fNSegYDip(0),
- fBegSegXDip(0),
- fNSegXDip(0),
- fSegIDDip(0),
-//
- fMinZSol(1e6),
- fMaxZSol(-1e6),
- fMaxRSol(-1e6),
-//
- fMinZDip(1e6),
- fMaxZDip(-1e6),
-//
- fMinZTPCInt(1e6),
- fMaxZTPCInt(-1e6),
- fMaxRTPCInt(-1e6),
-//
- fParamsSol(0),
- fParamsDip(0),
- fParamsTPCInt(0)
+ fNParamsDip(0),fNZSegDip(0),fNYSegDip(0),fNXSegDip(0),
+ fSegZDip(0),fSegYDip(0),fSegXDip(0),
+ fBegSegYDip(0),fNSegYDip(0),fBegSegXDip(0),fNSegXDip(0),fSegIDDip(0),fMinZDip(1.e6),fMaxZDip(-1.e6),fParamsDip(0)
//
{
// default constructor
//__________________________________________________________________________________________
AliMagWrapCheb::AliMagWrapCheb(const AliMagWrapCheb& src) :
TNamed(src),
- fNParamsSol(0),
- fNSegZSol(0),
- fNParamsTPCInt(0),
- fNSegZTPCInt(0),
- fNParamsDip(0),
-//
- fNZSegDip(0),
- fNYSegDip(0),
- fNXSegDip(0),
+ fNParamsSol(0),fNZSegSol(0),fNPSegSol(0),fNRSegSol(0),
+ fSegZSol(0),fSegPSol(0),fSegRSol(0),
+ fBegSegPSol(0),fNSegPSol(0),fBegSegRSol(0),fNSegRSol(0),fSegIDSol(0),fMinZSol(1.e6),fMaxZSol(-1.e6),fParamsSol(0),fMaxRSol(0),
//
- fSegZSol(0),
- fSegRSol(0),
+ fNParamsTPC(0),fNZSegTPC(0),fNPSegTPC(0),fNRSegTPC(0),
+ fSegZTPC(0),fSegPTPC(0),fSegRTPC(0),
+ fBegSegPTPC(0),fNSegPTPC(0),fBegSegRTPC(0),fNSegRTPC(0),fSegIDTPC(0),fMinZTPC(1.e6),fMaxZTPC(-1.e6),fParamsTPC(0),fMaxRTPC(0),
//
- fSegZTPCInt(0),
- fSegRTPCInt(0),
+ fNParamsTPCRat(0),fNZSegTPCRat(0),fNPSegTPCRat(0),fNRSegTPCRat(0),
+ fSegZTPCRat(0),fSegPTPCRat(0),fSegRTPCRat(0),
+ fBegSegPTPCRat(0),fNSegPTPCRat(0),fBegSegRTPCRat(0),fNSegRTPCRat(0),fSegIDTPCRat(0),fMinZTPCRat(1.e6),fMaxZTPCRat(-1.e6),fParamsTPCRat(0),fMaxRTPCRat(0),
//
- fSegZDip(0),
- fSegYDip(0),
- fSegXDip(0),
-//
- fNSegRSol(0),
- fSegZIdSol(0),
-//
- fNSegRTPCInt(0),
- fSegZIdTPCInt(0),
-//
- fBegSegYDip(0),
- fNSegYDip(0),
- fBegSegXDip(0),
- fNSegXDip(0),
- fSegIDDip(0),
-//
- fMinZSol(1e6),
- fMaxZSol(-1e6),
- fMaxRSol(-1e6),
-//
- fMinZDip(1e6),
- fMaxZDip(-1e6),
-//
- fMinZTPCInt(1e6),
- fMaxZTPCInt(-1e6),
- fMaxRTPCInt(-1e6),
-//
- fParamsSol(0),
- fParamsDip(0),
- fParamsTPCInt(0)
+ fNParamsDip(0),fNZSegDip(0),fNYSegDip(0),fNXSegDip(0),
+ fSegZDip(0),fSegYDip(0),fSegXDip(0),
+ fBegSegYDip(0),fNSegYDip(0),fBegSegXDip(0),fNSegXDip(0),fSegIDDip(0),fMinZDip(1.e6),fMaxZDip(-1.e6),fParamsDip(0)
{
// copy constructor
CopyFrom(src);
Clear();
SetName(src.GetName());
SetTitle(src.GetTitle());
+ //
fNParamsSol = src.fNParamsSol;
- fNSegZSol = src.fNSegZSol;
- fNParamsTPCInt = src.fNParamsTPCInt;
- fNSegZTPCInt = src.fNSegZTPCInt;
- fNParamsDip = src.fNParamsDip;
+ fNZSegSol = src.fNZSegSol;
+ fNPSegSol = src.fNPSegSol;
+ fNRSegSol = src.fNRSegSol;
+ fMinZSol = src.fMinZSol;
+ fMaxZSol = src.fMaxZSol;
+ fMaxRSol = src.fMaxRSol;
+ if (src.fNParamsSol) {
+ memcpy(fSegZSol = new Float_t[fNZSegSol], src.fSegZSol, sizeof(Float_t)*fNZSegSol);
+ memcpy(fSegPSol = new Float_t[fNPSegSol], src.fSegPSol, sizeof(Float_t)*fNPSegSol);
+ memcpy(fSegRSol = new Float_t[fNRSegSol], src.fSegRSol, sizeof(Float_t)*fNRSegSol);
+ memcpy(fBegSegPSol= new Int_t[fNZSegSol], src.fBegSegPSol, sizeof(Int_t)*fNZSegSol);
+ memcpy(fNSegPSol = new Int_t[fNZSegSol], src.fNSegPSol, sizeof(Int_t)*fNZSegSol);
+ memcpy(fBegSegRSol= new Int_t[fNPSegSol], src.fBegSegRSol, sizeof(Int_t)*fNPSegSol);
+ memcpy(fNSegRSol = new Int_t[fNPSegSol], src.fNSegRSol, sizeof(Int_t)*fNPSegSol);
+ memcpy(fSegIDSol = new Int_t[fNRSegSol], src.fSegIDSol, sizeof(Int_t)*fNRSegSol);
+ fParamsSol = new TObjArray(fNParamsSol);
+ for (int i=0;i<fNParamsSol;i++) fParamsSol->AddAtAndExpand(new AliCheb3D(*src.GetParamSol(i)),i);
+ }
+ //
+ fNParamsTPC = src.fNParamsTPC;
+ fNZSegTPC = src.fNZSegTPC;
+ fNPSegTPC = src.fNPSegTPC;
+ fNRSegTPC = src.fNRSegTPC;
+ fMinZTPC = src.fMinZTPC;
+ fMaxZTPC = src.fMaxZTPC;
+ fMaxRTPC = src.fMaxRTPC;
+ if (src.fNParamsTPC) {
+ memcpy(fSegZTPC = new Float_t[fNZSegTPC], src.fSegZTPC, sizeof(Float_t)*fNZSegTPC);
+ memcpy(fSegPTPC = new Float_t[fNPSegTPC], src.fSegPTPC, sizeof(Float_t)*fNPSegTPC);
+ memcpy(fSegRTPC = new Float_t[fNRSegTPC], src.fSegRTPC, sizeof(Float_t)*fNRSegTPC);
+ memcpy(fBegSegPTPC= new Int_t[fNZSegTPC], src.fBegSegPTPC, sizeof(Int_t)*fNZSegTPC);
+ memcpy(fNSegPTPC = new Int_t[fNZSegTPC], src.fNSegPTPC, sizeof(Int_t)*fNZSegTPC);
+ memcpy(fBegSegRTPC= new Int_t[fNPSegTPC], src.fBegSegRTPC, sizeof(Int_t)*fNPSegTPC);
+ memcpy(fNSegRTPC = new Int_t[fNPSegTPC], src.fNSegRTPC, sizeof(Int_t)*fNPSegTPC);
+ memcpy(fSegIDTPC = new Int_t[fNRSegTPC], src.fSegIDTPC, sizeof(Int_t)*fNRSegTPC);
+ fParamsTPC = new TObjArray(fNParamsTPC);
+ for (int i=0;i<fNParamsTPC;i++) fParamsTPC->AddAtAndExpand(new AliCheb3D(*src.GetParamTPCInt(i)),i);
+ }
+ //
+ fNParamsTPCRat = src.fNParamsTPCRat;
+ fNZSegTPCRat = src.fNZSegTPCRat;
+ fNPSegTPCRat = src.fNPSegTPCRat;
+ fNRSegTPCRat = src.fNRSegTPCRat;
+ fMinZTPCRat = src.fMinZTPCRat;
+ fMaxZTPCRat = src.fMaxZTPCRat;
+ fMaxRTPCRat = src.fMaxRTPCRat;
+ if (src.fNParamsTPCRat) {
+ memcpy(fSegZTPCRat = new Float_t[fNZSegTPCRat], src.fSegZTPCRat, sizeof(Float_t)*fNZSegTPCRat);
+ memcpy(fSegPTPCRat = new Float_t[fNPSegTPCRat], src.fSegPTPCRat, sizeof(Float_t)*fNPSegTPCRat);
+ memcpy(fSegRTPCRat = new Float_t[fNRSegTPCRat], src.fSegRTPCRat, sizeof(Float_t)*fNRSegTPCRat);
+ memcpy(fBegSegPTPCRat= new Int_t[fNZSegTPCRat], src.fBegSegPTPCRat, sizeof(Int_t)*fNZSegTPCRat);
+ memcpy(fNSegPTPCRat = new Int_t[fNZSegTPCRat], src.fNSegPTPCRat, sizeof(Int_t)*fNZSegTPCRat);
+ memcpy(fBegSegRTPCRat= new Int_t[fNPSegTPCRat], src.fBegSegRTPCRat, sizeof(Int_t)*fNPSegTPCRat);
+ memcpy(fNSegRTPCRat = new Int_t[fNPSegTPCRat], src.fNSegRTPCRat, sizeof(Int_t)*fNPSegTPCRat);
+ memcpy(fSegIDTPCRat = new Int_t[fNRSegTPCRat], src.fSegIDTPCRat, sizeof(Int_t)*fNRSegTPCRat);
+ fParamsTPCRat = new TObjArray(fNParamsTPCRat);
+ for (int i=0;i<fNParamsTPCRat;i++) fParamsTPCRat->AddAtAndExpand(new AliCheb3D(*src.GetParamTPCRatInt(i)),i);
+ }
//
+ fNParamsDip = src.fNParamsDip;
fNZSegDip = src.fNZSegDip;
fNYSegDip = src.fNYSegDip;
fNXSegDip = src.fNXSegDip;
- //
- fMinZSol = src.fMinZSol;
- fMaxZSol = src.fMaxZSol;
- fMaxRSol = src.fMaxRSol;
- //
fMinZDip = src.fMinZDip;
fMaxZDip = src.fMaxZDip;
- //
- fMinZTPCInt = src.fMinZTPCInt;
- fMaxZTPCInt = src.fMaxZTPCInt;
- fMaxRTPCInt = src.fMaxRTPCInt;
- //
- if (src.fNParamsSol) {
- memcpy(fSegZSol = new Float_t[fNSegZSol], src.fSegZSol, sizeof(Float_t)*fNSegZSol);
- memcpy(fSegRSol = new Float_t[fNParamsSol], src.fSegRSol, sizeof(Float_t)*fNParamsSol);
- memcpy(fNSegRSol = new Int_t[fNSegZSol], src.fNSegRSol, sizeof(Int_t)*fNSegZSol);
- memcpy(fSegZIdSol= new Int_t[fNSegZSol], src.fSegZIdSol, sizeof(Int_t)*fNSegZSol);
- fParamsSol = new TObjArray(fNParamsSol);
- for (int i=0;i<fNParamsSol;i++) fParamsSol->AddAtAndExpand(new AliCheb3D(*src.GetParamSol(i)),i);
- }
- //
if (src.fNParamsDip) {
memcpy(fSegZDip = new Float_t[fNZSegDip], src.fSegZDip, sizeof(Float_t)*fNZSegDip);
memcpy(fSegYDip = new Float_t[fNYSegDip], src.fSegYDip, sizeof(Float_t)*fNYSegDip);
- memcpy(fSegXDip = new Float_t[fNXSegDip], src.fSegZDip, sizeof(Float_t)*fNXSegDip);
+ memcpy(fSegXDip = new Float_t[fNXSegDip], src.fSegXDip, sizeof(Float_t)*fNXSegDip);
memcpy(fBegSegYDip= new Int_t[fNZSegDip], src.fBegSegYDip, sizeof(Int_t)*fNZSegDip);
memcpy(fNSegYDip = new Int_t[fNZSegDip], src.fNSegYDip, sizeof(Int_t)*fNZSegDip);
memcpy(fBegSegXDip= new Int_t[fNYSegDip], src.fBegSegXDip, sizeof(Int_t)*fNYSegDip);
for (int i=0;i<fNParamsDip;i++) fParamsDip->AddAtAndExpand(new AliCheb3D(*src.GetParamDip(i)),i);
}
//
- if (src.fNParamsTPCInt) {
- memcpy(fSegZTPCInt = new Float_t[fNSegZTPCInt], src.fSegZTPCInt, sizeof(Float_t)*fNSegZTPCInt);
- memcpy(fSegRTPCInt = new Float_t[fNParamsTPCInt], src.fSegRTPCInt, sizeof(Float_t)*fNParamsTPCInt);
- memcpy(fNSegRTPCInt = new Int_t[fNSegZTPCInt], src.fNSegRTPCInt, sizeof(Int_t)*fNSegZTPCInt);
- memcpy(fSegZIdTPCInt= new Int_t[fNSegZTPCInt], src.fSegZIdTPCInt, sizeof(Int_t)*fNSegZTPCInt);
- fParamsTPCInt = new TObjArray(fNParamsTPCInt);
- for (int i=0;i<fNParamsTPCInt;i++) fParamsTPCInt->AddAtAndExpand(new AliCheb3D(*src.GetParamTPCInt(i)),i);
- }
- //
}
//__________________________________________________________________________________________
{
// clear all dynamic parts
if (fNParamsSol) {
- delete fParamsSol;
- delete[] fSegZSol;
- delete[] fSegRSol;
- delete[] fNSegRSol;
- delete[] fSegZIdSol;
+ fParamsSol->SetOwner(kTRUE);
+ delete fParamsSol; fParamsSol = 0;
+ delete[] fSegZSol; fSegZSol = 0;
+ delete[] fSegPSol; fSegPSol = 0;
+ delete[] fSegRSol; fSegRSol = 0;
+ delete[] fBegSegPSol; fBegSegPSol = 0;
+ delete[] fNSegPSol; fNSegPSol = 0;
+ delete[] fBegSegRSol; fBegSegRSol = 0;
+ delete[] fNSegRSol; fNSegRSol = 0;
+ delete[] fSegIDSol; fSegIDSol = 0;
}
+ fNParamsSol = fNZSegSol = fNPSegSol = fNRSegSol = 0;
+ fMinZSol = 1e6;
+ fMaxZSol = -1e6;
+ fMaxRSol = 0;
//
- if (fNParamsTPCInt) {
- delete fParamsTPCInt;
- delete[] fSegZTPCInt;
- delete[] fSegRTPCInt;
- delete[] fNSegRTPCInt;
- delete[] fSegZIdTPCInt;
+ if (fNParamsTPC) {
+ fParamsTPC->SetOwner(kTRUE);
+ delete fParamsTPC; fParamsTPC = 0;
+ delete[] fSegZTPC; fSegZTPC = 0;
+ delete[] fSegPTPC; fSegPTPC = 0;
+ delete[] fSegRTPC; fSegRTPC = 0;
+ delete[] fBegSegPTPC; fBegSegPTPC = 0;
+ delete[] fNSegPTPC; fNSegPTPC = 0;
+ delete[] fBegSegRTPC; fBegSegRTPC = 0;
+ delete[] fNSegRTPC; fNSegRTPC = 0;
+ delete[] fSegIDTPC; fSegIDTPC = 0;
}
- //
+ fNParamsTPC = fNZSegTPC = fNPSegTPC = fNRSegTPC = 0;
+ fMinZTPC = 1e6;
+ fMaxZTPC = -1e6;
+ fMaxRTPC = 0;
+ //
+ if (fNParamsTPCRat) {
+ fParamsTPCRat->SetOwner(kTRUE);
+ delete fParamsTPCRat; fParamsTPCRat = 0;
+ delete[] fSegZTPCRat; fSegZTPCRat = 0;
+ delete[] fSegPTPCRat; fSegPTPCRat = 0;
+ delete[] fSegRTPCRat; fSegRTPCRat = 0;
+ delete[] fBegSegPTPCRat; fBegSegPTPCRat = 0;
+ delete[] fNSegPTPCRat; fNSegPTPCRat = 0;
+ delete[] fBegSegRTPCRat; fBegSegRTPCRat = 0;
+ delete[] fNSegRTPCRat; fNSegRTPCRat = 0;
+ delete[] fSegIDTPCRat; fSegIDTPCRat = 0;
+ }
+ fNParamsTPCRat = fNZSegTPCRat = fNPSegTPCRat = fNRSegTPCRat = 0;
+ fMinZTPCRat = 1e6;
+ fMaxZTPCRat = -1e6;
+ fMaxRTPCRat = 0;
+ //
if (fNParamsDip) {
- delete fParamsDip;
- delete[] fSegZDip;
- delete[] fSegYDip;
- delete[] fSegXDip;
- delete[] fBegSegYDip;
- delete[] fNSegYDip;
- delete[] fBegSegXDip;
- delete[] fNSegXDip;
- delete[] fSegIDDip;
+ fParamsDip->SetOwner(kTRUE);
+ delete fParamsDip; fParamsDip = 0;
+ delete[] fSegZDip; fSegZDip = 0;
+ delete[] fSegYDip; fSegYDip = 0;
+ delete[] fSegXDip; fSegXDip = 0;
+ delete[] fBegSegYDip; fBegSegYDip = 0;
+ delete[] fNSegYDip; fNSegYDip = 0;
+ delete[] fBegSegXDip; fBegSegXDip = 0;
+ delete[] fNSegXDip; fNSegXDip = 0;
+ delete[] fSegIDDip; fSegIDDip = 0;
}
- fNParamsSol = fNParamsTPCInt = fNParamsDip = fNZSegDip = fNYSegDip = fNXSegDip = 0;
- fNSegZSol = fNSegZTPCInt = 0;
- fMinZSol = fMinZDip = fMinZTPCInt = 1e6;
- fMaxZSol = fMaxZDip = fMaxZTPCInt = fMaxRSol = fMaxRTPCInt = -1e6;
+ fNParamsDip = fNZSegDip = fNYSegDip = fNXSegDip = 0;
+ fMinZDip = 1e6;
+ fMaxZDip = -1e6;
//
}
{
// compute field in cartesian coordinates. If point is outside of the parameterized region
// get it at closest valid point
- static Double_t rphiz[3];
+ Double_t rphiz[3];
//
#ifndef _BRING_TO_BOUNDARY_ // exact matching to fitted volume is requested
- if ( !(xyz[2]>=GetMinZSol()&&xyz[2]<=GetMaxZSol()) &&
- !(xyz[2]>=GetMinZDip()&&xyz[2]<=GetMaxZDip()) ) {for (int i=3;i--;) b[i]=0; return;}
+ b[0] = b[1] = b[2] = 0;
#endif
//
- if (xyz[2]<fMaxZDip) { // dipole part?
-#ifndef _BRING_TO_BOUNDARY_
- AliCheb3D* par = GetParamDip(FindDipSegment(xyz));
- if (par->IsInside(xyz)) {par->Eval(xyz,b); return;}
- for (int i=3;i--;) b[i]=0; return;
-#else
- GetParamDip(FindDipSegment(xyz))->Eval(xyz,b); return;
-#endif
+ if (xyz[2]>fMinZSol) {
+ CartToCyl(xyz,rphiz);
+ FieldCylSol(rphiz,b);
+ // convert field to cartesian system
+ CylToCartCylB(rphiz, b,b);
+ return;
}
//
- // Sol region: convert coordinates to cyl system
- CartToCyl(xyz,rphiz);
+ int iddip = FindDipSegment(xyz);
+ if (iddip<0) return;
+ AliCheb3D* par = GetParamDip(iddip);
#ifndef _BRING_TO_BOUNDARY_
- if (rphiz[0]>GetMaxRSol()) {for (int i=3;i--;) b[i]=0; return;}
+ if (!par->IsInside(xyz)) return;
#endif
- //
- FieldCylSol(rphiz,b);
- //
- // convert field to cartesian system
- CylToCartCylB(rphiz, b,b);
+ par->Eval(xyz,b);
//
}
{
// compute Bz for the point in cartesian coordinates. If point is outside of the parameterized region
// get it at closest valid point
- static Double_t rphiz[3];
+ Double_t rphiz[3];
//
-#ifndef _BRING_TO_BOUNDARY_ // exact matching to fitted volume is requested
- if ( !(xyz[2]>=GetMinZSol()&&xyz[2]<=GetMaxZSol()) &&
- !(xyz[2]>=GetMinZDip()&&xyz[2]<=GetMaxZDip()) ) return 0;
-#endif
+ if (xyz[2]>fMinZSol) {
+ CartToCyl(xyz,rphiz);
+ return FieldCylSolBz(rphiz);
+ }
//
- if (xyz[2]<fMaxZDip) { // dipole part?
+ int iddip = FindDipSegment(xyz);
+ if (iddip<0) return 0.;
+ AliCheb3D* par = GetParamDip(iddip);
#ifndef _BRING_TO_BOUNDARY_
- AliCheb3D* par = GetParamDip(FindDipSegment(xyz));
- if (par->IsInside(xyz)) return par->Eval(xyz,2);
- else return 0;
-#else
- return GetParamDip(FindDipSegment(xyz))->Eval(xyz,2);
+ if (!par->IsInside(xyz)) return 0.;
#endif
- }
- // Sol region: convert coordinates to cyl system
- CartToCyl(xyz,rphiz);
- return FieldCylSolBz(rphiz);
+ return par->Eval(xyz,2);
}
printf("Alice magnetic field parameterized by Chebyshev polynomials\n");
printf("Segmentation for Solenoid (%+.2f<Z<%+.2f cm | R<%.2f cm)\n",fMinZSol,fMaxZSol,fMaxRSol);
//
- if (fParamsSol) fParamsSol->Print();
- /*
- for (int iz=0;iz<fNSegZSol;iz++) {
- AliCheb3D* param = GetParamSol( fSegZIdSol[iz] );
- printf("*** Z Segment %2d (%+7.2f<Z<%+7.2f)\t***\n",iz,param->GetBoundMin(2),param->GetBoundMax(2));
- for (int ir=0;ir<fNSegRSol[iz];ir++) {
- param = GetParamSol( fSegZIdSol[iz]+ir );
- printf(" R Segment %2d (%+7.2f<R<%+7.2f, Precision: %.1e) (ID=%2d)\n",ir, param->GetBoundMin(0),
- param->GetBoundMax(0),param->GetPrecision(),fSegZIdSol[iz]+ir);
+ if (fParamsSol) {
+ for (int i=0;i<fNParamsSol;i++) {
+ printf("SOL%4d ",i);
+ GetParamSol(i)->Print();
}
}
- */
//
- printf("Segmentation for TPC field integral (%+.2f<Z<%+.2f cm | R<%.2f cm)\n",fMinZTPCInt,fMaxZTPCInt,fMaxRTPCInt);
+ printf("Segmentation for TPC field integral (%+.2f<Z<%+.2f cm | R<%.2f cm)\n",fMinZTPC,fMaxZTPC,fMaxRTPC);
//
- if (fParamsTPCInt) fParamsTPCInt->Print();
- /*
- for (int iz=0;iz<fNSegZTPCInt;iz++) {
- AliCheb3D* param = GetParamTPCInt( fSegZIdTPCInt[iz] );
- printf("*** Z Segment %2d (%+7.2f<Z<%+7.2f)\t***\n",iz,param->GetBoundMin(2),param->GetBoundMax(2));
- for (int ir=0;ir<fNSegRTPCInt[iz];ir++) {
- param = GetParamTPCInt( fSegZIdTPCInt[iz]+ir );
- printf(" R Segment %2d (%+7.2f<R<%+7.2f, Precision: %.1e) (ID=%2d)\n",ir, param->GetBoundMin(0),
- param->GetBoundMax(0),param->GetPrecision(),fSegZIdTPCInt[iz]+ir);
+ if (fParamsTPC) {
+ for (int i=0;i<fNParamsTPC;i++) {
+ printf("TPC%4d ",i);
+ GetParamTPCInt(i)->Print();
+ }
+ }
+ //
+ printf("Segmentation for TPC field ratios integral (%+.2f<Z<%+.2f cm | R<%.2f cm)\n",fMinZTPCRat,fMaxZTPCRat,fMaxRTPCRat);
+ //
+ if (fParamsTPCRat) {
+ for (int i=0;i<fNParamsTPCRat;i++) {
+ printf("TPCRat%4d ",i);
+ GetParamTPCRatInt(i)->Print();
}
}
- */
//
printf("Segmentation for Dipole (%+.2f<Z<%+.2f cm)\n",fMinZDip,fMaxZDip);
- if (fParamsDip) fParamsDip->Print();
+ if (fParamsDip) {
+ for (int i=0;i<fNParamsDip;i++) {
+ printf("DIP%4d ",i);
+ GetParamDip(i)->Print();
+ }
+ }
//
-
-
}
-
//__________________________________________________________________________________________________
-Int_t AliMagWrapCheb::FindDipSegment(const Double_t *xyz) const
+Int_t AliMagWrapCheb::FindDipSegment(const Double_t *xyz) const
{
// find the segment containing point xyz. If it is outside find the closest segment
+ if (!fNParamsDip) return -1;
int xid,yid,zid = TMath::BinarySearch(fNZSegDip,fSegZDip,(Float_t)xyz[2]); // find zsegment
- int ysegBeg = fBegSegYDip[zid];
//
- for (yid=0;yid<fNSegYDip[zid];yid++) if (xyz[1]<fSegYDip[ysegBeg+yid]) break;
- if ( --yid < 0 ) yid = 0;
- yid += ysegBeg;
+ Bool_t reCheck = kFALSE;
+ while(1) {
+ int ysegBeg = fBegSegYDip[zid];
+ //
+ for (yid=0;yid<fNSegYDip[zid];yid++) if (xyz[1]<fSegYDip[ysegBeg+yid]) break;
+ if ( --yid < 0 ) yid = 0;
+ yid += ysegBeg;
+ //
+ int xsegBeg = fBegSegXDip[yid];
+ for (xid=0;xid<fNSegXDip[yid];xid++) if (xyz[0]<fSegXDip[xsegBeg+xid]) break;
+ //
+ if ( --xid < 0) xid = 0;
+ xid += xsegBeg;
+ //
+ // to make sure that due to the precision problems we did not pick the next Zbin
+ if (!reCheck && (xyz[2] - fSegZDip[zid] < 3.e-5) && zid &&
+ !GetParamDip(fSegIDDip[xid])->IsInside(xyz)) { // check the previous Z bin
+ zid--;
+ reCheck = kTRUE;
+ continue;
+ }
+ break;
+ }
+ return fSegIDDip[xid];
+}
+
+//__________________________________________________________________________________________________
+Int_t AliMagWrapCheb::FindSolSegment(const Double_t *rpz) const
+{
+ // find the segment containing point xyz. If it is outside find the closest segment
+ if (!fNParamsSol) return -1;
+ int rid,pid,zid = TMath::BinarySearch(fNZSegSol,fSegZSol,(Float_t)rpz[2]); // find zsegment
+ //
+ Bool_t reCheck = kFALSE;
+ while(1) {
+ int psegBeg = fBegSegPSol[zid];
+ for (pid=0;pid<fNSegPSol[zid];pid++) if (rpz[1]<fSegPSol[psegBeg+pid]) break;
+ if ( --pid < 0 ) pid = 0;
+ pid += psegBeg;
+ //
+ int rsegBeg = fBegSegRSol[pid];
+ for (rid=0;rid<fNSegRSol[pid];rid++) if (rpz[0]<fSegRSol[rsegBeg+rid]) break;
+ if ( --rid < 0) rid = 0;
+ rid += rsegBeg;
+ //
+ // to make sure that due to the precision problems we did not pick the next Zbin
+ if (!reCheck && (rpz[2] - fSegZSol[zid] < 3.e-5) && zid &&
+ !GetParamSol(fSegIDSol[rid])->IsInside(rpz)) { // check the previous Z bin
+ zid--;
+ reCheck = kTRUE;
+ continue;
+ }
+ break;
+ }
+ return fSegIDSol[rid];
+}
+
+//__________________________________________________________________________________________________
+Int_t AliMagWrapCheb::FindTPCSegment(const Double_t *rpz) const
+{
+ // find the segment containing point xyz. If it is outside find the closest segment
+ if (!fNParamsTPC) return -1;
+ int rid,pid,zid = TMath::BinarySearch(fNZSegTPC,fSegZTPC,(Float_t)rpz[2]); // find zsegment
//
- int xsegBeg = fBegSegXDip[yid];
- for (xid=0;xid<fNSegXDip[yid];xid++) if (xyz[0]<fSegXDip[xsegBeg+xid]) break;
- if ( --xid < 0) xid = 0;
- xid += xsegBeg;
+ Bool_t reCheck = kFALSE;
+ while(1) {
+ int psegBeg = fBegSegPTPC[zid];
+ //
+ for (pid=0;pid<fNSegPTPC[zid];pid++) if (rpz[1]<fSegPTPC[psegBeg+pid]) break;
+ if ( --pid < 0 ) pid = 0;
+ pid += psegBeg;
+ //
+ int rsegBeg = fBegSegRTPC[pid];
+ for (rid=0;rid<fNSegRTPC[pid];rid++) if (rpz[0]<fSegRTPC[rsegBeg+rid]) break;
+ if ( --rid < 0) rid = 0;
+ rid += rsegBeg;
+ //
+ // to make sure that due to the precision problems we did not pick the next Zbin
+ if (!reCheck && (rpz[2] - fSegZTPC[zid] < 3.e-5) && zid &&
+ !GetParamTPCInt(fSegIDTPC[rid])->IsInside(rpz)) { // check the previous Z bin
+ zid--;
+ reCheck = kTRUE;
+ continue;
+ }
+ break;
+ }
+ return fSegIDTPC[rid];
+}
+
+//__________________________________________________________________________________________________
+Int_t AliMagWrapCheb::FindTPCRatSegment(const Double_t *rpz) const
+{
+ // find the segment containing point xyz. If it is outside find the closest segment
+ if (!fNParamsTPCRat) return -1;
+ int rid,pid,zid = TMath::BinarySearch(fNZSegTPCRat,fSegZTPCRat,(Float_t)rpz[2]); // find zsegment
//
- return fSegIDDip[xid];
+ Bool_t reCheck = kFALSE;
+ while(1) {
+ int psegBeg = fBegSegPTPCRat[zid];
+ //
+ for (pid=0;pid<fNSegPTPCRat[zid];pid++) if (rpz[1]<fSegPTPCRat[psegBeg+pid]) break;
+ if ( --pid < 0 ) pid = 0;
+ pid += psegBeg;
+ //
+ int rsegBeg = fBegSegRTPCRat[pid];
+ for (rid=0;rid<fNSegRTPCRat[pid];rid++) if (rpz[0]<fSegRTPCRat[rsegBeg+rid]) break;
+ if ( --rid < 0) rid = 0;
+ rid += rsegBeg;
+ //
+ // to make sure that due to the precision problems we did not pick the next Zbin
+ if (!reCheck && (rpz[2] - fSegZTPCRat[zid] < 3.e-5) && zid &&
+ !GetParamTPCRatInt(fSegIDTPCRat[rid])->IsInside(rpz)) { // check the previous Z bin
+ zid--;
+ reCheck = kTRUE;
+ continue;
+ }
+ break;
+ }
+ return fSegIDTPCRat[rid];
}
+
//__________________________________________________________________________________________
void AliMagWrapCheb::GetTPCInt(const Double_t *xyz, Double_t *b) const
{
//
}
+//__________________________________________________________________________________________
+void AliMagWrapCheb::GetTPCRatInt(const Double_t *xyz, Double_t *b) const
+{
+ // compute TPCRat region field integral in cartesian coordinates.
+ // If point is outside of the parameterized region get it at closeset valid point
+ static Double_t rphiz[3];
+ //
+ // TPCRatInt region
+ // convert coordinates to cyl system
+ CartToCyl(xyz,rphiz);
+#ifndef _BRING_TO_BOUNDARY_
+ if ( (rphiz[2]>GetMaxZTPCRatInt()||rphiz[2]<GetMinZTPCRatInt()) ||
+ rphiz[0]>GetMaxRTPCRatInt()) {for (int i=3;i--;) b[i]=0; return;}
+#endif
+ //
+ GetTPCRatIntCyl(rphiz,b);
+ //
+ // convert field to cartesian system
+ CylToCartCylB(rphiz, b,b);
+ //
+}
+
//__________________________________________________________________________________________
void AliMagWrapCheb::FieldCylSol(const Double_t *rphiz, Double_t *b) const
{
// compute Solenoid field in Cylindircal coordinates
// note: if the point is outside the volume get the field in closest parameterized point
- int SolZId = 0;
- while (rphiz[2]>fSegZSol[SolZId] && SolZId<fNSegZSol-1) ++SolZId; // find Z segment
- int SolRId = fSegZIdSol[SolZId]; // first R segment for this Z
- int SolRMax = SolRId + fNSegRSol[SolZId];
- while (rphiz[0]>fSegRSol[SolRId] && SolRId<SolRMax-1) ++SolRId; // find R segment
- GetParamSol( SolRId )->Eval(rphiz,b);
+ int id = FindSolSegment(rphiz);
+ if (id<0) return;
+ AliCheb3D* par = GetParamSol(id);
+#ifndef _BRING_TO_BOUNDARY_ // exact matching to fitted volume is requested
+ if (!par->IsInside(rphiz)) return;
+#endif
+ par->Eval(rphiz,b);
+ return;
//
}
{
// compute Solenoid field in Cylindircal coordinates
// note: if the point is outside the volume get the field in closest parameterized point
- int SolZId = 0;
- while (rphiz[2]>fSegZSol[SolZId] && SolZId<fNSegZSol-1) ++SolZId; // find Z segment
- int SolRId = fSegZIdSol[SolZId]; // first R segment for this Z
- int SolRMax = SolRId + fNSegRSol[SolZId];
- while (rphiz[0]>fSegRSol[SolRId] && SolRId<SolRMax-1) ++SolRId; // find R segment
- return GetParamSol( SolRId )->Eval(rphiz,2);
+ int id = FindSolSegment(rphiz);
+ if (id<0) return 0.;
+ AliCheb3D* par = GetParamSol(id);
+#ifndef _BRING_TO_BOUNDARY_
+ return par->IsInside(rphiz) ? par->Eval(rphiz,2) : 0;
+#endif
+ return par->Eval(rphiz,2);
//
}
{
// compute field integral in TPC region in Cylindircal coordinates
// note: the check for the point being inside the parameterized region is done outside
- int tpcIntZId = 0;
- while (rphiz[2]>fSegZTPCInt[tpcIntZId] && tpcIntZId<fNSegZTPCInt) ++tpcIntZId; // find Z segment
- int tpcIntRId = fSegZIdTPCInt[tpcIntZId]; // first R segment for this Z
- int tpcIntRIdMax = tpcIntRId + fNSegRTPCInt[tpcIntZId];
- while (rphiz[0]>fSegRTPCInt[tpcIntRId] && tpcIntRId<tpcIntRIdMax) ++tpcIntRId; // find R segment
- GetParamTPCInt( tpcIntRId )->Eval(rphiz,b);
+ int id = FindTPCSegment(rphiz);
+ if (id<0) {
+ b[0] = b[1] = b[2] = 0;
+ return;
+ }
+ if (id>=fNParamsTPC) {
+ AliError(Form("Wrong TPCParam segment %d",id));
+ b[0] = b[1] = b[2] = 0;
+ return;
+ }
+ AliCheb3D* par = GetParamTPCInt(id);
+ if (par->IsInside(rphiz)) {
+ par->Eval(rphiz,b);
+ return;
+ }
+ b[0] = b[1] = b[2] = 0;
+ return;
+ //
+}
+
+//__________________________________________________________________________________________
+void AliMagWrapCheb::GetTPCRatIntCyl(const Double_t *rphiz, Double_t *b) const
+{
+ // compute field integral in TPCRat region in Cylindircal coordinates
+ // note: the check for the point being inside the parameterized region is done outside
+ int id = FindTPCRatSegment(rphiz);
+ if (id<0) {
+ b[0] = b[1] = b[2] = 0;
+ return;
+ }
+ if (id>=fNParamsTPCRat) {
+ AliError(Form("Wrong TPCRatParam segment %d",id));
+ b[0] = b[1] = b[2] = 0;
+ return;
+ }
+ AliCheb3D* par = GetParamTPCRatInt(id);
+ if (par->IsInside(rphiz)) {
+ par->Eval(rphiz,b);
+ return;
+ }
+ b[0] = b[1] = b[2] = 0;
+ return;
//
}
exit(1);
}
//
+ // TPCRatInt part -----------------------------------------------------------
+ AliCheb3DCalc::ReadLine(buffs,stream);
+ if (!buffs.BeginsWith("START TPCRatINT")) {
+ Error("LoadData","Expected: \"START TPCRatINT\", found \"%s\"\nStop\n",buffs.Data());
+ exit(1);
+ }
+ AliCheb3DCalc::ReadLine(buffs,stream); // nparam
+ int nparTPCRatInt = buffs.Atoi();
+ //
+ for (int ip=0;ip<nparTPCRatInt;ip++) {
+ AliCheb3D* cheb = new AliCheb3D();
+ cheb->LoadData(stream);
+ AddParamTPCRatInt(cheb);
+ }
+ //
+ AliCheb3DCalc::ReadLine(buffs,stream);
+ if (!buffs.BeginsWith("END TPCRatINT")) {
+ Error("LoadData","Expected \"END TPCRatINT\", found \"%s\"\nStop\n",buffs.Data());
+ exit(1);
+ }
+ //
// Dipole part -----------------------------------------------------------
AliCheb3DCalc::ReadLine(buffs,stream);
if (!buffs.BeginsWith("START DIPOLE")) {
// ---------------------------------------------------------------------------
fclose(stream);
BuildTableSol();
- BuildTableTPCInt();
BuildTableDip();
+ BuildTableTPCInt();
+ BuildTableTPCRatInt();
+ //
printf("Loaded magnetic field \"%s\" from %s\n",GetName(),strf.Data());
//
}
+
+//__________________________________________________________________________________________
+void AliMagWrapCheb::BuildTableSol()
+{
+ BuildTable(fNParamsSol,fParamsSol,
+ fNZSegSol,fNPSegSol,fNRSegSol,
+ fMinZSol,fMaxZSol,
+ &fSegZSol,&fSegPSol,&fSegRSol,
+ &fBegSegPSol,&fNSegPSol,
+ &fBegSegRSol,&fNSegRSol,
+ &fSegIDSol);
+}
+
+//__________________________________________________________________________________________
+void AliMagWrapCheb::BuildTableDip()
+{
+ BuildTable(fNParamsDip,fParamsDip,
+ fNZSegDip,fNYSegDip,fNXSegDip,
+ fMinZDip,fMaxZDip,
+ &fSegZDip,&fSegYDip,&fSegXDip,
+ &fBegSegYDip,&fNSegYDip,
+ &fBegSegXDip,&fNSegXDip,
+ &fSegIDDip);
+}
+
+//__________________________________________________________________________________________
+void AliMagWrapCheb::BuildTableTPCInt()
+{
+ BuildTable(fNParamsTPC,fParamsTPC,
+ fNZSegTPC,fNPSegTPC,fNRSegTPC,
+ fMinZTPC,fMaxZTPC,
+ &fSegZTPC,&fSegPTPC,&fSegRTPC,
+ &fBegSegPTPC,&fNSegPTPC,
+ &fBegSegRTPC,&fNSegRTPC,
+ &fSegIDTPC);
+}
+
+//__________________________________________________________________________________________
+void AliMagWrapCheb::BuildTableTPCRatInt()
+{
+ BuildTable(fNParamsTPCRat,fParamsTPCRat,
+ fNZSegTPCRat,fNPSegTPCRat,fNRSegTPCRat,
+ fMinZTPCRat,fMaxZTPCRat,
+ &fSegZTPCRat,&fSegPTPCRat,&fSegRTPCRat,
+ &fBegSegPTPCRat,&fNSegPTPCRat,
+ &fBegSegRTPCRat,&fNSegRTPCRat,
+ &fSegIDTPCRat);
+}
+
#endif
//_______________________________________________
//__________________________________________________________________________________________
AliMagWrapCheb::AliMagWrapCheb(const char* inputFile) :
- fNParamsSol(0),
- fNSegZSol(0),
- fNParamsTPCInt(0),
- fNSegZTPCInt(0),
- fNParamsDip(0),
-//
- fNZSegDip(0),
- fNYSegDip(0),
- fNXSegDip(0),
-//
- fSegZSol(0),
- fSegRSol(0),
-//
- fSegZTPCInt(0),
- fSegRTPCInt(0),
-//
- fSegZDip(0),
- fSegYDip(0),
- fSegXDip(0),
-//
- fNSegRSol(0),
- fSegZIdSol(0),
-//
- fNSegRTPCInt(0),
- fSegZIdTPCInt(0),
-//
- fBegSegYDip(0),
- fNSegYDip(0),
- fBegSegXDip(0),
- fNSegXDip(0),
- fSegIDDip(0),
+ fNParamsSol(0),fNZSegSol(0),fNPSegSol(0),fNRSegSol(0),
+ fSegZSol(0),fSegPSol(0),fSegRSol(0),
+ fBegSegPSol(0),fNSegPSol(0),fBegSegRSol(0),fNSegRSol(0),fSegIDSol(0),fMinZSol(1.e6),fMaxZSol(-1.e6),fParamsSol(0),fMaxRSol(0),
//
- fMinZSol(0),
- fMaxZSol(0),
- fMaxRSol(0),
+ fNParamsTPC(0),fNZSegTPC(0),fNPSegTPC(0),fNRSegTPC(0),
+ fSegZTPC(0),fSegPTPC(0),fSegRTPC(0),
+ fBegSegPTPC(0),fNSegPTPC(0),fBegSegRTPC(0),fNSegRTPC(0),fSegIDTPC(0),fMinZTPC(1.e6),fMaxZTPC(-1.e6),fParamsTPC(0),fMaxRTPC(0),
//
- fMinZDip(0),
- fMaxZDip(0),
-//
- fMinZTPCInt(0),
- fMaxZTPCInt(0),
- fMaxRTPCInt(0),
-//
- fParamsSol(0),
- fParamsDip(0),
- fParamsTPCInt(0)
+ fNParamsTPCRat(0),fNZSegTPCRat(0),fNPSegTPCRat(0),fNRSegTPCRat(0),
+ fSegZTPCRat(0),fSegPTPCRat(0),fSegRTPCRat(0),
+ fBegSegPTPCRat(0),fNSegPTPCRat(0),fBegSegRTPCRat(0),fNSegRTPCRat(0),fSegIDTPCRat(0),fMinZTPCRat(1.e6),fMaxZTPCRat(-1.e6),fParamsTPCRat(0),fMaxRTPCRat(0),
//
+ fNParamsDip(0),fNZSegDip(0),fNYSegDip(0),fNXSegDip(0),
+ fSegZDip(0),fSegYDip(0),fSegXDip(0),
+ fBegSegYDip(0),fNSegYDip(0),fBegSegXDip(0),fNSegXDip(0),fSegIDDip(0),fMinZDip(1.e6),fMaxZDip(-1.e6),fParamsDip(0)
//
{
// construct from coeffs from the text file
if (!fParamsSol) fParamsSol = new TObjArray();
fParamsSol->Add( (AliCheb3D*)param );
fNParamsSol++;
+ if (fMaxRSol<param->GetBoundMax(0)) fMaxRSol = param->GetBoundMax(0);
//
}
// adds new parameterization piece for TPCInt
// NOTE: pieces must be added strictly in increasing R then increasing Z order
//
- if (!fParamsTPCInt) fParamsTPCInt = new TObjArray();
- fParamsTPCInt->Add( (AliCheb3D*)param);
- fNParamsTPCInt++;
+ if (!fParamsTPC) fParamsTPC = new TObjArray();
+ fParamsTPC->Add( (AliCheb3D*)param);
+ fNParamsTPC++;
+ if (fMaxRTPC<param->GetBoundMax(0)) fMaxRTPC = param->GetBoundMax(0);
+ //
+}
+
+//__________________________________________________________________________________________
+void AliMagWrapCheb::AddParamTPCRatInt(const AliCheb3D* param)
+{
+ // adds new parameterization piece for TPCRatInt
+ // NOTE: pieces must be added strictly in increasing R then increasing Z order
+ //
+ if (!fParamsTPCRat) fParamsTPCRat = new TObjArray();
+ fParamsTPCRat->Add( (AliCheb3D*)param);
+ fNParamsTPCRat++;
+ if (fMaxRTPCRat<param->GetBoundMax(0)) fMaxRTPCRat = param->GetBoundMax(0);
//
}
void AliMagWrapCheb::ResetTPCInt()
{
// clean TPC field integral (used for update)
- if (!fNParamsTPCInt) return;
- delete fParamsTPCInt;
- delete[] fSegZTPCInt;
- delete[] fSegRTPCInt;
- delete[] fNSegRTPCInt;
- delete[] fSegZIdTPCInt;
- //
- fNParamsTPCInt = 0;
- fNSegZTPCInt = 0;
- fSegZTPCInt = 0;
- fSegRTPCInt = 0;
- fNSegRTPCInt = 0;
- fSegZIdTPCInt = 0;
- fMinZTPCInt = 0;
- fMaxZTPCInt = 0;
- fMaxRTPCInt = 0;
- fParamsTPCInt = 0;
+ if (fNParamsTPC) {
+ delete fParamsTPC; fParamsTPC = 0;
+ delete[] fSegZTPC; fSegZTPC = 0;
+ delete[] fSegPTPC; fSegPTPC = 0;
+ delete[] fSegRTPC; fSegRTPC = 0;
+ delete[] fBegSegPTPC; fBegSegPTPC = 0;
+ delete[] fNSegPTPC; fNSegPTPC = 0;
+ delete[] fBegSegRTPC; fBegSegRTPC = 0;
+ delete[] fNSegRTPC; fNSegRTPC = 0;
+ delete[] fSegIDTPC; fSegIDTPC = 0;
+ }
+ fNParamsTPC = fNZSegTPC = fNPSegTPC = fNRSegTPC = 0;
+ fMinZTPC = 1e6;
+ fMaxZTPC = -1e6;
+ fMaxRTPC = 0;
//
}
+//__________________________________________________________________________________________
+void AliMagWrapCheb::ResetTPCRatInt()
+{
+ // clean TPCRat field integral (used for update)
+ if (fNParamsTPCRat) {
+ delete fParamsTPCRat; fParamsTPCRat = 0;
+ delete[] fSegZTPCRat; fSegZTPCRat = 0;
+ delete[] fSegPTPCRat; fSegPTPCRat = 0;
+ delete[] fSegRTPCRat; fSegRTPCRat = 0;
+ delete[] fBegSegPTPCRat; fBegSegPTPCRat = 0;
+ delete[] fNSegPTPCRat; fNSegPTPCRat = 0;
+ delete[] fBegSegRTPCRat; fBegSegRTPCRat = 0;
+ delete[] fNSegRTPCRat; fNSegRTPCRat = 0;
+ delete[] fSegIDTPCRat; fSegIDTPCRat = 0;
+ }
+ fNParamsTPCRat = fNZSegTPCRat = fNPSegTPCRat = fNRSegTPCRat = 0;
+ fMinZTPCRat = 1e6;
+ fMaxZTPCRat = -1e6;
+ fMaxRTPCRat = 0;
+ //
+}
+
+
+//__________________________________________________
+void AliMagWrapCheb::BuildTable(Int_t npar,TObjArray *parArr, Int_t &nZSeg, Int_t &nYSeg, Int_t &nXSeg,
+ Float_t &minZ,Float_t &maxZ,
+ Float_t **segZ,Float_t **segY,Float_t **segX,
+ Int_t **begSegY,Int_t **nSegY,
+ Int_t **begSegX,Int_t **nSegX,
+ Int_t **segID)
+{
+ // build lookup table for dipole
+ //
+ if (npar<1) return;
+ TArrayF segYArr,segXArr;
+ TArrayI begSegYDipArr,begSegXDipArr;
+ TArrayI nSegYDipArr,nSegXDipArr;
+ TArrayI segIDArr;
+ float *tmpSegZ,*tmpSegY,*tmpSegX;
+ //
+ // create segmentation in Z
+ nZSeg = SegmentDimension(&tmpSegZ, parArr, npar, 2, 1,-1, 1,-1, 1,-1) - 1;
+ nYSeg = 0;
+ nXSeg = 0;
+ //
+ // for each Z slice create segmentation in Y
+ begSegYDipArr.Set(nZSeg);
+ nSegYDipArr.Set(nZSeg);
+ float xyz[3];
+ for (int iz=0;iz<nZSeg;iz++) {
+ printf("\nZSegment#%d %+e : %+e\n",iz,tmpSegZ[iz],tmpSegZ[iz+1]);
+ int ny = SegmentDimension(&tmpSegY, parArr, npar, 1,
+ 1,-1, 1,-1, tmpSegZ[iz],tmpSegZ[iz+1]) - 1;
+ segYArr.Set(ny + nYSeg);
+ for (int iy=0;iy<ny;iy++) segYArr[nYSeg+iy] = tmpSegY[iy];
+ begSegYDipArr[iz] = nYSeg;
+ nSegYDipArr[iz] = ny;
+ printf(" Found %d YSegments, to start from %d\n",ny, begSegYDipArr[iz]);
+ //
+ // for each slice in Z and Y create segmentation in X
+ begSegXDipArr.Set(nYSeg+ny);
+ nSegXDipArr.Set(nYSeg+ny);
+ xyz[2] = (tmpSegZ[iz]+tmpSegZ[iz+1])/2.; // mean Z of this segment
+ //
+ for (int iy=0;iy<ny;iy++) {
+ int isg = nYSeg+iy;
+ printf("\n YSegment#%d %+e : %+e\n",iy, tmpSegY[iy],tmpSegY[iy+1]);
+ int nx = SegmentDimension(&tmpSegX, parArr, npar, 0,
+ 1,-1, tmpSegY[iy],tmpSegY[iy+1], tmpSegZ[iz],tmpSegZ[iz+1]) - 1;
+ //
+ segXArr.Set(nx + nXSeg);
+ for (int ix=0;ix<nx;ix++) segXArr[nXSeg+ix] = tmpSegX[ix];
+ begSegXDipArr[isg] = nXSeg;
+ nSegXDipArr[isg] = nx;
+ printf(" Found %d XSegments, to start from %d\n",nx, begSegXDipArr[isg]);
+ //
+ segIDArr.Set(nXSeg+nx);
+ //
+ // find corresponding params
+ xyz[1] = (tmpSegY[iy]+tmpSegY[iy+1])/2.; // mean Y of this segment
+ //
+ for (int ix=0;ix<nx;ix++) {
+ xyz[0] = (tmpSegX[ix]+tmpSegX[ix+1])/2.; // mean X of this segment
+ for (int ipar=0;ipar<npar;ipar++) {
+ AliCheb3D* cheb = (AliCheb3D*) parArr->At(ipar);
+ if (!cheb->IsInside(xyz)) continue;
+ segIDArr[nXSeg+ix] = ipar;
+ break;
+ }
+ }
+ nXSeg += nx;
+ //
+ delete[] tmpSegX;
+ }
+ delete[] tmpSegY;
+ nYSeg += ny;
+ }
+ //
+ minZ = tmpSegZ[0];
+ maxZ = tmpSegZ[nZSeg];
+ (*segZ) = new Float_t[nZSeg];
+ for (int i=nZSeg;i--;) (*segZ)[i] = tmpSegZ[i];
+ delete[] tmpSegZ;
+ //
+ (*segY) = new Float_t[nYSeg];
+ (*segX) = new Float_t[nXSeg];
+ (*begSegY) = new Int_t[nZSeg];
+ (*nSegY) = new Int_t[nZSeg];
+ (*begSegX) = new Int_t[nYSeg];
+ (*nSegX) = new Int_t[nYSeg];
+ (*segID) = new Int_t[nXSeg];
+ //
+ for (int i=nYSeg;i--;) (*segY)[i] = segYArr[i];
+ for (int i=nXSeg;i--;) (*segX)[i] = segXArr[i];
+ for (int i=nZSeg;i--;) {(*begSegY)[i] = begSegYDipArr[i]; (*nSegY)[i] = nSegYDipArr[i];}
+ for (int i=nYSeg;i--;) {(*begSegX)[i] = begSegXDipArr[i]; (*nSegX)[i] = nSegXDipArr[i];}
+ for (int i=nXSeg;i--;) {(*segID)[i] = segIDArr[i];}
+ //
+}
+
+/*
//__________________________________________________
void AliMagWrapCheb::BuildTableDip()
{
// build lookup table for dipole
//
+ if (fNParamsDip<1) return;
TArrayF segY,segX;
TArrayI begSegYDip,begSegXDip;
TArrayI nsegYDip,nsegXDip;
float *tmpSegZ,*tmpSegY,*tmpSegX;
//
// create segmentation in Z
- fNZSegDip = SegmentDipDimension(&tmpSegZ, fParamsDip, fNParamsDip, 2, 1,-1, 1,-1, 1,-1) - 1;
+ fNZSegDip = SegmentDimension(&tmpSegZ, fParamsDip, fNParamsDip, 2, 1,-1, 1,-1, 1,-1) - 1;
fNYSegDip = 0;
fNXSegDip = 0;
//
float xyz[3];
for (int iz=0;iz<fNZSegDip;iz++) {
printf("\nZSegment#%d %+e : %+e\n",iz,tmpSegZ[iz],tmpSegZ[iz+1]);
- int ny = SegmentDipDimension(&tmpSegY, fParamsDip, fNParamsDip, 1,
+ int ny = SegmentDimension(&tmpSegY, fParamsDip, fNParamsDip, 1,
1,-1, 1,-1, tmpSegZ[iz],tmpSegZ[iz+1]) - 1;
segY.Set(ny + fNYSegDip);
for (int iy=0;iy<ny;iy++) segY[fNYSegDip+iy] = tmpSegY[iy];
for (int iy=0;iy<ny;iy++) {
int isg = fNYSegDip+iy;
printf("\n YSegment#%d %+e : %+e\n",iy, tmpSegY[iy],tmpSegY[iy+1]);
- int nx = SegmentDipDimension(&tmpSegX, fParamsDip, fNParamsDip, 0,
- 1,-1, tmpSegY[iy],tmpSegY[iy+1], tmpSegZ[iz],tmpSegZ[iz+1]) - 1;
+ int nx = SegmentDimension(&tmpSegX, fParamsDip, fNParamsDip, 0,
+ 1,-1, tmpSegY[iy],tmpSegY[iy+1], tmpSegZ[iz],tmpSegZ[iz+1]) - 1;
//
segX.Set(nx + fNXSegDip);
for (int ix=0;ix<nx;ix++) segX[fNXSegDip+ix] = tmpSegX[ix];
for (int i=fNXSegDip;i--;) {fSegIDDip[i] = segID[i];}
//
}
+*/
-//__________________________________________________________________________________________
-void AliMagWrapCheb::BuildTableSol()
-{
- // build the indexes for each parameterization of Solenoid
- //
- const float kSafety=0.001;
- //
- if (fNParamsSol<1) return;
- fNSegZSol = 0;
- fMaxRSol = 0;
- fSegRSol = new Float_t[fNParamsSol];
- float *tmpbufF = new float[fNParamsSol+1];
- int *tmpbufI = new int[fNParamsSol+1];
- int *tmpbufI1 = new int[fNParamsSol+1];
- //
- // count number of Z slices and number of R slices in each Z slice
- for (int ip=0;ip<fNParamsSol;ip++) {
- if (ip==0 || (GetParamSol(ip)->GetBoundMax(2)-GetParamSol(ip-1)->GetBoundMax(2))>kSafety) { // new Z slice
- tmpbufF[fNSegZSol] = GetParamSol(ip)->GetBoundMax(2); //
- tmpbufI[fNSegZSol] = 0;
- tmpbufI1[fNSegZSol++] = ip;
- }
- fSegRSol[ip] = GetParamSol(ip)->GetBoundMax(0); // upper R
- tmpbufI[fNSegZSol-1]++;
- if (fMaxRSol<fSegRSol[ip]) fMaxRSol = fSegRSol[ip];
- }
- //
- fSegZSol = new Float_t[fNSegZSol];
- fSegZIdSol = new Int_t[fNSegZSol];
- fNSegRSol = new Int_t[fNSegZSol];
- for (int iz=0;iz<fNSegZSol;iz++) {
- fSegZSol[iz] = tmpbufF[iz];
- fNSegRSol[iz] = tmpbufI[iz];
- fSegZIdSol[iz] = tmpbufI1[iz];
- }
- //
- fMinZSol = GetParamSol(0)->GetBoundMin(2);
- fMaxZSol = GetParamSol(fNParamsSol-1)->GetBoundMax(2);
- //
- delete[] tmpbufF;
- delete[] tmpbufI;
- delete[] tmpbufI1;
- //
- //
-}
-
-//__________________________________________________________________________________________
-void AliMagWrapCheb::BuildTableTPCInt()
-{
- // build the indexes for each parameterization of TPC field integral
- //
- const float kSafety=0.001;
- //
- if (fNParamsTPCInt<1) return;
- fNSegZTPCInt = 0;
- fSegRTPCInt = new Float_t[fNParamsTPCInt];
- float *tmpbufF = new float[fNParamsTPCInt+1];
- int *tmpbufI = new int[fNParamsTPCInt+1];
- int *tmpbufI1 = new int[fNParamsTPCInt+1];
- //
- // count number of Z slices and number of R slices in each Z slice
- for (int ip=0;ip<fNParamsTPCInt;ip++) {
- if (ip==0 || (GetParamTPCInt(ip)->GetBoundMax(2)-GetParamTPCInt(ip-1)->GetBoundMax(2))>kSafety) { // new Z slice
- tmpbufF[fNSegZTPCInt] = GetParamTPCInt(ip)->GetBoundMax(2); //
- tmpbufI[fNSegZTPCInt] = 0;
- tmpbufI1[fNSegZTPCInt++] = ip;
- }
- fSegRTPCInt[ip] = GetParamTPCInt(ip)->GetBoundMax(0); // upper R
- tmpbufI[fNSegZTPCInt-1]++;
- }
- //
- fSegZTPCInt = new Float_t[fNSegZTPCInt];
- fSegZIdTPCInt = new Int_t[fNSegZTPCInt];
- fNSegRTPCInt = new Int_t[fNSegZTPCInt];
- for (int iz=0;iz<fNSegZTPCInt;iz++) {
- fSegZTPCInt[iz] = tmpbufF[iz];
- fNSegRTPCInt[iz] = tmpbufI[iz];
- fSegZIdTPCInt[iz] = tmpbufI1[iz];
- }
- //
- fMinZTPCInt = GetParamTPCInt(0)->GetBoundMin(2);
- fMaxZTPCInt = GetParamTPCInt(fNParamsTPCInt-1)->GetBoundMax(2);
- fMaxRTPCInt = GetParamTPCInt(fNParamsTPCInt-1)->GetBoundMax(0);
- //
- delete[] tmpbufF;
- delete[] tmpbufI;
- delete[] tmpbufI1;
- //
- //
-}
-
+//________________________________________________________________
void AliMagWrapCheb::SaveData(const char* outfile) const
{
// writes coefficients data to output text file
//
// TPCInt part ---------------------------------------------------------
fprintf(stream,"# Set of Chebyshev parameterizations for ALICE magnetic field\nSTART %s\n",GetName());
- fprintf(stream,"START TPCINT\n#Number of pieces\n%d\n",fNParamsTPCInt);
- for (int ip=0;ip<fNParamsTPCInt;ip++) GetParamTPCInt(ip)->SaveData(stream);
+ fprintf(stream,"START TPCINT\n#Number of pieces\n%d\n",fNParamsTPC);
+ for (int ip=0;ip<fNParamsTPC;ip++) GetParamTPCInt(ip)->SaveData(stream);
fprintf(stream,"#\nEND TPCINT\n");
//
+ // TPCRatInt part ---------------------------------------------------------
+ fprintf(stream,"# Set of Chebyshev parameterizations for ALICE magnetic field\nSTART %s\n",GetName());
+ fprintf(stream,"START TPCRatINT\n#Number of pieces\n%d\n",fNParamsTPCRat);
+ for (int ip=0;ip<fNParamsTPCRat;ip++) GetParamTPCRatInt(ip)->SaveData(stream);
+ fprintf(stream,"#\nEND TPCRatINT\n");
+ //
// Dip part ---------------------------------------------------------
fprintf(stream,"START DIPOLE\n#Number of pieces\n%d\n",fNParamsDip);
for (int ip=0;ip<fNParamsDip;ip++) GetParamDip(ip)->SaveData(stream);
//
}
-Int_t AliMagWrapCheb::SegmentDipDimension(float** seg,const TObjArray* par,int npar, int dim,
+Int_t AliMagWrapCheb::SegmentDimension(float** seg,const TObjArray* par,int npar, int dim,
float xmn,float xmx,float ymn,float ymx,float zmn,float zmx)
{
// find all boundaries in deimension dim for boxes in given region.