DefaultVisitor.h 6.02 KB
Newer Older
gsell's avatar
gsell committed
1
//
2
// Class DefaultVisitor
gsell's avatar
gsell committed
3
//   The default interface for a BeamlineVisitor.
4 5 6
//   A default implementation for all visitors that can iterate over a
//   beam line representation.
//   This abstract base class implements the default behaviour for the
frey_m's avatar
frey_m committed
7
//   structural classes Beamline and FlaggedElmPtr.
8 9
//   It also holds the data required for all visitors in a protected area.
//
frey_m's avatar
frey_m committed
10
// Copyright (c) 200x - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland
11 12 13
// All rights reserved
//
// This file is part of OPAL.
gsell's avatar
gsell committed
14
//
15 16 17 18
// OPAL is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
gsell's avatar
gsell committed
19
//
20 21
// You should have received a copy of the GNU General Public License
// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
gsell's avatar
gsell committed
22
//
23 24
#ifndef CLASSIC_DefaultVisitor_HH
#define CLASSIC_DefaultVisitor_HH
gsell's avatar
gsell committed
25 26 27

#include "AbsBeamline/BeamlineVisitor.h"

snuverink_j's avatar
snuverink_j committed
28
class ElementBase;
gsell's avatar
gsell committed
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47

class DefaultVisitor: public BeamlineVisitor {

public:

    /// Constructor.
    //  Arguments:
    //  [ol]
    //  [li]The beamline to be used.
    //  [li]If true, the beam runs backwards through the line.
    //  [li]If true, we track against the beam.
    //  [/ol]
    DefaultVisitor(const Beamline &beamline, bool backBeam, bool backTrack);

    virtual ~DefaultVisitor() = 0;

    /// Apply the algorithm to the top-level beamline.
    virtual void execute();

48 49 50
    /// Apply the algorithm to a beam stripping.
    virtual void visitBeamStripping(const BeamStripping &);

gsell's avatar
gsell committed
51
    /// Apply the algorithm to a collimator.
52
    virtual void visitCCollimator(const CCollimator &);
gsell's avatar
gsell committed
53 54 55 56 57 58 59

    /// Apply the algorithm to an arbitrary component.
    virtual void visitComponent(const Component &);

    /// Apply the algorithm to an cyclotron
    virtual void visitCyclotron(const Cyclotron &);

60
    /// Apply the algorithm to an opal ring..
kraus's avatar
kraus committed
61
    virtual void visitRing(const Ring &);
62

gsell's avatar
gsell committed
63 64 65
    /// Apply the algorithm to a corrector.
    virtual void visitCorrector(const Corrector &);

adelmann's avatar
adelmann committed
66 67 68
    /// Apply the algorithm to a drift.
    virtual void visitDegrader(const Degrader &);

gsell's avatar
gsell committed
69 70 71
    /// Apply the algorithm to a drift.
    virtual void visitDrift(const Drift &);

72 73 74
    /// Apply the algorithm to a flexible collimator
    virtual void visitFlexibleCollimator(const FlexibleCollimator &);

gsell's avatar
gsell committed
75 76 77 78 79 80 81 82 83
    /// Apply the algorithm to a marker.
    virtual void visitMarker(const Marker &);

    /// Apply the algorithm to a monitor.
    virtual void visitMonitor(const Monitor &);

    /// Apply the algorithm to a multipole.
    virtual void visitMultipole(const Multipole &);

ext-rogers_c's avatar
ext-rogers_c committed
84 85 86
    /// Apply the algorithm to a multipoleT.
    virtual void visitMultipoleT(const MultipoleT &);

87 88 89 90 91 92 93 94 95
    /// Apply the algorithm to a multipoleTStraight.
    virtual void visitMultipoleTStraight(const MultipoleTStraight &);

    /// Apply the algorithm to a multipoleTCurvedConstRadius.
    virtual void visitMultipoleTCurvedConstRadius(const MultipoleTCurvedConstRadius &);

