00001 //Based on the Geant4 example examples/advanced/purging_magnet/src/PurgMagTabulatedField3D.cc 00002 #include "G4MagneticField.hh" 00003 #include "G4ios.hh" 00004 #include "BDSMagField.hh" 00005 00006 #include <fstream> 00007 #include <vector> 00008 #include <cmath> 00009 00010 class BDSXYMagField2 00011 #ifndef STANDALONE 00012 // : public G4MagneticField 00013 : public BDSMagField 00014 #endif 00015 { 00016 00017 // Storage space for the table 00018 std::vector< std::vector< double > > xField; 00019 std::vector< std::vector< double > > yField; 00020 std::vector< std::vector< double > > zField; 00021 // The dimensions of the table 00022 int nx,ny; 00023 // The physical limits of the defined region 00024 double minx, maxx, miny, maxy; 00025 // The physical extent of the defined region 00026 double dx, dy; 00027 bool invertX, invertY; 00028 00029 public: 00030 BDSXYMagField2(const char* filename); 00031 void GetFieldValue( const double Point[4], 00032 double *Bfield ) const; 00033 }; 00034