CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/MagneticField/Interpolation/src/Grid3D.h

Go to the documentation of this file.
00001 #ifndef Grid3D_h
00002 #define Grid3D_h
00003 
00011 #include "DataFormats/GeometryVector/interface/Basic3DVector.h"
00012 #include "DataFormats/Math/interface/SSEVec.h"
00013 #include "MagneticField/Interpolation/src/Grid1D.h"
00014 #include <vector>
00015 
00016 class Grid3D {
00017 public:
00018 
00019  // typedef double   Scalar;
00020   typedef float   Scalar;
00021   typedef Basic3DVector<Scalar>   ValueType;
00022   typedef ValueType ReturnType; 
00023  
00024   Grid3D() {}
00025 
00026   Grid3D( const Grid1D& ga, const Grid1D& gb, const Grid1D& gc,
00027           std::vector<ValueType>& data) : 
00028     grida_(ga), gridb_(gb), gridc_(gc) {
00029      data_.swap(data);
00030      stride1_ = gridb_.nodes() * gridc_.nodes();
00031      stride2_ = gridc_.nodes();
00032   }
00033 
00034 
00035   //  Grid3D( const Grid1D& ga, const Grid1D& gb, const Grid1D& gc,
00036   //      std::vector<ValueType> const & data);
00037 
00038 
00039   int index(int i, int j, int k) const {return i*stride1_ + j*stride2_ + k;}
00040   int stride1() const { return stride1_;}
00041   int stride2() const { return stride2_;}
00042   int stride3() const { return 1;}
00043   const ValueType& operator()(int i) const {
00044     return data_[i];
00045   }
00046 
00047   ValueType const & operator()(int i, int j, int k) const {
00048     return (*this)(index(i,j,k));
00049   }
00050 
00051   const Grid1D& grida() const {return grida_;}
00052   const Grid1D& gridb() const {return gridb_;}
00053   const Grid1D& gridc() const {return gridc_;}
00054 
00055   const std::vector<ValueType>& data() const {return data_;}
00056 
00057   void dump() const;
00058 
00059 private:
00060 
00061   Grid1D grida_;
00062   Grid1D gridb_;
00063   Grid1D gridc_;
00064 
00065   std::vector<ValueType> data_;
00066 
00067   int stride1_;
00068   int stride2_;
00069 
00070 
00071 };
00072 
00073 #endif