Go to the documentation of this file.00001 #ifndef Grid3D_h
00002 #define Grid3D_h
00003
00011 #include "DataFormats/GeometryVector/interface/Basic3DVector.h"
00012
00013 #include "Grid1D.h"
00014 #include <vector>
00015 #include "FWCore/Utilities/interface/Visibility.h"
00016
00017
00018
00019 struct BStorageArray {
00020 BStorageArray(){}
00021 BStorageArray(float x,float y, float z) : v{x,y,z}{}
00022
00023 float const & operator[](int i) const { return v[i];}
00024
00025 float v[3];
00026 };
00027
00028 class dso_internal Grid3D {
00029 public:
00030
00031
00032 typedef float Scalar;
00033 typedef Basic3DVector<Scalar> ValueType;
00034 typedef ValueType ReturnType;
00035
00036 using BVector = BStorageArray;
00037
00038 using Container = std::vector<BVector>;
00039
00040 Grid3D() {}
00041
00042 Grid3D( const Grid1D& ga, const Grid1D& gb, const Grid1D& gc,
00043 std::vector<BVector>& data) :
00044 grida_(ga), gridb_(gb), gridc_(gc) {
00045 data_.swap(data);
00046 stride1_ = gridb_.nodes() * gridc_.nodes();
00047 stride2_ = gridc_.nodes();
00048 }
00049
00050
00051
00052
00053
00054
00055 int index(int i, int j, int k) const {return i*stride1_ + j*stride2_ + k;}
00056 int stride1() const { return stride1_;}
00057 int stride2() const { return stride2_;}
00058 int stride3() const { return 1;}
00059 ValueType operator()(int i) const {
00060 return ValueType(data_[i][0],data_[i][1],data_[i][2]);
00061 }
00062
00063 ValueType operator()(int i, int j, int k) const {
00064 return (*this)(index(i,j,k));
00065 }
00066
00067 const Grid1D& grida() const {return grida_;}
00068 const Grid1D& gridb() const {return gridb_;}
00069 const Grid1D& gridc() const {return gridc_;}
00070
00071 const Container & data() const {return data_;}
00072
00073 void dump() const;
00074
00075 private:
00076
00077 Grid1D grida_;
00078 Grid1D gridb_;
00079 Grid1D gridc_;
00080
00081 Container data_;
00082
00083 int stride1_;
00084 int stride2_;
00085
00086
00087 };
00088
00089 #endif