StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
STARField.h
1 #ifndef genfit_STARField_h
2 #define genfit_STARField_h
3 
4 #include "TVector3.h"
5 #include "StarMagField/StarMagField.h"
6 #include "GenFit/AbsBField.h"
7 
8 //_______________________________________________________________________________________
9 // Adaptor for STAR magnetic field loaded via StarMagField Maker
10 class StarFieldAdaptor : public genfit::AbsBField {
11  public:
12  StarFieldAdaptor() {};
13 
14  virtual TVector3 get(const TVector3 &position) const {
15  double x[] = {position[0], position[1], position[2]};
16  double B[] = {0, 0, 0};
17 
18  get( x[0], x[1], x[2], B[0], B[1], B[2] );
19 
20  return TVector3(B);
21  };
22 
23  inline virtual void get(const double &_x, const double &_y, const double &_z, double &Bx, double &By, double &Bz) const {
24  double x[] = {_x, _y, _z};
25  double B[] = {0, 0, 0};
26 
27  if (StarMagField::Instance()){
28 
29  float z = x[2];
30  float r = sqrt(pow(x[0],2) + pow(x[1],2));
31  if( fabs(z) < 250. && r < 50.) {
32  B[0] = 0.; B[1] = 0.; B[2] = 4.97979927;
33  } else if ( fabs(z) > 450 ) {
34  B[0] = 0.; B[1] = 0.; B[2] = 0.;
35  } else {
36  StarMagField::Instance()->Field(x, B);
37  }
38  }
39 
40 
41  Bx = B[0];
42  By = B[1];
43  Bz = B[2];
44  return;
45  };
46 };
47 
48 
49 #endif