17#include <svd/reconstruction/NNWaveFitter.h>
18#include <svd/reconstruction/NNWaveFitTool.h>
19#include <svd/simulation/SVDSimulationTools.h>
27 typedef chrono::high_resolution_clock myclock;
28 myclock::time_point beginning = myclock::now();
32 auto fitTool = fitter.getFitTool();
35 myclock::duration d = myclock::now() - beginning;
36 unsigned seed = d.count();
37 default_random_engine randn(seed);
38 normal_distribution<double> gaussian(0.0, 1.0);
42 size_t n_amplitudes = 3;
43 vector< tuple<double, double, double> > components(n_amplitudes);
44 components = {{6, -20, 300}, {6, -20, 300}, {6, -20, 300}};
45 vector<apvSamples> samples_arr(n_amplitudes);
46 vector<shared_ptr<nnFitterBinData> > parr(n_amplitudes);
48 fill(p.begin(), p.end(),
double(1.0));
49 double amplitude, t0, width;
50 double t0_fit, t0_err;
51 double a_fit, a_err, chi2;
52 cout <<
" >>>>>>>>>> SEPARRATE COMPONENTS <<<<<<<<<< " << endl;
53 for (
size_t icomp = 0; icomp < n_amplitudes; ++icomp) {
54 tie(amplitude, t0, width) = components[icomp];
57 transform(u.begin(), u.end(), samples_arr[icomp].begin(),
58 [&](
double x)->double {
59 double w = amplitude * x + gaussian(randn);
60 return (int(w) > 3 ? int(w) : 0.0);
63 copy(samples_arr[icomp].begin(), samples_arr[icomp].end(), ostream_iterator<double>(cout,
" "));
65 parr[icomp] = fitter.getFit(samples_arr[icomp], width);
66 copy(parr[icomp]->begin(), parr[icomp]->end(), ostream_iterator<double>(cout,
" "));
68 fitTool.multiply(p, *(parr[icomp]));
69 tie(t0_fit, t0_err) = fitTool.getTimeShift(*(parr[icomp]));
70 tie(a_fit, a_err, chi2) = fitTool.getAmplitudeChi2(u, t0_fit, width);
71 cout <<
"Component: " << icomp << endl;
72 cout <<
"Time: " << t0_fit <<
" +/- " << t0_err << endl;
73 cout <<
"Amplitude: " << a_fit <<
" +/- " << a_err << endl;
74 cout <<
"Chi-square " << chi2 << endl;
76 cout <<
" >>>>>>>>>> POOLED COMPONENTS <<<<<<<<<< " << endl;
77 tie(t0_fit, t0_err) = fitTool.getTimeShift(p);
78 cout <<
"Time: " << t0_fit <<
" +/- " << t0_err << endl;
79 for (
size_t icomp = 0; icomp < n_amplitudes; ++icomp) {
80 tie(a_fit, a_err, chi2) = fitTool.getAmplitudeChi2(samples_arr[icomp], t0_fit, width);
81 cout <<
"Component: " << icomp << endl;
82 cout <<
"Amplitude: " << a_fit <<
" +/- " << a_err << endl;
83 cout <<
"Chi-square " << chi2 << endl;
85 cout <<
" >>>>>>>>>> SUM OF SIGNALS COMPONENTS <<<<<<<<<< " << endl;
88 fill(u_sum.begin(), u_sum.end(),
double(0.0));
90 for (
size_t j = 0; j < n_amplitudes; ++j)
91 u_sum[i] += samples_arr[j][i];
92 shared_ptr<nnFitterBinData> p_sum = fitter.getFit(u_sum, width);
93 tie(t0_fit, t0_err) = fitTool.getTimeShift(*p_sum);
94 cout <<
"Time: " << t0_fit <<
" +/- " << t0_err << endl;
95 for (
size_t icomp = 0; icomp < n_amplitudes; ++icomp) {
96 tie(a_fit, a_err, chi2) = fitTool.getAmplitudeChi2(samples_arr[icomp], t0_fit, width);
97 cout <<
"Component: " << icomp << endl;
98 cout <<
"Amplitude: " << a_fit <<
" +/- " << a_err << endl;
99 cout <<
"Chi-square " << chi2 << endl;
The class uses a neural network to find a probability distribution of arrival times for a sextet of A...
Waveform generator This is a functor to calculate APV samples from waveform.
Namespace to encapsulate code needed for simulation and reconstrucion of the SVD.
std::array< apvSampleBaseType, nAPVSamples > apvSamples
vector od apvSample BaseType objects
const std::size_t nAPVSamples
Number of APV samples.
std::vector< double > nnFitterBinData
Vector of values defined for bins, such as bin times or bin probabilities.
bool pass3Samples(const T &a, double thr)
pass 3-samples