CMS 3D CMS Logo

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