G4QuadrupoleMagField.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: G4QuadrupoleMagField.cc 69786 2013-05-15 09:38:51Z gcosmo $
00028 //
00029 // -------------------------------------------------------------------
00030 
00031 #include "G4QuadrupoleMagField.hh"
00032 #include "G4RotationMatrix.hh"
00033 
00034 static G4RotationMatrix IdentityMatrix; 
00035 
00036 G4QuadrupoleMagField::G4QuadrupoleMagField(G4double pGradient)
00037 {
00038 
00039    fGradient = pGradient ;
00040    fOrigin      = G4ThreeVector( 0.0, 0.0, 0.0) ;
00041    fpMatrix      = &IdentityMatrix;
00042 }
00043 
00045 
00046 G4QuadrupoleMagField::G4QuadrupoleMagField(G4double pGradient, G4ThreeVector
00047 pOrigin, G4RotationMatrix* pMatrix)
00048 {
00049    fGradient    = pGradient ;
00050    fOrigin      = pOrigin ;
00051    fpMatrix      = pMatrix ;
00052 }
00053 
00055 
00056 G4QuadrupoleMagField::~G4QuadrupoleMagField()
00057 {
00058 }
00059 
00061 //  Allow displaced origin and rotation 
00062 //  Extensions by Björn Riese (GSI)
00063 
00064 void G4QuadrupoleMagField::GetFieldValue( const G4double y[7],
00065                                                 G4double B[3]  ) const  
00066 {
00067 
00068    G4ThreeVector r_global = G4ThreeVector(
00069         y[0] - fOrigin.x(), 
00070         y[1] - fOrigin.y(), 
00071         y[2] - fOrigin.z());
00072 
00073    G4ThreeVector r_local = G4ThreeVector(
00074            fpMatrix->colX() * r_global,
00075            fpMatrix->colY() * r_global,
00076            fpMatrix->colZ() * r_global);
00077 
00078    G4ThreeVector B_local = G4ThreeVector(
00079            fGradient * r_local.y(),
00080         fGradient * r_local.x(),
00081         0);
00082 
00083    G4ThreeVector B_global = G4ThreeVector(
00084            fpMatrix->inverse().rowX() * B_local,
00085            fpMatrix->inverse().rowY() * B_local,
00086            fpMatrix->inverse().rowZ() * B_local);
00087 
00088    B[0] = B_global.x() ;
00089    B[1] = B_global.y() ;
00090    B[2] = B_global.z() ;
00091 }

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