CMS 3D CMS Logo

CMSSW_4_4_3_patch1/src/MagneticField/VolumeGeometry/interface/MagVolume.h

Go to the documentation of this file.
00001 #ifndef MagVolume_H
00002 #define MagVolume_H
00003 
00004 #include "DataFormats/GeometrySurface/interface/GloballyPositioned.h"
00005 #include "DetectorDescription/Core/interface/DDSolidShapes.h"
00006 #include "MagneticField/VolumeGeometry/interface/VolumeSide.h"
00007 #include "MagneticField/Engine/interface/MagneticField.h"
00008 
00009 #include <vector>
00010 
00011 template <class T>
00012 class MagneticFieldProvider;
00013 
00014 class MagVolume : public GloballyPositioned<float>, public MagneticField {
00015 public:
00016 
00017   typedef GloballyPositioned<float>    Base;
00018   typedef GloballyPositioned<float>::LocalPoint     LocalPoint;
00019   typedef GloballyPositioned<float>::LocalVector    LocalVector;
00020   typedef GloballyPositioned<float>::GlobalPoint    GlobalPoint;
00021   typedef GloballyPositioned<float>::GlobalVector   GlobalVector;
00022 
00023   MagVolume( const PositionType& pos, const RotationType& rot, 
00024              DDSolidShape shape, const MagneticFieldProvider<float> * mfp,
00025              double sf=1.) :
00026     Base(pos,rot), MagneticField(), theShape(shape), theProvider(mfp), 
00027     theProviderOwned(false), theScalingFactor(sf), isIronFlag(false) {}
00028 
00029   virtual ~MagVolume();
00030 
00031   DDSolidShape shapeType() const {return theShape;}
00032 
00033   LocalVector fieldInTesla( const LocalPoint& lp) const;
00034   GlobalVector fieldInTesla( const GlobalPoint& lp) const;
00035 
00036   virtual bool inside( const GlobalPoint& gp, double tolerance=0.) const = 0;
00037   virtual bool inside( const LocalPoint& lp, double tolerance=0.) const {
00038     return inside( toGlobal(lp), tolerance);
00039   }
00040 
00041   const MagneticFieldProvider<float>* provider() const {return theProvider;}
00042 
00044   virtual const std::vector<VolumeSide>& faces() const = 0;
00045 
00046   virtual ::GlobalVector inTesla ( const ::GlobalPoint& gp) const {
00047     return fieldInTesla( gp);
00048   }
00049 
00051   bool isIron() const {return isIronFlag;}
00052   void setIsIron(bool iron) {isIronFlag = iron;}
00053   void ownsFieldProvider(bool o) {theProviderOwned=o;}
00054 
00055 private:
00056 
00057   DDSolidShape theShape;
00058   const MagneticFieldProvider<float> * theProvider;
00059   bool theProviderOwned;
00060   double theScalingFactor;
00061   // Temporary hack to keep information on material. Will eventually be replaced!
00062   bool isIronFlag;
00063 
00064 };
00065 
00066 #endif