18#include "BDSBunchRing.hh"
20#include "BDSException.hh"
21#include "BDSParticleCoordsFull.hh"
22#include "BDSUtilities.hh"
24#include "parser/beam.h"
26#include "Randomize.hh"
27#include "CLHEP/Units/PhysicalConstants.h"
28#include "CLHEP/Units/SystemOfUnits.h"
33BDSBunchRing::BDSBunchRing():
44BDSBunchRing::~BDSBunchRing()
50 G4Transform3D beamlineTransformIn,
51 const G4double beamlineSIn)
54 rMin = beam.
Rmin * CLHEP::m;
55 rMax = beam.
Rmax * CLHEP::m;
68 {
throw BDSException(__METHOD_NAME__,
"Rmin: " + std::to_string(rMin) +
" < 0");}
70 {
throw BDSException(__METHOD_NAME__,
"Rmax: " + std::to_string(rMin) +
" < 0");}
72 {
throw BDSException(__METHOD_NAME__,
"Rmax: " + std::to_string(rMax) +
" < Rmin: " + std::to_string(rMin));}
74 {
throw BDSException(__METHOD_NAME__,
"Rpmin: " + std::to_string(
rpMin) +
" < 0");}
76 {
throw BDSException(__METHOD_NAME__,
"Rpmax: " + std::to_string(
rpMax) +
" < 0");}
78 {
throw BDSException(__METHOD_NAME__,
"Rpmax: " + std::to_string(
rpMin) +
" < Rpmin: " + std::to_string(
rpMin));}
80 {
throw BDSException(__METHOD_NAME__,
"Rpmin: " + std::to_string(
rpMin) +
" > 1");}
82 {
throw BDSException(__METHOD_NAME__,
"Rpmax: " + std::to_string(
rpMin) +
" > 1");}
87 G4double r = std::sqrt(G4RandFlat::shoot(std::pow(rMin,2), std::pow(rMax,2)));
88 G4double phi = 2 * CLHEP::pi * G4RandFlat::shoot();
89 G4double x =
X0 + r * std::sin(phi);
90 G4double y =
Y0 + r * std::cos(phi);
95 G4double rp = std::sqrt(G4RandFlat::shoot(std::pow(
rpMin,2), std::pow(
rpMax,2)));
96 xp += rp * std::sin(phi);
97 yp += rp * std::cos(phi);
99 else if (anyNonZeroRp)
101 xp += rpSingleValue * std::sin(phi);
102 yp += rpSingleValue * std::cos(phi);
virtual BDSParticleCoordsFull GetNextParticleLocal()
virtual void SetOptions(const BDSParticleDefinition *beamParticle, const GMAD::Beam &beam, const BDSBunchType &distrType, G4Transform3D beamlineTransformIn=G4Transform3D::Identity, const G4double beamlineS=0)
virtual void CheckParameters()
G4double rpMin
Used for a range of rp.
G4double rpMax
Used for a range of rp.
The base class for bunch distribution generators.
G4double Yp0
Centre of distributions.
G4double T0
Centre of distributions.
G4double S0
Centre of distributions.
G4double Z0
Centre of distributions.
G4double X0
Centre of distributions.
G4double Zp0
Centre of distributions.
G4double Xp0
Centre of distributions.
G4double E0
Centre of distributions.
G4double Y0
Centre of distributions.
virtual void SetOptions(const BDSParticleDefinition *beamParticle, const GMAD::Beam &beam, const BDSBunchType &distrType, G4Transform3D beamlineTransformIn=G4Transform3D::Identity, const G4double beamlineS=0)
static G4double CalculateZp(G4double xp, G4double yp, G4double Zp0)
Calculate zp safely based on other components.
virtual void CheckParameters()
General exception with possible name of object and message.
A set of particle coordinates including energy and weight.
Wrapper for particle definition.
Improve type-safety of native enum data type in C++.
double Rmax
for the ring beam distribution
double Rpmax
for the ring beam distribution
double Rpmin
for the ring beam distribution
double Rmin
for the ring beam distribution
G4bool IsFinite(G4double value, G4double tolerance=std::numeric_limits< double >::epsilon())