CMS 3D CMS Logo

MagneticField.h
Go to the documentation of this file.
1 #ifndef MagneticField_MagneticField_h
2 #define MagneticField_MagneticField_h
3 
15 #include <atomic>
16 
18 {
19  public:
20  MagneticField();
21  MagneticField(const MagneticField& orig);
22  virtual ~MagneticField();
23 
26  virtual MagneticField* clone() const {
27  return 0;
28  }
29 
31  virtual GlobalVector inTesla (const GlobalPoint& gp) const = 0;
32 
34  GlobalVector inKGauss(const GlobalPoint& gp) const {
35  return inTesla(gp) * 10.F;
36  }
37 
40  return inTesla(gp) * 2.99792458e-3F;
41  }
42 
44  // engine is defined.
45  virtual bool isDefined(const GlobalPoint& /*gp*/) const {
46  return true;
47  }
48 
51  virtual GlobalVector inTeslaUnchecked (const GlobalPoint& gp) const {
52  return inTesla(gp); // default dummy implementation
53  }
54 
56  int nominalValue() const {
57  if(kSet==nominalValueCompiuted.load()) return theNominalValue;
58  return computeNominalValue();
59  }
60 
61 private:
62  //nominal field value
63  virtual int computeNominalValue() const;
64  mutable std::atomic<char> nominalValueCompiuted;
65 // [[cms::thread_guard("nominalValueCompiuted")]] mutable int theNominalValue;
66 // PG temporary fix for clang 3.4 which is not parsing thread_guard correctly
67  [[cms::thread_safe]] mutable int theNominalValue;
69 };
70 
71 #endif
virtual GlobalVector inTeslaUnchecked(const GlobalPoint &gp) const
Definition: MagneticField.h:51
int nominalValue() const
The nominal field value for this map in kGauss.
Definition: MagneticField.h:56
virtual ~MagneticField()
std::atomic< char > nominalValueCompiuted
Definition: MagneticField.h:64
GlobalVector inInverseGeV(const GlobalPoint &gp) const
Field value ad specified global point, in 1/Gev.
Definition: MagneticField.h:39
virtual bool isDefined(const GlobalPoint &) const
True if the point is within the region where the concrete field.
Definition: MagneticField.h:45
virtual int computeNominalValue() const
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
GlobalVector inKGauss(const GlobalPoint &gp) const
Field value ad specified global point, in KGauss.
Definition: MagneticField.h:34
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
Definition: blowfish.cc:281
virtual MagneticField * clone() const
Definition: MagneticField.h:26