CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
BFit3D.h
Go to the documentation of this file.
1 #ifndef BFit3D_h
2 #define BFit3D_h
3 
4 #include <iostream>
5 #include "HarmBasis3DCyl.h"
6 
7 //_______________________________________________________________________________
8 namespace magfieldparam {
9  class BFit3D {
10  private:
11  //The following constants are defined in BFit3D_data.h
12  static const double B_nom[4]; //Nom. field values at measurements
13  static const double C0[360][4]; //Expansion coeffs. at measurements
14  static const double C1[360][5]; //First derivatives of coeffs.
15  static const double C2[360][3]; //Second derivatives of coeffs.
16 
17  double C[360]; //interpolated expansion coeefs. for the field B_set
18 
19  bool use_spline;
20  bool signed_rad;
21  double B_set;
22 
24 
25  void SetCoeff_Linear(const double B);
26  void SetCoeff_Spline(const double B);
27 
28  public:
29  //Defaults: piecewise linear interpolation is used to calculate
30  //expansion coefficients for intermidiate field values,
31  //Signed "R" coordinate is accepted
33 
34  virtual ~BFit3D() { delete HB; }
35 
36  //Set the interpolation type (cubic spline or linear piecewise)
37  void UseSpline(const bool flag = true) { use_spline = flag; }
38 
39  //Switch between signed and unsigned "R" modes
40  void UseSignedRad(const bool flag = true) { signed_rad = flag; }
41 
42  //BASIC FUNCTION: Set nominal field
43  void SetField(const double B) {
44  if (use_spline)
45  SetCoeff_Spline(B);
46  else
47  SetCoeff_Linear(B);
48  B_set = B;
49  }
50 
51  //BASIC FUNCTION: Return field components at the point (r,z,phi)
52  void GetField(const double r, const double z, const double phi, double &Br, double &Bz, double &Bphi);
53 
54  //All the following functions are provided for diagnostic purposes
55 
56  unsigned GetLen() { return HB->GetLen(); } //Ret. the basis length
57  double GetBnom() { return B_set; } //Ret. nominal field
58  double GetC(const int k) { return C[k]; } //Ret. k-th expansion coefficient
59 
60  //The following functions return values of the k-th basis component
61  //(B_r, B_z or B_phi) at the point which is set by last GetField(...)
62  double GetBr_k(const unsigned k) { return HB->GetBr_k(k); }
63  double GetBz_k(const unsigned k) { return HB->GetBz_k(k); }
64  double GetBphi_k(const unsigned k) { return HB->GetBphi_k(k); }
65 
66  //The following functions prints the basis polynomials for the scalar
67  //field potential, B_r, B_z or B_phi.
68  void PrintPtnPoly(std::ostream &out = std::cout) { HB->PrintPtB(out); }
69  void PrintBrPoly(std::ostream &out = std::cout) { HB->PrintBrB(out); }
70  void PrintBzPoly(std::ostream &out = std::cout) { HB->PrintBzB(out); }
71  void PrintBphiPoly(std::ostream &out = std::cout) { HB->PrintBphiB(out); }
72  void PrintPoly(std::ostream &out = std::cout) { HB->Print(out); }
73  };
74 } // namespace magfieldparam
75 #endif
unsigned GetLen()
Definition: BFit3D.h:56
double GetBr_k(const unsigned k)
static const double B_nom[4]
Definition: BFit3D.h:12
void PrintBrB(std::ostream &out=std::cout)
void PrintBphiPoly(std::ostream &out=std::cout)
Definition: BFit3D.h:71
void PrintBphiB(std::ostream &out=std::cout)
void SetField(const double B)
Definition: BFit3D.h:43
virtual ~BFit3D()
Definition: BFit3D.h:34
double GetC(const int k)
Definition: BFit3D.h:58
double GetBz_k(const unsigned k)
void PrintBrPoly(std::ostream &out=std::cout)
Definition: BFit3D.h:69
void GetField(const double r, const double z, const double phi, double &Br, double &Bz, double &Bphi)
Definition: BFit3D.cc:73
static const double C0[360][4]
Definition: BFit3D.h:13
double GetBnom()
Definition: BFit3D.h:57
HarmBasis3DCyl * HB
Definition: BFit3D.h:23
double GetBphi_k(const unsigned k)
void SetCoeff_Linear(const double B)
Definition: BFit3D.cc:11
void PrintBzPoly(std::ostream &out=std::cout)
Definition: BFit3D.h:70
static const std::string B
void PrintPtnPoly(std::ostream &out=std::cout)
Definition: BFit3D.h:68
void Print(harm_poly_arr &B, std::ostream &out=std::cout)
static const double C1[360][5]
Definition: BFit3D.h:14
double C[360]
Definition: BFit3D.h:17
double GetBz_k(const unsigned k)
Definition: BFit3D.h:63
double GetBr_k(const unsigned k)
Definition: BFit3D.h:62
void UseSpline(const bool flag=true)
Definition: BFit3D.h:37
void UseSignedRad(const bool flag=true)
Definition: BFit3D.h:40
void PrintPoly(std::ostream &out=std::cout)
Definition: BFit3D.h:72
tuple cout
Definition: gather_cfg.py:144
void PrintBzB(std::ostream &out=std::cout)
void SetCoeff_Spline(const double B)
Definition: BFit3D.cc:40
static const double C2[360][3]
Definition: BFit3D.h:15
void PrintPtB(std::ostream &out=std::cout)
double GetBphi_k(const unsigned k)
Definition: BFit3D.h:64