OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
DefaultVisitor.cpp
Go to the documentation of this file.
1 // ------------------------------------------------------------------------
2 // $RCSfile: DefaultVisitor.cpp,v $
3 // ------------------------------------------------------------------------
4 // $Revision: 1.2 $
5 // ------------------------------------------------------------------------
6 // Copyright: see Copyright.readme
7 // ------------------------------------------------------------------------
8 //
9 // Class: DefaultVisitor
10 // Defines the default interface for a BeamlineVisitor.
11 //
12 // ------------------------------------------------------------------------
13 // Class category: Algorithms
14 // ------------------------------------------------------------------------
15 //
16 // $Date: 2000/05/03 08:16:04 $
17 // $Author: mad $
18 //
19 // ------------------------------------------------------------------------
20 
22 
24 #include "AbsBeamline/BeamBeam.h"
27 #include "AbsBeamline/Corrector.h"
28 #include "AbsBeamline/Cyclotron.h"
29 #include "AbsBeamline/Diagnostic.h"
30 #include "AbsBeamline/Drift.h"
31 #include "AbsBeamline/Degrader.h"
34 #include "AbsBeamline/Lambertson.h"
35 #include "AbsBeamline/Offset.h"
36 #include "AbsBeamline/Marker.h"
37 #include "AbsBeamline/Monitor.h"
38 #include "AbsBeamline/Multipole.h"
39 #include "AbsBeamline/MultipoleT.h"
43 #include "AbsBeamline/Patch.h"
44 #include "AbsBeamline/Probe.h"
45 #include "AbsBeamline/RBend.h"
46 #include "AbsBeamline/RBend3D.h"
47 #include "AbsBeamline/RFCavity.h"
52 #include "AbsBeamline/SBend.h"
53 #include "AbsBeamline/SBend3D.h"
56 #include "AbsBeamline/Separator.h"
57 #include "AbsBeamline/Septum.h"
58 #include "AbsBeamline/Solenoid.h"
59 #include "AbsBeamline/Source.h"
62 #include "AbsBeamline/Stripper.h"
63 
66 
67 #include "Beamlines/Beamline.h"
69 
75 
76 #include "AbsBeamline/Ring.h" // OPAL file
77 
78 // Class DefaultVisitor
79 // ------------------------------------------------------------------------
80 
82  bool backBeam, bool backTrack):
83  itsLine(beamline), back_beam(backBeam), back_track(backTrack) {
85  ( back_beam && ! back_track ) || ( back_track && ! back_beam );
86  flip_B = back_beam ? -1.0 : 1.0;
87  flip_s = back_path ? -1.0 : 1.0;
88 }
89 
90 
92 {}
93 
94 
96  local_flip = ( back_beam && ! back_track ) || ( back_track && ! back_beam );
97  itsLine.accept(*this);
98 }
99 
100 
102  applyDefault(bb);
103 }
104 
106  applyDefault(bstp);
107 }
108 
110  applyDefault(coll);
111 }
112 
114  applyDefault(cyc);
115 }
116 
118  applyDefault(comp);
119 }
120 
122  applyDefault(corr);
123 }
124 
126  applyDefault(deg);
127 }
128 
130  applyDefault(diag);
131 }
132 
134  applyDefault(drf);
135 }
136 
138  applyDefault(coll);
139 }
140 
142  applyDefault(lamb);
143 }
144 
146  applyDefault(mark);
147 }
148 
150  applyDefault(mon);
151 }
152 
154  applyDefault(mult);
155 }
156 
158  applyDefault(multT);
159 }
160 
162  applyDefault(multTstraight);
163 }
164 
166  applyDefault(multTccurv);
167 }
168 
170  applyDefault(multTvcurv);
171 }
172 
174  applyDefault(off);
175 }
176 
177 void DefaultVisitor::visitRing(const Ring &ring) {
178  applyDefault(ring);
179 }
180 
181 
182 void DefaultVisitor::visitPatch(const Patch &patch) {
183  applyDefault(patch);
184 }
185 
186 void DefaultVisitor::visitProbe(const Probe &probe) {
187  applyDefault(probe);
188 }
189 
191  applyDefault(bend);
192 }
193 
195  applyDefault(bend);
196 }
197 
199  applyDefault(vcav);
200 }
201 
204  applyDefault(vcav);
205 }
206 
208  applyDefault(cav);
209 }
210 
211 
213  applyDefault(trw);
214 }
215 
216 
218  applyDefault(quad);
219 }
220 
221 
223  applyDefault(bend);
224 }
225 
226 
228  applyDefault(bend);
229 }
230 
231 
233  applyDefault(spiral);
234 }
235 
237  applyDefault(mag);
238 }
239 
241  applyDefault(sep);
242 }
243 
244 
246  applyDefault(sept);
247 }
248 
249 
251  applyDefault(sol);
252 }
253 
255  applyDefault(sou);
256 }
257 
258 
260  applyDefault(pplate);
261 }
262 
264  applyDefault(cv);
265 }
266 
268  applyDefault(cv);
269 }
270 
272  // Default behaviour: Apply algorithm to all beamline members.
273  // If flip_local is true, track from right to left.
274  bl.iterate(*this, local_flip);
275 }
276 
277 
279  if(fep.getReflectionFlag()) {
281  fep.getElement()->accept(*this);
283  } else {
284  fep.getElement()->accept(*this);
285  }
286 }
287 
288 
290  // Default behaviour: Apply algorithm to the non-offset element.
291  wrap.getElement()->accept(*this);
292 }
293 
294 
296  visitCorrector(wrap);
297 }
298 
300  visitCyclotron(wrap);
301 }
302 
303 
305  visitMultipole(wrap);
306 }
307 
308 
310  visitRBend(wrap);
311 }
312 
313 
315  visitSBend(wrap);
316 }
317 
318 
320  // Default: cannot use integrator.
321  i.getElement()->accept(*this);
322 }
323 
324 
326  // Default: cannot use integrator.
327  i.getElement()->accept(*this);
328 }
329 
330 
332  // Default: cannot use integrator.
333  i.getElement()->accept(*this);
334 }
335 
336 
338 {}
virtual void visitCyclotron(const Cyclotron &)
Apply the algorithm to an cyclotron.
virtual void visitFlexibleCollimator(const FlexibleCollimator &)
Apply the algorithm to a flexible collimator.
virtual ElementBase * getElement() const
Return the contained element.
virtual void iterate(BeamlineVisitor &, bool reverse) const =0
Apply visitor to all elements of the line.
Definition: Source.h:12
Interface for solenoids.
Definition: RBend3D.h:39
virtual void visitMultipoleWrapper(const MultipoleWrapper &)
Apply the algorithm to an multipole wrapper..
virtual void visitDrift(const Drift &)
Apply the algorithm to a drift.
virtual void visitMonitor(const Monitor &)
Apply the algorithm to a monitor.
Interface for basic beam line object.
Definition: ElementBase.h:128
Definition: Offset.h:66
virtual void applyDefault(const ElementBase &)
Interface for septum magnet.
Definition: Septum.h:11
Interface for electrostatic separator.
Definition: Separator.h:33
Interface for a Cyclotron.
Definition: Cyclotron.h:91
virtual void visitTravelingWave(const TravelingWave &)
Apply the algorithm to a RF cavity.
Interface for beam position monitors.
Definition: Monitor.h:41
Interface for RF Quadrupole.
Definition: RFQuadrupole.h:30
ElementBase * getElement() const
Return the embedded element.
Definition: Integrator.h:97
virtual void visitRFQuadrupole(const RFQuadrupole &)
Apply the algorithm to a RF quadrupole.
virtual void visitAlignWrapper(const AlignWrapper &)
Apply the algorithm to an align wrapper..
virtual void visitVerticalFFAMagnet(const VerticalFFAMagnet &)
Apply the algorithm to a RF cavity.
virtual void visitSolenoid(const Solenoid &)
Apply the algorithm to a solenoid.
virtual void visitOffset(const Offset &)
Apply the algorithm to an Offset.
Define the position of a misaligned element.
Definition: AlignWrapper.h:39
Interface for RF cavity.
Definition: ParallelPlate.h:36
virtual void visitMultipoleTCurvedVarRadius(const MultipoleTCurvedVarRadius &)
Apply the algorithm to a multipoleTCurvedVarRadius.
virtual void visitCyclotronWrapper(const CyclotronWrapper &)
Apply the algorithm to an cyclotron wrapper..
virtual void visitCorrector(const Corrector &)
Apply the algorithm to a corrector.
virtual void visitRing(const Ring &)
Apply the algorithm to an opal ring..
Interface for general corrector.
Definition: Corrector.h:35
Abstract collimator.
Definition: RBend.h:73
Interface for beam diagnostics.
Definition: Diagnostic.h:32
Interface for a marker.
Definition: Marker.h:32
virtual void visitFlaggedElmPtr(const FlaggedElmPtr &)
Apply the algorithm to a FlaggedElmPtr.
Representation of a perturbed multipole.
virtual void visitBeamBeam(const BeamBeam &)
Apply the algorithm to a beam-beam.
Interface for drift space.
Definition: Drift.h:33
virtual void visitCyclotronValley(const CyclotronValley &)
Apply the algorithm to a CyclotronValley.
virtual void visitCorrectorWrapper(const CorrectorWrapper &)
Apply the algorithm to an corrector wrapper..
virtual void visitMapIntegrator(const MapIntegrator &)
Apply the algorithm to an integrator capable of mapping.
virtual void visitMultipoleTCurvedConstRadius(const MultipoleTCurvedConstRadius &)
Apply the algorithm to a multipoleTCurvedConstRadius.
Interface for general multipole.
Definition: Multipole.h:46
virtual void visitIntegrator(const Integrator &)
Apply the algorithm to a generic integrator.
virtual void visitMultipoleT(const MultipoleT &)
Apply the algorithm to a multipoleT.
virtual void visitTrackIntegrator(const TrackIntegrator &)
Apply the algorithm to an integrator capable of tracking.
T deg(T x)
Convert radians to degrees.
Definition: matheval.hpp:82
virtual void visitMarker(const Marker &)
Apply the algorithm to a marker.
virtual void visitRFCavity(const RFCavity &)
Apply the algorithm to a RF cavity.
Interface for probe.
Definition: Probe.h:16
virtual void visitRBend(const RBend &)
Apply the algorithm to a rectangular bend.
virtual void visitVariableRFCavity(const VariableRFCavity &vcav)
Apply the algorithm to a RF cavity.
virtual ~DefaultVisitor()=0
virtual void visitMultipoleTStraight(const MultipoleTStraight &)
Apply the algorithm to a multipoleTStraight.
virtual void accept(BeamlineVisitor &visitor) const =0
Apply visitor.
virtual void visitDegrader(const Degrader &)
Apply the algorithm to a drift.
virtual void visitBeamStripping(const BeamStripping &)
Apply the algorithm to a beam stripping.
virtual void visitSBend3D(const SBend3D &)
Apply the algorithm to a sector bend.
Interface for cyclotron collimator.
Definition: CCollimator.h:13
Abstract beam-beam interaction.
Definition: BeamBeam.h:37
Interface for RF cavity.
Definition: TravelingWave.h:37
Definition: SBend.h:68
Representation of a perturbed cyclotron.
const Beamline & itsLine
virtual void visitMultipole(const Multipole &)
Apply the algorithm to a multipole.
Interface for cyclotron valley.
virtual void visitRBendWrapper(const RBendWrapper &)
Apply the algorithm to an RBend wrapper..
Representation of a perturbed sector bend.
Definition: SBendWrapper.h:37
Interface for solenoids.
Definition: Solenoid.h:36
An abstract sequence of beam line components.
Definition: Beamline.h:37
Integrate particle.
virtual void visitSeptum(const Septum &)
Apply the algorithm to a septum.
virtual void visitBeamline(const Beamline &)
Apply the algorithm to a beam line.
virtual void visitStripper(const Stripper &)
Apply the algorithm to a charge stripper.
virtual void execute()
Apply the algorithm to the top-level beamline.
Representation for a perturbed closed orbit corrector.
virtual void visitDiagnostic(const Diagnostic &)
Apply the algorithm to a diagnostic.
virtual void visitPatch(const Patch &pat)
Apply the algorithm to a patch.
Interface for RF cavity.
Definition: RFCavity.h:37
virtual void visitComponent(const Component &)
Apply the algorithm to an arbitrary component.
virtual void visitSBend(const SBend &)
Apply the algorithm to a sector bend.
virtual void visitProbe(const Probe &prob)
Apply the algorithm to a probe.
Abstract collimator.
Definition: Degrader.h:37
virtual void visitCCollimator(const CCollimator &)
Apply the algorithm to a collimator.
virtual void visitLambertson(const Lambertson &)
Apply the algorithm to a Lambertson.
virtual void visitScalingFFAMagnet(const ScalingFFAMagnet &)
Apply the algorithm to a scaling FFA magnet.
virtual void visitParallelPlate(const ParallelPlate &)
Apply the algorithm to a ParallelPlate.
Base class for special integrators.
Definition: Integrator.h:41
bool getReflectionFlag() const
Get reflection flag.
Ring describes a ring type geometry for tracking.
Definition: Ring.h:64
Interface for a geometric patch.
Definition: Patch.h:34
Interface for a single beam element.
Definition: Component.h:51
virtual void visitVariableRFCavityFringeField(const VariableRFCavityFringeField &vcav)
Apply the algorithm to a RF cavity.
Representation of a perturbed rectangular bend.
Definition: RBendWrapper.h:37
virtual void visitRBend3D(const RBend3D &)
Apply the algorithm to a rectangular bend.
ElementBase * getElement() const
Get the element pointer.
Definition: ElmPtr.h:58
virtual void visitSource(const Source &)
Apply the algorithm to a source.
virtual void visitSeparator(const Separator &)
Apply the algorithm to a separator.
Interface for a Lambertson septum.
Definition: Lambertson.h:33
Integrate a map.
Definition: MapIntegrator.h:41
virtual void visitSBendWrapper(const SBendWrapper &)
Apply the algorithm to an SBend wrapper..
A section of a beam line.
Definition: FlaggedElmPtr.h:36