CGEM BOSS 6.6.5.h
BESIII Offline Software System
Loading...
Searching...
No Matches
DiffusionGTS.cxx
Go to the documentation of this file.
1// implementation:
2// R. Farinelli (University of Ferrara & INFN of Ferrara)
3// L. Lavezzi (IHEP & INFN of Torino)
5
6#include "TRandom.h"
7
8#include <iostream>
9#include <fstream>
10#include <math.h>
11
12using namespace std;
13
15 m_geomSvc = geomSvc;
16}
18
19void DiffusionGTS::readGasPerpParameters(std::string fileName){
20
21 ifstream fin(fileName.c_str(), ios::in);
22
23 string strline;
24 string strpar;
25 if( ! fin.is_open() ){
26 std::cout << "DiffusionGTS::readGasPerpParameters ERROR: can not open file " << fileName.c_str() << endl;
27 }
28 while(fin >> strpar){
29 if(strpar[0] == '#'){
30 getline(fin, strline);
31 }
32 else if(strpar == "n_shift_x_drift"){
33 fin >> n_shift_x_drift;
34 }
35 else if(strpar == "shift_x_drift_par"){
36 for(int i=0; i<n_shift_x_drift; i++) fin >> m_shift_x_drift_par[i];
37 }
38 else if(strpar == "n_sigma_x_drift"){
39 fin >> n_sigma_x_drift;
40 }
41 else if(strpar == "sigma_x_drift_par"){
42 for(int i=0; i<n_sigma_x_drift; i++) fin >> m_sigma_x_drift_par[i];
43 }
44 else if(strpar == "shift_x_transf_par"){
45 fin >> m_shift_x_transf_par;
46 }
47 else if(strpar == "sigma_x_transf_par"){
48 fin >> m_sigma_x_transf_par;
49 }
50 else if(strpar == "shift_x_induct_par"){
51 fin >> m_shift_x_induct_par;
52 }
53 else if(strpar == "sigma_x_induct_par"){
54 fin >> m_sigma_x_induct_par;
55 }
56 else if(strpar == "n_shift_t_drift"){
57 fin >> n_shift_t_drift;
58 }
59 else if(strpar == "shift_t_drift_par"){
60 for(int i=0; i<n_shift_t_drift; i++) fin >> m_shift_t_drift_par[i];
61 }
62 else if(strpar == "n_sigma_t_drift"){
63 fin >> n_sigma_t_drift;
64 }
65 else if(strpar == "sigma_t_drift_par"){
66 for(int i=0; i<n_sigma_t_drift; i++) fin >> m_sigma_t_drift_par[i];
67 }
68 else if(strpar == "shift_t_transf_par"){
69 fin >> m_shift_t_transf_par;
70 }
71 else if(strpar == "sigma_t_transf_par"){
72 fin >> m_sigma_t_transf_par;
73 }
74 else if(strpar == "shift_t_induct_par"){
75 fin >> m_shift_t_induct_par;
76 }
77 else if(strpar == "sigma_t_induct_par"){
78 fin >> m_sigma_t_induct_par;
79 }
80 }
81
82 std::cout << "DiffusionGTS::readGasPerpParameters: open file " << fileName.c_str() << endl;
83
84 // cout << n_shift_x_drift << endl;
85 cout << "shift x in drift";
86 for(int i=0; i<n_shift_x_drift; i++) cout << " " << m_shift_x_drift_par[i];
87 cout << endl;
88 // cout << n_sigma_x_drift << endl;
89 cout << "sigma x in drift";
90 for(int i=0; i<n_sigma_x_drift; i++) cout << " " << m_sigma_x_drift_par[i];
91 cout << endl;
92 cout << "shift x in transf " << m_shift_x_transf_par << endl;
93 cout << "sigma x in transf " << m_sigma_x_transf_par << endl;
94 cout << "shift x in induct " << m_shift_x_induct_par << endl;
95 cout << "sigma x in induct " << m_sigma_x_induct_par << endl;
96
97 cout << "shift t in drift";
98 // cout << n_shift_t_drift << endl;
99 for(int i=0; i<n_shift_t_drift; i++) cout << " " << m_shift_t_drift_par[i];
100 cout << endl;
101 // cout << n_sigma_t_drift << endl;
102 cout << "sigma t in drift";
103 for(int i=0; i<n_sigma_t_drift; i++) cout << " " << m_sigma_t_drift_par[i];
104 cout << endl;
105 cout << "shift t in transf " << m_shift_t_transf_par << endl;
106 cout << "sigma t in transf " << m_sigma_t_transf_par << endl;
107 cout << "shift t in induct " << m_shift_t_induct_par << endl;
108 cout << "sigma t in induct " << m_sigma_t_induct_par << endl;
109
110}
111// --- WITHOUT FIELD ---
112void DiffusionGTS::readGasParalParameters(std::string fileName){
113
114 ifstream fin(fileName.c_str(), ios::in);
115
116 string strline;
117 string strpar;
118 if( ! fin.is_open() ){
119 std::cout << "DiffusionGTS::readGasParalParameters ERROR: can not open file " << fileName.c_str() << endl;
120 }
121 while(fin >> strpar){
122 if(strpar[0] == '#'){
123 getline(fin, strline);
124 }
125 else if(strpar == "n_shift_x_drift"){
126 fin >> n_shift_y_drift;
127 }
128 else if(strpar == "shift_x_drift_par"){
129 for(int i=0; i<n_shift_y_drift; i++) fin >> m_shift_y_drift_par[i];
130 }
131 else if(strpar == "n_sigma_x_drift"){
132 fin >> n_sigma_y_drift;
133 }
134 else if(strpar == "sigma_x_drift_par"){
135 for(int i=0; i<n_sigma_y_drift; i++) fin >> m_sigma_y_drift_par[i];
136 }
137 else if(strpar == "shift_x_transf_par"){
138 fin >> m_shift_y_transf_par;
139 }
140 else if(strpar == "sigma_x_transf_par"){
141 fin >> m_sigma_y_transf_par;
142 }
143 else if(strpar == "shift_x_induct_par"){
144 fin >> m_shift_y_induct_par;
145 }
146 else if(strpar == "sigma_x_induct_par"){
147 fin >> m_sigma_y_induct_par;
148 }
149 else break;
150 }
151
152
153 std::cout << "DiffusionGTS::readGasParalParameters: open file " << fileName.c_str() << endl;
154
155 cout << "shift y in drift";
156 for(int i=0; i<n_shift_y_drift; i++) cout << " " << m_shift_y_drift_par[i];
157 cout << endl;
158 cout << "sigma y in drift";
159 for(int i=0; i<n_sigma_y_drift; i++) cout << " " << m_sigma_y_drift_par[i];
160 cout << endl;
161 cout << "shift y in transf " << m_shift_y_transf_par << endl;
162 cout << "sigma y in transf " << m_sigma_y_transf_par << endl;
163 cout << "shift y in induct " << m_shift_y_induct_par << endl;
164 cout << "sigma y in induct " << m_sigma_y_induct_par << endl;
165
166 cout << "shift t in drift";
167 // cout << n_shift_t_drift << endl;
168 for(int i=0; i<n_shift_t_drift; i++) cout << " " << m_shift_t_drift_par[i];
169 cout << endl;
170
171}
172// ----------------- X -------------------
174
175 double dx = 0;
176 /**
177 if(z<0||z>5.) { // CHECK 16) gap from geometry!
178 cout<<"DiffusionGTS::shift_x_drift: error in z = " << z << endl;
179 return dx;
180 }
181 **/
182 for(int i=0; i<n_shift_x_drift; i++) dx += pow(z, i) * m_shift_x_drift_par[i];
183 return dx;
184}
186 double dx = m_shift_x_transf_par;
187 return dx;
188}
190 double dx = m_shift_x_induct_par;
191 return dx;
192}
193
194
196 double dx = 0;
197 /**
198 if(z<0||z>5.) { // CHECK 16) gap from geometry!
199 cout<<"DiffusionGTS::sigma_x_drift: error in z = " << z << endl;
200 return dx;
201 }
202 **/
203 for(int i=0; i<n_sigma_x_drift; i++) dx += pow(z, i) * m_sigma_x_drift_par[i];
204 return dx;
205}
207 double dx = m_sigma_x_transf_par;
208 return dx;
209}
211 double dx = m_sigma_x_induct_par;
212 return dx;
213}
214
215//----------------- Y
217
218 double dy = 0;
219 /**
220 if(z<0||z>5.) { // CHECK 16) gap from geometry!
221 cout<<"DiffusionGTS::shift_y_drift: error in z = " << z << endl;
222 return dy;
223 }
224 **/
225 for(int i=0; i<n_shift_y_drift; i++) dy += pow(z, i) * m_shift_y_drift_par[i];
226 return dy;
227}
229 double dy = m_shift_y_transf_par;
230 return dy;
231}
233 double dy = m_shift_y_induct_par;
234 return dy;
235}
236
238 double dy = 0;
239 /**
240 if(z<0||z>5.) { // CHECK 16) gap from geometry!
241 cout<<"DiffusionGTS::sigma_y_drift: error in z = " << z << endl;
242 return dy;
243 }
244 **/
245 for(int i=0; i<n_sigma_y_drift; i++) dy += pow(z, i) * m_sigma_y_drift_par[i];
246 return dy;
247}
249 double dy = m_sigma_y_transf_par;
250 return dy;
251}
253 double dy = m_sigma_y_induct_par;
254 return dy;
255}
256
257// ----------------------------------------
259 double dt = 0;
260 /**
261 if(z<0||z>5.) { // CHECK 16) gap from geometry!
262 cout<<"DiffusionGTS::shift_t_drift: error in z = " << z << endl;
263 return dt;
264 }
265 **/
266 for(int i=0; i<n_shift_t_drift; i++) dt += pow(z, i) * m_shift_t_drift_par[i];
267 return dt;
268}
269
271 double dx = m_shift_t_transf_par;
272 return dx;
273}
275 double dx = m_shift_t_induct_par;
276 return dx;
277}
278
280 double dt = 0;
281 /**
282 if(z<0||z>5.) { // CHECK 16) gap from geometry!
283 cout<<"DiffusionGTS::sigma_t_drift: error in z = " << z << endl;
284 return dt;
285 }
286 **/
287 for(int i=0; i<n_sigma_t_drift; i++) dt += pow(z, i) * m_sigma_t_drift_par[i];
288 return dt;
289}
291 double dx = m_sigma_t_transf_par;
292 return dx;
293}
295 double dx = m_sigma_t_induct_par;
296 return dx;
297}
298
299
300
301// ----------------------------------------------------------- drifting
302void DiffusionGTS::diffusion_drift(double xi, double yi, double zi, double ti, double &xf, double &yf, double &zf, double &tf) {
303
304 // x
305 double dx = shift_x_drift(zi);
306 double sx = sigma_x_drift(zi);
307 xf = xi + gRandom->Gaus(dx, sx);
308
309 // y
310 double dy = shift_y_drift(zi);
311 double sy = sigma_y_drift(zi);
312 yf = yi + gRandom->Gaus(dy, sy);
313
314 // t
315 double dt = shift_t_drift(zi);
316 double st = sigma_t_drift(zi);
317 tf = ti + gRandom->Gaus(dt, st);
318}
319
320void DiffusionGTS::diffusion_transf(double xi, double yi, double zi, double ti, double &xf, double &yf, double &zf, double &tf) {
321
322 // x
323 double dx = shift_x_transf();
324 double sx = sigma_x_transf();
325 xf = xi + gRandom->Gaus(dx, sx);
326
327 // y
328 double dy = shift_y_transf();
329 double sy = sigma_y_transf();
330 yf = yi + gRandom->Gaus(dy, sy);
331
332 // t
333 double dt = shift_t_transf();
334 double st = sigma_t_transf();
335 tf = ti + gRandom->Gaus(dt, st);
336}
337
338
339void DiffusionGTS::diffusion_induct(double xi, double yi, double zi, double ti, double &xf, double &yf, double &zf, double &tf) {
340
341 // x
342 double dx = shift_x_induct();
343 double sx = sigma_x_induct();
344 xf = xi + gRandom->Gaus(dx, sx);
345
346 // y
347 double dy = shift_y_induct();
348 double sy = sigma_y_induct();
349 yf = yi + gRandom->Gaus(dy, sy);
350
351 // t
352 double dt = shift_t_induct();
353 double st = sigma_t_induct();
354 tf = ti + gRandom->Gaus(dt, st);
355
356}
357
358// -------------------------------------
359
TGraphErrors * dt
Definition AbsCor.cxx:72
double sigma_t_transf()
double sigma_x_induct()
double sigma_t_drift(double z)
void diffusion_transf(double xi, double yi, double zi, double ti, double &xf, double &yf, double &zf, double &tf)
double sigma_x_transf()
double sigma_x_drift(double z)
DiffusionGTS(ICgemGeomSvc *geomSvc)
void readGasPerpParameters(std::string fileName)
void readGasParalParameters(std::string fileName)
double sigma_y_transf()
double shift_t_drift(double z)
double shift_y_induct()
double shift_t_transf()
double shift_y_transf()
double shift_x_induct()
double shift_y_drift(double z)
double shift_t_induct()
double sigma_y_induct()
double sigma_y_drift(double z)
double sigma_t_induct()
void diffusion_induct(double xi, double yi, double zi, double ti, double &xf, double &yf, double &zf, double &tf)
void diffusion_drift(double xi, double yi, double zi, double ti, double &xf, double &yf, double &zf, double &tf)
double shift_x_transf()
double shift_x_drift(double z)