CMS 3D CMS Logo

Field.h
Go to the documentation of this file.
1 #ifndef SimG4Core_Field_H
2 #define SimG4Core_Field_H
3 
4 #include "G4MagneticField.hh"
5 
7 
9 
10 #include "CLHEP/Units/SystemOfUnits.h"
11 
12 namespace sim {
13  class Field final : public G4MagneticField {
14  public:
15  Field(const MagneticField *f, double d);
16  ~Field() override;
17  inline void GetFieldValue(const G4double p[], G4double b[3]) const override;
18 
19  private:
21  double theDelta;
22 
23  mutable double oldx[3];
24  mutable double oldb[3];
25  };
26 }; // namespace sim
27 
28 void sim::Field::GetFieldValue(const G4double xyz[], G4double bfield[3]) const {
29  if (std::abs(oldx[0] - xyz[0]) > theDelta || std::abs(oldx[1] - xyz[1]) > theDelta ||
30  std::abs(oldx[2] - xyz[2]) > theDelta) {
31  constexpr float lunit = (1.0 / CLHEP::cm);
32  GlobalPoint ggg((float)(xyz[0]) * lunit, (float)(xyz[1]) * lunit, (float)(xyz[2]) * lunit);
34 
35  constexpr float btesla = CLHEP::tesla;
36  oldb[0] = (v.x() * btesla);
37  oldb[1] = (v.y() * btesla);
38  oldb[2] = (v.z() * btesla);
39  oldx[0] = xyz[0];
40  oldx[1] = xyz[1];
41  oldx[2] = xyz[2];
42  }
43 
44  bfield[0] = oldb[0];
45  bfield[1] = oldb[1];
46  bfield[2] = oldb[2];
47 }
48 
49 #endif
const MagneticField * theCMSMagneticField
Definition: Field.h:20
void GetFieldValue(const G4double p[], G4double b[3]) const override
Definition: Field.h:28
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
double oldb[3]
Definition: Field.h:24
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 b
Definition: hdecay.h:118
double theDelta
Definition: Field.h:21
double oldx[3]
Definition: Field.h:23
Field(const MagneticField *f, double d)
Definition: Field.cc:10