Collimator.h 4.68 KB
Newer Older
gsell's avatar
gsell committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
#ifndef CLASSIC_Collimator_HH
#define CLASSIC_Collimator_HH

// Class category: AbsBeamline
// ------------------------------------------------------------------------
//
// $Date: 2000/03/27 09:32:31 $
// $Author: fci $
// Copyright: see Copyright.readme
// ------------------------------------------------------------------------
//
// Class: Collimator
//   Defines the abstract interface for a beam Collimator.
//   *** MISSING *** Collimator interface is still incomplete.
//
// ------------------------------------------------------------------------
// Class category: AbsBeamline
// ------------------------------------------------------------------------
//
// $Date: 2000/03/27 09:32:31 $
// $Author: fci $
//
// ------------------------------------------------------------------------

#include "AbsBeamline/Component.h"
#include "AbsBeamline/BeamlineVisitor.h"
#include "BeamlineGeometry/StraightGeometry.h"

29
//#include "H5hut.h"
gsell's avatar
gsell committed
30 31
#include <vector>

32
typedef struct h5_file h5_file_t;
33 34
class LossDataSink;

gsell's avatar
gsell committed
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
// Class Collimator
// ------------------------------------------------------------------------
/// Abstract collimator.
//  Class Collimator defines the abstract interface for a collimator.

class Collimator: public Component {

public:

    /// Plane selection.
    enum Plane {
        /// Monitor is off (inactive).
        OFF,
        /// Monitor acts on x-plane.
        X,
        /// Monitor acts on y-plane.
        Y,
        /// Monitor acts on both planes.
        XY
    };

    /// Constructor with given name.
    explicit Collimator(const string &name);

    Collimator();
    Collimator(const Collimator &rhs);
    virtual ~Collimator();

    /// Apply visitor to Collimator.
    virtual void accept(BeamlineVisitor &) const;

    /// Return the horizontal half-aperture.
    virtual double getXsize() const {return a_m;}

    /// Return the vertical half-aperture.
    virtual double getYsize() const {return b_m;}

    virtual bool apply(const int &i, const double &t, double E[], double B[]);

    virtual bool apply(const int &i, const double &t, Vector_t &E, Vector_t &B);

    virtual bool apply(const Vector_t &R, const Vector_t &centroid, const double &t, Vector_t &E, Vector_t &B);

    virtual bool checkCollimator(PartBunch &bunch, const int turnnumber, const double t, const double tstep);

    virtual void initialise(PartBunch *bunch, double &startField, double &endField, const double &scaleFactor);

    virtual void initialise(PartBunch *bunch, const double &scaleFactor);

    virtual void finalise();

    virtual bool bends() const;

    virtual void goOnline();

    virtual void goOffline();

    virtual const string &getType() const;

    virtual void getDimensions(double &zBegin, double &zEnd) const;

    string  getCollimatorShape();
    void setOutputFN(string fn);
    string getOutputFN();

    void setXsize(double a) ;

    void setYsize(double b) ;

    void setXpos(double x0) ;

    void setYpos(double y0) ;

    double getXsize(double a) ;

    double getYsize(double b) ;

    double getXpos() ;

    double getYpos() ;

    // --------Cyclotron collimator

118
    void setXStart(double xstart) ;
gsell's avatar
gsell committed
119

120
    void setYStart(double ystart) ;
gsell's avatar
gsell committed
121

122
    void setXEnd(double xend) ;
gsell's avatar
gsell committed
123

124
    void setYEnd(double yend) ;
gsell's avatar
gsell committed
125

126
    void setWidth(double width) ;
gsell's avatar
gsell committed
127

128
    double getXStart() ;
gsell's avatar
gsell committed
129

130
    double getYStart() ;
gsell's avatar
gsell committed
131

132
    double getXEnd() ;
gsell's avatar
gsell committed
133

134
    double getYEnd() ;
gsell's avatar
gsell committed
135 136 137 138 139 140 141 142 143 144 145 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

    double getWidth() ;

    //-----------------

    void setRHole(double r) ;

    void setNHoles(unsigned int nx, unsigned int ny) ;

    void setPitch(double p) ;

    void setPepperPot() ;
    void setSlit() ;
    void setRColl() ;
    void setCColl() ;
    void setWire() ;

private:

    // Not implemented.
    void operator=(const Collimator &);
    h5_file_t *H5file_m;
    string filename_m;               /**< The name of the outputfile*/
    Plane plane_m;
    double position_m;
    std::vector<double> PosX_m;
    std::vector<double> PosY_m;
    std::vector<double> PosZ_m;
    std::vector<double> MomentumX_m;
    std::vector<double> MomentumY_m;
    std::vector<double> MomentumZ_m;
    std::vector<double> time_m;
    std::vector<int> id_m;
    bool informed_m;
    double a_m;
    double b_m;
    double x0_m;
    double y0_m;
173 174 175 176 177 178 179

    //parameters for CCollimator
    double xstart_m;
    double xend_m;
    double ystart_m;
    double yend_m;
    double width_m;
gsell's avatar
gsell committed
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199


    /** This defines a pepperpot */
    bool isAPepperPot_m;
    bool isASlit_m;
    bool isARColl_m;
    bool isACColl_m;
    bool isAWire_m;
    double rHole_m;
    unsigned int nHolesX_m;
    unsigned int nHolesY_m;
    double pitch_m;

    Point  geom_m[5];
    void setGeom();
    int  checkPoint( const double & x, const double & y );
    LossDataSink *lossDs_m;
};

#endif // CLASSIC_Collimator_HH