Fork me on GitHub

source: svn/trunk/Utilities/Hector/include/H_OpticalElement.h@ 124

Last change on this file since 124 was 3, checked in by Xavier Rouby, 16 years ago

first commit

File size: 7.6 KB
Line 
1#ifndef _H_OpticalElement_
2#define _H_OpticalElement_
3
4/*
5---- Hector the simulator ----
6 A fast simulator of particles through generic beamlines.
7 J. de Favereau, X. Rouby ~~~ hector_devel@cp3.phys.ucl.ac.be
8
9 http://www.fynu.ucl.ac.be/hector.html
10
11 Centre de Physique des Particules et de Phénoménologie (CP3)
12 Université Catholique de Louvain (UCL)
13*/
14
15/// \file H_OpticalElement.h
16/// \brief Class aiming at describing any beam optical element.
17///
18/// This is an abstract base class
19/// subclass must define setTypeString() and setMatrix() methods.
20/// Quadrupole, Dipole, Kickers and Drift inherit from this class.
21
22// c++ #includes
23#include <iostream>
24#include <string>
25
26// ROOT #includes
27#include "TMatrix.h"
28#include "TVectorD.h"
29
30// local #includes
31#include "H_TransportMatrices.h"
32#include "H_Parameters.h"
33#include "H_Aperture.h"
34
35using namespace std;
36
37 // type #defines
38#define DRIFT 1
39#define RDIPOLE 2
40#define SDIPOLE 3
41#define VQUADRUPOLE 4
42#define HQUADRUPOLE 5
43#define VKICKER 6
44#define HKICKER 7
45#define RCOLLIMATOR 8
46#define ECOLLIMATOR 9
47#define CCOLLIMATOR 10
48#define RP 11
49#define IP 12
50#define MARKER 13
51
52 // typestring[30] #defines
53#define DRIFTNAME "Drift "
54#define RDIPOLENAME "R-Dipole "
55#define SDIPOLENAME "S-Dipole "
56#define VQUADRUPOLENAME "V-Quadrupole "
57#define HQUADRUPOLENAME "H-Quadrupole "
58#define VKICKERNAME "V-Kicker "
59#define HKICKERNAME "H-Kicker "
60#define RCOLLIMATORNAME "R-Collimator "
61#define ECOLLIMATORNAME "E-Collimator "
62#define CCOLLIMATORNAME "C-Collimator "
63#define RPNAME "Roman Pot "
64#define IPNAME "IP "
65#define MARKERNAME "Marker "
66
67/// Describes any beam optical element.
68class H_OpticalElement {
69
70 public:
71 /// init method for constructors
72 void init(const string, const int , const double , const double , const double);
73 /// Constructors and destructor
74 //@{
75 H_OpticalElement(const string, const int, const double, const double, const double, H_Aperture*);
76 H_OpticalElement(const int, const double, const double, const double, H_Aperture*);
77 H_OpticalElement(const string, const int, const double, const double, const double);
78 H_OpticalElement(const int, const double, const double, const double);
79 H_OpticalElement();
80 H_OpticalElement(const H_OpticalElement&);
81 virtual ~H_OpticalElement() { delete element_aperture;};
82 //@}
83 /// Prints the element features
84 virtual void printProperties() const ;
85 /// Shows the element transport matrix
86 void showMatrix() const ;
87 /// Draws the aperture shape
88 void drawAperture() const ;
89 /// Sets the aperture of the element
90 void setAperture(const H_Aperture*);
91 /// Ordering operator acting on the s coordinate
92 inline bool operator>(const H_OpticalElement tocomp) const {if(fs>tocomp.getS()) { return true; } else { return false; }};
93 /// Ordering operator acting on the s coordinate
94 inline bool operator<(const H_OpticalElement tocomp) const {if(fs<tocomp.getS()) { return true; } else { return false; }};
95 /// Copy operator
96 H_OpticalElement& operator=(const H_OpticalElement&);
97 /// Sets the element longitudinal (s), and horizontal (x) and vertical (y) coordinates.
98 //@{
99 inline void setS(const double new_s) {fs=new_s;};
100 inline void setLength(const double new_l) { element_length = new_l;};
101 inline void setX(const double new_pos) {
102 /// @param new_pos in [m]
103 element_aperture->setPosition(new_pos*URAD,ypos);
104 xpos = new_pos;
105 };
106 inline void setY(const double new_pos) {
107 /// @param new_pos in [m]
108 element_aperture->setPosition(xpos,new_pos*URAD);
109 ypos = new_pos;
110 };
111 inline void setTX(const double new_ang) {
112 txpos = new_ang;
113 };
114 inline void setTY(const double new_ang) {
115 typos = new_ang;
116 }
117 //@}
118 /// Returns the element longitudinal (s), horizontal (x) and vertical (y) coordinates, and corresponding angles.
119 //@{
120 inline double getS() const {return fs;};
121 inline double getX() const {return xpos;};
122 inline double getY() const {return ypos;};
123 inline double getTX() const {return txpos;};
124 inline double getTY() const {return typos;};
125 //@}
126 /// Returns the element length
127 inline double getLength() const { return element_length; };
128 /// Returns the element magnetic strength
129 inline double getK() const { return fk; };
130 /// Returns the element type, as (int) or (string)
131 //@{
132 inline int getType() const { return type; };
133 inline const string getTypeString() const { return typestring; };
134 //@}
135 /// Returns the element (string) name
136 inline const string getName() const { return name; };
137 /// Draws the element from min to max in the current pad
138 void draw(const float, const float) const;
139 /// Checks if the (x,y) coordinates are within the aperture acceptance
140 inline bool isInside(const double x, const double y) const { return (bool) element_aperture->isInside(x,y);};
141 /// Returns the element transport matrix
142 //@{
143 TMatrix getMatrix() ;
144 TMatrix getMatrix(const float, const float, const float) ;
145 //@}
146 /// Returns the element aperture
147 H_Aperture* getAperture() const {return element_aperture;};
148 /// Sets the beta functions
149 //@{
150 inline void setBetaX(const double beta) { betax = beta;};
151 inline void setBetaY(const double beta) { betay = beta;};
152 //@}
153 /// Returns the beta functions
154 //@{
155 inline double getBetaX() const {return betax;};
156 inline double getBetaY() const {return betay;};
157 //@}
158 /// Sets the dispersion functions
159 //@{
160 inline void setDX(const double disp) { dx = disp;};
161 inline void setDY(const double disp) { dy = disp;};
162 //@}
163 /// Returns the dispersion functions
164 //@{
165 inline double getDX() const {return dx;};
166 inline double getDY() const {return dy;};
167 //@}
168 //@}
169 /// Sets the relative position functions (from MAD), relative to the beamline reference frame
170 //@{
171 inline void setRelX(const double rel_x) { relx = rel_x;};
172 inline void setRelY(const double rel_y) { rely = rel_y;};
173 //@}
174 /// Returns the position functions (from MAD), relative to the beamline reference frame
175 //@{
176 inline double getRelX() const {return relx;};
177 inline double getRelY() const {return rely;};
178 //@}
179 virtual H_OpticalElement* clone() const { return new H_OpticalElement();};
180 TVectorD getHitPosition(TVectorD, double, double, double);
181
182
183 protected:
184 /// Optical element coordinates : fs [m], xpos [m], ypos [m], txpos [rad], typos [rad].
185 //@{
186 double fs, xpos, ypos, txpos, typos;
187 //@}
188 /// Optical element lenght.
189 double element_length;
190 /// Magnetic field strength.
191 double fk;
192 /// Beam \f$ \beta \f$ functions.
193 //@{
194 double betax, betay;
195 //@}
196 /// Beam dispersion in position
197 //@{
198 double dx, dy;
199 //@}
200 /// Beam position, relative to the beam ideal path, from MAD
201 //@{
202 double relx, rely;
203 //@}
204 /// Optical element type (Dipole, drift, etc).
205 int type;
206 /// Optical element name and type.
207 //@{
208 string name, typestring;
209 //@}
210 virtual void setTypeString() {return;};
211 /// Optical element transport matrix.
212 virtual void setMatrix(const float, const float, const float) { cout<<"dummy setmatrix"<<endl; return;};
213 /// Optical element transport matrix.
214 TMatrix element_mat;
215 /// Optical element aperture.
216 H_Aperture* element_aperture;
217};
218
219#endif
Note: See TracBrowser for help on using the repository browser.