Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-09-14 02:34:03

0001 #ifndef MagneticField_MagneticField_h
0002 #define MagneticField_MagneticField_h
0003 
0004 /** \class MagneticField
0005  *
0006  *  Base class for the different implementation of magnetic field engines.
0007  *
0008  *  \author N. Amapane - CERN
0009  */
0010 
0011 #include <atomic>
0012 
0013 #include "DataFormats/GeometryVector/interface/GlobalVector.h"
0014 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
0015 #include "FWCore/Utilities/interface/Visibility.h"
0016 #include "FWCore/Utilities/interface/Likely.h"
0017 #include "FWCore/Utilities/interface/thread_safety_macros.h"
0018 
0019 class MagneticField {
0020 public:
0021   MagneticField();
0022   MagneticField(const MagneticField& orig);
0023   virtual ~MagneticField();
0024 
0025   /// Derived classes can implement cloning without ownership of the
0026   /// underlying engines.
0027   virtual MagneticField* clone() const { return nullptr; }
0028 
0029   /// Field value ad specified global point, in Tesla
0030   virtual GlobalVector inTesla(const GlobalPoint& gp) const = 0;
0031 
0032   /// Field value ad specified global point, in KGauss
0033   GlobalVector inKGauss(const GlobalPoint& gp) const { return inTesla(gp) * 10.F; }
0034 
0035   /// Field value ad specified global point, in 1/Gev
0036   GlobalVector inInverseGeV(const GlobalPoint& gp) const { return inTesla(gp) * 2.99792458e-3F; }
0037 
0038   /// True if the point is within the region where the concrete field
0039   // engine is defined.
0040   virtual bool isDefined(const GlobalPoint& /*gp*/) const { return true; }
0041 
0042   /// Optional implementation that derived classes can implement to provide faster query
0043   /// by skipping the check to isDefined.
0044   virtual GlobalVector inTeslaUnchecked(const GlobalPoint& gp) const {
0045     return inTesla(gp);  // default dummy implementation
0046   }
0047 
0048   /// The nominal field value for this map in kGauss
0049   int nominalValue() const { return theNominalValue; }
0050 
0051   /// The inverse of field z component for this map in GeV
0052   float inverseBzAtOriginInGeV() const { return theInverseBzAtOriginInGeV; }
0053 
0054 protected:
0055   // need to be called from the constructor of the deriving classes
0056   void setNominalValue();
0057 
0058 private:
0059   //nominal field values
0060   int theNominalValue = 0;
0061   float theInverseBzAtOriginInGeV = 0;
0062 };
0063 
0064 #endif