Fork me on GitHub

source: svn/trunk/Utilities/Hector/include/H_Beam.h@ 192

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

first commit

File size: 6.8 KB
Line 
1#ifndef _H_Beam_
2#define _H_Beam_
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_Beam.h
16/// \brief Describes a set a particles as a beam
17///
18
19// c++ #includes
20//#include <iostream>
21#include <vector>
22#include <sstream>
23#include <cmath>
24
25// ROOT #includes
26#include "TH2F.h"
27#include "TGraphErrors.h"
28#include "TMultiGraph.h"
29
30// local #includes
31#include "H_BeamParticle.h"
32#include "H_AbstractBeamLine.h"
33#include "H_Parameters.h"
34#include "H_OpticalElement.h"
35using namespace std;
36
37/// \brief Beam made from a STL vector of H_BeamParticle.
38///
39/// Example of usage :
40/// <PRE>
41/// H_Beam mybeam;
42/// mybeam.createBeamParticles(100);
43/// H_AbstractBeamLine * beamline = new H_AbstractBeamLine(200);
44/// ... (<-- fills the beam)
45/// mybeam.computePath(beamline)
46/// </PRE>
47class H_Beam {
48
49 public:
50 /// Constructors, destructor and operator
51 //@{
52 H_Beam();
53 H_Beam(const H_Beam&);
54 H_Beam& operator=(const H_Beam&);
55 ~H_Beam();
56 //@}
57 /// Fills the beam with particles in given position/angle/energy intervals (flat distribution)
58 //void particleGun(const unsigned int Number_of_particles, const float E_min, const float E_max, const float fs_min, const float fs_max, const float fx_min, const float fx_max, const float fy_min, const float fy_max, const float tx_min, const float tx_max, const float ty_min, const float ty_max, const float p_mass, const double p_charge);
59 void particleGun(const unsigned int Number_of_particles, const float E_min=BE, const float E_max=BE, const float fs_min=0, const float fs_max=0, const float fx_min=0, const float fx_max=0, const float fy_min=0, const float fy_max=0, const float tx_min=-PI/2., const float tx_max=PI/2., const float ty_min=-PI/2., const float ty_max=PI/2., const float p_mass=MP, const double p_charge=QP, const bool flat = true);
60
61 /// Fills the beam with particles
62 //@{
63 void createBeamParticles(const unsigned int , const double , const double );
64 void createBeamParticles(const unsigned int);
65 //@}
66 /// Fills the beam with particles with incremental offset and no initial transverse momentum
67 //@{
68 void createXScanningBeamParticles(const unsigned int, const float);
69 void createYScanningBeamParticles(const unsigned int, const float);
70 //@}
71 /// Fills the beam with particles with incremental initial angle and no offset.
72 //@{
73 void createTXScanningBeamParticles(const unsigned int, const float);
74 void createTYScanningBeamParticles(const unsigned int, const float);
75 //@}
76 /// Returns the ith particle
77 //@{
78 const H_BeamParticle * getBeamParticle(const unsigned int ) const;
79 H_BeamParticle * getBeamParticle(const unsigned int );
80 //@}
81 /// Adds a particle to the beam
82 void add(const H_BeamParticle&);
83 /// Compute the position of each particle in the beamline
84 //@{
85 void computePath(const H_AbstractBeamLine *, const bool);
86 void computePath(const H_AbstractBeamLine *);
87 //@}
88 // Photon emission by the particle
89 // @{
90 void emitGamma(const double, const double, const double, const double);
91 void emitGamma(const double, const double);
92 //@}
93 // Propagates the beam until a given s
94 void propagate(const float );
95 /// Returns the \f$ \beta \f$ function of the beam
96 //@{
97 float getBetaX(const float , float& );
98 float getBetaY(const float , float& );
99 //@}
100 /// Draws the \f$ \beta \f$ function of the beam
101 //@{
102 TGraphErrors * getBetaX(const float, const unsigned int);
103 TGraphErrors * getBetaY(const float, const unsigned int);
104 //@}
105 /// Returns the position of the beam
106 //@{
107 float getX(const float , float& );
108 float getY(const float , float& );
109 //@}
110 /// Returns the emittance \f$ \epsilon \f$ of the beam in x and y
111 //@{
112 inline const float getEmittanceX() const {
113 if(!x_disp*tx_disp) cout<<"Warning : Degenerate Beam : x-emittance = 0"<<endl;
114 return x_disp * tan(tx_disp/URAD)/URAD;
115 }
116 inline const float getEmittanceY() const {
117 if(!y_disp*ty_disp) cout<<"Warning : Degenerate Beam : y-emittance = 0"<<endl;
118 return y_disp * tan(ty_disp/URAD)/URAD;
119 }
120 //@}
121 /// Sets the initial parameters of the beam \f$ s , x , y , \theta_x , \theta_y \f$
122 //@{
123 void setS(const float fs) { fs_ini = fs;}
124 void setX(const float fx) { fx_ini = fx;}
125 void setY(const float fy) { fy_ini = fy;}
126 void setTX(const float tx) { tx_ini = tx;}
127 void setTY(const float ty) { ty_ini = ty;}
128 void setE(const float fe) {fe_ini = fe;}
129 void setPosition(const float fx, const float fy, const float tx, const float ty, const float fs) {setS(fs); setX(fx); setY(fy); setTX(tx); setTY(ty);}
130 //@}
131 /// Sets the initial divergence of the beam \f$ \sigma_x , \sigma_y , \sigma (\theta_x), \sigma(\theta_y) \f$
132 //@{
133 void setDS(const float ds) {s_disp = ds;}
134 void setDX(const float dx) {x_disp = dx;}
135 void setDY(const float dy) {y_disp = dy;}
136 void setDTX(const float dtx) {tx_disp = dtx;}
137 void setDTY(const float dty) {ty_disp = dty;}
138 void setDE(const float de) {e_disp = de;}
139 void setDispersion(const float dx, const float dy, const float dtx, const float dty, const float ds) {setDS(ds); setDX(dx); setDY(dy); setDTX(dtx); setDTY(dty);}
140 //@}
141 /// Returns the number of particles which have been stopped
142 unsigned int getStoppedNumber(const H_AbstractBeamLine *);
143 /// Returns the list of the stopping elements in the beamline
144 vector<TVectorD> getStoppingElements(const H_AbstractBeamLine *, vector<H_OpticalElement>&, vector<int>&);
145 /// Prints the initial parameters
146 void printInitialState() const;
147 /// Prints the properties for each particle
148 void printProperties() const;
149 /// Prints the list of the stopping elements in the beamline
150 void printStoppingElements(const vector<H_OpticalElement>&, const vector<int>&) const;
151 /// Returns the number of particle is this beam
152 const int getNumberOfBeamParticles() const {return Nparticles;}
153 /// Draws the beam profile at a given s
154 TH2F * drawProfile(const float);
155 TH2F * drawAngleProfile(const float);
156 /// Draws the beam width and height
157 //@{
158 TMultiGraph * drawBeamX(const int) const;
159 TMultiGraph * drawBeamY(const int) const ;
160 //@}
161
162 protected:
163 /// List of particles
164 vector<H_BeamParticle> beamParticles;
165 /// IP position
166 //@{
167 float fx_ini, fy_ini, fs_ini;
168 //@}
169 /// IP \f$ \theta \f$ (angular) position
170 //@{
171 float tx_ini, ty_ini;
172 //@}
173 /// nominal beam energy
174 float fe_ini;
175 /// dispersion in position
176 //@{
177 float x_disp, y_disp, s_disp;
178 //@}
179 /// dispersion in \f$ \theta \f$
180 //@{
181 float tx_disp, ty_disp;
182 //@}
183 /// dispersion in energy
184 float e_disp;
185 /// Number of particles in this beam
186 unsigned int Nparticles;
187};
188
189#endif
Note: See TracBrowser for help on using the repository browser.