00001 #ifndef MagneticField_MagneticField_h 00002 #define MagneticField_MagneticField_h 00003 00013 #include "DataFormats/GeometryVector/interface/GlobalVector.h" 00014 #include "DataFormats/GeometryVector/interface/GlobalPoint.h" 00015 #include "FWCore/Utilities/interface/Visibility.h" 00016 #include "FWCore/Utilities/interface/Likely.h" 00017 00018 class MagneticField 00019 { 00020 public: 00021 MagneticField(); 00022 virtual ~MagneticField(); 00023 00026 virtual MagneticField* clone() const { 00027 return 0; 00028 } 00029 00030 00032 virtual GlobalVector inTesla (const GlobalPoint& gp) const = 0; 00033 00035 GlobalVector inKGauss(const GlobalPoint& gp) const { 00036 return inTesla(gp) * 10.F; 00037 } 00038 00040 GlobalVector inInverseGeV(const GlobalPoint& gp) const { 00041 return inTesla(gp) * 2.99792458e-3F; 00042 } 00043 00045 // engine is defined. 00046 virtual bool isDefined(const GlobalPoint& gp) const { 00047 return true; 00048 } 00049 00052 virtual GlobalVector inTeslaUnchecked (const GlobalPoint& gp) const { 00053 return inTesla(gp); // default dummy implementation 00054 } 00055 00057 int nominalValue() const { 00058 if unlikely(!nominalValueCompiuted) { 00059 theNominalValue = computeNominalValue(); 00060 nominalValueCompiuted=true; 00061 } 00062 return theNominalValue; 00063 } 00064 private: 00065 //nominal field value 00066 virtual int computeNominalValue() const; 00067 mutable bool nominalValueCompiuted; 00068 mutable int theNominalValue; 00069 }; 00070 00071 #endif