Fork me on GitHub

source: svn/trunk/Utilities/Hector/include/H_AbstractBeamLine.h@ 59

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

first commit

File size: 5.1 KB
Line 
1#ifndef _H_AbstractBeamLine_
2#define _H_AbstractBeamLine_
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_AbstractBeamLine.h
16/// \brief Class aiming at simulating the LHC beamline.
17///
18/// Units : angles [ï¿œrad], distances [ï¿œm], energies [GeV], c=[1].
19
20 /// default length of the beam line
21#define LENGTH_DEF 100
22
23// c++ #includes
24#include <vector>
25#include <algorithm>
26#include <string>
27
28
29// ROOT #includes
30#include "TMatrix.h"
31#include "TGraph.h"
32
33// local #includes
34#include "H_OpticalElement.h"
35using namespace std;
36
37/// Beamline made from a vector of H_OpticalElement.
38class H_AbstractBeamLine {
39
40 public:
41 void init(const float );
42 /// Constructors, destructor and operator
43 //@{
44 H_AbstractBeamLine() {init(LENGTH_DEF);};
45 H_AbstractBeamLine(const float length) {init(length);};
46 H_AbstractBeamLine(const H_AbstractBeamLine &);
47 H_AbstractBeamLine& operator=(const H_AbstractBeamLine&);
48 H_AbstractBeamLine* clone() const ;
49 ~H_AbstractBeamLine();
50 //@}
51 /// Adds an element to the beamline
52 //@{
53 void add(H_OpticalElement *);
54 void add(H_OpticalElement &);
55 //@}
56 /// Returns the (float) length of the beamline
57 inline float getLength() const { return beam_length;};
58 /// Returns the (int) number of optics element of the beamline, including drifts
59 inline int getNumberOfElements() const { return (int)elements.size();};
60 /// Returns the transport matrix for the whole beam
61 const TMatrix getBeamMatrix() const;
62 /// Returns the transport matrix for the whole beam, for given energy loss/mass/charge
63 const TMatrix getBeamMatrix(const float , const float, const float ) ;
64 /// Returns the transport matrix for a part of the beam from the IP to a given element
65 const TMatrix getPartialMatrix(const H_OpticalElement *) const;
66 /// Returns the transport matrix for a part of the beam from the IP to the ith element
67 const TMatrix getPartialMatrix(const unsigned int ) const;
68 /// Returns the transport matrix for a part of the beam from the IP to a given element, given energy loss/mass/charge
69 const TMatrix getPartialMatrix(const string, const float, const float, const float);
70 /// Returns the ith element of the beamline
71 //@{
72 H_OpticalElement * getElement(const unsigned int );
73 H_OpticalElement * getElement(const unsigned int ) const;
74 //@}
75 /// Returns a given element of the beamline, choosen by name
76 //@{
77 H_OpticalElement * getElement(const string );
78 H_OpticalElement * getElement(const string ) const;
79 //@}
80 /// Print some info
81 void printProperties() const;
82 /// Prints the element list
83 void showElements() const;
84 /// Prints the list of elements of a give type
85 void showElements(const int) const;
86 /// Prints the transport matrix for the whole beam
87 void showMatrix() const;
88 /// Prints the transport matrix for each element of the beamline
89 void showMatrices() const;
90 /// Reorders elements and adds the drift sections
91 void calcSequence();
92 /// Computes global transport matrix
93 void calcMatrix();
94 /// Draws the legend of the elements of the beam
95 void draw(const float xmin =0.85, const float ymin=0.5, const float xmax=1, const float ymax=1) const;
96 /// Draws the elements of the beam in the (x,s) plane
97 void drawX(const float, const float, const float scale=1) const;
98 /// Draws the elements of the beam in the (y,s) plane
99 void drawY(const float, const float) const;
100 /// Moves an element in the list, reorders the lists and recomputes the transport matrix
101 void moveElement(const string, const float );
102 /// Moves the given element tranversely by given amounts.
103 void alignElement(const string, const float, const float);
104 /// Tilts the given element tranversely by given angles.
105 void tiltElement(const string, const float, const float);
106 /// Offsets all element in X pos from the start position
107 void offsetElements(const float start, const float offset);
108 /// Draws the beta functions, from MAD
109 //@{
110 TGraph * getBetaX() const;
111 TGraph * getBetaY() const;
112 //@}
113 /// Draws the dispersion functions, from MAD
114 //@{
115 TGraph * getDX() const;
116 TGraph * getDY() const;
117 //@}
118 /// Draws the relative position functions, from MAD
119 //@{
120 TGraph * getRelX() const;
121 TGraph * getRelY() const;
122 //@}
123
124
125 private:
126 /// list of all optics elements, including drifts
127 vector<H_OpticalElement*> elements;
128 /// list of matrices, 1 matrix = the transport till the end of each element
129 vector<TMatrix> matrices;
130 /// transport matrix for the whole beam
131 TMatrix beam_mat;
132 /// Orderting method for the vector of H_OpticalElement*
133 struct ordering{ bool operator()(H_OpticalElement* el1, H_OpticalElement* el2) const { return (*el1 < *el2);}};
134
135 protected:
136 /// total length of the beamline
137 float beam_length;
138};
139
140#endif
Note: See TracBrowser for help on using the repository browser.