use the stored residuals to improve the given r-t relationship to give smoother residuals; the user can request that the radii for the minimum and maximum drift time are untouched
178 {
180
182
183 unsigned int nb_bins;
184 unsigned int min_nb_entries_per_bin(20);
185
186 double step_size;
187 double r_max(16.0);
188 double aux_rad;
189 double aux_corr;
190 unsigned int bin_index;
191
193
195
196
197
198
199
200
201
202 nb_bins =
static_cast<unsigned int>(std::sqrt(
m_residual_point.size() / 6.));
203
204
205 if (nb_bins == 0) { nb_bins = 1; }
207
209
211
214 log << MSG::WARNING <<
"performSmoothing() - No residuals are stored. no correction applied to r(t)!" <<
endmsg;
215 }
216
217 step_size = r_max / static_cast<double>(nb_bins);
218
220
222
223
224 std::vector<SamplePoint> corr(nb_bins);
225 std::vector<double> radii(nb_bins);
226
227
228
231
232
233 std::vector<std::vector<const DataPoint *> > sample_points_per_r_bin(nb_bins);
234
235
237 if (std::abs(
k.dataVector()[0]) >= r_max) {
continue; }
238 bin_index =
static_cast<unsigned int>(std::abs(
k.dataVector()[0]) / step_size);
239 sample_points_per_r_bin[bin_index].push_back(&k);
240 }
241
242
243
244
245 for (
unsigned int bin = 0;
bin < nb_bins;
bin++) {
246 aux_rad = 0.0;
247 aux_corr = 0.0;
248
249
250 unsigned int k_min(static_cast<unsigned int>(0.01 * sample_points_per_r_bin[bin].size()));
251 unsigned int k_max(static_cast<unsigned int>(0.99 * sample_points_per_r_bin[bin].size()));
252
253
254
255
256 for (
unsigned int k = k_min;
k < k_max;
k++) {
257 aux_rad = aux_rad + sample_points_per_r_bin[
bin][
k]->dataVector()[0];
258 aux_corr = aux_corr + sample_points_per_r_bin[
bin][
k]->dataVector()[1];
259 }
260 if (k_max - k_min < 0.25 * min_nb_entries_per_bin) {
261 radii[
bin] = (0.5 +
bin) * step_size;
262 corr[
bin] = SamplePoint(radii[bin], 0.0, 1.0);
263 } else {
264 radii[
bin] = aux_rad /
static_cast<double>(k_max - k_min);
265 corr[
bin] = SamplePoint(radii[bin], aux_corr /
static_cast<double>(k_max - k_min), 1.0);
266 }
267 }
268
269
270 PolygonBase polygon(radii);
271 BaseFunctionFitter
fitter(nb_bins);
272 fitter.fit_parameters(corr, 1, corr.size(), polygon);
273
274
275 std::vector<double> rt_params;
276 rt_params.push_back(rt_rel.
tLower());
277 rt_params.push_back(0.01 * (rt_rel.
tUpper() - rt_rel.
tLower()));
278
279 for (
double t = rt_rel.
tLower(); t <= rt_rel.
tUpper(); t = t + rt_params[1]) {
280 double delta_r(0.0);
281 for (
unsigned int l = 0;
l < radii.size();
l++) {
282 delta_r = delta_r +
fitter.coefficients()[
l] * polygon.value(l, rt_rel.
radius(t));
283 }
284 if (rt_rel.
radius(t) > r_max) { delta_r = 0.0; }
285 if (fix_t_min && (rt_rel.
radius(t) < 0.5)) { delta_r = 0.0; }
286 if (fix_t_max && (rt_rel.
radius(t) > 14.1)) { delta_r = 0.0; }
287 rt_params.push_back(rt_rel.
radius(t) - delta_r);
288 }
289
290 RtRelationLookUp improved_rt(rt_params);
291
292
293
294
295
296 return improved_rt;
297}
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
virtual double tLower() const =0
Returns the lower time covered by the r-t.
virtual double radius(double t) const =0
returns drift radius for a given time
virtual double tUpper() const =0
Returns the upper time covered by the r-t.
IMessageSvc * getMessageSvc(bool quiet=false)
l
Printing final latex table to .tex output file.