37 #ifndef ALIMAGWRAPCHEB_H 38 #define ALIMAGWRAPCHEB_H 42 #include <TObjArray.h> 43 #include <TStopwatch.h> 46 #ifndef _MAGCHEB_CACHE_ 47 #define _MAGCHEB_CACHE_ // use to spead up, but then Field calls are not thread safe 50 #ifndef _USE_FAST_ATAN2_ 51 #define _USE_FAST_ATAN2_ // use approximate atan2 calculation, still precision is ~10^-4 of nominal field 67 virtual void Clear(
const Option_t * =
"");
109 virtual void Print(Option_t * =
"")
const;
111 virtual void Field(
const Double_t *xyz, Double_t *
b)
const;
112 Double_t
GetBz(
const Double_t *xyz)
const;
114 void FieldCyl(
const Double_t *rphiz, Double_t *b)
const;
115 void GetTPCInt(
const Double_t *xyz, Double_t *b)
const;
116 void GetTPCIntCyl(
const Double_t *rphiz, Double_t *b)
const;
117 void GetTPCRatInt(
const Double_t *xyz, Double_t *b)
const;
124 static void CylToCartCylB(
const Double_t *rphiz,
const Double_t *brphiz,Double_t *bxyz);
125 static void CylToCartCartB(
const Double_t *xyz,
const Double_t *brphiz,Double_t *bxyz);
126 static void CartToCylCartB(
const Double_t *xyz,
const Double_t *bxyz, Double_t *brphiz);
127 static void CartToCylCylB(
const Double_t *rphiz,
const Double_t *bxyz, Double_t *brphiz);
128 static void CartToCyl(
const Double_t *xyz, Double_t *rphiz);
129 static void CylToCart(
const Double_t *rphiz,Double_t *xyz);
131 #ifdef _INC_CREATION_ALICHEB3D_ // see AliCheb3D.h for explanation 135 void SaveData(
const char* outfile)
const;
137 Float_t xmn,Float_t xmx,Float_t ymn,Float_t ymx,Float_t zmn,Float_t zmx);
144 Float_t &minZ,Float_t &maxZ,Float_t **segZ,Float_t **segY,Float_t **segX,
145 Int_t **begSegY,Int_t **nSegY,Int_t **begSegX,Int_t **nSegX,Int_t **segID);
158 static double useATan2(
double y,
double x);
161 void FieldCylSol(
const Double_t *rphiz, Double_t *b)
const;
163 static double fastATan2(
float y,
float x);
236 #ifdef _MAGCHEB_CACHE_ 253 b[0] = b[1] = b[2] = 0;
261 Double_t btr = TMath::Sqrt(brphiz[0]*brphiz[0]+brphiz[1]*brphiz[1]);
262 Double_t psiPLUSphi =
useATan2(brphiz[1],brphiz[0]) + rphiz[1];
263 bxyz[0] = btr*TMath::Cos(psiPLUSphi);
264 bxyz[1] = btr*TMath::Sin(psiPLUSphi);
273 Double_t btr = TMath::Sqrt(brphiz[0]*brphiz[0]+brphiz[1]*brphiz[1]);
274 Double_t phiPLUSpsi =
useATan2(xyz[1],xyz[0]) +
useATan2(brphiz[1],brphiz[0]);
275 bxyz[0] = btr*TMath::Cos(phiPLUSpsi);
276 bxyz[1] = btr*TMath::Sin(phiPLUSpsi);
285 Double_t btr = TMath::Sqrt(bxyz[0]*bxyz[0]+bxyz[1]*bxyz[1]);
288 brphiz[0] = btr*TMath::Cos(psiMINphi);
289 brphiz[1] = btr*TMath::Sin(psiMINphi);
298 Double_t btr = TMath::Sqrt(bxyz[0]*bxyz[0]+bxyz[1]*bxyz[1]);
299 Double_t psiMINphi =
useATan2(bxyz[1],bxyz[0]) - rphiz[1];
300 brphiz[0] = btr*TMath::Cos(psiMINphi);
301 brphiz[1] = btr*TMath::Sin(psiMINphi);
309 rphiz[0] = TMath::Sqrt(xyz[0]*xyz[0]+xyz[1]*xyz[1]);
317 xyz[0] = rphiz[0]*TMath::Cos(rphiz[1]);
318 xyz[1] = rphiz[0]*TMath::Sin(rphiz[1]);
325 #ifdef _USE_FAST_ATAN2_ 328 return TMath::ATan2(y,x);
339 return ((y<0.) ? -TMath::Pi() : TMath::Pi()) -
fastATan2px(y,-x);
342 return y<0.f ? -0.5*TMath::Pi() : 0.5*TMath::Pi();
363 const float kThresh = 0.315f;
364 return x>kThresh ? x*(7.85398163397448279e-01+0.273f*(1.-x)) : x/(1.+x*x*0.2815f);
static void CylToCartCylB(const Double_t *rphiz, const Double_t *brphiz, Double_t *bxyz)
Float_t GetMaxZTPCRatInt() const
Int_t GetNSegZTPCRatInt() const
void AddParamTPCInt(const AliCheb3D *param)
Float_t GetMaxRTPCRatInt() const
AliCheb3D * GetParamTPCInt(Int_t ipar) const
void BuildTableTPCRatInt()
Float_t GetMinZTPCRatInt() const
Int_t GetNSegZDip() const
void 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)
static void CartToCylCartB(const Double_t *xyz, const Double_t *bxyz, Double_t *brphiz)
Int_t GetNSegZSol() const
Float_t GetMaxRTPCInt() const
Int_t GetNParamsDip() const
Double_t GetBz(const Double_t *xyz) const
void GetTPCInt(const Double_t *xyz, Double_t *b) const
Int_t FindDipSegment(const Double_t *xyz) const
Int_t GetDipSegmentsForZSlice(int zid, TObjArray &arr) const
Float_t GetMaxZDip() const
Int_t SegmentDimension(Float_t **seg, const TObjArray *par, int npar, int dim, Float_t xmn, Float_t xmx, Float_t ymn, Float_t ymx, Float_t zmn, Float_t zmx)
void GetTPCRatInt(const Double_t *xyz, Double_t *b) const
TObjArray * fParamsTPCRat
void LoadData(const char *inpfile)
AliCheb3D * GetParamDip(Int_t ipar) const
Float_t GetMinZTPCInt() const
Int_t FindSolSegment(const Double_t *xyz) const
static double useATan2(double y, double x)
AliCheb3D * GetParamSol(Int_t ipar) const
AliCheb3D * fCacheTPCInt
last used dipole patch
virtual void Print(Option_t *="") const
virtual void Clear(const Option_t *="")
static void CylToCart(const Double_t *rphiz, Double_t *xyz)
Int_t GetNParamsSol() const
AliCheb3D * GetParamTPCRatInt(Int_t ipar) const
void GetTPCIntCyl(const Double_t *rphiz, Double_t *b) const
Int_t FindTPCRatSegment(const Double_t *xyz) const
Int_t FindTPCSegment(const Double_t *xyz) const
static void CylToCartCartB(const Double_t *xyz, const Double_t *brphiz, Double_t *bxyz)
static void CartToCylCylB(const Double_t *rphiz, const Double_t *bxyz, Double_t *brphiz)
AliCheb3D * fCacheDip
last used solenoid patch
Float_t GetMaxZTPCInt() const
static double fastATan2px(float y, float x)
void FieldCyl(const Double_t *rphiz, Double_t *b) const
Int_t GetNParamsTPCInt() const
void SaveData(const char *outfile) const
virtual void Field(const Double_t *xyz, Double_t *b) const
AliMagWrapCheb & operator=(const AliMagWrapCheb &rhs)
Float_t * GetSegZSol() const
void AddParamTPCRatInt(const AliCheb3D *param)
Int_t GetNParamsTPCRatInt() const
static double fastATan(float x)
static double fastATan2(float y, float x)
Double_t FieldCylSolBz(const Double_t *rphiz) const
Float_t GetMinZDip() const
Float_t GetMaxZSol() const
Float_t GetMaxRSol() const
static void CartToCyl(const Double_t *xyz, Double_t *rphiz)
void AddParamDip(const AliCheb3D *param)
AliCheb3D * fCacheTPCRat
last used patch for TPC integral
void CopyFrom(const AliMagWrapCheb &src)
void AddParamSol(const AliCheb3D *param)
void GetTPCRatIntCyl(const Double_t *rphiz, Double_t *b) const
Int_t GetNSegZTPCInt() const
Float_t GetMinZSol() const
void FieldCylSol(const Double_t *rphiz, Double_t *b) const
Float_t * GetDipZSegArray() const