OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
OpalProbe.cpp
Go to the documentation of this file.
1 // ------------------------------------------------------------------------
2 // $RCSfile: OpalProbe.cpp,v $
3 // ------------------------------------------------------------------------
4 // $Revision: 1.1.1.1 $
5 // ------------------------------------------------------------------------
6 // Copyright: see Copyright.readme
7 // ------------------------------------------------------------------------
8 //
9 // Class: OpalProbe
10 // The class of OPAL Probes.
11 //
12 // ------------------------------------------------------------------------
13 //
14 // $Date: 2009/10/07 10:06:06 $
15 // $Author: bi $
16 //
17 // ------------------------------------------------------------------------
18 
19 #include "Elements/OpalProbe.h"
21 #include "Attributes/Attributes.h"
22 #include "BeamlineCore/ProbeRep.h"
23 #include "Structure/OpalWake.h"
24 #include "Physics/Physics.h"
25 
26 
27 // Class OpalProbe
28 // ------------------------------------------------------------------------
29 
31  OpalElement(SIZE, "PROBE",
32  "The \"PROBE\" element defines a Probe."),
33  owk_m(nullptr) {
34 
36  ("XSTART", " Start of x coordinate [mm]");
38  ("XEND", " End of x coordinate [mm]");
40  ("YSTART", "Start of y coordinate [mm]");
42  ("YEND", "End of y coordinate [mm]");
44  ("WIDTH", "Width of the probe, not used.");
46  ("STEP", "Step size of the probe [mm]", 1.0);
48  ("OUTFN", "Output filename");
49 
50  registerRealAttribute("XSTART");
51  registerRealAttribute("XEND");
52  registerRealAttribute("YSTART");
53  registerRealAttribute("YEND");
54  registerRealAttribute("WIDTH");
55  registerRealAttribute("STEP");
56  registerStringAttribute("OUTFN");
57 
59 
60  setElement((new ProbeRep("PROBE"))->makeAlignWrapper());
61 }
62 
63 
64 OpalProbe::OpalProbe(const std::string &name, OpalProbe *parent):
65  OpalElement(name, parent),
66  owk_m(nullptr) {
67  setElement((new ProbeRep(name))->makeAlignWrapper());
68 }
69 
70 
72  delete owk_m;
73 }
74 
75 
76 OpalProbe *OpalProbe::clone(const std::string &name) {
77  return new OpalProbe(name, this);
78 }
79 
80 
83 }
84 
85 
88 
89  ProbeRep *prob =
90  dynamic_cast<ProbeRep *>(getElement()->removeWrappers());
91  double length = Attributes::getReal(itsAttr[LENGTH]);
92  double xstart = Attributes::getReal(itsAttr[XSTART]);
93  double xend = Attributes::getReal(itsAttr[XEND]);
94  double ystart = Attributes::getReal(itsAttr[YSTART]);
95  double yend = Attributes::getReal(itsAttr[YEND]);
96  double step = Attributes::getReal(itsAttr[STEP]);
97 
98  if(itsAttr[WAKEF] && owk_m == nullptr) {
99  owk_m = (OpalWake::find(Attributes::getString(itsAttr[WAKEF])))->clone(getOpalName() + std::string("_wake"));
100  owk_m->initWakefunction(*prob);
101  prob->setWake(owk_m->wf_m);
102  }
103  prob->setElementLength(length); // is this needed here?
104  prob->setDimensions(xstart, xend, ystart, yend);
105  prob->setStep(step);
107 
108  // Transmit "unknown" attributes.
110 }
void setStep(double step)
Set probe histogram bin width.
Definition: Probe.cpp:43
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.
Definition: OpalProbe.cpp:81
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.
OpalWake * owk_m
Definition: OpalProbe.h:68
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
virtual OpalProbe * clone(const std::string &name)
Make clone.
Definition: OpalProbe.cpp:76
The Probe element.
Definition: OpalProbe.h:30
void initWakefunction(ElementBase &element)
Definition: OpalWake.cpp:157
Representation for Probe.
Definition: ProbeRep.h:31
const std::string & getOpalName() const
Return object name.
Definition: Object.cpp:284
virtual void update()
Update the embedded CLASSIC probe.
Definition: OpalProbe.cpp:86
static OpalWake * find(const std::string &name)
Find named WAKE.
Definition: OpalWake.cpp:136
virtual ~OpalProbe()
Definition: OpalProbe.cpp:71
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
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.
OpalProbe()
Exemplar constructor.
Definition: OpalProbe.cpp:30
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.