OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
OpalHKicker.cpp
Go to the documentation of this file.
1 // ------------------------------------------------------------------------
2 // $RCSfile: OpalHKicker.cpp,v $
3 // ------------------------------------------------------------------------
4 // $Revision: 1.1.1.1 $
5 // ------------------------------------------------------------------------
6 // Copyright: see Copyright.readme
7 // ------------------------------------------------------------------------
8 //
9 // Class: OpalHKicker
10 // The class of OPAL horizontal orbit correctors.
11 //
12 // ------------------------------------------------------------------------
13 //
14 // $Date: 2000/03/27 09:33:39 $
15 // $Author: Andreas Adelmann $
16 //
17 // ------------------------------------------------------------------------
18 
19 #include "Elements/OpalHKicker.h"
22 #include "Attributes/Attributes.h"
25 #include "Physics/Physics.h"
26 
27 
28 // Class OpalHKicker
29 // ------------------------------------------------------------------------
30 
32  OpalElement(SIZE, "HKICKER",
33  "The \"HKICKER\" element defines a closed orbit corrector "
34  "acting on the horizontal plane.") {
36  ("KICK", "Horizontal deflection in rad");
38  ("DESIGNENERGY", "the mean energy of the particles");
40  ("K0", "Normal dipole field in T");
41 
42  registerRealAttribute("HKICK");
43  registerRealAttribute("DESIGNENERGY");
45 
47 
48  setElement((new XCorrectorRep("HKICKER"))->makeWrappers());
49 }
50 
51 
52 OpalHKicker::OpalHKicker(const std::string &name, OpalHKicker *parent):
53  OpalElement(name, parent) {
54  setElement((new XCorrectorRep(name))->makeWrappers());
55 }
56 
57 
59 {}
60 
61 
62 OpalHKicker *OpalHKicker::clone(const std::string &name) {
63  return new OpalHKicker(name, this);
64 }
65 
66 
67 void OpalHKicker::
70  const CorrectorWrapper *corr =
71  dynamic_cast<const CorrectorWrapper *>(base.removeAlignWrapper());
72  BDipoleField field;
73 
74  if(flag == ERROR_FLAG) {
75  field = corr->errorField();
76  } else if(flag == ACTUAL_FLAG) {
77  field = corr->getField();
78  } else if(flag == IDEAL_FLAG) {
79  field = corr->getDesign().getField();
80  }
81 
82  double scale = Physics::c / OpalData::getInstance()->getP0();
83  attributeRegistry["HKICK"]->setReal(- field.getBy() * scale);
84  attributeRegistry["VKICK"]->setReal(+ field.getBx() * scale);
85 }
86 
87 
90 
91  XCorrectorRep *corr =
92  dynamic_cast<XCorrectorRep *>(getElement()->removeWrappers());
93  double length = Attributes::getReal(itsAttr[LENGTH]);
94  double factor = OpalData::getInstance()->getP0() / Physics::c;
95  double kick = Attributes::getReal(itsAttr[KICK]);
96 
97  corr->setElementLength(length);
98  corr->setBy(- kick * factor);
99 
100  corr->setKickX(kick);
101  if(itsAttr[DESIGNENERGY]) {
102  double kineticEnergy = Attributes::getReal(itsAttr[DESIGNENERGY]) * 1e6;
103  corr->setDesignEnergy(kineticEnergy, false);
104  }
105 
106  if (itsAttr[K0]) {
108  }
109 
110  // Transmit "unknown" attributes.
112 }
virtual ElementBase * removeAlignWrapper()
Remove align wrapper.
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.
The HKICKER element.
Definition: OpalHKicker.h:30
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.
void setKickX(double k)
Definition: Corrector.h:132
Representation for an orbit corrector.
Definition: XCorrectorRep.h:31
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 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 setBy(double)
Set vertical field component in Teslas.
virtual void update()
Update the embedded CLASSIC element.
virtual void fillRegisteredAttributes(const ElementBase &, ValueFlag)
Fill in all registered attributes.
Definition: OpalHKicker.cpp:68
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
virtual OpalHKicker * clone(const std::string &name)
Make clone.
Definition: OpalHKicker.cpp:62
virtual void update()
Update the embedded CLASSIC corrector.
Definition: OpalHKicker.cpp:88
const std::string name
double getReal(const Attribute &attr)
Return real value.
Definition: Attributes.cpp:217
virtual ~OpalHKicker()
Definition: OpalHKicker.cpp:58
Attribute makeReal(const std::string &name, const std::string &help)
Make real attribute.
Definition: Attributes.cpp:205
static AttCell * registerRealAttribute(const std::string &name)
Register a ``real&#39;&#39; element attribute.
void setKickField(const Vector_t &k0)
Definition: Corrector.h:152
OpalHKicker()
Exemplar constructor.
Definition: OpalHKicker.cpp:31