61 double AttAdd(
double a,
double b) {
return a + b; }
67 "The \"LINE\" statement defines a beamline list.\n"
68 "\t<name> : line = (<list>)") {
72 itsAttr[LENGTH].setReadOnly(
true);
77 "ORIENTATION",
"The Tait-Bryan angles for the orientation of the particle source");
89 "THETA",
"The rotation about the y-axis of the particle source", 0);
116 std::copy(oldLine->begin(), oldLine->end(), std::back_inserter(*newLine));
152 line->push_front(first);
156 line->push_back(last);
160 for (FlaggedBeamline::iterator i = line->begin(); i != line->end(); ++i) {
161 auto actname = i->getElement()->getName();
184 attr->
parse(stat,
true);
186 attr->
parse(stat,
false);
195 if (origin.size() == 3) {
201 "Line::parse",
"Parameter origin is array of 3 values (x, y, z);\n"
202 + std::to_string(origin.size())
203 +
" values provided");
208 if (direction.size() == 3) {
209 const double& theta = direction[0];
210 const double& phi = direction[1];
211 const double& psi = direction[2];
213 Quaternion rotTheta(cos(0.5 * theta), 0, -sin(0.5 * theta), 0);
214 Quaternion rotPhi(cos(0.5 * phi), -sin(0.5 * phi), 0, 0);
215 Quaternion rotPsi(cos(0.5 * psi), 0, 0, -sin(0.5 * psi));
222 "Parameter orientation is array of 3 values (theta, phi, psi);\n"
223 + std::to_string(direction.size()) +
" values provided");
237 Quaternion rotTheta(cos(0.5 * theta), 0, -sin(0.5 * theta), 0);
238 Quaternion rotPhi(cos(0.5 * phi), -sin(0.5 * phi), 0, 0);
239 Quaternion rotPsi(cos(0.5 * psi), 0, 0, -sin(0.5 * psi));
247 || !
itsAttr[PSI].defaultUsed());
256 for (FlaggedBeamline::const_iterator i = line->begin(); i != line->end(); ++i) {
257 const std::string name = i->getElement()->getName();
258 if (name[0] !=
'#') {
260 if (i->getReflectionFlag()) os <<
'-';
291 while (repeat-- > 0) {
293 for (FlaggedBeamline::reverse_iterator i = subLine->rbegin();
294 i != subLine->rend(); ++i) {
297 line->push_back(fep);
300 for (FlaggedBeamline::iterator i = subLine->begin(); i != subLine->end(); ++i) {
302 line->push_back(fep);
308 std::string name =
parseString(stat,
"Line member expected.");
313 throw ParseError(
"Line::parseList()",
"Element \"" + name +
"\" is undefined.");
319 obj = obj->makeInstance(
325 while (repeat-- > 0) {
328 line->push_back(member);
333 "Line::parseList()",
"Object \"" + name +
"\" cannot be a line member.");
345 if (oldElement != 0 && newElement != 0) {
ippl::Vector< T, Dim > Vector_t
TBeamline< FlaggedElmPtr > FlaggedBeamline
A beam line with flagged elements.
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.
void execute() override
Apply the algorithm to the top-level beamline.
virtual ElementBase * copyStructure()
Make a structural copy.
std::shared_ptr< ElementBase > getElementPtr() const
Return the embedded OPALX element as shared_ptr.
static Element * find(const std::string &name)
Find named Element.
ElementBase * getElement() const
Return the embedded OPALX element.
void setElement(ElementBase *)
Assign new OPALX element.
A section of a beam line.
A pointer to a scalar expression.
Object attribute with an `‘automatic’' scalar value.
static Scalar< T > * make(const TFunction2< T, U > &, PtrToScalar< U > left, PtrToScalar< U > right)
Make a new expression.
An expression defined as a reference to a scalar.
A section of a beam line.
void setReflectionFlag(bool flag) const
Set reflection flag.
void parseTemplate(TokenStream &is, Statement &stat)
Parse the line template.
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 OPALX 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.
The base class for all OPAL objects.
void registerOwnership(const AttributeHandler::OwnerType &itsClass) const
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()
Quaternion storage and rotation algebra used by OPALX geometry code.
Replace all references to named element by a new version.
Interface for statements.
bool integer(int &value)
Return signed integer.
bool delimiter(char c)
Test for delimiter.
void setRelativeFlag(bool flag)
void setOrigin3D(const Vector_t< double, 3 > &ori)
void setInitialDirection(const Quaternion &rot)
Abstract interface for a stream of input tokens.
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.
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.
A function of two U's returning a T.