Fork me on GitHub

source: git/external/Hector/H_Beam.h@ 1f1f858

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

switch to a more stable Hector version

  • Property mode set to 100644
File size: 5.9 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
58 //@{
59 void createBeamParticles(const unsigned int , const double , const double );
60 void createBeamParticles(const unsigned int);
61 //@}
62 /// Fills the beam with particles with incremental offset and no initial transverse momentum
63 //@{
64 void createXScanningBeamParticles(const unsigned int, const float);
65 void createYScanningBeamParticles(const unsigned int, const float);
66 //@}
67 /// Fills the beam with particles with incremental initial angle and no offset.
68 //@{
69 void createTXScanningBeamParticles(const unsigned int, const float);
70 void createTYScanningBeamParticles(const unsigned int, const float);
71 //@}
72 /// Returns the ith particle
73 //@{
74 const H_BeamParticle * getBeamParticle(const unsigned int ) const;
75 H_BeamParticle * getBeamParticle(const unsigned int );
76 //@}
77 /// Adds a particle to the beam
78 void add(const H_BeamParticle&);
79 /// Compute the position of each particle in the beamline
80 //@{
81 void computePath(const H_AbstractBeamLine *, const bool);
82 void computePath(const H_AbstractBeamLine *);
83 //@}
84 // Photon emission by the particle
85 // @{
86 void emitGamma(const double, const double, const double, const double);
87 void emitGamma(const double, const double);
88 //@}
89 // Propagates the beam until a given s
90 void propagate(const float );
91 /// Returns the \f$ \beta \f$ function of the beam
92 //@{
93 float getBetaX(const float , float& );
94 float getBetaY(const float , float& );
95 //@}
96 /// Draws the \f$ \beta \f$ function of the beam
97 //@{
98 //// TGraphErrors * getBetaX(const float, const unsigned int);
99 //// TGraphErrors * getBetaY(const float, const unsigned int);
100 //@}
101 /// Returns the position of the beam
102 //@{
103 float getX(const float , float& );
104 float getY(const float , float& );
105 //@}
106 /// Returns the emittance \f$ \epsilon \f$ of the beam in x and y
107 //@{
108 inline const float getEmittanceX() const {
109 if(!x_disp*tx_disp) cout<<"Warning : Degenerate Beam : x-emittance = 0"<<endl;
110 return x_disp * tan(tx_disp/URAD)/URAD;
111 }
112 inline const float getEmittanceY() const {
113 if(!y_disp*ty_disp) cout<<"Warning : Degenerate Beam : y-emittance = 0"<<endl;
114 return y_disp * tan(ty_disp/URAD)/URAD;
115 }
116 //@}
117 /// Sets the initial parameters of the beam \f$ s , x , y , \theta_x , \theta_y \f$
118 //@{
119 void setS(const float fs) { fs_ini = fs;}
120 void setX(const float fx) { fx_ini = fx;}
121 void setY(const float fy) { fy_ini = fy;}
122 void setTX(const float tx) { tx_ini = tx;}
123 void setTY(const float ty) { ty_ini = ty;}
124 void setE(const float fe) {fe_ini = fe;}
125 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);}
126 //@}
127 /// Sets the initial divergence of the beam \f$ \sigma_x , \sigma_y , \sigma (\theta_x), \sigma(\theta_y) \f$
128 //@{
129 void setDS(const float ds) {s_disp = ds;}
130 void setDX(const float dx) {x_disp = dx;}
131 void setDY(const float dy) {y_disp = dy;}
132 void setDTX(const float dtx) {tx_disp = dtx;}
133 void setDTY(const float dty) {ty_disp = dty;}
134 void setDE(const float de) {e_disp = de;}
135 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);}
136 //@}
137 /// Returns the number of particles which have been stopped
138 unsigned int getStoppedNumber(const H_AbstractBeamLine *);
139 /// Returns the list of the stopping elements in the beamline
140 void getStoppingElements(const H_AbstractBeamLine *, vector<H_OpticalElement>&, vector<int>&);
141 /// Prints the initial parameters
142 void printInitialState() const;
143 /// Prints the properties for each particle
144 void printProperties() const;
145 /// Prints the list of the stopping elements in the beamline
146 void printStoppingElements(const vector<H_OpticalElement>&, const vector<int>&) const;
147 /// Returns the number of particle is this beam
148 const int getNumberOfBeamParticles() const {return Nparticles;}
149 /// Draws the beam profile at a given s
150 //// TH2F * drawProfile(const float);
151 /// Draws the beam width and height
152 //@{
153 //// TMultiGraph * drawBeamX(const int) const;
154 //// TMultiGraph * drawBeamY(const int) const ;
155 //@}
156
157 protected:
158 /// List of particles
159 vector<H_BeamParticle> beamParticles;
160 /// IP position
161 //@{
162 float fx_ini, fy_ini, fs_ini;
163 //@}
164 /// IP \f$ \theta \f$ (angular) position
165 //@{
166 float tx_ini, ty_ini;
167 //@}
168 /// nominal beam energy
169 float fe_ini;
170 /// dispersion in position
171 //@{
172 float x_disp, y_disp, s_disp;
173 //@}
174 /// dispersion in \f$ \theta \f$
175 //@{
176 float tx_disp, ty_disp;
177 //@}
178 /// dispersion in energy
179 float e_disp;
180 /// Number of particles in this beam
181 unsigned int Nparticles;
182};
183
184#endif
Note: See TracBrowser for help on using the repository browser.