19#include "BDSCavityInfo.hh"
21#include "BDSException.hh"
22#include "BDSFieldEMRFCavity.hh"
23#include "BDSMagnetStrength.hh"
24#include "BDSUtilities.hh"
26#include "CLHEP/Units/PhysicalConstants.h"
28#include "G4ThreeVector.hh"
42 (*strength)[
"frequency"],
44 (*strength)[
"equatorradius"])
46 eFieldMax *= BDS::Sign(brho);
52 G4double cavityRadiusIn):
53 eFieldMax(eFieldAmplitude),
55 cavityRadius(cavityRadiusIn),
56 wavelength(CLHEP::c_light / frequencyIn),
57 normalisedCavityRadius(j0FirstZero/cavityRadius),
58 angularFrequency(CLHEP::twopi * frequencyIn)
61 if (!
BDS::IsFinite(cavityRadiusIn) || std::isnan(normalisedCavityRadius) || std::isinf(normalisedCavityRadius))
62 {
throw BDSException(__METHOD_NAME__,
"no cavity radius supplied - required for pill box model");}
66 const G4double t)
const
69 G4double phi = std::atan2(position.y(),position.x());
70 G4double r = std::hypot(position.x(),position.y());
81 G4double J0r = TMath::BesselJ0(rNormalised);
82 G4double J1r = TMath::BesselJ1(rNormalised);
86 G4double Bmax = hMax * CLHEP::mu0;
89 G4double zFactor = std::cos(CLHEP::twopi*position.z() / wavelength);
94 G4TwoVector bxby(0,Bphi);
96 G4double Bx = bxby.x();
97 G4double By = bxby.y();
100 G4ThreeVector LocalB = G4ThreeVector(Bx, By, 0);
101 G4ThreeVector LocalE = G4ThreeVector(0, 0, Ez);
103 auto result = std::make_pair(LocalB, LocalE);
General exception with possible name of object and message.
Pill box cavity electromagnetic field.
virtual std::pair< G4ThreeVector, G4ThreeVector > GetField(const G4ThreeVector &position, const G4double t) const
Accessor to get B and E field.
const G4double angularFrequency
Angular frequency calculated from frequency - cached to avoid repeated calculation.
G4double phase
Phase offset of the oscillator.
BDSFieldEMRFCavity()
Private constructor to force use of provided one.
static const G4double j0FirstZero
X coordinate of first 0 point for bessel J0.
static const G4double Z0
Impedance of free space.
G4double eFieldMax
Maximum field in V/m.
const G4double normalisedCavityRadius
Pre-calculated normalised calculated radius w.r.t. bessel first 0.
Efficient storage of magnet strengths.
G4bool IsFinite(G4double value, G4double tolerance=std::numeric_limits< double >::epsilon())