20#include "BDSFieldMagUndulator.hh"
21#include "BDSMagnetStrength.hh"
22#include "BDSUtilities.hh"
25#include "G4ThreeVector.hh"
27#include "CLHEP/Units/PhysicalConstants.h"
28#include "CLHEP/Units/SystemOfUnits.h"
33 G4double beamPipeRadiusIn):
34 beamPipeRadius(beamPipeRadiusIn)
36 wavenumber = (CLHEP::twopi)/(*strength)[
"length"];
37 B = (*strength)[
"field"];
41 G4cout << __METHOD_NAME__ <<
"B = " << B << G4endl;
42 G4cout << __METHOD_NAME__ <<
"B_limit = " << limit << G4endl;
47 const G4double )
const
52 {
return G4ThreeVector(0,0,0);}
54 G4double yFactor = std::cosh(position.y() *
wavenumber);
57 G4double zFactor = std::sinh(position.y() *
wavenumber);
62 field[1] =
B * std::cos(position.z() *
wavenumber) * yFactor;
63 field[2] = -
B * std::sin(position.z() *
wavenumber) * zFactor;
67 if (field[1] >
limit || std::isnan(field[1]))
69 if (field[2] >
limit || std::isnan(field[2]))
G4double wavenumber
The undulator wavenumber.
BDSFieldMagUndulator()
Private default constructor to force use of supplied constructor.
G4double beamPipeRadius
Cache of beam pipe radius to know maximum valid extent of field.
virtual G4ThreeVector GetField(const G4ThreeVector &position, const G4double t=0) const
Access the field value.
G4double B
The peak field.
Efficient storage of magnet strengths.
G4bool IsFinite(G4double value, G4double tolerance=std::numeric_limits< double >::epsilon())