24
24
const double PI = acos(-1 );
25
25
const double ANG_FWD = 47 *PI/180 .;
26
26
27
+
27
28
Worker::Worker (Beam_t *beam, Target_t *target, Telescope_t *telescope)
28
29
: theBeam( beam )
29
30
, theTarget( target )
@@ -136,6 +137,7 @@ bool Worker::Curve(QVector<double> &Ex, QVector<double> &dE, QVector<double> &E,
136
137
}
137
138
138
139
double Ehalf = stopTargetB->Loss (theBeam->E , target->GetWidth (tUnit)/2 ., INTPOINTS);
140
+ double Ewhole = stopTargetB->Loss (theBeam->E , INTPOINTS);
139
141
140
142
double dEx = (Ehalf + get_Q_keV (theBeam->A , theBeam->Z , theTarget->A , theTarget->Z , fA , fZ )/1000 .)/double (POINTS - 1 );
141
143
@@ -164,23 +166,33 @@ bool Worker::Curve(QVector<double> &Ex, QVector<double> &dE, QVector<double> &E,
164
166
return false ; // Reaction not possible. Not enough energy :(
165
167
}
166
168
167
- QVector<double > Ex_tmp (POINTS), dE_tmp (POINTS), E_tmp (POINTS), is_punch (POINTS);
169
+ QVector<double > Ex_tmp (POINTS), dE_tmp (POINTS), E_tmp (POINTS), E_err_tmp (POINTS), is_punch (POINTS);
168
170
169
171
Ex.clear ();
170
172
dE.clear ();
171
173
E.clear ();
172
174
173
-
175
+ double l;
174
176
double m, dm, em;
177
+ double n;
175
178
176
179
for (int i = 0 ; i < POINTS ; ++i){
177
180
Ex_tmp[i] = i*dEx;
178
181
182
+ l = scat->EvaluateY (theBeam->E , Angle, Ex_tmp[i]);
179
183
m = scat->EvaluateY (Ehalf, Angle, Ex_tmp[i]);
184
+ n = scat->EvaluateY (Ewhole, Angle, Ex_tmp[i]);
180
185
186
+ l = stopTargetF->Loss (l, target->GetWidth (tUnit)/fabs (2 *cos (Angle)), INTPOINTS);
181
187
m = stopTargetF->Loss (m, target->GetWidth (tUnit)/fabs (2 *cos (Angle)), INTPOINTS);
182
188
189
+ l = stopAbsor->Loss (l, INTPOINTS);
183
190
m = stopAbsor->Loss (m, INTPOINTS);
191
+ n = stopAbsor->Loss (n, INTPOINTS);
192
+
193
+ E_err_tmp[i] = sqrt (3 *l*l + 3 *n*n + 4 *m*m - 2 *n*l -4 *m*(l + n))/4 .;
194
+
195
+ m = (l + 2 *m + n)/4 .;
184
196
185
197
dm = stopDE->Loss (m, INTPOINTS);
186
198
@@ -192,14 +204,15 @@ bool Worker::Curve(QVector<double> &Ex, QVector<double> &dE, QVector<double> &E,
192
204
if (em != em)
193
205
is_punch[i] = 1000 ;
194
206
}
195
- QVector<double > is_punch2;
207
+ QVector<double > is_punch2, E_err ;
196
208
int not_punch = 0 ;
197
209
for (int i = 0 ; i < Ex_tmp.size () ; ++i){
198
210
if (E_tmp[i] >= 0.35 ){
199
211
Ex.push_back (Ex_tmp[i]);
200
212
dE.push_back (dE_tmp[i]);
201
213
E.push_back (E_tmp[i]);
202
214
is_punch2.push_back (is_punch[i]);
215
+ E_err.push_back (E_err_tmp[i]);
203
216
if (is_punch[i] <= 0.05 )
204
217
not_punch += 1 ;
205
218
}
@@ -208,18 +221,25 @@ bool Worker::Curve(QVector<double> &Ex, QVector<double> &dE, QVector<double> &E,
208
221
if (not_punch >= 3 ){
209
222
double *x = new double [not_punch];
210
223
double *y = new double [not_punch];
224
+ double *dx = new double [not_punch];
211
225
int j = 0 ;
212
226
for (int i = 0 ; i < is_punch2.size () ; ++i){
213
227
if (is_punch2[i] <= 0.05 && j < not_punch){
214
228
x[j] = dE[i] + E[i];
215
229
y[j] = Ex[i];
230
+ dx[j] = E_err[i];
216
231
++j;
217
232
}
218
233
}
219
234
Polyfit fitting (x, y, not_punch);
220
235
Vector fit = fitting (3 );
221
- coeff = QVector<double >(3 );
222
- coeff[0 ] = fit[0 ]; coeff[1 ] = fit[1 ]; coeff[2 ] = fit[2 ];
236
+ coeff = QVector<double >(4 );
237
+ coeff[0 ] = fit[0 ]; coeff[1 ] = fit[1 ]; coeff[2 ] = fit[2 ], coeff[3 ] = 0 ;
238
+
239
+ for (int i = 0 ; i < not_punch ; ++i){
240
+ coeff[3 ] += (y[i] - coeff[0 ] - coeff[1 ]*x[i] - coeff[2 ]*x[i]*x[i])*(y[i] - coeff[0 ] - coeff[1 ]*x[i] - coeff[2 ]*x[i]*x[i])/(dx[i]*dx[i]);
241
+ }
242
+ coeff[3 ] /= double (not_punch - 3 );
223
243
224
244
delete[] x;
225
245
delete[] y;
0 commit comments