60 double AttAdd(
double a,
double b)
67 "The \"LINE\" statement defines a beamline list.\n"
68 "\t<name> : line = (<list>)") {
70 (
"TYPE",
"Design type");
73 (
"L",
"Total length of line in m");
74 itsAttr[LENGTH].setReadOnly(
true);
77 (
"ORIGIN",
"The location of the particle source");
80 (
"ORIENTATION",
"The Tait-Bryan angles for the orientation of the particle source");
83 (
"X",
"The x-coordinate of the location of the particle source", 0);
86 (
"Y",
"The y-coordinate of the location of the particle source", 0);
89 (
"Z",
"The z-coordinate of the location of the particle source", 0);
92 (
"THETA",
"The rotation about the y-axis of the particle source", 0);
95 (
"PHI",
"The rotation about the x-axis of the particle source", 0);
98 (
"PSI",
"The rotation about the z-axis of the particle source", 0);
126 std::copy(oldLine->begin(), oldLine->end(), std::back_inserter(*newLine));
167 line->push_front(first);
171 line->push_back(last);
199 attr->
parse(stat,
true);
201 attr->
parse(stat,
false);
210 if (origin.size() == 3) {
217 throw OpalException(
"Line::parse",
"Parameter origin is array of 3 values (x, y, z);\n" +
218 std::to_string(origin.size()) +
" values provided");
223 if (direction.size() == 3) {
224 const double &theta = direction[0];
225 const double &phi = direction[1];
226 const double &psi = direction[2];
235 throw OpalException(
"Line::parse",
"Parameter orientation is array of 3 values (theta, phi, psi);\n" +
236 std::to_string(direction.size()) +
" values provided");
260 !
itsAttr[THETA].defaultUsed() ||
272 for(FlaggedBeamline::const_iterator i = line->begin();
273 i != line->end(); ++i) {
274 const std::string
name = i->getElement()->getName();
277 if(i->getReflectionFlag()) os <<
'-';
312 while(repeat-- > 0) {
314 for(FlaggedBeamline::reverse_iterator i = subLine->rbegin();
315 i != subLine->rend(); ++i) {
318 line->push_back(fep);
322 i != subLine->end(); ++i) {
324 line->push_back(fep);
335 "Element \"" +
name +
"\" is undefined.");
345 while(repeat-- > 0) {
348 line->push_back(member);
352 "Object \"" +
name +
"\" cannot be a line member.");
365 if(oldElement != 0 && newElement != 0) {
TBeamline< FlaggedElmPtr > FlaggedBeamline
A beam line with flagged elements.
Tps< T > cos(const Tps< T > &x)
Cosine.
Tps< T > sin(const Tps< T > &x)
Sine.
Inform & endl(Inform &inf)
Representation objects and parsers for attribute expressions.
std::string parseString(Statement &, const char msg[])
Parse string value.
void parseDelimiter(Statement &stat, char delim)
Test for one-character delimiter.
double getReal(const Attribute &attr)
Return real value.
Attribute makeReal(const std::string &name, const std::string &help)
Make real attribute.
Attribute makeRealArray(const std::string &name, const std::string &help)
Create real array attribute.
std::vector< double > getRealArray(const Attribute &attr)
Get array value.
Attribute makeString(const std::string &name, const std::string &help)
Make string attribute.
std::string::iterator iterator
A representation of an Object attribute.
void setDefault()
Assign default value.
void parse(Statement &stat, bool eval)
Parse attribute.
The base class for all OPAL beam lines and sequences.
static Element * find(const std::string &name)
Find named Element.
ElementBase * getElement() const
Return the embedded CLASSIC element.
void setElement(ElementBase *)
Assign new CLASSIC element.
The base class for all OPAL objects.
void registerOwnership(const AttributeHandler::OwnerType &itsClass) const
virtual Object * makeInstance(const std::string &name, Statement &, const Parser *)
Macro handler function.
const std::string & getOpalName() const
Return object name.
int increment()
Increment and return the occurrence counter.
virtual Attribute * findAttribute(const std::string &name)
Find an attribute by name.
std::vector< Attribute > itsAttr
The object attributes.
void apply(const ObjectFunction &)
Apply a function to all objects.
Object * find(const std::string &name)
Find entry.
static OpalData * getInstance()
virtual const std::string & getName() const
Get element name.
virtual ElementBase * copyStructure()
Make a structural copy.
virtual void execute()
Apply the algorithm to the top-level beamline.
A section of a beam line.
void setReflectionFlag(bool flag) const
Set reflection flag.
void setRelativeFlag(bool flag)
void setOrigin3D(const Vector_t &ori)
void setInitialDirection(const Quaternion &rot)
bool isValid() const
Test for validity.
Reference-counted pointer.
bool isValid() const
Test for validity.
Interface for statements.
bool integer(int &value)
Return signed integer.
bool delimiter(char c)
Test for delimiter.
Abstract interface for a stream of input tokens.
Object attribute with an `‘automatic’' scalar value.
A scalar expression with two scalar operands.
An expression defined as a reference to a scalar.
A function of two U's returning a T.
virtual void replace(Object *oldObject, Object *newObject)
Replace references.
friend class LineTemplate
virtual void parse(Statement &stat)
Parse the line object.
virtual FlaggedBeamline * fetchLine() const
Return the embedded CLASSIC beam line.
virtual void print(std::ostream &stream) const
Print the line.
virtual Line * copy(const std::string &name)
Make complete copy.
virtual double getLength() const
Return line length.
virtual Object * makeTemplate(const std::string &name, TokenStream &is, Statement &stat)
Make a line template.
void parseList(Statement &)
Line()
Exemplar constructor.
virtual Line * clone(const std::string &name)
Make clone.
void parseTemplate(TokenStream &is, Statement &stat)
Parse the line template.
Replace all references to named element by a new version.
The base class for all OPAL exceptions.
Vektor< double, 3 > Vector_t