OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
OpalSeparator.cpp
Go to the documentation of this file.
1 // ------------------------------------------------------------------------
2 // $RCSfile: OpalSeparator.cpp,v $
3 // ------------------------------------------------------------------------
4 // $Revision: 1.1.1.1 $
5 // ------------------------------------------------------------------------
6 // Copyright: see Copyright.readme
7 // ------------------------------------------------------------------------
8 //
9 // Class: OpalSeparator
10 // The class of OPAL electrostatic separators.
11 //
12 // ------------------------------------------------------------------------
13 //
14 // $Date: 2000/03/27 09:33:40 $
15 // $Author: Andreas Adelmann $
16 //
17 // ------------------------------------------------------------------------
18 
19 #include "Elements/OpalSeparator.h"
20 #include "Attributes/Attributes.h"
22 
23 
24 // Class OpalSeparator
25 // ------------------------------------------------------------------------
26 
28  OpalElement(SIZE, "SEPARATOR",
29  "The \"SEPARATOR\" element defines an electrostatic separator.") {
31  ("EX", "The horizontal electrostatic field in MV");
33  ("EY", "The vertical electrostatic field in MV");
34 
35  registerRealAttribute("EXL");
36  registerRealAttribute("EYL");
37 
39 
40  setElement((new SeparatorRep("SEPARATOR"))->makeAlignWrapper());
41 }
42 
43 
44 OpalSeparator::OpalSeparator(const std::string &name, OpalSeparator *parent):
45  OpalElement(name, parent) {
46  setElement((new SeparatorRep(name))->makeAlignWrapper());
47 }
48 
49 
51 {}
52 
53 
54 OpalSeparator *OpalSeparator::clone(const std::string &name) {
55  return new OpalSeparator(name, this);
56 }
57 
58 
59 void OpalSeparator::
62 
63  if(flag != ERROR_FLAG) {
64  const SeparatorRep *sep =
65  dynamic_cast<const SeparatorRep *>(base.removeWrappers());
66  double length = sep->getElementLength();
67  attributeRegistry["EXL"]->setReal(length * sep->getEx());
68  attributeRegistry["EYL"]->setReal(length * sep->getEy());
69  }
70 }
71 
72 
75 
76  SeparatorRep *sep =
77  dynamic_cast<SeparatorRep *>(getElement()->removeWrappers());
78  double length = Attributes::getReal(itsAttr[LENGTH]);
79  double Ex = Attributes::getReal(itsAttr[EX]) * 1.0e6;
80  double Ey = Attributes::getReal(itsAttr[EY]) * 1.0e6;
81  sep->setElementLength(length);
82  sep->setEx(Ex);
83  sep->setEy(Ey);
84 
85  // Transmit "unknown" attributes.
87 }
Interface for basic beam line object.
Definition: ElementBase.h:128
virtual void fillRegisteredAttributes(const ElementBase &, ValueFlag)
Fill in all registered attributes.
ValueFlag
Switch for value desired on ATTLIST command.
Definition: OpalElement.h:71
virtual ElementBase * removeWrappers()
Return the design element.
virtual void setElementLength(double length)
Set design length.
Definition: ElementBase.h:515
OpalSeparator()
Exemplar constructor.
std::vector< Attribute > itsAttr
The object attributes (see Attribute.hh).
Definition: Object.h:214
Representation for an electrostatic separator.
Definition: SeparatorRep.h:32
static std::map< std::string, OwnPtr< AttCell > > attributeRegistry
The registry for named attributes.
Definition: OpalElement.h:172
virtual double getElementLength() const
Get design length.
Definition: ElementBase.h:511
virtual double getEy() const
Get component.
virtual void fillRegisteredAttributes(const ElementBase &, ValueFlag)
Fill in all registered attributes.
Base class for all beam line elements.
Definition: OpalElement.h:41
void setElement(ElementBase *)
Assign new CLASSIC element.
Definition: Element.h:133
void registerOwnership() const
virtual void update()
Update the embedded CLASSIC element.
virtual void updateUnknown(ElementBase *)
Transmit the ``unknown&#39;&#39; (not known to OPAL) attributes to CLASSIC.
ElementBase * getElement() const
Return the embedded CLASSIC element.
Definition: Element.h:128
virtual void setEy(double Ey)
Set component.
const std::string name
double getReal(const Attribute &attr)
Return real value.
Definition: Attributes.cpp:217
virtual double getEx() const
Get component.
The ELSEPARATOR element.
Definition: OpalSeparator.h:28
Attribute makeReal(const std::string &name, const std::string &help)
Make real attribute.
Definition: Attributes.cpp:205
virtual OpalSeparator * clone(const std::string &name)
Make clone.
static AttCell * registerRealAttribute(const std::string &name)
Register a ``real&#39;&#39; element attribute.
virtual void update()
Update the embedded CLASSIC separator.
virtual ~OpalSeparator()
virtual void setEx(double Ex)
Set component.