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