35 using namespace Expressions;
57 "The \"BEAM\" statement defines data for the particles "
62 (
"PARTICLE",
"Name of particle to be used",
77 (
"MASS",
"Particle rest mass [GeV]");
80 (
"CHARGE",
"Particle charge in proton charges");
83 (
"ENERGY",
"Particle energy [GeV]");
86 (
"PC",
"Particle momentum [GeV/c]");
89 (
"GAMMA",
"ENERGY / MASS");
92 (
"BCURRENT",
"Beam current [A] (all bunches)");
95 (
"BFREQ",
"Beam frequency [MHz] (all bunches)");
98 (
"NPART",
"Number of particles in bunch");
101 (
"MOMENTUMTOLERANCE",
102 "Fractional tolerance to deviations in the distribution "
103 "compared to the reference data at initialisation (default=1e-2). "
104 "If MOMENTUMTOLERANCE<=0, no tolerance checking is done.", 1
e-2);
123 reference(parent->reference)
133 return dynamic_cast<Beam*
>(object) != 0;
138 return new Beam(name,
this);
147 "The energy hasn't been set. "
148 "Set either \"GAMMA\", \"ENERGY\" or \"PC\".");
153 "The beam particle hasn't been set. "
154 "Set either \"PARTICLE\" or \"MASS\" and \"CHARGE\".");
158 throw OpalException(
"Beam::execute()",
"\"NPART\" must be set.");
167 throw OpalException(
"Beam::find()",
"Beam \"" + name +
"\" not found.");
178 "Wrong number of particles in beam!. \"NPART\" must be positive");
239 "\"GAMMA\" should be greater than 1.");
247 "\"ENERGY\" should be greater than \"MASS\".");
255 "\"PC\" should be greater than 0.");
269 os <<
"* ************* B E A M ************************************************************ " <<
std::endl;
273 <<
"* CHARGE " << (charge > 0 ?
'+' :
'-') <<
"e * " <<
std::abs(charge) <<
" \n"
281 os <<
"* ********************************************************************************** " <<
std::endl;
void setMomentumTolerance(double tolerance)
Set the momentum tolerance.
Attribute makeReal(const std::string &name, const std::string &help)
Make real attribute.
static OpalData * getInstance()
bool builtin
Built-in flag.
void setOpalName(const std::string &name)
Set object name.
static ParticleType getParticleType(const std::string &str)
The base class for all OPAL objects.
void setReal(Attribute &attr, double val)
Set real value.
PETE_TBTree< FnCopysign, PETE_Scalar< Vektor< T1, Dim > >, typename T2::PETE_Expr_t > copysign(const Vektor< T1, Dim > &l, const PETE_Expr< T2 > &r)
std::string getString(const Attribute &attr)
Get string value.
PETE_TUTree< FnAbs, typename T::PETE_Expr_t > abs(const PETE_Expr< T > &l)
double getMassPerParticle() const
Mass per macro particle in GeV/c^2.
void define(Object *newObject)
Define a new object.
virtual Beam * clone(const std::string &name)
Make clone.
const PartData & getReference() const
Return the embedded CLASSIC PartData.
virtual void update()
Update the BEAM data.
void setP(double p)
Set reference momentum.
size_t getNumberOfParticles() const
Return the number of (macro)particles.
double getM() const
The constant mass per particle.
Inform & endl(Inform &inf)
std::string getParticleName() const
Return Particle's name.
void print(std::ostream &os) const
Print the object.
void registerOwnership(const AttributeHandler::OwnerType &itsClass) const
The base class for all OPAL exceptions.
Attribute makePredefinedString(const std::string &name, const std::string &help, const std::initializer_list< std::string > &predefinedStrings)
Make predefined string attribute.
constexpr double q_e
The elementary charge in As.
virtual void execute()
Check the BEAM data.
const std::string & getOpalName() const
Return object name.
static double getParticleCharge(const ParticleType &type)
std::vector< Attribute > itsAttr
The object attributes.
void setE(double E)
Set reference energy.
double getMass() const
Return Particle's rest mass in GeV.
static Beam * find(const std::string &name)
Find named BEAM.
double getChargePerParticle() const
Charge per macro particle in C.
double getReal(const Attribute &attr)
Return real value.
constexpr double m_p
The proton rest mass in GeV.
double getCurrent() const
Return the beam current in A.
The base class for all OPAL definitions.
Beam()
Exemplar constructor.
Object * find(const std::string &name)
Find entry.
constexpr double e
The value of .
static double getParticleMass(const ParticleType &type)
double getP() const
The constant reference momentum per particle.
we sometimes make exceptions for this Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally NO WARRANTY BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE
void setGamma(double gamma)
Set gamma.
virtual bool canReplaceBy(Object *object)
Test if replacement is allowed.
double getCharge() const
Return the charge number in elementary charge.
double getFrequency() const
Return the beam frequency in MHz.