40 using namespace Expressions;
62 double AttAdd(
double a,
double b)
69 "The \"LINE\" statement defines a beamline list.\n"
70 "\t<name> : line = (<list>)") {
72 (
"TYPE",
"Design type");
75 (
"L",
"Total length of line in m");
76 itsAttr[LENGTH].setReadOnly(
true);
79 (
"ORIGIN",
"The location of the particle source");
82 (
"ORIENTATION",
"The Tait-Bryan angles for the orientation of the particle source");
85 (
"X",
"The x-coordinate of the location of the particle source", 0);
88 (
"Y",
"The y-coordinate of the location of the particle source", 0);
91 (
"Z",
"The z-coordinate of the location of the particle source", 0);
94 (
"THETA",
"The rotation about the y-axis of the particle source", 0);
97 (
"PHI",
"The rotation about the x-axis of the particle source", 0);
100 (
"PSI",
"The rotation about the z-axis of the particle source", 0);
120 return new Line(name,
this);
128 std::copy(oldLine->begin(), oldLine->end(), std::back_inserter(*newLine));
169 line->push_front(first);
173 line->push_back(last);
201 attr->
parse(stat,
true);
203 attr->
parse(stat,
false);
212 if (origin.size() == 3) {
219 throw OpalException(
"Line::parse",
"Parameter origin is array of 3 values (x, y, z);\n" +
220 std::to_string(origin.size()) +
" values provided");
225 if (direction.size() == 3) {
226 const double &theta = direction[0];
227 const double &phi = direction[1];
228 const double &psi = direction[2];
237 throw OpalException(
"Line::parse",
"Parameter orientation is array of 3 values (theta, phi, psi);\n" +
238 std::to_string(direction.size()) +
" values provided");
262 !
itsAttr[THETA].defaultUsed() ||
274 for(FlaggedBeamline::const_iterator i = line->begin();
275 i != line->end(); ++i) {
276 const std::string name = i->getElement()->getName();
279 if(i->getReflectionFlag()) os <<
'-';
314 while(repeat-- > 0) {
316 for(FlaggedBeamline::reverse_iterator i = subLine->rbegin();
317 i != subLine->rend(); ++i) {
320 line->push_back(fep);
324 i != subLine->end(); ++i) {
326 line->push_back(fep);
332 std::string name =
parseString(stat,
"Line member expected.");
337 "Element \"" + name +
"\" is undefined.");
346 if(
Element *elem = dynamic_cast<Element *>(&*obj)) {
347 while(repeat-- > 0) {
350 line->push_back(member);
354 "Object \"" + name +
"\" cannot be a line member.");
367 if(oldElement != 0 && newElement != 0) {
An expression defined as a reference to a scalar.
bool integer(int &value)
Return signed integer.
Interface for basic beam line object.
Abstract interface for a stream of input tokens.
void setDefault()
Assign default value.
virtual void print(std::ostream &stream) const
Print the line.
The base class for all OPAL exceptions.
Tps< T > sin(const Tps< T > &x)
Sine.
virtual Attribute * findAttribute(const std::string &name)
Find an attribute by name.
virtual ElementBase * removeWrappers()
Return the design element.
void setRelativeFlag(bool flag)
virtual FlaggedBeamline * fetchLine() const
Return the embedded CLASSIC beam line.
A scalar expression with two scalar operands.
virtual const std::string & getName() const
Get element name.
A function of two U's returning a T.
std::vector< Attribute > itsAttr
The object attributes (see Attribute.hh).
virtual Line * clone(const std::string &name)
Make clone.
virtual Line * copy(const std::string &name)
Make complete copy.
void apply(const ObjectFunction &)
Apply a function to all objects.
void parseDelimiter(Statement &stat, char delim)
Test for one-character delimiter.
static OpalData * getInstance()
const std::string & getOpalName() const
Return object name.
Template class for beam lines.
virtual Object * makeTemplate(const std::string &name, TokenStream &is, Statement &stat)
Make a line template.
The base class for all OPAL elements.
A representation of an Object attribute.
void setOrigin3D(const Vector_t &ori)
virtual double getLength() const
Return line length.
Object attribute with an ``automatic'' scalar value.
Interface for statements.
Reference-counted pointer.
void setInitialDirection(const Quaternion &rot)
void registerOwnership(const AttributeHandler::OwnerType &itsClass) const
bool isValid() const
Test for validity.
std::vector< double > getRealArray(const Attribute &attr)
Get array value.
virtual Object * makeInstance(const std::string &name, Statement &, const Parser *)
Macro handler function.
void setElement(ElementBase *)
Assign new CLASSIC element.
Vektor< double, 3 > Vector_t
virtual ElementBase * copyStructure()
Make a structural copy.
bool isValid() const
Test for validity.
virtual void execute()
Apply the algorithm to the top-level beamline.
ElementBase * getElement() const
Return the embedded CLASSIC element.
The base class for all OPAL beam lines and sequences.
static Element * find(const std::string &name)
Find named Element.
void parseTemplate(TokenStream &is, Statement &stat)
Parse the line template.
An ``archetype'' for a OPAL beam line with arguments.
Object * find(const std::string &name)
Find entry.
The base class for all OPAL objects.
Tps< T > cos(const Tps< T > &x)
Cosine.
int increment()
Increment and return the occurrence counter.
virtual void parse(Statement &stat)
Parse the line object.
Attribute makeRealArray(const std::string &name, const std::string &help)
Create real array attribute.
Line()
Exemplar constructor.
void parseList(Statement &)
virtual void replace(Object *oldObject, Object *newObject)
Replace references.
std::string::iterator iterator
double getReal(const Attribute &attr)
Return real value.
std::string parseString(Statement &, const char msg[])
Parse string value.
Replace all references to named element by a new version.
bool delimiter(char c)
Test for delimiter.
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.
void parse(Statement &stat, bool eval)
Parse attribute.
Inform & endl(Inform &inf)
TBeamline< FlaggedElmPtr > FlaggedBeamline
A beam line with flagged elements.
A section of a beam line.
void setReflectionFlag(bool flag) const
Set reflection flag.