OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
OpalSeptum.cpp
Go to the documentation of this file.
1 // ------------------------------------------------------------------------
2 // $RCSfile: OpalSeptum.cpp,v $
3 // ------------------------------------------------------------------------
4 // $Revision: 1.1.1.1 $
5 // ------------------------------------------------------------------------
6 // Copyright: see Copyright.readme
7 // ------------------------------------------------------------------------
8 //
9 // Class: OpalSeptum
10 // The class of OPAL Septums.
11 //
12 // ------------------------------------------------------------------------
13 //
14 // $Date: 2009/09/21 10:06:06 $
15 // $Author: bi $
16 //
17 // ------------------------------------------------------------------------
18 
19 #include "Elements/OpalSeptum.h"
21 #include "Attributes/Attributes.h"
22 #include "BeamlineCore/SeptumRep.h"
23 #include "Structure/OpalWake.h"
24 #include "Physics/Physics.h"
25 
26 
27 // Class OpalSeptum
28 // ------------------------------------------------------------------------
29 
31  OpalElement(SIZE, "SEPTUM",
32  "The \"SEPTUM\" element defines a Septum."),
33  owk_m(NULL) {
34 
36  ("XSTART", " Start of x coordinate");
38  ("XEND", " End of x coordinate");
40  ("YSTART", "Start of y coordinate");
42  ("YEND", "End of y coordinate");
44  ("WIDTH", "Width of the septum");
46  ("OUTFN", "Output filename");
47 
48  registerRealAttribute("XSTART");
49  registerRealAttribute("XEND");
50  registerRealAttribute("YSTART");
51  registerRealAttribute("YEND");
52  registerRealAttribute("WIDTH");
53  registerStringAttribute("OUTFN");
54 
56 
57  setElement((new SeptumRep("SEPTUM"))->makeAlignWrapper());
58 }
59 
60 
61 OpalSeptum::OpalSeptum(const std::string &name, OpalSeptum *parent):
62  OpalElement(name, parent),
63  owk_m(NULL) {
64  setElement((new SeptumRep(name))->makeAlignWrapper());
65 }
66 
67 
69  if(owk_m)
70  delete owk_m;
71 }
72 
73 
74 OpalSeptum *OpalSeptum::clone(const std::string &name) {
75  return new OpalSeptum(name, this);
76 }
77 
78 
81 
82 }
83 
84 
87 
88  SeptumRep *sept =
89  dynamic_cast<SeptumRep *>(getElement()->removeWrappers());
90  double length = Attributes::getReal(itsAttr[LENGTH]);
91  double xstart = Attributes::getReal(itsAttr[XSTART]);
92  double xend = Attributes::getReal(itsAttr[XEND]);
93  double ystart = Attributes::getReal(itsAttr[YSTART]);
94  double yend = Attributes::getReal(itsAttr[YEND]);
95  double width = Attributes::getReal(itsAttr[WIDTH]);
96 
97  if(itsAttr[WAKEF] && owk_m == NULL) {
98  owk_m = (OpalWake::find(Attributes::getString(itsAttr[WAKEF])))->clone(getOpalName() + std::string("_wake"));
99  owk_m->initWakefunction(*sept);
100  sept->setWake(owk_m->wf_m);
101  }
102  sept->setElementLength(length);
103  sept->setDimensions(xstart, xend, ystart, yend);
104  sept->setWidth(width);
106 
107  // Transmit "unknown" attributes.
109 }
virtual ~OpalSeptum()
Definition: OpalSeptum.cpp:68
static AttCell * registerStringAttribute(const std::string &name)
Register a ``string&#39;&#39; element attribute.
WakeFunction * wf_m
Definition: OpalWake.h:65
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 OpalSeptum * clone(const std::string &name)
Make clone.
Definition: OpalSeptum.cpp:74
virtual void setElementLength(double length)
Set design length.
Definition: ElementBase.h:515
std::vector< Attribute > itsAttr
The object attributes (see Attribute.hh).
Definition: Object.h:214
OpalWake * owk_m
Definition: OpalSeptum.h:66
void initWakefunction(ElementBase &element)
Definition: OpalWake.cpp:157
virtual void fillRegisteredAttributes(const ElementBase &, ValueFlag)
Fill in all registered attributes.
Definition: OpalSeptum.cpp:79
const std::string & getOpalName() const
Return object name.
Definition: Object.cpp:284
OpalSeptum()
Exemplar constructor.
Definition: OpalSeptum.cpp:30
static OpalWake * find(const std::string &name)
Find named WAKE.
Definition: OpalWake.cpp:136
virtual void update()
Update the embedded CLASSIC septum.
Definition: OpalSeptum.cpp:85
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.
The Septum element.
Definition: OpalSeptum.h:29
ElementBase * getElement() const
Return the embedded CLASSIC element.
Definition: Element.h:128
void setWidth(double width)
Member variable access.
Definition: Septum.cpp:48
Representation for Septum.
Definition: SeptumRep.h:31
const std::string name
double getReal(const Attribute &attr)
Return real value.
Definition: Attributes.cpp:217
void setOutputFN(std::string fn)
Set output filename.
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
virtual void setWake(WakeFunction *wf)
attach a wake field to the element
static AttCell * registerRealAttribute(const std::string &name)
Register a ``real&#39;&#39; element attribute.
std::string getString(const Attribute &attr)
Get string value.
Definition: Attributes.cpp:307
void setDimensions(double xstart, double xend, double ystart, double yend)
Set dimensions and consistency checks.