BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
__w
bdsim
bdsim
src
BDSFieldMagMuonSpoiler.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 "BDSDebug.hh"
19
#include "BDSFieldMagMuonSpoiler.hh"
20
#include "BDSMagnetStrength.hh"
21
#include "BDSUtilities.hh"
22
23
#include "globals.hh"
24
#include "G4ThreeVector.hh"
25
26
#include <cmath>
27
28
BDSFieldMagMuonSpoiler::BDSFieldMagMuonSpoiler(
BDSMagnetStrength
const
* strength,
29
G4double
const
/*brho*/
)
30
{
31
bField = (*strength)[
"field"
];
32
finiteStrength
=
BDS::IsFinite
(bField);
33
#ifdef BDSDEBUG
34
G4cout << __METHOD_NAME__ <<
"B = "
<< bField << G4endl;
35
#endif
36
}
37
38
G4ThreeVector
BDSFieldMagMuonSpoiler::GetField
(
const
G4ThreeVector &position,
39
const
G4double
/*t*/
)
const
40
{
41
G4double x = position.x();
42
G4double y = position.y();
43
G4double r = std::hypot(std::abs(x), std::abs(y));
44
45
G4ThreeVector localField;
46
G4double cyor = y/r;
47
if
(std::isnan(cyor))
48
{cyor = 0;}
49
G4double cxor = -x/r;
50
if
(std::isnan(cxor))
51
{cxor = 0;}
52
localField[0] = cyor * bField;
53
localField[1] = cxor * bField;
54
localField[2] = 0;
55
56
return
localField;
57
}
BDSFieldMagMuonSpoiler::GetField
virtual G4ThreeVector GetField(const G4ThreeVector &position, const G4double t=0) const
Access the field value.
Definition
BDSFieldMagMuonSpoiler.cc:38
BDSFieldMag::finiteStrength
G4bool finiteStrength
Flag to cache whether finite nor not.
Definition
BDSFieldMag.hh:82
BDSMagnetStrength
Efficient storage of magnet strengths.
Definition
BDSMagnetStrength.hh:44
BDS::IsFinite
G4bool IsFinite(G4double value, G4double tolerance=std::numeric_limits< double >::epsilon())
Definition
BDSUtilities.cc:329
Generated on Thu Nov 12 2026 21:37:00 for BDSIM by
1.9.8