Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:31:23

0001 #ifndef MFGrid3D_h
0002 #define MFGrid3D_h
0003 
0004 /** \class MFGrid3D
0005  *
0006  *  Generic virtual implementation of a MFGrid for a 3D underlying regular grid.
0007  *
0008  *  \author T. Todorov
0009  */
0010 
0011 #include "MagneticField/Interpolation/interface/MFGrid.h"
0012 #include "DataFormats/GeometryVector/interface/Basic3DVector.h"
0013 #include "Grid1D.h"
0014 #include "Grid3D.h"
0015 #include "FWCore/Utilities/interface/Visibility.h"
0016 
0017 class dso_internal MFGrid3D : public MFGrid {
0018 public:
0019   explicit MFGrid3D(const GloballyPositioned<float>& vol) : MFGrid(vol) {}
0020 
0021   Dimensions dimensions(void) const override {
0022     Dimensions tmp;
0023     tmp.w = grid_.grida().nodes();
0024     tmp.h = grid_.gridb().nodes();
0025     tmp.d = grid_.gridc().nodes();
0026     return tmp;
0027   }
0028 
0029   /// Position of node in local frame
0030   LocalPoint nodePosition(int i, int j, int k) const override {
0031     return fromGridFrame(grid_.grida().node(i), grid_.gridb().node(j), grid_.gridc().node(k));
0032   }
0033 
0034   /// Field value at node
0035   LocalVector nodeValue(int i, int j, int k) const override {
0036     /// must check range here: FIX ME !!!!
0037     return MFGrid::LocalVector(grid_(i, j, k));
0038   }
0039 
0040   Indexes index(const LocalPoint& p) const override {
0041     Indexes result;
0042     double a, b, c;
0043     toGridFrame(p, a, b, c);
0044     result.i = grid_.grida().index(a);
0045     result.j = grid_.gridb().index(b);
0046     result.k = grid_.gridc().index(c);
0047     return result;
0048   }
0049 
0050   LocalVector valueInTesla(const LocalPoint& p) const override;
0051 
0052   /// Interpolated field value at given point; does not check for exceptions
0053   virtual LocalVector uncheckedValueInTesla(const LocalPoint& p) const = 0;
0054 
0055 protected:
0056   using GridType = Grid3D;
0057   using BVector = Grid3D::BVector;
0058 
0059   GridType grid_;  // should become private...
0060 
0061   void setGrid(const GridType& grid) { grid_ = grid; }
0062 };
0063 
0064 #endif