OPALX (Object Oriented Parallel Accelerator Library for Exascal) MINIorX
OPALX
OpalProbe.cpp
Go to the documentation of this file.
1//
2// Class OpalProbe
3// The Probe element.
4//
5// Copyright (c) 200x - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland
6// All rights reserved
7//
8// This file is part of OPAL.
9//
10// OPAL is free software: you can redistribute it and/or modify
11// it under the terms of the GNU General Public License as published by
12// the Free Software Foundation, either version 3 of the License, or
13// (at your option) any later version.
14//
15// You should have received a copy of the GNU General Public License
16// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
17//
18#include "Elements/OpalProbe.h"
22#include "Physics/Physics.h"
23#include "Physics/Units.h"
24
25OpalProbe::OpalProbe() : OpalElement(SIZE, "PROBE", "The \"PROBE\" element defines a Probe.") {
26 itsAttr[XSTART] = Attributes::makeReal("XSTART", " Start of x coordinate [mm]");
27 itsAttr[XEND] = Attributes::makeReal("XEND", " End of x coordinate [mm]");
28 itsAttr[YSTART] = Attributes::makeReal("YSTART", "Start of y coordinate [mm]");
29 itsAttr[YEND] = Attributes::makeReal("YEND", "End of y coordinate [mm]");
30 itsAttr[WIDTH] = Attributes::makeReal("WIDTH", "Width of the probe, not used.");
31 itsAttr[STEP] = Attributes::makeReal("STEP", "Step size of the probe [mm]", 1.0);
32
34
35 setElement(new ProbeRep("PROBE"));
36}
37
38OpalProbe::OpalProbe(const std::string& name, OpalProbe* parent) : OpalElement(name, parent) {
39 setElement(new ProbeRep(name));
40}
41
44
45OpalProbe* OpalProbe::clone(const std::string& name) {
46 return new OpalProbe(name, this);
47}
48
51
52 ProbeRep* prob = dynamic_cast<ProbeRep*>(getElement());
53
59
60 double length = Attributes::getReal(itsAttr[LENGTH]);
61
62 prob->setElementLength(length); // is this needed here?
63 prob->setDimensions(xstart, xend, ystart, yend);
64 prob->setStep(step);
66
67 // Transmit "unknown" attributes.
69}
double getReal(const Attribute &attr)
Return real value.
Attribute makeReal(const std::string &name, const std::string &help)
Make real attribute.
std::string getString(const Attribute &attr)
Get string value.
constexpr double mm2m
Definition Units.h:29
virtual void setElementLength(double length)
Set design length.
void setOutputFN(std::string fn)
Set output filename.
void setDimensions(double xstart, double xend, double ystart, double yend)
Set dimensions and consistency checks.
void setStep(double step)
Set probe histogram bin width.
Definition Probe.cpp:57
ElementBase * getElement() const
Return the embedded CLASSIC element.
Definition Element.h:121
void setElement(ElementBase *)
Assign new CLASSIC element.
Definition Element.h:126
std::vector< Attribute > itsAttr
The object attributes.
Definition Object.h:216
virtual void updateUnknown(ElementBase *)
Transmit the ``unknown'' (not known to OPAL) attributes to CLASSIC.
virtual void update()
Update the embedded CLASSIC element.
OpalElement(int size, const char *name, const char *help)
Exemplar constructor.
void registerOwnership() const
OpalProbe()
Exemplar constructor.
Definition OpalProbe.cpp:25
virtual ~OpalProbe()
Definition OpalProbe.cpp:42
virtual OpalProbe * clone(const std::string &name)
Make clone.
Definition OpalProbe.cpp:45
virtual void update()
Update the embedded CLASSIC probe.
Definition OpalProbe.cpp:49