OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
Aperture.h
Go to the documentation of this file.
1 #ifndef OPAL_Aperture_HH
2 #define OPAL_Aperture_HH
3 
4 
7 #include "FixedAlgebra/FMatrix.h"
8 #include "FixedAlgebra/FVector.h"
10 #include "Beamlines/TBeamline.h"
11 #include "Tables/Twiss.h"
12 #include <cmath>
13 #include <vector>
14 #include <string>
15 
16 #include <iosfwd>
17 
18 class Aperture: public DefaultVisitor, public Table {
19 protected:
20 
21  //Properties of the optic element
22  struct Data {
23  double kq, k0s, e1, e2, l, phi, courb;
24  std::string type;
25  } data;
26 
27  //data needed for the aperture calculation
28  double co, K_beta, delta_p, n1;
29 
31 
32  //vector of points of the beam screen
33  struct coord {
34  double x;
35  double y;
36  };
37  std::vector<coord> ShapeBeamScreen;
38  std::vector<coord> ShapeHalo;
39 
40 public:
41 
42  class A_row: public FlaggedElmPtr {
43  friend class Aperture;
44  public:
45 
46 
47  A_row() {};
48  A_row(const A_row &a);
49 
50  A_row(ElementBase *elem, int occur): FlaggedElmPtr(elem) {
51  setCounter(occur);
52  }
53  A_row(const FlaggedElmPtr &rhs, int order):
54  FlaggedElmPtr(rhs), Interpol(order)
55  {}
56  inline double getBeta_x(int ind) ;
57  inline double getBeta_y(int ind) ;
58  inline double getDisp_x(int ind) ;
59  inline double getDisp_y(int ind) ;
60  inline double getDisp_x_prim(int ind) ;
61  inline double getDisp_y_prim(int ind) ;
62  inline double getApert(int ind);
63  inline std::string getType_elm() ;
64  inline double getOrb();
65 
66  private:
67  std::string Type_elm;
68  double Orb;
69  struct pt_interpol {
70  double Beta_x, Beta_y;
73  double delta_x, delta_y;
74  double apert;
75  };
76  //Vector of pt_interpol of size "order" containing the different values of Beta
77  //and Disp... inside the optic element pointed by p.
78  std::vector<pt_interpol> Interpol;
79 
80 
81  };
83 
84  Aperture();
85  Aperture(const std::string &name, Aperture *parent);
86  virtual ~Aperture() {};
87 
88  //return the maximum of the betax(y) function in the elm
89  double getBETXMAX(const A_row &, int i1 = 0, int i2 = 0) const;
90  double getBETYMAX(const A_row &, int i1 = 0, int i2 = 0) const;
91  //return the minimum of the aperture function inside the elm
92  double getAPERTMIN(const A_row &row, int i1 = 0, int i2 = 0) const;
93  //return the shape of the beam screen or the halo
94  std::vector<Aperture::coord> getShape(std::vector<double> vec);
95  //return the minimum apert of a slice if an element
96  void calcul_Apert(A_row &a, int slice, Twiss *tp);
97 
98  //return the lenght of the table
99  virtual double getLength();
100 
101  virtual double getCell(const PlaceRep &place, const std::string &colName);
102 
103  //return the beamline used
104  virtual const Beamline *getLine() const;
105  //comments in Twiss class
106  virtual CellArray getDefault() const;
107  virtual std::vector<double> getColumn(const RangeRep &rng, const std::string
108  &colName);
109  virtual std::vector<double> getRow(const PlaceRep &pos, const
110  std::vector<std::string> &cols);
111  virtual bool isDependent(const std::string &name) const;
112  virtual bool matches(Table *rhs) const;
113  virtual Expressions::PtrToScalar<double> makeColumnExpression(const std::string &colname) const;
114  virtual Object *clone(const std::string &name);
115  virtual void printTable(std::ostream &, const CellArray &)const;
116  virtual void fill();
117 
118  A_Tline::const_iterator begin() const;
120  A_Tline::const_iterator end() const;
122 
123  const A_row &getCurrent() const;
124 
125  //functions in charge of catching the properties of optic elements
126  virtual void visitMultipole(const Multipole &);
127  virtual void visitRBend(const RBend &);
128  virtual void visitSBend(const SBend &);
129  virtual void visitCyclotron(const Cyclotron &);
130  virtual void applyDefault(const ElementBase &);
131 
132  //call of the aperture command
133  void execute();
134  //execution of the aperture command
135  void run();
136 
137  void calcul(Twiss::TLine::iterator i, A_row &a, int order, Twiss *tp);
138 
139 
140 protected:
141 
142  enum {
151  };
152 
155  const Beam *beam;
158 
159  //Transformation matrix for optic elements
161 
162  //vector alpha,beta,gamma
165 
166  //Variable for dispersion
169 
170 private:
171  A_row &findRow(const PlaceRep &row);
172  mutable A_Tline::const_iterator current;
173  //line name
174  std::string itsLine;
175 };
176 
177 
178 
179 #endif //OPAL_Aperture_HH
virtual std::vector< double > getRow(const PlaceRep &pos, const std::vector< std::string > &cols)
Return a table row.
Definition: Aperture.cpp:982
std::vector< Cell > CellArray
An array of cell descriptors.
Definition: Table.h:63
void calcul_Apert(A_row &a, int slice, Twiss *tp)
Definition: Aperture.cpp:684
double courb
Definition: Aperture.h:23
double getBeta_y(int ind)
Definition: Aperture.cpp:213
double getDisp_y_prim(int ind)
Definition: Aperture.cpp:226
virtual Expressions::PtrToScalar< double > makeColumnExpression(const std::string &colname) const
Definition: Aperture.cpp:1016
double getOrb()
Definition: Aperture.cpp:235
Twiss * tp
Definition: Aperture.h:156
Interface for basic beam line object.
Definition: ElementBase.h:128
double getDisp_x_prim(int ind)
Definition: Aperture.cpp:220
virtual void visitSBend(const SBend &)
Apply the algorithm to a sector bend.
Definition: Aperture.cpp:329
A_row & findRow(const PlaceRep &row)
Definition: Aperture.cpp:1026
Interface for a Cyclotron.
Definition: Cyclotron.h:91
double tolerance_y
Definition: Aperture.h:30
std::string getType_elm()
Definition: Aperture.cpp:232
A_Tline itsTable
Definition: Aperture.h:153
const A_row & getCurrent() const
Definition: Aperture.cpp:940
void execute()
Apply the algorithm to the top-level beamline.
Definition: Aperture.cpp:831
double co
Definition: Aperture.h:28
virtual bool isDependent(const std::string &name) const
Find out if table depends on the object identified by [b]name[/b].
Definition: Aperture.cpp:1003
double k0s
Definition: Aperture.h:23
double offsetx
Definition: Aperture.h:30
Definition: RBend.h:73
double tolerance_x
Definition: Aperture.h:30
void run()
Definition: Aperture.cpp:879
double e1
Definition: Aperture.h:23
Default algorithms.
double kq
Definition: Aperture.h:23
double n1
Definition: Aperture.h:28
Twiss::TLine::iterator i
Definition: Aperture.h:157
Interface for general multipole.
Definition: Multipole.h:46
virtual ~Aperture()
Definition: Aperture.h:86
A_Tline::const_iterator begin() const
Definition: Aperture.cpp:244
Representation of a place within a beam line or sequence.
Definition: PlaceRep.h:41
std::string itsLine
Definition: Aperture.h:174
double getBETXMAX(const A_row &, int i1=0, int i2=0) const
Definition: Aperture.cpp:254
virtual double getLength()
Return the length of the table.
Definition: Aperture.cpp:944
FVector< double, 3 > Euler_x
Definition: Aperture.h:163
A_Tline::const_iterator current
Definition: Aperture.h:172
virtual std::vector< double > getColumn(const RangeRep &rng, const std::string &colName)
Return column [b]col[/b] of this table, limited by [b]range[/b].
Definition: Aperture.cpp:965
virtual void visitCyclotron(const Cyclotron &)
Apply the algorithm to an cyclotron.
Definition: Aperture.cpp:324
virtual const Beamline * getLine() const
Return embedded CLASSIC beamline.
Definition: Aperture.cpp:953
double offsety
Definition: Aperture.h:30
std::string Type_elm
Definition: Aperture.h:67
struct Aperture::Data data
double l
Definition: Aperture.h:23
FMatrix< double, 6, 6 > Transf_mat
Definition: Aperture.h:160
A_row(ElementBase *elem, int occur)
Definition: Aperture.h:50
void setCounter(int) const
Set clone counter.
std::vector< Aperture::coord > getShape(std::vector< double > vec)
Definition: Aperture.cpp:737
const Beam * beam
Definition: Aperture.h:155
A_Tline::const_iterator end() const
Definition: Aperture.cpp:250
TBeamline< A_row > A_Tline
Definition: Aperture.h:82
Definition: SBend.h:68
double phi
Definition: Aperture.h:23
double Orb
Definition: Aperture.h:68
double getDisp_x(int ind)
Definition: Aperture.cpp:217
std::vector< coord > ShapeHalo
Definition: Aperture.h:38
virtual void fill()
Refill the buffer.
Definition: Aperture.cpp:872
Representation of a range within a beam line or sequence.
Definition: RangeRep.h:34
Class Twiss.
Definition: Twiss.h:41
An abstract sequence of beam line components.
Definition: Beamline.h:37
FVector< double, 2 > Dispx
Definition: Aperture.h:167
double K_beta
Definition: Aperture.h:28
virtual void visitMultipole(const Multipole &)
Apply the algorithm to a multipole.
Definition: Aperture.cpp:287
double getDisp_y(int ind)
Definition: Aperture.cpp:223
std::vector< pt_interpol > Interpol
Definition: Aperture.h:78
Definition: Vec.h:21
double e2
Definition: Aperture.h:23
virtual void applyDefault(const ElementBase &)
Definition: Aperture.cpp:350
virtual Object * clone(const std::string &name)
Return a clone.
Definition: Aperture.cpp:1020
The base class for all OPAL objects.
Definition: Object.h:48
A_row(const FlaggedElmPtr &rhs, int order)
Definition: Aperture.h:53
The BEAM definition.
Definition: Beam.h:35
const std::string name
double getBETYMAX(const A_row &, int i1=0, int i2=0) const
Definition: Aperture.cpp:264
double delta_p
Definition: Aperture.h:28
virtual double getCell(const PlaceRep &place, const std::string &colName)
Return value in selected table cell.
Definition: Aperture.cpp:948
std::vector< coord > ShapeBeamScreen
Definition: Aperture.h:37
double getBeta_x(int ind)
Definition: Aperture.cpp:210
std::string::iterator iterator
Definition: MSLang.h:16
double getAPERTMIN(const A_row &row, int i1=0, int i2=0) const
Definition: Aperture.cpp:275
FVector< double, 2 > Dispy
Definition: Aperture.h:168
virtual CellArray getDefault() const
Return the default print columns.
Definition: Aperture.cpp:956
virtual bool matches(Table *rhs) const
Check that [b]rhs[/b] is of same type as [b]this[/b].
Definition: Aperture.cpp:1015
The base class for all OPAL tables.
Definition: Table.h:42
FVector< double, 3 > Euler_y
Definition: Aperture.h:164
std::string type
Definition: Aperture.h:24
A_Tline::iterator n
Definition: Aperture.h:154
virtual void printTable(std::ostream &, const CellArray &) const
Print list for the table.
Definition: Aperture.cpp:1024
double getApert(int ind)
Definition: Aperture.cpp:229
void calcul(Twiss::TLine::iterator i, A_row &a, int order, Twiss *tp)
Definition: Aperture.cpp:360
virtual void visitRBend(const RBend &)
Apply the algorithm to a rectangular bend.
Definition: Aperture.cpp:302
A section of a beam line.
Definition: FlaggedElmPtr.h:36