Geant4 Cross Reference |
>> 1 // This code implementation is the intellectual property of >> 2 // the GEANT4 collaboration. 1 // 3 // 2 // ******************************************* << 4 // By copying, distributing or modifying the Program (or any work 3 // * License and Disclaimer << 5 // based on the Program) you indicate your acceptance of this statement, 4 // * << 6 // and all its terms. 5 // * The Geant4 software is copyright of th << 6 // * the Geant4 Collaboration. It is provided << 7 // * conditions of the Geant4 Software License << 8 // * LICENSE and available at http://cern.ch/ << 9 // * include a list of copyright holders. << 10 // * << 11 // * Neither the authors of this software syst << 12 // * institutes,nor the agencies providing fin << 13 // * work make any representation or warran << 14 // * regarding this software system or assum << 15 // * use. Please see the license in the file << 16 // * for the full disclaimer and the limitatio << 17 // * << 18 // * This code implementation is the result << 19 // * technical work of the GEANT4 collaboratio << 20 // * By using, copying, modifying or distri << 21 // * any work based on the software) you ag << 22 // * use in resulting scientific publicati << 23 // * acceptance of all terms of the Geant4 Sof << 24 // ******************************************* << 25 // 7 // 26 // G4UniformElectricField implementation << 8 // $Id: G4UniformElectricField.cc,v 1.2 1999/12/15 14:49:50 gunter Exp $ >> 9 // GEANT4 tag $Name: geant4-03-00 $ >> 10 // >> 11 // >> 12 // >> 13 // Class for creation of uniform Electric Field >> 14 // >> 15 // 30.1.97 V.Grichine 27 // 16 // 28 // Created: V.Grichine, 30.01.1997 << 29 // ------------------------------------------- << 30 << 31 #include "G4UniformElectricField.hh" 17 #include "G4UniformElectricField.hh" 32 #include "G4PhysicalConstants.hh" << 18 #include "globals.hh" >> 19 #include "geomdefs.hh" 33 20 34 G4UniformElectricField:: << 21 G4UniformElectricField::G4UniformElectricField(const G4ThreeVector FieldVector ) 35 G4UniformElectricField(const G4ThreeVector& Fi << 36 { 22 { 37 fFieldComponents[0] = 0.0; << 23 fFieldComponents[3] = FieldVector.x(); 38 fFieldComponents[1] = 0.0; << 24 fFieldComponents[4] = FieldVector.y(); 39 fFieldComponents[2] = 0.0; << 25 fFieldComponents[5] = FieldVector.z(); 40 fFieldComponents[3] = FieldVector.x(); << 41 fFieldComponents[4] = FieldVector.y(); << 42 fFieldComponents[5] = FieldVector.z(); << 43 } 26 } 44 27 45 G4UniformElectricField::G4UniformElectricField 28 G4UniformElectricField::G4UniformElectricField(G4double vField, 46 << 29 G4double vTheta, 47 << 30 G4double vPhi ) 48 { 31 { 49 if ( (vField<0) || (vTheta<0) || (vTheta>pi << 32 if(vField >= 0 && >> 33 vTheta >= 0 && vTheta <= pi && >> 34 vPhi >= 0 && vPhi <= twopi) 50 { 35 { 51 G4Exception("G4UniformElectricField::G4U << 36 fFieldComponents[3] = vField*sin(vTheta)*cos(vPhi) ; 52 "GeomField0002", FatalExcept << 37 fFieldComponents[4] = vField*sin(vTheta)*sin(vPhi) ; >> 38 fFieldComponents[5] = vField*cos(vTheta) ; >> 39 } >> 40 else >> 41 { >> 42 G4Exception("Invalid parameters in G4UniformElectricField::G4UniformElectricField") ; 53 } 43 } 54 << 55 fFieldComponents[0] = 0.0; << 56 fFieldComponents[1] = 0.0; << 57 fFieldComponents[2] = 0.0; << 58 fFieldComponents[3] = vField*std::sin(vThet << 59 fFieldComponents[4] = vField*std::sin(vThet << 60 fFieldComponents[5] = vField*std::cos(vThet << 61 } 44 } 62 45 63 G4UniformElectricField::~G4UniformElectricFiel << 46 G4UniformElectricField::~G4UniformElectricField() >> 47 { >> 48 ; >> 49 } 64 50 65 G4UniformElectricField:: << 51 G4UniformElectricField::G4UniformElectricField (const G4UniformElectricField &p) 66 G4UniformElectricField (const G4UniformElectri << 67 : G4ElectricField(p) << 68 { 52 { 69 for (auto i=0; i<6; ++i) << 53 for (G4int i=3; i<6; i++) 70 { << 54 fFieldComponents[i] = p.fFieldComponents[i]; 71 fFieldComponents[i] = p.fFieldComponents[ << 72 } << 73 } 55 } 74 56 75 G4UniformElectricField& << 57 G4UniformElectricField& G4UniformElectricField::operator = (const G4UniformElectricField &p) 76 G4UniformElectricField::operator = (const G4Un << 77 { 58 { 78 if (&p == this) { return *this; } << 59 for (G4int i=3; i<6; i++) 79 G4ElectricField::operator=(p); << 60 fFieldComponents[i] = p.fFieldComponents[i]; 80 for (auto i=0; i<6; ++i) << 61 return *this; 81 { << 82 fFieldComponents[i] = p.fFieldComponents[i << 83 } << 84 return *this; << 85 } << 86 << 87 G4Field* G4UniformElectricField::Clone() const << 88 { << 89 return new G4UniformElectricField( G4ThreeV << 90 << 91 << 92 } 62 } 93 63 94 // ------------------------------------------- 64 // ------------------------------------------------------------------------ 95 65 96 void G4UniformElectricField::GetFieldValue (co << 66 97 G4 << 67 void G4UniformElectricField::GetFieldValue (const G4double [3], >> 68 G4double E[3] ) const 98 { 69 { 99 fieldBandE[0] = 0.0; << 70 E[0]= fFieldComponents[3] ; 100 fieldBandE[1] = 0.0; << 71 E[1]= fFieldComponents[4] ; 101 fieldBandE[2] = 0.0; << 72 E[2]= fFieldComponents[5] ; 102 fieldBandE[3] = fFieldComponents[3]; << 73 return ; 103 fieldBandE[4] = fFieldComponents[4]; << 104 fieldBandE[5] = fFieldComponents[5]; << 105 } 74 } >> 75 106 76