Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DMagneticFieldMapPSConst.cc
Go to the documentation of this file.
1 // $Id$
2 //
3 // File: DMagneticFieldMapPSConst.cc
4 //
5 
6 #include <cmath>
7 using namespace std;
8 
10 
11 
12 
13 //---------------------------------
14 // DMagneticFieldMapPSConst (Constructor)
15 //---------------------------------
17 {
18  int32_t runnumber = 1;
19  jcalib = japp->GetJCalibration(runnumber);
20  if(GetValues(namepath, runnumber)==0){
21  _DBG_<<"Error getting JCalibration object for magnetic field!"<<endl;
22  japp->Quit();
23  }
24 }
25 
26 //---------------------------------
27 // DMagneticFieldMapPSConst (Constructor)
28 //---------------------------------
29 DMagneticFieldMapPSConst::DMagneticFieldMapPSConst(JCalibration *jcalib, string namepath)
30 {
31  this->jcalib = jcalib;
32  if(GetValues(namepath)==0){
33  _DBG_<<"Error getting JCalibration object for magnetic field!"<<endl;
34  exit(-1);
35  }
36 }
37 
38 //---------------------------------
39 // DMagneticFieldMapPSConst (Constructor)
40 //---------------------------------
42 {
43  this->jcalib = NULL;
44 
45  this->Bx = Bx;
46  this->By = By;
47  this->Bz = Bz;
48 }
49 
50 //---------------------------------
51 // ~DMagneticFieldMapPSConst (Destructor)
52 //---------------------------------
54 {
55 
56 }
57 
58 //---------------------------------
59 // GetValues
60 //---------------------------------
61 int DMagneticFieldMapPSConst::GetValues(string namepath, int32_t runnumber, string context)
62 {
63  /// Read the parameters for the constant magnetic field map from the calibration database.
64 
65  if(!jcalib)return 0;
66 
67  cout<<"Reading Constant Magnetic field values from "<<namepath<<" ..."<<endl;
68  map<string,double> vals;
69  jcalib->Get(namepath, vals);
70  if(vals.size()==0)return 0;
71 
72  Bx = vals["Bx"];
73  By = vals["By"];
74  Bz = vals["Bz"];
75  cout<<" Bx="<<Bx<<" By="<<By<<" Bz="<<Bz<<endl;
76 
77  return vals.size();
78 }
79 
80 
81 //-------------
82 // GetFieldGradient
83 //-------------
84 void DMagneticFieldMapPSConst::GetFieldGradient(double x, double y, double z,
85  double &dBxdx, double &dBxdy,
86  double &dBxdz,
87  double &dBydx, double &dBydy,
88  double &dBydz,
89  double &dBzdx, double &dBzdy,
90  double &dBzdz) const{
91 
92 
93  // Constant field has zero gradient
94  dBxdx = 0.0;
95  dBxdy = 0.0;
96  dBxdz = 0.0;
97  dBydx = 0.0;
98  dBydy = 0.0;
99  dBydz = 0.0;
100  dBzdx = 0.0;
101  dBzdy = 0.0;
102  dBzdz = 0.0;
103 }
104 
105 
106 
107 //---------------------------------
108 // GetField
109 //---------------------------------
110 void DMagneticFieldMapPSConst::GetField(double x, double y, double z, double &Bx, double &By, double &Bz, int method) const
111 {
112  /// This calculates the magnetic field at an arbitrary point
113  /// in space using the constant field map parameters read from the calibaration
114  /// database.
115 
116  Bx = this->Bx;
117  By = this->By;
118  Bz = this->Bz;
119 }
120 
121 //---------------------------------
122 // GetField
123 //---------------------------------
125  DVector3 &Bout) const
126 {
127  /// This calculates the magnetic field at an arbitrary point
128  /// in space using the constant field map parameters read from the calibaration
129  /// database.
130 
131  Bout.SetXYZ(this->Bx,this->By,this->Bz);
132 }
133 
134 
135 void DMagneticFieldMapPSConst::GetFieldBicubic(double x,double y,double z,
136  double &Bx,double &By,double &Bz)
137  const{
138  GetField(x,y,z,Bx,By,Bz);
139 }
140 
141 
143  double &Bx,double &By,
144  double &Bz,
145  double &dBxdx, double &dBxdy,
146  double &dBxdz,
147  double &dBydx, double &dBydy,
148  double &dBydz,
149  double &dBzdx, double &dBzdy,
150  double &dBzdz) const{
151  GetField(x,y,z,Bx,By,Bz);
152  // Constant field has zero gradient
153  dBxdx = 0.0;
154  dBxdy = 0.0;
155  dBxdz = 0.0;
156  dBydx = 0.0;
157  dBydy = 0.0;
158  dBydz = 0.0;
159  dBzdx = 0.0;
160  dBzdy = 0.0;
161  dBzdz = 0.0;
162 }
void GetFieldBicubic(double x, double y, double z, double &Bx, double &By, double &Bz) const
void GetFieldGradient(double x, double y, double z, double &dBxdx, double &dBxdy, double &dBxdz, double &dBydx, double &dBydy, double &dBydz, double &dBzdx, double &dBzdy, double &dBzdz) const
TVector3 DVector3
Definition: DVector3.h:14
Double_t x[NCHANNELS]
Definition: st_tw_resols.C:39
#define y
JApplication * japp
void GetFieldAndGradient(double x, double y, double z, double &Bx, double &By, double &Bz, double &dBxdx, double &dBxdy, double &dBxdz, double &dBydx, double &dBydy, double &dBydz, double &dBzdx, double &dBzdy, double &dBzdz) const
#define _DBG_
Definition: HDEVIO.h:12
int GetValues(string namepath, int32_t runnumber=1, string context="")
void GetField(const DVector3 &pos, DVector3 &Bout) const
DMagneticFieldMapPSConst(JApplication *japp, string namepath="Magnets/PairSpectrometer/PS_const_field")