CMS 3D CMS Logo

Field.cc
Go to the documentation of this file.
3 
5 
6 #include "CLHEP/Units/GlobalSystemOfUnits.h"
7 
8 using namespace sim;
9 
10 Field::Field(const MagneticField *f, double d) : G4MagneticField(), theCMSMagneticField(f), theDelta(d) {
11  for (int i = 0; i < 3; ++i) {
12  oldx[i] = 1.0e12;
13  oldb[i] = 0.0;
14  }
15 }
16 
18 
19 void Field::GetFieldValue(const G4double xyz[4], G4double bfield[3]) const {
20  if (std::abs(oldx[0] - xyz[0]) > theDelta || std::abs(oldx[1] - xyz[1]) > theDelta ||
21  std::abs(oldx[2] - xyz[2]) > theDelta) {
22  static const float lunit = (1.0 / CLHEP::cm);
23  GlobalPoint ggg((float)(xyz[0]) * lunit, (float)(xyz[1]) * lunit, (float)(xyz[2]) * lunit);
25 
26  static const float btesla = CLHEP::tesla;
27  oldb[0] = (v.x() * btesla);
28  oldb[1] = (v.y() * btesla);
29  oldb[2] = (v.z() * btesla);
30  oldx[0] = xyz[0];
31  oldx[1] = xyz[1];
32  oldx[2] = xyz[2];
33  }
34 
35  bfield[0] = oldb[0];
36  bfield[1] = oldb[1];
37  bfield[2] = oldb[2];
38 }
const MagneticField * theCMSMagneticField
Definition: Field.h:16
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
void GetFieldValue(const G4double p[4], G4double b[3]) const override
Definition: Field.cc:19
double oldb[3]
Definition: Field.h:20
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double f[11][100]
d
Definition: ztail.py:151
~Field() override
Definition: Field.cc:17
double theDelta
Definition: Field.h:17
double oldx[3]
Definition: Field.h:19
Field(const MagneticField *f, double d)
Definition: Field.cc:10