OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
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 "Structure/OpalWake.h"
23#include "Physics/Physics.h"
24#include "Physics/Units.h"
25
27 OpalElement(SIZE, "PROBE",
28 "The \"PROBE\" element defines a Probe."),
29 owk_m(nullptr) {
30
32 ("XSTART", " Start of x coordinate [mm]");
34 ("XEND", " End of x coordinate [mm]");
36 ("YSTART", "Start of y coordinate [mm]");
38 ("YEND", "End of y coordinate [mm]");
40 ("WIDTH", "Width of the probe, not used.");
42 ("STEP", "Step size of the probe [mm]", 1.0);
43
45
46 setElement(new ProbeRep("PROBE"));
47}
48
49
50OpalProbe::OpalProbe(const std::string &name, OpalProbe *parent):
51 OpalElement(name, parent),
52 owk_m(nullptr) {
54}
55
56
58 delete owk_m;
59}
60
61
62OpalProbe *OpalProbe::clone(const std::string &name) {
63 return new OpalProbe(name, this);
64}
65
66
69
70 ProbeRep *prob =
71 dynamic_cast<ProbeRep *>(getElement());
72
78
79 double length = Attributes::getReal(itsAttr[LENGTH]);
80
81 if(itsAttr[WAKEF] && owk_m == nullptr) {
83 owk_m->initWakefunction(*prob);
84 prob->setWake(owk_m->wf_m);
85 }
86 prob->setElementLength(length); // is this needed here?
87 prob->setDimensions(xstart, xend, ystart, yend);
88 prob->setStep(step);
90
91 // Transmit "unknown" attributes.
93}
@ SIZE
Definition: IndexMap.cpp:174
const std::string name
double getReal(const Attribute &attr)
Return real value.
Definition: Attributes.cpp:252
Attribute makeReal(const std::string &name, const std::string &help)
Make real attribute.
Definition: Attributes.cpp:240
std::string getString(const Attribute &attr)
Get string value.
Definition: Attributes.cpp:343
constexpr double mm2m
Definition: Units.h:29
ElementBase * getElement() const
Return the embedded CLASSIC element.
Definition: Element.h:120
void setElement(ElementBase *)
Assign new CLASSIC element.
Definition: Element.h:125
const std::string & getOpalName() const
Return object name.
Definition: Object.cpp:310
std::vector< Attribute > itsAttr
The object attributes.
Definition: Object.h:216
virtual void setElementLength(double length)
Set design length.
Definition: ElementBase.h:418
void setOutputFN(std::string fn)
Set output filename.
virtual void setWake(WakeFunction *wf)
attach a wake field to the element
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:60
virtual void updateUnknown(ElementBase *)
Transmit the `‘unknown’' (not known to OPAL) attributes to CLASSIC.
virtual void update()
Update the embedded CLASSIC element.
void registerOwnership() const
OpalProbe()
Exemplar constructor.
Definition: OpalProbe.cpp:26
OpalWake * owk_m
Definition: OpalProbe.h:59
virtual ~OpalProbe()
Definition: OpalProbe.cpp:57
virtual OpalProbe * clone(const std::string &name)
Make clone.
Definition: OpalProbe.cpp:62
virtual void update()
Update the embedded CLASSIC probe.
Definition: OpalProbe.cpp:67
WakeFunction * wf_m
Definition: OpalWake.h:56
static OpalWake * find(const std::string &name)
Find named WAKE.
Definition: OpalWake.cpp:127
void initWakefunction(const ElementBase &element)
Definition: OpalWake.cpp:147