BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
__w
bdsim
bdsim
src
BDSFieldMagDetectorSolenoid.cc
1
/*
2
Beam Delivery Simulation (BDSIM) Copyright (C) Royal Holloway,
3
University of London 2001 - 2024.
4
5
This file is part of BDSIM.
6
7
BDSIM is free software: you can redistribute it and/or modify
8
it under the terms of the GNU General Public License as published
9
by the Free Software Foundation version 3 of the License.
10
11
BDSIM is distributed in the hope that it will be useful, but
12
WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
GNU General Public License for more details.
15
16
You should have received a copy of the GNU General Public License
17
along with BDSIM. If not, see <http://www.gnu.org/licenses/>.
18
*/
19
#include "BDSFieldMagDetectorSolenoid.hh"
20
21
#include "globals.hh"
// geant4 types / globals
22
#include "G4ThreeVector.hh"
23
24
#include <cmath>
25
26
BDSFieldMagDetectorSolenoid::BDSFieldMagDetectorSolenoid(G4double BIn,
27
G4double BOut,
28
G4double radiusIn,
29
G4double radiusOut,
30
G4double zMin,
31
G4double zMax):
32
itsBIn(BIn),
33
itsBOut(BOut),
34
itsRadiusIn(radiusIn),
35
itsRadiusOut(radiusOut),
36
itsZMin(zMin),
37
itsZMax(zMax)
38
{;}
39
40
G4ThreeVector
BDSFieldMagDetectorSolenoid::GetField
(
const
G4ThreeVector &position,
41
const
G4double
/*t*/
)
const
42
{
43
G4ThreeVector result(0,0,0);
44
G4double zField = 0;
45
G4double localRad = std::hypot(position.y(),position.x());
46
47
if
( (position.z() > itsZMin) && (position.z() < itsZMax) )
48
{
49
if
(localRad<itsRadiusIn)
50
{zField = itsBIn;}
51
else
if
(localRad<itsRadiusOut)
52
{zField = itsBOut;}
53
else
54
{zField=0;}
55
}
56
else
57
{zField=0;}
58
59
result[2] = zField;
60
return
result;
61
}
62
63
64
BDSFieldMagDetectorSolenoid::GetField
virtual G4ThreeVector GetField(const G4ThreeVector &position, const G4double t=0) const
Get the magnetic field vector in local coordinates.
Definition
BDSFieldMagDetectorSolenoid.cc:40
Generated on Sat Oct 18 2025 18:31:04 for BDSIM by
1.9.8