Warning, file /include/Geant4/G4TUniformMagneticField.hh was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027 #ifndef G4UniformMagneticField_HH
0028 #define G4UniformMagneticField_HH
0029
0030 #include "G4Types.hh"
0031 #include "G4ThreeVector.hh"
0032 #include "G4MagneticField.hh"
0033
0034 class G4TUniformMagneticField : public G4MagneticField
0035 {
0036 public:
0037
0038 G4TUniformMagneticField(const G4ThreeVector& FieldVector )
0039
0040 {
0041 fFieldComponents[0] = FieldVector.x();
0042 fFieldComponents[1] = FieldVector.y();
0043 fFieldComponents[2] = FieldVector.z();
0044 }
0045
0046
0047 G4TUniformMagneticField(G4double vField,
0048 G4double vTheta,
0049 G4double vPhi )
0050 {
0051 if ( (vField<0) || (vTheta<0) || (vTheta>pi) || (vPhi<0) || (vPhi>twopi) )
0052 {
0053 G4Exception("G4TUniformMagneticField::G4TUniformMagneticField()",
0054 "GeomField0002", FatalException, "Invalid parameters.") ;
0055 }
0056 fFieldComponents[0] = vField*std::sin(vTheta)*std::cos(vPhi) ;
0057 fFieldComponents[1] = vField*std::sin(vTheta)*std::sin(vPhi) ;
0058 fFieldComponents[2] = vField*std::cos(vTheta) ;
0059 }
0060
0061 virtual ~G4TUniformMagneticField() {;}
0062
0063 G4TUniformMagneticField(const G4TUniformMagneticField &p)
0064 : G4MagneticField(p)
0065 {
0066 for (G4int i=0; i<3; ++i)
0067 fFieldComponents[i] = p.fFieldComponents[i];
0068 }
0069
0070 G4TUniformMagneticField& operator = (const G4TUniformMagneticField &p)
0071
0072 {
0073 if (&p == this) return *this;
0074 for (G4int i=0; i<3; ++i)
0075 fFieldComponents[i] = p.fFieldComponents[i];
0076 return *this;
0077 }
0078
0079 inline void GetFieldValue(const G4double yTrack[4],
0080 G4double *B) const
0081 {
0082 B[0]= fFieldComponents[0] ;
0083 B[1]= fFieldComponents[1] ;
0084 B[2]= fFieldComponents[2] ;
0085 }
0086
0087 void SetFieldValue(const G4ThreeVector& newFieldVector)
0088 {
0089 fFieldComponents[0] = newFieldVector.x();
0090 fFieldComponents[1] = newFieldVector.y();
0091 fFieldComponents[2] = newFieldVector.z();
0092 }
0093
0094 G4ThreeVector GetConstantFieldValue() const
0095 {
0096 G4ThreeVector B(fFieldComponents[0],
0097 fFieldComponents[1],
0098 fFieldComponents[2]);
0099 return B;
0100 }
0101
0102
0103 virtual G4TUniformMagneticField* Clone() const
0104 {
0105 return new G4TUniformMagneticField( G4ThreeVector(this->fFieldComponents[0],
0106 this->fFieldComponents[1],
0107 this->fFieldComponents[2]) );
0108 }
0109
0110 private:
0111 G4double fFieldComponents[3] ;
0112 };
0113
0114 #endif