Fork me on GitHub

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

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

new Hector version

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