31 using namespace Expressions;
69 "The \"BEAM\" statement defines data for the particles "
71 reference(1.0, Physics::
m_p *energy_scale, 1.0 * energy_scale) {
75 (
"PARTICLE",
"Name of particle to be used");
77 (
"MASS",
"Particle rest mass in GeV");
79 (
"CHARGE",
"Particle charge in proton charges");
81 (
"ENERGY",
"Particle energy in GeV");
83 (
"PC",
"Particle momentum in GeV/c");
87 (
"GAMMA",
"ENERGY / MASS");
91 (
"BCURRENT",
"Beam current in A (all bunches)");
93 (
"EX",
"Horizontal emittance");
95 (
"EY",
"Vertical emittance");
97 (
"ET",
"Longitudinal emittance");
101 (
"BFREQ",
"Beam frequency in MHz (all bunches)");
105 (
"NPART",
"Number of particles in bunch");
107 (
"NSLICE",
"Number of slices in bunch");
126 reference(parent->reference)
136 return dynamic_cast<Beam *
>(object) != 0;
141 return new Beam(name,
this);
154 throw OpalException(
"Beam::find()",
"Beam \"" + name +
"\" not found.");
227 static const char *names[] = {
228 "ELECTRON",
"PROTON",
"POSITRON",
"ANTIPROTON",
"CARBON",
"HMINUS",
"URANIUM",
"MUON",
"DEUTERON",
"XENON",
"H2P"
231 static const double masses[] = {
245 static const double charges[] = {
246 -1.0, 1.0, 1.0, -1.0, 12.0, -1.0, 35.0, -1.0, 1.0, 20.0, 1.0
248 const unsigned int numParticleNames = std::end(names) - std::begin(names);
251 for(
unsigned int i = 0; i < numParticleNames; ++ i) {
252 if(pName == names[i]) {
272 "\"GAMMA\" should be greater than 1.");
280 "\"ENERGY\" should be greater than \"MASS\".");
288 "\"PC\" should be greater than 0.");
310 os <<
"* ************* B E A M ************************************************************ " <<
std::endl;
315 <<
"* CHARGE " << (charge > 0 ?
'+' :
'-') <<
"e * " <<
std::abs(charge) <<
" \n"
319 os <<
"* ********************************************************************************** " <<
std::endl;
An expression defined as a reference to a scalar.
void setReal(Attribute &attr, double val)
Set real value.
void setEX(double)
Store emittance for mode 1.
virtual bool canReplaceBy(Object *object)
Test if replacement is allowed.
void setET(double)
Store emittance for mode 3.
PETE_TUTree< FnAbs, typename T::PETE_Expr_t > abs(const PETE_Expr< T > &l)
std::string getParticleName() const
Return Particle's name.
void define(Object *newObject)
Define a new object.
The base class for all OPAL definitions.
constexpr double m_hm
The H- rest mass in GeV.
double getMass() const
Return Particle's rest mass in GeV.
size_t getNumberOfSlices()
Return the number of slices.
constexpr double m_d
The deuteron rest mass in GeV.
The base class for all OPAL exceptions.
constexpr double m_u
The uranium rest mass in GeV.
double getCurrent() const
Return the beam current in A.
virtual void execute()
Check the BEAM data.
constexpr double m_p
The proton rest mass in GeV.
double getET() const
Return emittance for mode 3.
constexpr double m_mu
The muon rest mass in GeV.
std::vector< Attribute > itsAttr
The object attributes (see Attribute.hh).
double getEY() const
Return emittance for mode 2.
virtual void update()
Update the BEAM data.
static const double energy_scale
constexpr double m_e
The electron rest mass in GeV.
size_t getNumberOfParticles()
Return the number of (macro)particles.
static OpalData * getInstance()
const std::string & getOpalName() const
Return object name.
double getCharge() const
Return the charge number in elementary charge.
void setP(double p)
Set reference momentum.
Object attribute with an ``automatic'' scalar value.
void print(std::ostream &os) const
Print the object.
static Beam * find(const std::string &name)
Find named BEAM.
double getFrequency() const
Return the beam frequency in MHz.
void registerOwnership(const AttributeHandler::OwnerType &itsClass) const
void setE(double E)
Set reference energy.
double getEX() const
Return emittance for mode 1.
constexpr double m_h2p
The H2+ rest mass in GeV.
virtual Beam * clone(const std::string &name)
Make clone.
const PartData & getReference() const
Return the embedded CLASSIC PartData.
double getM() const
The constant mass per particle.
Object * find(const std::string &name)
Find entry.
The base class for all OPAL objects.
void setGamma(double gamma)
Set gamma.
void setOpalName(const std::string &name)
Set object name.
constexpr double m_xe
The xenon rest mass in GeV.
bool builtin
Built-in flag.
void setEY(double)
Store emittance for mode 2.
constexpr double m_c
The carbon rest mass in GeV.
double getReal(const Attribute &attr)
Return real value.
Attribute makeString(const std::string &name, const std::string &help)
Make string attribute.
Attribute makeReal(const std::string &name, const std::string &help)
Make real attribute.
Beam()
Exemplar constructor.
Inform & endl(Inform &inf)
std::string getString(const Attribute &attr)
Get string value.