Fork me on GitHub

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

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

new Hector version

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