Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:22:35

0001 #ifndef MagVolume_H
0002 #define MagVolume_H
0003 
0004 #include "DataFormats/GeometrySurface/interface/GloballyPositioned.h"
0005 #include "MagneticField/VolumeGeometry/interface/VolumeSide.h"
0006 #include "MagneticField/Engine/interface/MagneticField.h"
0007 
0008 #include <vector>
0009 
0010 template <class T>
0011 class MagneticFieldProvider;
0012 
0013 class MagVolume : public GloballyPositioned<float>, public MagneticField {
0014 public:
0015   typedef GloballyPositioned<float> Base;
0016   typedef GloballyPositioned<float>::LocalPoint LocalPoint;
0017   typedef GloballyPositioned<float>::LocalVector LocalVector;
0018   typedef GloballyPositioned<float>::GlobalPoint GlobalPoint;
0019   typedef GloballyPositioned<float>::GlobalVector GlobalVector;
0020 
0021   MagVolume(const PositionType& pos, const RotationType& rot, const MagneticFieldProvider<float>* mfp, double sf = 1.)
0022       : Base(pos, rot),
0023         MagneticField(),
0024         theProvider(mfp),
0025         theProviderOwned(false),
0026         theScalingFactor(sf),
0027         isIronFlag(false) {}
0028 
0029   ~MagVolume() override;
0030 
0031   LocalVector fieldInTesla(const LocalPoint& lp) const;
0032   GlobalVector fieldInTesla(const GlobalPoint& lp) const;
0033 
0034   virtual bool inside(const GlobalPoint& gp, double tolerance = 0.) const = 0;
0035   virtual bool inside(const LocalPoint& lp, double tolerance = 0.) const { return inside(toGlobal(lp), tolerance); }
0036 
0037   const MagneticFieldProvider<float>* provider() const { return theProvider; }
0038 
0039   /// Access to volume faces
0040   virtual const std::vector<VolumeSide>& faces() const = 0;
0041 
0042   ::GlobalVector inTesla(const ::GlobalPoint& gp) const override { return fieldInTesla(gp); }
0043 
0044   /// Temporary hack to pass information on material. Will eventually be replaced!
0045   bool isIron() const { return isIronFlag; }
0046   void setIsIron(bool iron) { isIronFlag = iron; }
0047   void ownsFieldProvider(bool o) { theProviderOwned = o; }
0048 
0049 private:
0050   const MagneticFieldProvider<float>* theProvider;
0051   bool theProviderOwned;
0052   double theScalingFactor;
0053   // Temporary hack to keep information on material. Will eventually be replaced!
0054   bool isIronFlag;
0055 };
0056 
0057 #endif