#include <iomanip>
#include <TRandom.h>
void use_functions_wo_measurement() {
int n_entries = 15;
double bin_size = 1.8;
double* test_arr = new double[n_entries];
double* x = new double[n_entries];
int x0 = static_cast<int>(n_entries / 2);
cout << "\noriginal: ";
for (int i = 0; i < n_entries; i++) {
x[i] = static_cast<double>(i) * bin_size;
test_arr[i] = gRandom->Gaus(0, .5) + 10. / (1. + static_cast<double>((i - x0) * (i - x0)) * (bin_size * bin_size));
cout << setprecision(2) << test_arr[i] << "\t";
}
auto orig = new TGraph(n_entries, x, test_arr);
orig->SetTitle("original data; x title [arb.]; y title [arb.]");
cout << "\n\nsmoothed: ";
for (int i = 0; i < n_entries; i++) cout << setprecision(2) << test_arr[i] << "\t";
auto smoothed = new TGraph(n_entries, x, test_arr);
smoothed->SetTitle("smoothed data");
cout << endl;
cout << "\naveraged: ";
for (int i = 0; i < n_entries; i++) cout << setprecision(2) << test_arr[i] << "\t";
cout << endl;
auto more_smoothed = new TGraph(n_entries, x, test_arr);
more_smoothed->SetTitle("even more smoothed data");
more_smoothed->SetLineColor(4);
gStyle->SetOptTitle(0);
orig->Draw("AC+");
smoothed->Draw("C same");
more_smoothed->Draw("C same");
gPad->BuildLegend(.5,.7,.9,.9);
gPad->SaveAs("examples/use_functions_wo_measurement.png");
delete[] test_arr;
delete[] x;
}
static void SmoothArray(double *&, int, double=.625, string="Gaus", double=.3125, double=1.5)
Apply smoothing array of double with length nbins.
static int rcolor(unsigned int)
Translate a random number into a useful root color https://root.cern.ch/doc/master/classTColor....