    /// Apply the algorithm to a multipoleTCurvedVarRadius.
    virtual void visitMultipoleTCurvedVarRadius(const MultipoleTCurvedVarRadius &);

96 97 98
    /// Apply the algorithm to an Offset.
    virtual void visitOffset(const Offset &);

gsell's avatar
gsell committed
99 100 101 102 103 104
    /// Apply the algorithm to a probe.
    virtual void visitProbe(const Probe &prob);

    /// Apply the algorithm to a rectangular bend.
    virtual void visitRBend(const RBend &);

105 106 107
    /// Apply the algorithm to a rectangular bend.
    virtual void visitRBend3D(const RBend3D &);

108 109 110
    /// Apply the algorithm to a RF cavity.
    virtual void visitVariableRFCavity(const VariableRFCavity &vcav);

111 112 113
    /// Apply the algorithm to a RF cavity.
    virtual void visitVariableRFCavityFringeField(const VariableRFCavityFringeField &vcav);

gsell's avatar
gsell committed
114 115 116 117 118 119
    /// Apply the algorithm to a RF cavity.
    virtual void visitRFCavity(const RFCavity &);

    /// Apply the algorithm to a RF cavity.
    virtual void visitTravelingWave(const TravelingWave &);

120 121 122 123 124
#ifdef ENABLE_OPAL_FEL
    /// Apply the algorithm to an undulator.
    virtual void visitUndulator(const Undulator &);
#endif

gsell's avatar
gsell committed
125 126 127
    /// Apply the algorithm to a sector bend.
    virtual void visitSBend(const SBend &);

128 129 130
    /// Apply the algorithm to a sector bend.
    virtual void visitSBend3D(const SBend3D &);

ext-rogers_c's avatar
ext-rogers_c committed
131 132
    /// Apply the algorithm to a scaling FFA magnet.
    virtual void visitScalingFFAMagnet(const ScalingFFAMagnet &);
133

134 135 136
    /// Apply the algorithm to a RF cavity.
    virtual void visitVerticalFFAMagnet(const VerticalFFAMagnet &);

gsell's avatar
gsell committed
137 138 139 140 141 142
    /// Apply the algorithm to a septum.
    virtual void visitSeptum(const Septum &);

    /// Apply the algorithm to a solenoid.
    virtual void visitSolenoid(const Solenoid &);

143 144 145
    /// Apply the algorithm to a source.
    virtual void visitSource(const Source &);

gsell's avatar
gsell committed
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184
    /// Apply the algorithm to a charge stripper.
    virtual void visitStripper(const Stripper &);

    /// Apply the algorithm to a beam line.
    virtual void visitBeamline(const Beamline &);

    /// Apply the algorithm to a FlaggedElmPtr.
    virtual void visitFlaggedElmPtr(const FlaggedElmPtr &);

protected:

    // The top level beamline.
    const Beamline &itsLine;

    // The direction flags and corresponding factors.
    bool back_beam;   // true, if beam runs from right (s=C) to left (s=0).
    bool back_track;  // true, if tracking opposite to the beam direction.
    bool back_path;   // true, if tracking from right (s=C) to left (s=0).
    // back_path = back_beam && ! back_track || back_track && ! back_beam.

    double flip_B;    // set to -1.0 to flip B fields, when back_beam is true.
    double flip_s;    // set to -1.0 to flip direction of s,
    // when back_path is true.

private:

    // Not implemented.
    DefaultVisitor();
    DefaultVisitor(const DefaultVisitor &);
    void operator=(const DefaultVisitor &);

    // Default do-nothing routine.
    virtual void applyDefault(const ElementBase &);

    // The element order flag. Initially set to back_path.
    // This flag is reversed locally for reflected beam lines.
    bool local_flip;
};

185
#endif // CLASSIC_DefaultVisitor_HH