OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
OpalVKicker.cpp
Go to the documentation of this file.
1 // ------------------------------------------------------------------------
2 // $RCSfile: OpalVKicker.cpp,v $
3 // ------------------------------------------------------------------------
4 // $Revision: 1.2 $
5 // ------------------------------------------------------------------------
6 // Copyright: see Copyright.readme
7 // ------------------------------------------------------------------------
8 //
9 // Class: OpalVKicker
10 // The class of OPAL vertical orbit correctors.
11 //
12 // ------------------------------------------------------------------------
13 //
14 // $Date: 2001/08/13 15:32:24 $
15 // $Author: jowett $
16 //
17 // ------------------------------------------------------------------------
18 
19 #include "Elements/OpalVKicker.h"
22 #include "Attributes/Attributes.h"
25 #include "Physics/Physics.h"
26 
27 
28 // Class OpalVKicker
29 // ------------------------------------------------------------------------
30 
32  OpalElement(SIZE, "VKICKER",
33  "The \"VKICKER\" element defines a closed orbit corrector "
34  "acting on the vertical plane.") {
36  ("KICK", "Vertical deflection in rad");
38  ("DESIGNENERGY", "the mean energy of the particles");
40  ("K0", "Normal dipole field in T");
41 
42  registerRealAttribute("KICK");
43  registerRealAttribute("DESIGNENERGY");
45 
47 
48  setElement((new YCorrectorRep("VKICKER"))->makeWrappers());
49 }
50 
51 
52 OpalVKicker::OpalVKicker(const std::string &name, OpalVKicker *parent):
53  OpalElement(name, parent) {
54  setElement((new YCorrectorRep(name))->makeWrappers());
55 }
56 
57 
59 {}
60 
61 
62 OpalVKicker *OpalVKicker::clone(const std::string &name) {
63  return new OpalVKicker(name, this);
64 }
65 
66 
67 void OpalVKicker::
69  Inform m("fillRegisteredAttributes ");
71 
72  const CorrectorWrapper *corr =
73  dynamic_cast<const CorrectorWrapper *>(base.removeAlignWrapper());
74  BDipoleField field;
75 
76  if(flag == ERROR_FLAG) {
77  field = corr->errorField();
78  } else if(flag == ACTUAL_FLAG) {
79  field = corr->getField();
80  } else if(flag == IDEAL_FLAG) {
81  field = corr->getDesign().getField();
82  }
83 
84  double scale = Physics::c / OpalData::getInstance()->getP0();
85  attributeRegistry["HKICK"]->setReal(- field.getBy() * scale);
86  attributeRegistry["VKICK"]->setReal(+ field.getBx() * scale);
87 
88  m << "P= " << OpalData::getInstance()->getP0()
89  << " Bx= " << field.getBx()
90  << " By= " << field.getBy() << endl;
91 
92 }
93 
94 
97 
98  YCorrectorRep *corr = dynamic_cast<YCorrectorRep *>(getElement()->removeWrappers());
99 
100  double length = Attributes::getReal(itsAttr[LENGTH]);
101  double factor = OpalData::getInstance()->getP0() / Physics::c;
102  double kick = Attributes::getReal(itsAttr[KICK]);
103 
104  corr->setElementLength(length);
105  corr->setBx(kick * factor);
106  corr->setKickY(kick);
107  if(itsAttr[DESIGNENERGY]) {
108  double kineticEnergy = Attributes::getReal(itsAttr[DESIGNENERGY]) * 1e6;
109  corr->setDesignEnergy(kineticEnergy, false);
110  }
111 
112  if (itsAttr[K0]) {
114  }
115  // Transmit "unknown" attributes.
117 }
virtual ElementBase * removeAlignWrapper()
Remove align wrapper.
OpalVKicker()
Exemplar constructor.
Definition: OpalVKicker.cpp:31
virtual BDipoleField & getField()=0
Return the corrector field.
Interface for basic beam line object.
Definition: ElementBase.h:128
virtual void fillRegisteredAttributes(const ElementBase &, ValueFlag)
Fill in all registered attributes.
The field of a magnetic dipole.
Definition: BDipoleField.h:31
double getP0() const
Return value of global reference momentum.
Definition: OpalData.cpp:623
virtual BDipoleField & errorField() const
Get corrector field error.
ValueFlag
Switch for value desired on ATTLIST command.
Definition: OpalElement.h:71
virtual ElementBase * removeWrappers()
Return the design element.
void setKickY(double k)
Definition: Corrector.h:137
virtual void setElementLength(double length)
Set design length.
Definition: ElementBase.h:515
virtual double getBy() const
Get vertical component.
std::vector< Attribute > itsAttr
The object attributes (see Attribute.hh).
Definition: Object.h:214
virtual void setDesignEnergy(const double &ekin, bool changeable=true)
Definition: Corrector.cpp:127
static OpalData * getInstance()
Definition: OpalData.cpp:209
static std::map< std::string, OwnPtr< AttCell > > attributeRegistry
The registry for named attributes.
Definition: OpalElement.h:172
virtual BDipoleField & getField()
Get corrector field.
constexpr double c
The velocity of light in m/s.
Definition: Physics.h:52
Base class for all beam line elements.
Definition: OpalElement.h:41
virtual void fillRegisteredAttributes(const ElementBase &, ValueFlag)
Fill in all registered attributes.
Definition: OpalVKicker.cpp:68
virtual double getBx() const
Get horizontal component.
virtual const Corrector & getDesign() const
Get design corrector.
void setElement(ElementBase *)
Assign new CLASSIC element.
Definition: Element.h:133
Vektor< double, 3 > Vector_t
Definition: Vektor.h:6
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.
Representation for a perturbed closed orbit corrector.
ElementBase * getElement() const
Return the embedded CLASSIC element.
Definition: Element.h:128
const std::string name
virtual void update()
Update the embedded CLASSIC corrector.
Definition: OpalVKicker.cpp:95
virtual OpalVKicker * clone(const std::string &name)
Make clone.
Definition: OpalVKicker.cpp:62
double getReal(const Attribute &attr)
Return real value.
Definition: Attributes.cpp:217
Definition: Inform.h:41
virtual void setBx(double)
Set horizontal field component in Teslas.
The VKICKER element.
Definition: OpalVKicker.h:29
Attribute makeReal(const std::string &name, const std::string &help)
Make real attribute.
Definition: Attributes.cpp:205
virtual ~OpalVKicker()
Definition: OpalVKicker.cpp:58
Representation for an orbit corrector.
Definition: YCorrectorRep.h:31
static AttCell * registerRealAttribute(const std::string &name)
Register a ``real&#39;&#39; element attribute.
Inform & endl(Inform &inf)
Definition: Inform.cpp:42
void setKickField(const Vector_t &k0)
Definition: Corrector.h:152