G4UniformElectricField.cc

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 // $Id: G4UniformElectricField.cc 69786 2013-05-15 09:38:51Z gcosmo $
00028 //
00029 // 
00030 //
00031 // Class for creation of uniform Electric Field
00032 //
00033 // 30.1.97 V.Grichine
00034 //
00035 // -------------------------------------------------------------------
00036 
00037 #include "G4UniformElectricField.hh"
00038 #include "G4PhysicalConstants.hh"
00039 
00040 G4UniformElectricField::G4UniformElectricField(const G4ThreeVector FieldVector )
00041 {
00042       fFieldComponents[0] = 0.0;
00043       fFieldComponents[1] = 0.0;
00044       fFieldComponents[2] = 0.0;
00045       fFieldComponents[3] = FieldVector.x();
00046       fFieldComponents[4] = FieldVector.y();
00047       fFieldComponents[5] = FieldVector.z();
00048 }
00049    
00050 G4UniformElectricField::G4UniformElectricField(G4double vField,
00051                                                G4double vTheta,
00052                                                G4double vPhi    )
00053 {
00054    if ( (vField<0) || (vTheta<0) || (vTheta>pi) || (vPhi<0) || (vPhi>twopi) )
00055    {
00056       G4Exception("G4UniformElectricField::G4UniformElectricField()",
00057                   "GeomField0002", FatalException, "Invalid parameters.");
00058    }
00059 
00060    fFieldComponents[0] = 0.0;
00061    fFieldComponents[1] = 0.0;
00062    fFieldComponents[2] = 0.0;
00063    fFieldComponents[3] = vField*std::sin(vTheta)*std::cos(vPhi) ;
00064    fFieldComponents[4] = vField*std::sin(vTheta)*std::sin(vPhi) ;
00065    fFieldComponents[5] = vField*std::cos(vTheta) ;
00066 }
00067 
00068 G4UniformElectricField::~G4UniformElectricField()
00069 {
00070 }
00071 
00072 G4UniformElectricField::G4UniformElectricField (const G4UniformElectricField &p)
00073    : G4ElectricField(p)
00074 {
00075    for (G4int i=0; i<6; i++)
00076       fFieldComponents[i] = p.fFieldComponents[i];
00077 }
00078 
00079 G4UniformElectricField&
00080 G4UniformElectricField::operator = (const G4UniformElectricField &p)
00081 {
00082    for (G4int i=0; i<6; i++)
00083       fFieldComponents[i] = p.fFieldComponents[i];
00084    return *this;
00085 }
00086 
00087 // ------------------------------------------------------------------------
00088 
00089 void G4UniformElectricField::GetFieldValue (const G4double[4],
00090                                             G4double *fieldBandE ) const 
00091 {
00092    fieldBandE[0]= 0.0;
00093    fieldBandE[1]= 0.0;
00094    fieldBandE[2]= 0.0;
00095    fieldBandE[3]= fFieldComponents[3] ;
00096    fieldBandE[4]= fFieldComponents[4] ;
00097    fieldBandE[5]= fFieldComponents[5] ;
00098 }

Generated on Mon May 27 17:50:07 2013 for Geant4 by  doxygen 1.4.7