1 | #ifndef LATTICE_H |
---|
2 | #define LATTICE_H |
---|
3 | #include <iostream> |
---|
4 | #include <fstream> |
---|
5 | #include <vector> |
---|
6 | #include <string> |
---|
7 | #include "StandardCollimator.h" |
---|
8 | #include "FlukaCollimator.h" |
---|
9 | #include "MagneticCollimator.h" |
---|
10 | #include "CrystalCollimator.h" |
---|
11 | |
---|
12 | #if defined(FLUKA) |
---|
13 | #include "FlukaIO.h" |
---|
14 | #endif |
---|
15 | |
---|
16 | using namespace std; |
---|
17 | /* |
---|
18 | ############################################################################################################ |
---|
19 | |
---|
20 | Class which represent the lattice of the experiment |
---|
21 | |
---|
22 | ########################################################################################################### |
---|
23 | */ |
---|
24 | |
---|
25 | |
---|
26 | class Lattice |
---|
27 | { |
---|
28 | |
---|
29 | public: |
---|
30 | |
---|
31 | |
---|
32 | //==========================Constructors, destructor====================== |
---|
33 | |
---|
34 | Lattice() {}; |
---|
35 | |
---|
36 | Lattice(Element start, const vector <int>& ips); |
---|
37 | |
---|
38 | Lattice(Element element1, Element element2, StandardCollimator stdcolli, FlukaCollimator flukacolli, MagneticCollimator magnetcolli, const vector <int>& ips, int size = 5, int npart = 1); |
---|
39 | |
---|
40 | virtual ~Lattice(); |
---|
41 | |
---|
42 | //=============================== Other methods =============================== |
---|
43 | |
---|
44 | //method used to set the variable size_res |
---|
45 | |
---|
46 | void setsize_res(int s); |
---|
47 | |
---|
48 | |
---|
49 | //non-linear tracking of the particles through the accelerator |
---|
50 | |
---|
51 | void trackensemblechrom(vector <Particle>& bunch, const int& irev, const int& i0, const int& im, const double& Apr, const double& Zpr, const double& wecolli, const double& betgam, const int& nonlinflag, const int& scaleorbit, double& attr1, const int& idpart, const int& idelt, const int& outcoord, const string& plotflag, vector <vector <double> >& xco, vector <vector <double> >& yco, string outputpath, int RFflag, int& indication); |
---|
52 | |
---|
53 | |
---|
54 | //used to add a collimator to resColli, the lattice containing only the collimators |
---|
55 | |
---|
56 | void addCollimator(Collimator* colli); |
---|
57 | |
---|
58 | |
---|
59 | //used to add an element to the accelerator's lattice |
---|
60 | |
---|
61 | void addElement(Element* elt); |
---|
62 | |
---|
63 | |
---|
64 | //used to compute the 6th coordinate of the particles |
---|
65 | |
---|
66 | double time(Particle& p, const double& l, const double& betgam, const int& elt); |
---|
67 | |
---|
68 | |
---|
69 | //linear tracking of the particles; here, we only look for collision with primary collimators |
---|
70 | |
---|
71 | void trackensemblelinearnew(vector <Particle>& bunch, vector <Particle>& bunchhit, const int& nrev, const double& blowup2, const int& blowupperiod); |
---|
72 | |
---|
73 | |
---|
74 | //output of the x-, y- and t- coordinates of the particles in the file coordinates.dat; mostly used for tests; the choice of the particle is made in lattice.cc with the static int choicePart |
---|
75 | //the first column in the file coordinates.dat is the x-coordinate and the second one is the y-coordinate |
---|
76 | |
---|
77 | void outCoord(const Particle& p, const int& indic, const string& fileOut); |
---|
78 | |
---|
79 | |
---|
80 | |
---|
81 | //displays the x-, y- and t-coordinates of a chosen particle at each turn at a given element in the lattice; the result is written in the file coordinates_punctual.dat; |
---|
82 | //the chosen element number must be set in lattice.cc with the variable eltOutNber; the chosen particle must be set in lattice.cc with the variable choicePart |
---|
83 | |
---|
84 | void outPunct(const int& elt, const Particle& p, const Particle& p2, const double& var, string outputpath); |
---|
85 | |
---|
86 | |
---|
87 | //displays the phase advance and the the amount of provided energy for the passage through RF-cavities in the file "valuestestrf.dat"; used for tests; if their are more than one cavity in the turns, |
---|
88 | //for the first turn only one cavity is taken into account; to use it, the call must be uncomment in the file "lattice.cc" |
---|
89 | |
---|
90 | void outrf(const double& x1, const double& x2, string outputpath); |
---|
91 | |
---|
92 | |
---|
93 | //displays coordinates of all the particles at a certain element of the lattice in the file "coordinates_elt.dat"; the element is chosen throught the global variable eltOutNber in lattice.cc |
---|
94 | |
---|
95 | void outElt(const int& elt, const Particle& p, string outputpath, int& indication); |
---|
96 | |
---|
97 | |
---|
98 | void read(vector <Particle>& bunch); |
---|
99 | |
---|
100 | |
---|
101 | //=========================================== Attributs ============================================ |
---|
102 | |
---|
103 | #if defined(FLUKA) |
---|
104 | flukaio_connection_t* conn; //connection with an external server (e.g. Fluka) |
---|
105 | #endif |
---|
106 | |
---|
107 | int size_res; //size of the lattice |
---|
108 | |
---|
109 | int npart; //number of particles |
---|
110 | vector <int> ips; //vector indicating the position of the collimators (gives the index of the collimators in the complete lattice, e.g. if the first collimator is the 5th element, we will have ips[0] = 5) |
---|
111 | |
---|
112 | vector <int> cocount;//count the number of particles crashing on each collimator |
---|
113 | |
---|
114 | vector < Element* > reseau; //lattice formed by all the elements |
---|
115 | vector < Collimator* > resColli; //vector containing only the primary collimators that are in the lattice |
---|
116 | |
---|
117 | //The following vectors contains the indices of the positions of such collimators |
---|
118 | |
---|
119 | vector <int> ii;//'TCI' collimators |
---|
120 | vector < int > ip;//'TCP', 'CRYSTAL' and 'TCRYO' collimators |
---|
121 | vector < int > is;//'TCS' collimators |
---|
122 | vector < int > it;//'TCT' collimators |
---|
123 | vector < int > itcla;//'TCLA' collimators |
---|
124 | |
---|
125 | vector < int > ipcoll; // vector giving the position like ips, but only for 'TCP' collimators |
---|
126 | |
---|
127 | vector <int> ixcormag;// vector of all i's such that etype(i) starts with 'KICKER' of 'HKICKER' and px(i) != px(i-1) |
---|
128 | vector <int> iycormag;// same as above for for 'KICKER' OR 'VKICKER' and py |
---|
129 | vector <double> xcormag;// px(i)-px(i-1) for all the i's in ixcormag |
---|
130 | vector <double> ycormag;// same as above for py |
---|
131 | |
---|
132 | vector <double> hits;//positions of the hits |
---|
133 | vector <double> Aphit;//mass for particles hitting the aperture |
---|
134 | vector <double> Zphit;//charge for particles hitting the aperture |
---|
135 | vector <int> nhitcolli;//for each collimator, number of particles getting lost on it |
---|
136 | vector <int> nhitspoiler;//for each ion spoiler, number of particles getting lost on it |
---|
137 | |
---|
138 | vector <double> sh;//vector used to store the position of the elements during the computation (used in simulation.cc) |
---|
139 | |
---|
140 | //apertures (used in simulation.cc) |
---|
141 | vector <double> aperx1; |
---|
142 | vector <double> apery1; |
---|
143 | |
---|
144 | vector <double> apdepth;//a particle's perpendicular depth in a collimator as it hits the collimator. Measured at the beginning of the collimator |
---|
145 | vector <double> apdepth2;//a particle's perpendicular depth in a collimator as it hits the collimator. Measured at the end of the collimator |
---|
146 | |
---|
147 | //elements of the matrix R |
---|
148 | vector <double> R11X; |
---|
149 | vector <double> R12X; |
---|
150 | vector <double> R21X; |
---|
151 | vector <double> R22X; |
---|
152 | vector <double> R11Y; |
---|
153 | vector <double> R12Y; |
---|
154 | vector <double> R21Y; |
---|
155 | vector <double> R22Y; |
---|
156 | vector <double> Lelem;//distance between 2 consecutive elements |
---|
157 | //elements of the matrix RC |
---|
158 | vector <double> R11XC; |
---|
159 | vector <double> R12XC; |
---|
160 | vector <double> R21XC; |
---|
161 | vector <double> R22XC; |
---|
162 | vector <double> R11YC; |
---|
163 | vector <double> R12YC; |
---|
164 | vector <double> R21YC; |
---|
165 | vector <double> R22YC; |
---|
166 | |
---|
167 | double freqrf;//RF frequency |
---|
168 | double rfvoltage;//RF voltage |
---|
169 | double rfharmonic;//RF harmonic number |
---|
170 | double momentum;//momentum |
---|
171 | |
---|
172 | static int count;//count the number of particles lost on a crystal collimator |
---|
173 | static int turn;//count the number of turns in the ring |
---|
174 | static int choicePart;//identification of the particle chosen for the study in the file coordinates.dat |
---|
175 | static int eltOutNber;//id of the element for which we want the output in coordinates_punctual.dat |
---|
176 | |
---|
177 | }; |
---|
178 | |
---|
179 | |
---|
180 | #endif |
---|
181 | |
---|