File indexing completed on 2023-03-17 11:14:35
0001 #ifndef BFit3D_h
0002 #define BFit3D_h
0003
0004 #include <iostream>
0005 #include "HarmBasis3DCyl.h"
0006
0007
0008 namespace magfieldparam {
0009 class BFit3D {
0010 private:
0011
0012 static const double B_nom[4];
0013 static const double C0[360][4];
0014 static const double C1[360][5];
0015 static const double C2[360][3];
0016
0017 double C[360];
0018
0019 bool use_spline;
0020 bool signed_rad;
0021 double B_set;
0022
0023 HarmBasis3DCyl *HB;
0024
0025 void SetCoeff_Linear(const double B);
0026 void SetCoeff_Spline(const double B);
0027
0028 public:
0029
0030
0031
0032 BFit3D() : use_spline(false), signed_rad(true), B_set(0.), HB(new HarmBasis3DCyl(18)) {}
0033
0034 virtual ~BFit3D() { delete HB; }
0035
0036
0037 void UseSpline(const bool flag = true) { use_spline = flag; }
0038
0039
0040 void UseSignedRad(const bool flag = true) { signed_rad = flag; }
0041
0042
0043 void SetField(const double B) {
0044 if (use_spline)
0045 SetCoeff_Spline(B);
0046 else
0047 SetCoeff_Linear(B);
0048 B_set = B;
0049 }
0050
0051
0052 void GetField(const double r, const double z, const double phi, double &Br, double &Bz, double &Bphi);
0053
0054
0055
0056 unsigned GetLen() { return HB->GetLen(); }
0057 double GetBnom() { return B_set; }
0058 double GetC(const int k) { return C[k]; }
0059
0060
0061
0062 double GetBr_k(const unsigned k) { return HB->GetBr_k(k); }
0063 double GetBz_k(const unsigned k) { return HB->GetBz_k(k); }
0064 double GetBphi_k(const unsigned k) { return HB->GetBphi_k(k); }
0065
0066
0067
0068 void PrintPtnPoly(std::ostream &out = std::cout) { HB->PrintPtB(out); }
0069 void PrintBrPoly(std::ostream &out = std::cout) { HB->PrintBrB(out); }
0070 void PrintBzPoly(std::ostream &out = std::cout) { HB->PrintBzB(out); }
0071 void PrintBphiPoly(std::ostream &out = std::cout) { HB->PrintBphiB(out); }
0072 void PrintPoly(std::ostream &out = std::cout) { HB->Print(out); }
0073 };
0074 }
0075 #endif