GEMC  2.3
Geant4 Monte-Carlo Framework
mappedField.h
Go to the documentation of this file.
1 #ifndef MAPPED_FIELD_H
6 #define MAPPED_FIELD_H 1
7 
8 // G4 headers
9 #include "G4MagneticField.hh"
10 
11 
12 // c++ headers
13 #include <vector>
14 #include <string>
15 #include <iostream>
16 
17 using namespace std;
18 
19 // CLHEP units
20 #include "CLHEP/Units/PhysicalConstants.h"
21 using namespace CLHEP;
22 
23 // defines one dimension of the field
24 // number of points, range and units
25 class gcoord
26 {
27  public:
28  gcoord(string nm, unsigned int n, double m, double M, string u, int s)
29  {
30  name = nm;
31  np = n;
32  min = m;
33  max = M;
34  unit = u;
35  speed = s;
36  }
37 
38  public:
39  string name;
40  unsigned int np;
41  double min;
42  double max;
43  string unit;
44  int speed; // 0 is the slowest varying coordinate
45 
46  friend ostream &operator<<(ostream &stream, gcoord gc)
47  {
48  cout << gc.name << ": np=" << gc.np ;
49 
50  if(gc.unit == "mm" || gc.unit == "m" || gc.unit == "cm")
51  {
52  cout << ", min=" << gc.min/cm << " cm"
53  << ", max=" << gc.max/cm << " cm";
54  }
55  if(gc.unit == "deg" || gc.unit == "rad" )
56  {
57  cout << ", min=" << gc.min/degree << " deg"
58  << ", max=" << gc.max/degree << " deg";
59  }
60 
61  cout << ", index speed=" << gc.speed << endl;
62  return stream;
63  }
64 };
65 
66 
67 
68 // define a mapped field
75 {
76  public:
77  gMappedField(string i, string s)
78  {
79  symmetry = s;
80  identifier = i;
81  mapOrigin[0] = 0;
82  mapOrigin[1] = 0;
83  mapOrigin[2] = 0;
84  scaleFactor = 1;
85  unit = "gauss";
86  interpolation = "none";
87  verbosity = 0;
88  }
90 
91  string symmetry;
92  string identifier;
93  vector<gcoord> coordinates;
94 
95  double mapOrigin[3];
96  double scaleFactor;
97  string unit;
98  string interpolation;
99  int verbosity;
100 
101  // field depending on 3D map
102  double ***B1_3D;
103  double ***B2_3D;
104  double ***B3_3D;
105 
106  // field depending on 2D map
107  double **B1_2D;
108  double **B2_2D;
109 
110  // these are initialized based on the map
111  // symmetry and coordinates
112  // it will avoid the time spend in retrieving
113  // the infos in GetFieldValue
114  double *startMap;
115  double *cellSize;
116  unsigned int *np;
117  void initializeMap();
118 
119  gcoord getCoordinateWithSpeed(int speed);
120  gcoord getCoordinateWithName(string name);
121 
122  // returns the field at point x. This is a dispatcher for the various symmetries below
123  void GetFieldValue( const double x[3], double *Bfield) const;
124 
125  void GetFieldValue_Dipole( const double x[3], double *Bfield, int FIRST_ONLY) const;
126  void GetFieldValue_Cylindrical( const double x[3], double *Bfield, int FIRST_ONLY) const;
127  void GetFieldValue_phiSegmented( const double x[3], double *Bfield, int FIRST_ONLY) const;
128 
129 };
130 
131 #endif
132 
133 
134 
135 
136 
137 
138 
int verbosity
map verbosity
Definition: mappedField.h:99
double * cellSize
Definition: mappedField.h:115
unsigned int np
Definition: mappedField.h:40
string unit
field unit in the map
Definition: mappedField.h:97
double verbosity
STL namespace.
string name
Definition: mappedField.h:39
gMappedField(string i, string s)
Definition: mappedField.h:77
unsigned int * np
Definition: mappedField.h:116
double *** B2_3D
Definition: mappedField.h:103
double scaleFactor
copy of the gfield scaleFactor
Definition: mappedField.h:96
double min
Definition: mappedField.h:41
double ** B1_2D
Definition: mappedField.h:107
double *** B3_3D
Definition: mappedField.h:104
gcoord(string nm, unsigned int n, double m, double M, string u, int s)
Definition: mappedField.h:28
double * startMap
Definition: mappedField.h:114
vector< gcoord > coordinates
Vector size depend on the symmetry.
Definition: mappedField.h:93
string interpolation
map interpolation technique. Choices are "none", "linear", "quadratic"
Definition: mappedField.h:98
double max
Definition: mappedField.h:42
double ** B2_2D
Definition: mappedField.h:108
string unit
Definition: mappedField.h:43
string symmetry
map symmetry
Definition: mappedField.h:91
int speed
Definition: mappedField.h:44
double *** B1_3D
Definition: mappedField.h:102
string identifier
Pointer to map in factory (for example, hostname / filename with path / date)
Definition: mappedField.h:92
friend ostream & operator<<(ostream &stream, gcoord gc)
Definition: mappedField.h:46