Fork me on GitHub

source: git/external/Hector/H_OpticalElement.h@ 282f591

ImprovedOutputFile Timing dual_readout llp
Last change on this file since 282f591 was 3c40083, checked in by pavel <pavel@…>, 11 years ago

switch to a more stable Hector version

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