OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
BeamBeamRep.cpp
Go to the documentation of this file.
1 // ------------------------------------------------------------------------
2 // $RCSfile: BeamBeamRep.cpp,v $
3 // ------------------------------------------------------------------------
4 // $Revision: 1.1.1.1 $
5 // ------------------------------------------------------------------------
6 // Copyright: see Copyright.readme
7 // ------------------------------------------------------------------------
8 //
9 // Class: BeamBeamRep
10 // Defines a concrete beam-beam interaction.
11 //
12 // ------------------------------------------------------------------------
13 // Class category: BeamlineCore
14 // ------------------------------------------------------------------------
15 //
16 // $Date: 2000/03/27 09:32:33 $
17 // $Author: fci $
18 //
19 // ------------------------------------------------------------------------
20 
27 
28 
29 // Attribute access table.
30 // ------------------------------------------------------------------------
31 
32 namespace {
33  struct Entry {
34  const char *name;
35  double(BeamBeamRep::*get)() const;
36  void (BeamBeamRep::*set)(double);
37  };
38 
39  const Entry entries[] = {
40  {
41  "L",
43  0
44  },
45  {
46  "CHARGE",
49  },
50  { 0, 0, 0 }
51  };
52 }
53 
54 
55 // Class BeamBeamRep
56 // ------------------------------------------------------------------------
57 
59  BeamBeam(), geometry()
60 {}
61 
62 
64  BeamBeam(right), geometry()
65 {}
66 
67 
68 BeamBeamRep::BeamBeamRep(const std::string &name):
69  BeamBeam(name), geometry()
70 {}
71 
72 
74 {}
75 
76 
78  return new BeamBeamRep(*this);
79 }
80 
81 
82 Channel *BeamBeamRep::getChannel(const std::string &aKey, bool create) {
83  static char plane[] = "XYS";
84  if(aKey[0] == 'D') {
85  for(int i = 0; i < 3; i++) {
86  if(aKey[1] == plane[i]) {
90  }
91  }
92  } else if(aKey[0] == 'R') {
93  for(int i = 0; i < 3; i++) {
94  if(aKey[1] == plane[i]) {
95  for(int j = 0; j < 3; j++) {
96  if(aKey[2] == plane[j]) {
97  int index = 3 * i + j;
99  (*this, &BeamBeamRep::getMoment,
100  &BeamBeamRep::setMoment, index);
101  }
102  }
103  }
104  }
105  }
106 
107  for(const Entry *entry = entries; entry->name != 0; ++entry) {
108  if(aKey == entry->name) {
109  return new IndirectChannel<BeamBeamRep>(*this, entry->get, entry->set);
110  }
111  }
112 
113  return ElementBase::getChannel(aKey, create);
114 }
115 
116 
118  return Q;
119 }
120 
121 
123  return sigma;
124 }
125 
126 
128  return delta;
129 }
130 
131 
133  return field;
134 }
135 
136 
138  return field;
139 }
140 
141 
143  return geometry;
144 }
145 
147  return geometry;
148 }
149 
150 
153 
154  for(const Entry *entry = entries; entry->name != 0; ++entry) {
155  image->setAttribute(entry->name, (this->*(entry->get))());
156  }
157 
158  return image;
159 }
160 
161 
162 void BeamBeamRep::setBunchCharge(double charge) {
163  Q = charge;
164 }
165 
166 
167 void BeamBeamRep::setBunchMoment(const Matrix3D &moments) {
168  sigma = moments;
169 }
170 
171 
173  delta = disp;
174 }
175 
176 
177 double BeamBeamRep::getMoment(int index) const {
178  int i1 = index / 3;
179  int i2 = index % 3;
180  return sigma(i1, i2);
181 }
182 
183 
184 double BeamBeamRep::getDisplacement(int index) const {
185  return delta(index);
186 }
187 
188 
189 void BeamBeamRep::setMoment(int index, double moment) {
190  int i1 = index / 3;
191  int i2 = index % 3;
192  sigma(i1, i2) = sigma(i2, i1) = moment;
193 }
194 
195 
196 void BeamBeamRep::setDisplacement(int index, double disp) {
197  delta(index) = disp;
198 }
Interface for basic beam line object.
Definition: ElementBase.h:128
virtual const Vector3D & getBunchDisplacement() const
Get displacement.
Matrix3D sigma
Definition: BeamBeamRep.h:149
virtual ElementBase * clone() const
Return clone.
Definition: BeamBeamRep.cpp:77
Representation of beam-beam interaction.
Definition: BeamBeamRep.h:47
void setBunchMoment(const Matrix3D &)
Set moments.
double getMoment(int index) const
virtual double getBunchCharge() const
Get bunch charge.
virtual Channel * getChannel(const std::string &aKey, bool create=false)
Construct a read/write channel.
void setBunchDisplacement(const Vector3D &)
Set displacement.
void setMoment(int index, double)
Vector3D delta
Definition: BeamBeamRep.h:146
A zero electromagnetic field.
Definition: NullField.h:30
Access to an indexed [b]double[/b] data member.
virtual ElementImage * getImage() const
Construct an image.
virtual double getElementLength() const
Get design length.
Definition: ElementBase.h:511
virtual ~BeamBeamRep()
Definition: BeamBeamRep.cpp:73
NullGeometry geometry
Definition: BeamBeamRep.h:139
virtual NullGeometry & getGeometry()
Get geometry.
An image of an element.
Definition: ElementImage.h:35
virtual ElementImage * getImage() const
Construct an image.
Geometry representing an identity transform.
Definition: NullGeometry.h:32
Abstract beam-beam interaction.
Definition: BeamBeam.h:37
void setAttribute(const std::string &aKey, double val)
Set value of an attribute.
3-dimensional matrix.
Definition: Matrix3D.h:33
NullField field
Definition: BeamBeamRep.h:136
virtual const Matrix3D & getBunchMoment() const
Get moments.
double getDisplacement(int index) const
A 3-dimension vector.
Definition: Vector3D.h:31
Abstract interface for read/write access to variable.
Definition: Channel.h:32
void setDisplacement(int index, double)
const std::string name
void setBunchCharge(double)
Set the bunch charge.
virtual Channel * getChannel(const std::string &aKey, bool=false)
Construct a read/write channel.
Definition: BeamBeamRep.cpp:82
virtual NullField & getField()
Get field.
Access to a [b]double[/b] data member.