G4HarmonicPolMagField.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: G4HarmonicPolMagField.cc 69786 2013-05-15 09:38:51Z gcosmo $
00028 //
00029 // -------------------------------------------------------------------
00030 
00031 #include "G4HarmonicPolMagField.hh"
00032 #include "globals.hh"
00033 
00034 G4HarmonicPolMagField::G4HarmonicPolMagField()
00035 {
00036 }
00037 
00039 
00040 G4HarmonicPolMagField::~G4HarmonicPolMagField()
00041 {
00042 }
00043 
00045 
00046 
00047 void G4HarmonicPolMagField::GetFieldValue(const G4double yTrack[7],
00048                                                 G4double B[3]     ) const  
00049 {
00050    G4int i ;
00051    G4double a = 1.00 ;   // mm -> m 
00052    G4double x = a*yTrack[0], y = a*yTrack[1], z = a*yTrack[2] ;
00053    G4double x2 = x*x, y2 = y*y, z2 = z*z ;
00054    G4double x3 = x2*x, y3 = y2*y, z3 = z2*z ;
00055    G4double xy = x*y, xz = x*z, yz = y*z, xyz = x*y*z ;
00056    static G4double
00057    c[24] = {
00058              .010, .010, .010,                                       // 3(0)
00059              .0001, .0001, .0001, .0001, .0001,                      // 5(1)
00060              .00001, .00001, .00001, .00001, .00001, .00001, .00001, // 7(2)
00061              .000001, .000001, .000001, .000001, .000001, .000001,
00062              .0000001, .0000001, .0000001                            // 9(3)
00063             } ;                                            // total :   24
00064    
00065    //   for(i=0;i<24;i++)
00066    //   {
00067    //      c[i] = 1.0*c[i] ;
00068    //   }
00069    B[0] =  c[1]
00070           -2*c[3]*x + c[4]*z +c[6]*y -2*c[7]*x
00071           -6*c[8]*xz + c[9]*(z2-x2) -2*c[10]*xy + c[11]*yz - 2*c[12]*xz
00072           +c[13]*(y2-x2) - 6*c[14]*xy
00073           -4*c[15]*(3*x*z2-x3) +c[16]*(z3-3*x2*z) - 6*c[17]*xyz +c[18]*y*(z2-x2)
00074           -2*c[19]*(x*z2+x*y2-2*x3/3) + c[20]*z*(y2-x2) - 6*c[21]*xyz
00075           +c[22]*(y3-3*x2*y) - 4*c[23]*(3*x*y2-x3) ;
00076    
00077    B[1] =  c[2]
00078           +c[5]*z + c[6]*x + 2*c[7]*y
00079           +c[10]*(z2-x2) + c[11]*xz +2*c[12]*yz +2*c[13]*xy + 3*c[14]*(y2-x2)
00080           +c[17]*(z3-3*x2*z) + c[18]*(x*z2-x3/3) +2*c[19]*y*(z2-x2)
00081           +2*c[20]*xyz
00082           +3*c[21]*z*(y2-x2) + c[22]*(3*x*y2-x3) + 4*c[23]*(y3-3*x2*y) ;
00083    
00084    B[2] =  c[0]
00085           +c[3]*z + c[4]*x + c[5]*y
00086           +3*c[8]*(z2-x2) + 2*c[9]*xz + 2*c[10]*yz + c[11]*xy + c[12]*(y2-x2)
00087           +4*c[15]*(z3-3*x2*z) + c[16]*(3*x*z2-x3) + 3*c[17]*(y*z2-x2*y)
00088           +2*c[18]*xyz
00089           +2*c[19]*z*(y2-x2) + c[20]*(x*y2-x3/3) + c[21]*(y3-3*x2*y) ;
00090    for(i=0;i<3;i++)
00091    {
00092       B[i] = 0.1*B[i] ;
00093    }
00094 }
00095 
00096 // -----------------------------------------------------------------

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