GEMC  2.2
Geant4 Monte-Carlo Framework
field.h
Go to the documentation of this file.
1 #ifndef FIELD_H
6 #define FIELD_H 1
7 
8 
9 
10 // The magnetic fields are self-descriptive, using an XML reader
11 // The maps are stored in several format.
12 // Each format corresponds to a gfield factory. Example: ASCII, EVIO.
13 //
14 // At start time gemc loads a map<string, string> looking for
15 // eligible field definitions. Value is the factory type.
16 // Each gfield factory will then produce a map<string, gfield>
17 // from this list, based on the file format.
18 //
19 // The gfield is loaded in the map if the header of
20 // the file is understood and provides a valid gfield description
21 //
22 // At detector construction time the mfield entry in detector.h, if
23 // different than "no" must be associated to a key of the map<string, gfield>.
24 //
25 // At that point the MFM is checked on the gfield. If NULL, the MFM is created. Either way, the MFM will be
26 // associated with the logical volume.
27 
28 // gemc headers
29 #include "options.h"
30 #include "mappedField.h"
31 // forward declaration of fieldFactory
32 class fieldFactory;
33 
34 // C++ headers
35 #include <string>
36 using namespace std;
37 
38 // G4 headers
39 #include "G4FieldManager.hh"
40 #include "G4MagIntegratorStepper.hh"
41 #include "G4Mag_UsualEqRhs.hh"
42 
43 // CLHEP units
44 #include "CLHEP/Units/PhysicalConstants.h"
45 using namespace CLHEP;
46 
47 
52 class gfield
53 {
54  public:
55  gfield(){;}
57  {
58  // initialize Magnetic Field Manager and Mapped field to NULL
59  MFM = NULL;
60  map = NULL;
61  symmetry = "na";
62  format = "na";
63  dimensions = "na";
64  scaleFactor = 1;
65  minStep = 0.1*mm;
66  integration = "ClassicalRK4";
67  verbosity = opts.optMap["FIELD_VERBOSITY"].arg;
68  }
69  ~gfield(){}
70 
71  public:
72  string name;
73  string symmetry;
74  string format;
75  string factory;
76  string description;
77  string dimensions;
78  string integration;
79  double verbosity;
80  double minStep;
81  string unit;
82 
83  // Scale factor is set from options
84  double scaleFactor;
85  void initialize(goptions);
86 
87  // creates simple magnetic field manager (uniform fields, etc)
88  void create_simple_MFM();
89  void create_simple_multipole_MFM();
90 
91  // mapped Field. We need to factory to load the map
94 
95  private:
96  G4FieldManager *MFM;
97  void create_MFM();
98 
99  public:
100  // Returns Magnetic Field Manager Pointer
101  // creates one if it doesn't exist
102  G4FieldManager* get_MFM()
103  {
104  if(MFM == NULL)
105  create_MFM();
106 
107  return MFM;
108  }
109 
111  friend ostream &operator<<(ostream &stream, gfield gf);
112 
113 };
114 
115 
116 // creates custom integrator based on the equation
117 G4MagIntegratorStepper *createStepper(string sname, G4Mag_UsualEqRhs *iE);
118 
119 
120 #endif
string description
Field Description.
Definition: field.h:76
gMappedField * map
Mapped Field.
Definition: field.h:92
gfield()
Definition: field.h:55
ostream & operator<<(ostream &stream, detector Detector)
Definition: detector.cc:1071
double verbosity
STL namespace.
string integration
Integration Method.
Definition: field.h:78
G4MagIntegratorStepper * createStepper(string sname, G4Mag_UsualEqRhs *iE)
Definition: field.cc:100
string format
Field format (available: simple (for uniform) and map)
Definition: field.h:74
string symmetry
Field symmetry.
Definition: field.h:73
G4FieldManager * get_MFM()
Overloaded "<<" for gfield class. Dumps infos on screen.
Definition: field.h:102
~gfield()
Definition: field.h:69
string name
Field name - used as key in the map<string, gfield>
Definition: field.h:72
gfield(goptions opts)
Definition: field.h:56
map< string, aopt > optMap
Options map.
Definition: options.h:71
string dimensions
Field dimensions (with units), for non-mapped fields.
Definition: field.h:77
string factory
Field factory (format of magnetic field)
Definition: field.h:75
double verbosity
Log verbosity.
Definition: field.h:79
Definition: field.h:52
fieldFactory * fFactory
fieldFactory that created the field
Definition: field.h:93
double minStep
Minimum Step for the G4ChordFinder.
Definition: field.h:80
string unit
Field Unit.
Definition: field.h:81
double scaleFactor
Definition: field.h:84