/scratch0/jsnuveri/BDSIM/BDSIMgit/bdsim/src/BDSMuSpoilerMagField.cc

00001 /* BDSIM code.    Version 1.0
00002    Author: Grahame A. Blair, Royal Holloway, Univ. of London.
00003    Last modified 12.12.2004
00004    Copyright (c) 2004 by G.A.Blair.  ALL RIGHTS RESERVED. 
00005 */
00006 #include "BDSGlobalConstants.hh" 
00007 
00008 #include "globals.hh"
00009 #include "BDSMuSpoilerMagField.hh"
00010 #include "G4Navigator.hh"
00011 #include "G4TransportationManager.hh"
00012 
00013 BDSMuSpoilerMagField::BDSMuSpoilerMagField(G4double aField)
00014   :itsBField(aField)
00015 {
00016   MuSpoilerNavigator = new G4Navigator();
00017 }
00018 
00019 BDSMuSpoilerMagField::~BDSMuSpoilerMagField(){
00020   delete MuSpoilerNavigator;
00021 }
00022 
00023 void BDSMuSpoilerMagField::GetFieldValue(const G4double Point[4],
00024                                               G4double *Bfield ) const
00025 {
00026   G4ThreeVector GlobalPosition= G4ThreeVector( Point[0], Point[1], Point[2]);  
00027   MuSpoilerNavigator->SetWorldVolume(G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()->GetWorldVolume()); 
00028   MuSpoilerNavigator->LocateGlobalPointAndSetup(GlobalPosition);
00029 
00030   G4AffineTransform GlobalAffine=MuSpoilerNavigator->
00031     GetGlobalToLocalTransform();  
00032   G4ThreeVector LocalR=GlobalAffine.TransformPoint(GlobalPosition); 
00033 
00034   G4double LocalX = LocalR.x();
00035   G4double LocalY = LocalR.y();
00036   G4double LocalRadius = std::sqrt(LocalX*LocalX + LocalY*LocalY);
00037 
00038   Bfield[0]=  LocalY/LocalRadius * itsBField;
00039   Bfield[1]= -LocalX/LocalRadius * itsBField;
00040   Bfield[2]=0;
00041 }
00042 
00043 
00044 

Generated on 28 Jun 2015 for BDSIM by  doxygen 1.4.7