OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
OpalElement.cpp
Go to the documentation of this file.
1 // ------------------------------------------------------------------------
2 // $RCSfile: OpalElement.cpp,v $
3 // ------------------------------------------------------------------------
4 // $Revision: 1.2.4.1 $
5 // ------------------------------------------------------------------------
6 // Copyright: see Copyright.readme
7 // ------------------------------------------------------------------------
8 //
9 // Class: OpalElement
10 // The base class for all OPAL beamline elements.
11 
12 // and for printing in OPAL-8 format.
13 //
14 // ------------------------------------------------------------------------
15 //
16 // $Date: 2002/12/09 15:06:07 $
17 // $Author: jsberg $
18 //
19 // ------------------------------------------------------------------------
20 
21 #include "Elements/OpalElement.h"
24 #include "AbsBeamline/Bend2D.h"
28 #include "Attributes/Attributes.h"
29 #include "Parser/Statement.h"
30 #include "Physics/Physics.h"
32 #include "Utilities/Options.h"
33 #include "Utilities/ParseError.h"
34 #include "Utilities/Round.h"
35 #include "Utilities/Util.h"
36 
37 #include <cmath>
38 #include <cctype>
39 #include <sstream>
40 #include <vector>
41 #include <boost/regex.hpp>
42 
43 extern Inform *gmsg;
44 // Class OpalElement
45 // ------------------------------------------------------------------------
46 
47 std::map < std::string, OwnPtr<AttCell> > OpalElement::attributeRegistry;
48 
49 OpalElement::OpalElement(int size, const char *name, const char *help):
50  Element(size, name, help), itsSize(size) {
52  ("TYPE", "The element design type (the project name)");
54  ("L", "The element length in m");
56  ("ELEMEDGE", "The position of the element in path length (in m)");
58  ("APERTURE", "The element aperture");
60  ("WAKEF", "Defines the wake function");
62  ("PARTICLEMATTERINTERACTION", "Defines the particle mater interaction handler");
64  ("ORIGIN", "The location of the element");
65 
67  ("ORIENTATION", "The Tait-Bryan angles for the orientation of the element");
68 
70  ("X", "The x-coordinate of the location of the element", 0);
71 
73  ("Y", "The y-coordinate of the location of the element", 0);
74 
76  ("Z", "The z-coordinate of the location of the element", 0);
77 
79  ("THETA", "The rotation about the y-axis of the element", 0);
80 
82  ("PHI", "The rotation about the x-axis of the element", 0);
83 
85  ("PSI", "The rotation about the z-axis of the element", 0);
86 
88  ("DX", "Misalignment in x direction",0.0);
90  ("DY", "Misalignment in y direction",0.0);
92  ("DZ", "Misalignment in z direction",0.0);
94  ("DTHETA", "Misalignment in theta (Tait-Bryan angles)",0.0);
96  ("DPHI", "Misalignment in theta (Tait-Bryan angles)",0.0);
98  ("DPSI", "Misalignment in theta (Tait-Bryan angles)",0.0);
99 
100  const unsigned int end = COMMON;
101  for (unsigned int i = 0; i < end; ++ i) {
103  }
104 
105  static bool first = true;
106  if(first) {
107  registerStringAttribute("NAME");
108  registerStringAttribute("TYPE");
109  registerStringAttribute("CLASS");
110  registerStringAttribute("KEYWORD");
112  registerStringAttribute("WAKEF");
113  registerStringAttribute("PARTICLEMATTERINTERACTION");
114  registerStringAttribute("APERT");
118  registerRealAttribute("THETA");
119  registerRealAttribute("PHI");
120  registerRealAttribute("PSI");
121  registerRealAttribute("DX");
122  registerRealAttribute("DY");
123  registerRealAttribute("DZ");
124  registerRealAttribute("DTHETA");
125  registerRealAttribute("DPHI");
126  registerRealAttribute("DPSI");
127  first = false;
128  }
129 
130 }
131 
132 
133 OpalElement::OpalElement(const std::string &name, OpalElement *parent):
134  Element(name, parent), itsSize(parent->itsSize)
135 {}
136 
137 
139 {}
140 
141 
142 void OpalElement::
144  // Fill in the common data for all elements.
145  attributeRegistry["NAME"]->setString(getOpalName());
146  attributeRegistry["TYPE"]->setString(getTypeName());
147  attributeRegistry["CLASS"]->setString(getParent()->getOpalName());
148  attributeRegistry["KEYWORD"]->setString(getBaseObject()->getOpalName());
149  attributeRegistry["L"]->setReal(base.getElementLength());
150 
151  CoordinateSystemTrafo global2local = base.getCSTrafoGlobal2Local();
152  Vector_t origin = global2local.getOrigin();
153  Vector_t orientation = Util::getTaitBryantAngles(global2local.getRotation().conjugate());
154  attributeRegistry["X"]->setReal(origin[0]);
155  attributeRegistry["Y"]->setReal(origin[1]);
156  attributeRegistry["Z"]->setReal(origin[2]);
157  attributeRegistry["THETA"]->setReal(orientation[0]);
158  attributeRegistry["PHI"]->setReal(orientation[1]);
159  attributeRegistry["PSI"]->setReal(orientation[2]);
160 
161  // Misalignments.
162  const AlignWrapper *wrap = dynamic_cast<const AlignWrapper *>(&base);
163  if(wrap) {
164  double dx, dy, dz, dphi, dtheta, dpsi;
165  wrap->offset().getAll(dx, dy, dz, dtheta, dphi, dpsi);
166  attributeRegistry["DX"]->setReal(dx);
167  attributeRegistry["DY"]->setReal(dy);
168  attributeRegistry["DZ"]->setReal(dz);
169  attributeRegistry["DTHETA"]->setReal(dtheta);
170  attributeRegistry["DPHI"]->setReal(dphi);
171  attributeRegistry["DPSI"]->setReal(dpsi);
172  }
173 
174  CoordinateSystemTrafo misalignment = base.getMisalignment();
175  Vector_t misalignmentShift = misalignment.getOrigin();
176  Vector_t misalignmentAngles = Util::getTaitBryantAngles(misalignment.getRotation().conjugate());
177 
178  attributeRegistry["DX"]->setReal(misalignmentShift(0));
179  attributeRegistry["DY"]->setReal(misalignmentShift(1));
180  attributeRegistry["DZ"]->setReal(misalignmentShift(2));
181  attributeRegistry["DTHETA"]->setReal(misalignmentAngles[0]);
182  attributeRegistry["DPHI"]->setReal(misalignmentAngles[1]);
183  attributeRegistry["DPSI"]->setReal(misalignmentAngles[2]);
184 
185  // Fill in the "unknown" attributes.
186  ElementImage *image = base.ElementBase::getImage();
187  AttributeSet::const_iterator cur = image->begin();
188  AttributeSet::const_iterator end = image->end();
189  for(; cur != end; ++cur) {
190  attributeRegistry[cur->first]->setReal(cur->second);
191  }
192 }
193 
194 
196  AttCell *cell = &*attributeRegistry[name];
197 
198  if(cell == 0) {
199  std::string::size_type i = 0;
200 
201  if(name[i] == 'K') {
202  ++i;
203  while(isdigit(name[i])) ++i;
204  if(name[i] == 'S') ++i;
205 
206  if(name[i] == 'L' && ++i == name.length()) {
207  attributeRegistry[name] = cell = new AttReal();
208  } else {
209  throw OpalException("OpalElement::findRegisteredAttribute()",
210  "There is no element which has an attribute "
211  "called \"" + name + "\".");
212  }
213  }
214  }
215 
216  return cell;
217 }
218 
219 std::pair<ElementBase::ApertureType, std::vector<double> > OpalElement::getApert() const {
220 
221  std::pair<ElementBase::ApertureType, std::vector<double> > retvalue(ElementBase::ELLIPTICAL,
222  std::vector<double>({0.5, 0.5, 1.0}));
223  if (!itsAttr[APERT]) return retvalue;
224 
225  std::string aperture = Attributes::getString(itsAttr[APERT]);
226 
227  boost::regex square("square *\\((.*)\\)", boost::regex::icase);
228  boost::regex rectangle("rectangle *\\((.*)\\)", boost::regex::icase);
229  boost::regex circle("circle *\\((.*)\\)", boost::regex::icase);
230  boost::regex ellipse("ellipse *\\((.*)\\)", boost::regex::icase);
231 
232  boost::regex twoArguments("([^,]*),([^,]*)");
233  boost::regex threeArguments("([^,]*),([^,]*),([^,]*)");
234 
235  boost::smatch match;
236 
237  const double width2HalfWidth = 0.5;
238 
239  if (boost::regex_search(aperture, match, square)) {
240  std::string arguments = match[1];
241  if (!boost::regex_search(arguments, match, twoArguments)) {
242  retvalue.first = ElementBase::RECTANGULAR;
243 
244  try {
245  retvalue.second[0] = width2HalfWidth * std::stod(arguments);
246  retvalue.second[1] = retvalue.second[0];
247  } catch (const std::exception &ex) {
248  throw OpalException("OpalElement::getApert()",
249  "could not convert '" + arguments + "' to double");
250  }
251 
252  } else {
253  retvalue.first = ElementBase::CONIC_RECTANGULAR;
254 
255  try {
256  retvalue.second[0] = width2HalfWidth * std::stod(match[1]);
257  retvalue.second[1] = retvalue.second[0];
258  retvalue.second[2] = std::stod(match[2]);
259  } catch (const std::exception &ex) {
260  throw OpalException("OpalElement::getApert()",
261  "could not convert '" + arguments + "' to doubles");
262  }
263  }
264 
265  return retvalue;
266  }
267 
268  if (boost::regex_search(aperture, match, rectangle)) {
269  std::string arguments = match[1];
270 
271  if (!boost::regex_search(arguments, match, threeArguments)) {
272  retvalue.first = ElementBase::RECTANGULAR;
273 
274  try {
275  size_t sz = 0;
276 
277  retvalue.second[0] = width2HalfWidth * std::stod(arguments, &sz);
278  sz = arguments.find_first_of(",", sz) + 1;
279  retvalue.second[1] = width2HalfWidth * std::stod(arguments.substr(sz));
280 
281  } catch (const std::exception &ex) {
282  throw OpalException("OpalElement::getApert()",
283  "could not convert '" + arguments + "' to doubles");
284  }
285 
286  } else {
287  retvalue.first = ElementBase::CONIC_RECTANGULAR;
288 
289  try {
290  retvalue.second[0] = width2HalfWidth * std::stod(match[1]);
291  retvalue.second[1] = width2HalfWidth * std::stod(match[2]);
292  retvalue.second[2] = std::stod(match[3]);
293  } catch (const std::exception &ex) {
294  throw OpalException("OpalElement::getApert()",
295  "could not convert '" + arguments + "' to doubles");
296  }
297  }
298 
299  return retvalue;
300  }
301 
302  if (boost::regex_search(aperture, match, circle)) {
303  std::string arguments = match[1];
304  if (!boost::regex_search(arguments, match, twoArguments)) {
305  retvalue.first = ElementBase::ELLIPTICAL;
306 
307  try {
308  retvalue.second[0] = width2HalfWidth * std::stod(arguments);
309  retvalue.second[1] = retvalue.second[0];
310  } catch (const std::exception &ex) {
311  throw OpalException("OpalElement::getApert()",
312  "could not convert '" + arguments + "' to double");
313  }
314 
315  } else {
316  retvalue.first = ElementBase::CONIC_ELLIPTICAL;
317 
318  try {
319  retvalue.second[0] = width2HalfWidth * std::stod(match[1]);
320  retvalue.second[1] = retvalue.second[0];
321  retvalue.second[2] = std::stod(match[2]);
322  } catch (const std::exception &ex) {
323  throw OpalException("OpalElement::getApert()",
324  "could not convert '" + arguments + "' to doubles");
325  }
326  }
327 
328  return retvalue;
329  }
330 
331  if (boost::regex_search(aperture, match, ellipse)) {
332  std::string arguments = match[1];
333 
334  if (!boost::regex_search(arguments, match, threeArguments)) {
335  retvalue.first = ElementBase::ELLIPTICAL;
336 
337  try {
338  size_t sz = 0;
339 
340  retvalue.second[0] = width2HalfWidth * std::stod(arguments, &sz);
341  sz = arguments.find_first_of(",", sz) + 1;
342  retvalue.second[1] = width2HalfWidth * std::stod(arguments.substr(sz));
343 
344  } catch (const std::exception &ex) {
345  throw OpalException("OpalElement::getApert()",
346  "could not convert '" + arguments + "' to doubles");
347  }
348 
349  } else {
350  retvalue.first = ElementBase::CONIC_ELLIPTICAL;
351 
352  try {
353  retvalue.second[0] = width2HalfWidth * std::stod(match[1]);
354  retvalue.second[1] = width2HalfWidth * std::stod(match[2]);
355  retvalue.second[2] = std::stod(match[3]);
356  } catch (const std::exception &ex) {
357  throw OpalException("OpalElement::getApert()",
358  "could not convert '" + arguments + "' to doubles");
359  }
360  }
361 
362  return retvalue;
363  }
364 
365  if (aperture != "")
366  throw OpalException("OpalElement::getApert()",
367  "Unknown aperture type '" + aperture + "'.");
368 
369  return retvalue;
370 }
371 
372 double OpalElement::getLength() const {
374 }
375 
376 
377 const std::string OpalElement::getTypeName() const {
378  const Attribute *attr = findAttribute("TYPE");
379  return attr ? Attributes::getString(*attr) : std::string();
380 }
381 
386 const std::string OpalElement::getWakeF() const {
387  const Attribute *attr = findAttribute("WAKEF");
388  return attr ? Attributes::getString(*attr) : std::string();
389 }
390 
391 const std::string OpalElement::getParticleMatterInteraction() const {
392  const Attribute *attr = findAttribute("PARTICLEMATTERINTERACTION");
393  return attr ? Attributes::getString(*attr) : std::string();
394 }
395 
397  while(stat.delimiter(',')) {
398  std::string name = Expressions::parseString(stat, "Attribute name expected.");
399  Attribute *attr = findAttribute(name);
400 
401  if(attr == 0) {
402  throw OpalException("OpalElement::parse",
403  "unknown attribute \"" + name + "\"");
404  }
405 
406  if(stat.delimiter('[')) {
407  int index = int(Round(Expressions::parseRealConst(stat)));
408  Expressions::parseDelimiter(stat, ']');
409 
410  if(stat.delimiter('=')) {
411  attr->parseComponent(stat, true, index);
412  } else if(stat.delimiter(":=")) {
413  attr->parseComponent(stat, false, index);
414  } else {
415  throw ParseError("OpalElement::parse()",
416  "Delimiter \"=\" or \":=\" expected.");
417  }
418  } else {
419  if(stat.delimiter('=')) {
420  attr->parse(stat, true);
421  } else if(stat.delimiter(":=")) {
422  attr->parse(stat, false);
423  } else {
424  attr->setDefault();
425  }
426  }
427  }
428 }
429 
430 
431 void OpalElement::print(std::ostream &os) const {
432  std::string head = getOpalName();
433 
434  Object *parent = getParent();
435  if(parent != 0 && ! parent->getOpalName().empty()) {
436  if(! getOpalName().empty()) head += ':';
437  head += parent->getOpalName();
438  }
439 
440  os << head;
441  os << ';'; // << "JMJdebug OPALElement.cc" ;
442  os << std::endl;
443 }
444 
445 
447 (const std::string &name, double value) {
448  attributeRegistry[name]->setReal(value);
449 }
450 
451 
453 (const std::string &name, const std::string &value) {
454  attributeRegistry[name]->setString(value);
455 }
456 
457 
459 (std::ostream &os, int order, int &len,
460  const std::string &sName, const std::string &tName,
461  const Attribute &length, const Attribute &sNorm, const Attribute &sSkew) {
462  // Find out which type of output is required.
463  int flag = 0;
464  if(sNorm) {
465  if(sNorm.getBase().isExpression()) {
466  flag += 2;
467  } else if(Attributes::getReal(sNorm) != 0.0) {
468  flag += 1;
469  }
470  }
471 
472  if(sSkew) {
473  if(sSkew.getBase().isExpression()) {
474  flag += 6;
475  } else if(Attributes::getReal(sSkew) != 0.0) {
476  flag += 3;
477  }
478  }
479  // cout << "JMJdebug, OpalElement.cc: flag=" << flag << endl ;
480  // Now do the output.
481  int div = 2 * (order + 1);
482 
483  switch(flag) {
484 
485  case 0:
486  // No component at all.
487  break;
488 
489  case 1:
490  case 2:
491  // Pure normal component.
492  {
493  std::string normImage = sNorm.getImage();
494  if(length) {
495  normImage = "(" + normImage + ")*(" + length.getImage() + ")";
496  }
497  printAttribute(os, sName, normImage, len);
498  }
499  break;
500 
501  case 3:
502  case 6:
503  // Pure skew component.
504  {
505  std::string skewImage = sSkew.getImage();
506  if(length) {
507  skewImage = "(" + skewImage + ")*(" + length.getImage() + ")";
508  }
509  printAttribute(os, sName, skewImage, len);
510  double tilt = Physics::pi / double(div);
511  printAttribute(os, tName, tilt, len);
512  }
513  break;
514 
515  case 4:
516  // Both components are non-zero constants.
517  {
518  double sn = Attributes::getReal(sNorm);
519  double ss = Attributes::getReal(sSkew);
520  double strength = sqrt(sn * sn + ss * ss);
521  if(strength) {
522  std::ostringstream ts;
523  ts << strength;
524  std::string image = ts.str();
525  if(length) {
526  image = "(" + image + ")*(" + length.getImage() + ")";
527  }
528  printAttribute(os, sName, image, len);
529  double tilt = - atan2(ss, sn) / double(div);
530  if(tilt) printAttribute(os, tName, tilt, len);
531  }
532  }
533  break;
534 
535  case 5:
536  case 7:
537  case 8:
538  // One or both components is/are expressions.
539  {
540  std::string normImage = sNorm.getImage();
541  std::string skewImage = sSkew.getImage();
542  std::string image =
543  "SQRT((" + normImage + ")^2+(" + skewImage + ")^2)";
544  printAttribute(os, sName, image, len);
545  if(length) {
546  image = "(" + image + ")*(" + length.getImage() + ")";
547  }
548  std::string divisor;
549  if(div < 9) {
550  divisor = "0";
551  divisor[0] += div;
552  } else {
553  divisor = "00";
554  divisor[0] += div / 10;
555  divisor[1] += div % 10;
556  }
557  image = "-ATAN2(" + skewImage + ',' + normImage + ")/" + divisor;
558  printAttribute(os, tName, image, len);
559  break;
560  }
561  }
562 }
563 
566 
567  auto apert = getApert();
568  base->setAperture(apert.first, apert.second);
569 
570  if (itsAttr[ORIGIN] || itsAttr[ORIENTATION]) {
571  std::vector<double> ori = Attributes::getRealArray(itsAttr[ORIGIN]);
572  std::vector<double> dir = Attributes::getRealArray(itsAttr[ORIENTATION]);
573  Vector_t origin(0.0);
574  Quaternion rotation;
575 
576  if (dir.size() == 3) {
577  Quaternion rotTheta(cos(0.5 * dir[0]), 0, sin(0.5 * dir[0]), 0);
578  Quaternion rotPhi(cos(0.5 * dir[1]), sin(0.5 * dir[1]), 0, 0);
579  Quaternion rotPsi(cos(0.5 * dir[2]), 0, 0, sin(0.5 * dir[2]));
580  rotation = rotTheta * (rotPhi * rotPsi);
581  } else {
582  if (itsAttr[ORIENTATION]) {
583  throw OpalException("Line::parse","Parameter orientation is array of 3 values (theta, phi, psi);\n" +
584  std::to_string(dir.size()) + " values provided");
585  }
586  }
587 
588  if (ori.size() == 3) {
589  origin = Vector_t(ori[0], ori[1], ori[2]);
590  } else {
591  if (itsAttr[ORIGIN]) {
592  throw OpalException("Line::parse","Parameter origin is array of 3 values (x, y, z);\n" +
593  std::to_string(ori.size()) + " values provided");
594  }
595  }
596 
597  CoordinateSystemTrafo global2local(origin,
598  rotation.conjugate());
599  base->setCSTrafoGlobal2Local(global2local);
600  base->fixPosition();
601 
602  } else if (!itsAttr[PSI].defaultUsed() &&
603  itsAttr[X].defaultUsed() &&
604  itsAttr[Y].defaultUsed() &&
605  itsAttr[Z].defaultUsed() &&
606  itsAttr[THETA].defaultUsed() &&
607  itsAttr[PHI].defaultUsed()) {
609  } else if (!itsAttr[X].defaultUsed() ||
610  !itsAttr[Y].defaultUsed() ||
611  !itsAttr[Z].defaultUsed() ||
612  !itsAttr[THETA].defaultUsed() ||
613  !itsAttr[PHI].defaultUsed() ||
614  !itsAttr[PSI].defaultUsed()) {
615  const Vector_t origin(Attributes::getReal(itsAttr[X]),
618 
619  const double theta = Attributes::getReal(itsAttr[THETA]);
620  const double phi = Attributes::getReal(itsAttr[PHI]);
621  const double psi = Attributes::getReal(itsAttr[PSI]);
622 
623  Quaternion rotTheta(cos(0.5 * theta), 0, sin(0.5 * theta), 0);
624  Quaternion rotPhi(cos(0.5 * phi), sin(0.5 * phi), 0, 0);
625  Quaternion rotPsi(cos(0.5 * psi), 0, 0, sin(0.5 * psi));
626  Quaternion rotation = rotTheta * (rotPhi * rotPsi);
627 
628  CoordinateSystemTrafo global2local(origin,
629  rotation.conjugate());
630  base->setCSTrafoGlobal2Local(global2local);
631  base->fixPosition();
633  }
634 
635  Vector_t misalignmentShift(Attributes::getReal(itsAttr[DX]),
638  double dtheta = Attributes::getReal(itsAttr[DTHETA]);
639  double dphi = Attributes::getReal(itsAttr[DPHI]);
640  double dpsi = Attributes::getReal(itsAttr[DPSI]);
641  Quaternion rotationY(cos(0.5 * dtheta), 0, sin(0.5 * dtheta), 0);
642  Quaternion rotationX(cos(0.5 * dphi), sin(0.5 * dphi), 0, 0);
643  Quaternion rotationZ(cos(0.5 * dpsi), 0, 0, sin(0.5 * dpsi));
644  Quaternion misalignmentRotation = rotationY * rotationX * rotationZ;
645  CoordinateSystemTrafo misalignment(misalignmentShift,
646  misalignmentRotation.conjugate());
647 
648  base->setMisalignment(misalignment);
649 
650  if (itsAttr[ELEMEDGE])
652 }
653 
655  for(std::vector<Attribute>::size_type i = itsSize;
656  i < itsAttr.size(); ++i) {
657  Attribute &attr = itsAttr[i];
658  base->setAttribute(attr.getName(), Attributes::getReal(attr));
659 
660  }
661 }
662 
663 
665 (std::ostream &os, const std::string &name, const std::string &image, int &len) {
666  len += name.length() + image.length() + 2;
667  if(len > 74) {
668  os << ",&\n ";
669  len = name.length() + image.length() + 3;
670  } else {
671  os << ',';
672  }
673  os << name << '=' << image;
674 }
675 
677 (std::ostream &os, const std::string &name, double value, int &len) {
678  std::ostringstream ss;
679  ss << value << std::ends;
680  printAttribute(os, name, ss.str(), len);
681 }
682 
683 
684 AttCell *OpalElement::registerRealAttribute(const std::string &name) {
686  if(! cell.isValid()) {
687  cell = new AttReal();
688  }
689  return &*cell;
690 }
691 
692 
695  if(! cell.isValid()) {
696  cell = new AttString();
697  }
698  return &*cell;
699 }
700 
702  if (getParent() != 0) return;
703 
704  const unsigned int end = itsSize;
705  const std::string name = getOpalName();
706  for (unsigned int i = COMMON; i < end; ++ i) {
708  }
709 }
double Round(double value)
Round the double argument.
Definition: Round.cpp:23
const std::string getTypeName() const
Return the element&#39;s type name.
Euclid3D & offset() const
Return the offset.
void getMisalignment(double &x, double &y, double &s) const
static AttCell * registerStringAttribute(const std::string &name)
Register a ``string&#39;&#39; element attribute.
double parseRealConst(Statement &)
Parse real constant.
Interface for basic beam line object.
Definition: ElementBase.h:128
Vector_t getTaitBryantAngles(Quaternion rotation, const std::string &elementName)
Definition: Util.cpp:100
Parse exception.
Definition: ParseError.h:32
void fixPosition()
Definition: ElementBase.h:677
virtual void fillRegisteredAttributes(const ElementBase &, ValueFlag)
Fill in all registered attributes.
ValueFlag
Switch for value desired on ATTLIST command.
Definition: OpalElement.h:71
void setDefault()
Assign default value.
Definition: Attribute.cpp:143
The base class for all OPAL exceptions.
Definition: OpalException.h:28
Tps< T > sin(const Tps< T > &x)
Sine.
Definition: TpsMath.h:111
virtual Attribute * findAttribute(const std::string &name)
Find an attribute by name.
const_iterator end() const
Iterator marking the end of the list.
Definition: AttributeSet.h:108
virtual ElementBase * removeWrappers()
Return the design element.
Define the position of a misaligned element.
Definition: AlignWrapper.h:39
void setRotationAboutZ(double rotation)
Set rotation about z axis in bend frame.
Definition: ElementBase.h:695
Object * getParent() const
Return parent pointer.
Definition: Object.cpp:289
NameMap::const_iterator const_iterator
An iterator for a map of name versus value.
Definition: AttributeSet.h:49
Inform * gmsg
Definition: Main.cpp:21
The abstract base class for attribute cells.
Definition: AttCell.h:30
virtual double getLength() const
Return element length.
virtual void setAttribute(const std::string &aKey, double val)
Set value of an attribute.
static void setRegisteredAttribute(const std::string &, double)
Store a registered real attribute.
A pointer which owns the object pointed at.
Definition: OwnPtr.h:31
std::vector< Attribute > itsAttr
The object attributes (see Attribute.hh).
Definition: Object.h:214
std::pair< ElementBase::ApertureType, std::vector< double > > getApert() const
const_iterator begin() const
Iterator accessing first member.
Definition: AttributeSet.h:105
static void addAttributeOwner(const std::string &owner, const OwnerType &type, const std::string &name)
void parseDelimiter(Statement &stat, char delim)
Test for one-character delimiter.
virtual void parse(Statement &)
Parse the element.
const Object * getBaseObject() const
Return the object&#39;s base type object.
Definition: Object.cpp:277
static std::map< std::string, OwnPtr< AttCell > > attributeRegistry
The registry for named attributes.
Definition: OpalElement.h:172
const std::string & getOpalName() const
Return object name.
Definition: Object.cpp:284
void parseComponent(Statement &stat, bool eval, int index)
Parse array component.
Definition: Attribute.cpp:131
The base class for all OPAL elements.
Definition: Element.h:46
A representation of an Object attribute.
Definition: Attribute.h:55
void setMisalignment(double x, double y, double s)
constexpr double pi
The value of .
Definition: Physics.h:31
std::string getImage() const
Return printable representation.
Definition: Attribute.cpp:85
Quaternion getRotation() const
virtual double getElementLength() const
Get design length.
Definition: ElementBase.h:511
void getAll(double &x, double &y, double &z, double &vx, double &vy, double &vz) const
Unpack.
Definition: Euclid3D.cpp:52
const std::string getWakeF() const
Return the element&#39;s type name.
Interface for statements.
Definition: Statement.h:38
An image of an element.
Definition: ElementImage.h:35
Base class for all beam line elements.
Definition: OpalElement.h:41
const std::string getParticleMatterInteraction() const
std::vector< double > getRealArray(const Attribute &attr)
Get array value.
Definition: Attributes.cpp:258
static void printAttribute(std::ostream &os, const std::string &name, const std::string &image, int &len)
Print an attribute with a OPAL-8 name (as an expression).
PETE_TBTree< FnArcTan2, PETE_Scalar< Vektor< T1, Dim > >, typename T2::PETE_Expr_t > atan2(const Vektor< T1, Dim > &l, const PETE_Expr< T2 > &r)
void setCSTrafoGlobal2Local(const CoordinateSystemTrafo &ori)
Definition: ElementBase.h:595
Vektor< double, 3 > Vector_t
Definition: Vektor.h:6
bool isValid() const
Test for validity.
Definition: OwnPtr.h:144
void registerOwnership() const
Vector_t getOrigin() const
virtual void update()
Update the embedded CLASSIC element.
static void printMultipoleStrength(std::ostream &os, int order, int &len, const std::string &sName, const std::string &tName, const Attribute &length, const Attribute &vNorm, const Attribute &vSkew)
Print multipole components in OPAL-8 format.
virtual void updateUnknown(ElementBase *)
Transmit the ``unknown&#39;&#39; (not known to OPAL) attributes to CLASSIC.
Tps< T > sqrt(const Tps< T > &x)
Square root.
Definition: TpsMath.h:91
The class for attribute cells with a real value.
Definition: AttCell.h:69
ElementBase * getElement() const
Return the embedded CLASSIC element.
Definition: Element.h:128
The base class for all OPAL objects.
Definition: Object.h:48
Tps< T > cos(const Tps< T > &x)
Cosine.
Definition: TpsMath.h:129
virtual bool isExpression() const
Test for expression.
const std::string name
void setAperture(const ApertureType &type, const std::vector< double > &args)
Definition: ElementBase.h:625
The class for attribute cells with a string value.
Definition: AttCell.h:104
Attribute makeRealArray(const std::string &name, const std::string &help)
Create real array attribute.
Definition: Attributes.cpp:253
void setElementPosition(double elemedge)
Access to ELEMEDGE attribute.
Definition: ElementBase.h:709
Quaternion conjugate() const
Definition: Quaternion.h:104
static AttCell * findRegisteredAttribute(const std::string &name)
Find a registered attribute.
double getReal(const Attribute &attr)
Return real value.
Definition: Attributes.cpp:217
std::string parseString(Statement &, const char msg[])
Parse string value.
bool delimiter(char c)
Test for delimiter.
Definition: Statement.cpp:103
Definition: Inform.h:41
Attribute makeString(const std::string &name, const std::string &help)
Make string attribute.
Definition: Attributes.cpp:296
Attribute makeReal(const std::string &name, const std::string &help)
Make real attribute.
Definition: Attributes.cpp:205
void parse(Statement &stat, bool eval)
Parse attribute.
Definition: Attribute.cpp:125
virtual ~OpalElement()
static AttCell * registerRealAttribute(const std::string &name)
Register a ``real&#39;&#39; element attribute.
const std::string & getName() const
Return the attribute name.
Definition: Attribute.cpp:90
AttributeBase & getBase() const
Return reference to polymorphic value.
Definition: Attribute.cpp:67
Inform & endl(Inform &inf)
Definition: Inform.cpp:42
virtual void print(std::ostream &) const
Print the object.
std::string getString(const Attribute &attr)
Get string value.
Definition: Attributes.cpp:307
CoordinateSystemTrafo getCSTrafoGlobal2Local() const
Definition: ElementBase.h:603