OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
CyclotronRep.cpp
Go to the documentation of this file.
1//
2// Class CyclotronRep
3// Representation for a cyclotron magnet system
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//
20
21// Attribute access table.
22// ------------------------------------------------------------------------
23
24namespace {
25 struct Entry {
26 const char *name;
27 double(CyclotronRep::*get)() const;
28 void (CyclotronRep::*set)(double);
29 };
30
31 static const Entry entries[] = {
32 {
33 "RINIT",
34 0, // :FIXME: Why commented out? &CyclotronRep::getRadius,
35 0 // :FIXME: &CyclotronRep::setRadius
36 },
37 { 0, 0, 0 }
38 };
39}
40
41
43 Cyclotron(),
44 geometry(0.0, 0.0),
45 field() {
46 rInit = 0.0;
47}
48
49
51 Cyclotron(rhs),
52 geometry(rhs.geometry),
53 field(rhs.field) {
54 rInit = rhs.rInit;
55}
56
57
58CyclotronRep::CyclotronRep(const std::string &name):
60 geometry(0.0, 0.0),
61 field() {
62 rInit = 0.0;
63}
64
65
67{}
68
69
71 return new CyclotronRep(*this);
72}
73
74
75Channel *CyclotronRep::getChannel(const std::string &aKey, bool create) {
76 for(const Entry *entry = entries; entry->name != 0; ++entry) {
77 if(aKey == entry->name) {
78 return new IndirectChannel<CyclotronRep>(*this, entry->get, entry->set);
79 }
80 }
81
82 return ElementBase::getChannel(aKey, create);
83}
84
85
87 return slices;
88}
89
91 return stepsize;
92}
93
94void CyclotronRep::setSlices(double sl) {
95 slices = sl;
96}
97
99 stepsize = ds;
100}
101
102/*
103void CyclotronRep::setRadius(double r)
104{
105 rInit = r;
106}
107
108double CyclotronRep::getRadius() const
109{
110 return rInit ;
111}
112*/
113
115 return geometry;
116}
117
119 return geometry;
120}
121
123 return field;
124}
125
127 return field;
128}
129
131 field = f;
132}
133
const std::string name
virtual Channel * getChannel(const std::string &aKey, bool create=false)
Construct a read/write channel.
double stepsize
Definition: CyclotronRep.h:115
virtual double getStepsize() const
Get stepsize.
virtual void setStepsize(double ds)
Set stepsize.
virtual void setSlices(double sl)
Set number of slices.
virtual ~CyclotronRep()
virtual BMultipoleField & getField()
Get field.
virtual ElementBase * clone() const
Return clone.
virtual Channel * getChannel(const std::string &aKey, bool=false)
Construct a read/write channel.
BMultipoleField field
The field expansion.
Definition: CyclotronRep.h:111
virtual double getSlices() const
Get the initial radius.
double rInit
The initial radius of the cyclotron.
Definition: CyclotronRep.h:96
virtual void setField(const BMultipoleField &field)
Set field.
PlanarArcGeometry geometry
The cyclotron geometry.
Definition: CyclotronRep.h:108
virtual PlanarArcGeometry & getGeometry()
Get geometry.
A simple arc in the XZ plane.
Abstract interface for read/write access to variable.
Definition: Channel.h:32
Access to a [b]double[/b] data member.
The magnetic field of a multipole.