GEMC  2.3
Geant4 Monte-Carlo Framework
mappedField.cc
Go to the documentation of this file.
1 // gemc include
2 #include "mappedField.h"
3 
4 
5 
6 void gMappedField::GetFieldValue( const double point[3], double *Bfield) const
7 {
8  static int FIRST_ONLY;
9 
10  double Point[3];
11  Point[0] = point[0] - mapOrigin[0];
12  Point[1] = point[1] - mapOrigin[1];
13  Point[2] = point[2] - mapOrigin[2];
14 
15  Bfield[0] = Bfield[1] = Bfield[2] = 0;
16 
17  // dipole field
18  if(symmetry == "dipole-x" || symmetry == "dipole-y" || symmetry == "dipole-z")
19  GetFieldValue_Dipole(Point, Bfield, FIRST_ONLY);
20 
21  // phi-symmetric cylindrical field
22  if(symmetry == "cylindrical-x" || symmetry == "cylindrical-y" || symmetry == "cylindrical-z")
23  GetFieldValue_Cylindrical(Point, Bfield, FIRST_ONLY);
24 
25  // phi-segmented
26  if(symmetry == "phi-segmented")
27  GetFieldValue_phiSegmented(Point, Bfield, FIRST_ONLY);
28 
29  if(verbosity == 99)
30  FIRST_ONLY = 99;
31 
32 }
33 
34 
35 
36 
37 
39 {
40  gcoord dummy("na", 0, 0, 0, "na", 0);
41 
42  for(unsigned int i=0; i<coordinates.size(); i++)
43  if(coordinates[i].speed == speed) return coordinates[i];
44 
45  return dummy;
46 }
47 
48 
50 {
51  gcoord dummy("na", 0, 0, 0, "na", 0);
52 
53  for(unsigned int i=0; i<coordinates.size(); i++)
54  if(coordinates[i].name == name) return coordinates[i];
55 
56  return dummy;
57 }
58 
59 
60 
62 {
63  // startMap and cellSize and np class member variables
64  // are ordered and stored as pointers in order to speed up GetFieldValue
65 
66  // dipole field
67  // first index is longitudinal
68  if(symmetry == "dipole-x" || symmetry == "dipole-y" || symmetry == "dipole-z")
69  {
70  startMap = new double[2];
71  cellSize = new double[2];
72  np = new unsigned int[2];
73 
74  np[0] = getCoordinateWithName("longitudinal").np;
75  np[1] = getCoordinateWithName("transverse").np;
76  startMap[0] = getCoordinateWithName("longitudinal").min;
77  startMap[1] = getCoordinateWithName("transverse").min;
78  cellSize[0] = (getCoordinateWithName("longitudinal").max - startMap[0]) / (np[0] - 1);
79  cellSize[1] = (getCoordinateWithName("transverse").max - startMap[1]) / (np[1] - 1);
80  }
81 
82  // phi-symmetric cylindrical field
83  // first index is transverse
84  if(symmetry == "cylindrical-x" || symmetry == "cylindrical-y" || symmetry == "cylindrical-z")
85  {
86  startMap = new double[2];
87  cellSize = new double[2];
88  np = new unsigned int[2];
89 
90  np[0] = getCoordinateWithName("transverse").np;
91  np[1] = getCoordinateWithName("longitudinal").np;
92  startMap[0] = getCoordinateWithName("transverse").min;
93  startMap[1] = getCoordinateWithName("longitudinal").min;
94  cellSize[0] = (getCoordinateWithName("transverse").max - startMap[0]) / (np[0] - 1);
95  cellSize[1] = (getCoordinateWithName("longitudinal").max - startMap[1]) / (np[1] - 1);
96  }
97 
98  // phi-segmented cylindrical field
99  // first index is transverse
100  if(symmetry == "phi-segmented")
101  {
102  startMap = new double[3];
103  cellSize = new double[3];
104  np = new unsigned int[3];
105 
106  np[0] = getCoordinateWithName("azimuthal").np;
107  np[1] = getCoordinateWithName("transverse").np;
108  np[2] = getCoordinateWithName("longitudinal").np;
109  startMap[0] = getCoordinateWithName("azimuthal").min;
110  startMap[1] = getCoordinateWithName("transverse").min;
111  startMap[2] = getCoordinateWithName("longitudinal").min;
112  cellSize[0] = (getCoordinateWithName("azimuthal").max - startMap[0]) / (np[0] - 1);
113  cellSize[1] = (getCoordinateWithName("transverse").max - startMap[1]) / (np[1] - 1);
114  cellSize[2] = (getCoordinateWithName("longitudinal").max - startMap[2]) / (np[2] - 1);
115  }
116 
117 }
118 
119 
120 
121 
122 
123 
double mapOrigin[3]
Displacement of map. This is used in GetFieldValue.
Definition: mappedField.h:95
gcoord getCoordinateWithName(string name)
return coordinate based on type
Definition: mappedField.cc:49
int verbosity
map verbosity
Definition: mappedField.h:99
double * cellSize
Definition: mappedField.h:115
unsigned int np
Definition: mappedField.h:40
unsigned int * np
Definition: mappedField.h:116
double min
Definition: mappedField.h:41
void GetFieldValue_Dipole(const double x[3], double *Bfield, int FIRST_ONLY) const
Definition: dipole.cc:118
void initializeMap()
Definition: mappedField.cc:61
double * startMap
Definition: mappedField.h:114
vector< gcoord > coordinates
Vector size depend on the symmetry.
Definition: mappedField.h:93
void GetFieldValue(const double x[3], double *Bfield) const
Definition: mappedField.cc:6
double max
Definition: mappedField.h:42
gcoord getCoordinateWithSpeed(int speed)
return coordinate based on speed
Definition: mappedField.cc:38
void GetFieldValue_Cylindrical(const double x[3], double *Bfield, int FIRST_ONLY) const
Definition: cylindrical.cc:124
void GetFieldValue_phiSegmented(const double x[3], double *Bfield, int FIRST_ONLY) const
string symmetry
map symmetry
Definition: mappedField.h:91