00001
00002 #ifndef myMultipoleField_h
00003 #define myMultipoleField_h 1
00004
00005
00006
00007
00008 #include <vector>
00009 #include <utility>
00010 #include <iostream>
00011
00012
00013 #include<complex>
00014
00015
00016
00017 #include"G4ThreeVector.hh"
00018 #include "globals.hh"
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 typedef complex<G4double> Complex;
00040 typedef G4ThreeVector Vector3D;
00041 typedef G4ThreeVector Point3D;
00042
00043 class myMultipoleField
00044 {
00045 public:
00046
00047 typedef std::vector<Complex > TermExpansion;
00048
00049
00050 typedef TermExpansion::iterator iterator;
00051
00052 typedef TermExpansion::const_iterator const_iterator;
00053
00054 public:
00055 myMultipoleField (G4double scale, size_t nt = 0);
00056 myMultipoleField (int np, G4double bn, G4double an, G4double r0);
00057
00058 myMultipoleField (int np, G4double bn, G4double r0, bool skew = false);
00059 myMultipoleField (int np, G4double bn, bool skew = false);
00060
00061
00062
00063
00064
00065 G4double GetFieldScale () const;
00066
00067
00068
00069 void SetFieldScale (G4double scale);
00070
00071
00072 bool IsNullField () const;
00073
00074
00075
00076
00077
00078
00079 Complex GetKn (int np, G4double rigidity) const;
00080
00081
00082
00083
00084
00085
00086
00087
00088 Complex GetField2D (G4double x, G4double y, int exclude = -1) const;
00089
00090
00091
00092 G4double* GetBFieldAt (const G4double* x,
00093 G4double t = 0) const;
00094
00095
00096 Vector3D GetEFieldAt (const Point3D& x, G4double t = 0) const;
00097
00098
00099
00100
00101
00102 virtual Vector3D GetForceAt (const Point3D& x,
00103 const Vector3D& v, G4double q, G4double t = 0) const;
00104
00105
00106
00107 void RotateY180 ();
00108
00109
00110
00111 void PrintField (std::ostream& os) const;
00112
00113
00114
00115
00116 void SetComponent (int np, G4double bn, G4double an = 0, G4double r0 = 1);
00117
00118
00119
00120 Complex GetComponent (int np, G4double r0 = 1.0) const;
00121
00122
00123
00124
00125 Complex GetCoefficient (int np, G4double r0 = 1.0) const;
00126
00127
00128
00129
00130 void SetCoefficient (int np, const Complex& b, G4double r0 = 1.0);
00131
00132 int HighestMultipole () const;
00133
00134 protected:
00135 private:
00136
00137
00138
00139
00140
00141 G4double B0;
00142 TermExpansion expansion;
00143
00144 private:
00145 };
00146
00147
00148
00149 inline myMultipoleField::myMultipoleField (G4double scale, size_t nt)
00150 : B0(scale),expansion(nt,Complex(0,0)){}
00151
00152 inline bool myMultipoleField::IsNullField () const
00153 {
00154 return B0==0;
00155 }
00156
00157 inline int myMultipoleField::HighestMultipole () const
00158 {
00159 return expansion.size()-1;
00160 }
00161
00162
00163 #endif
00164