#include <iostream>
#include <assert.h>
#include <time.h>
#include <chrono>
#ifndef HYDRA_HOST_SYSTEM
#define HYDRA_HOST_SYSTEM CPP
#endif
#ifndef HYDRA_DEVICE_SYSTEM
#define HYDRA_DEVICE_SYSTEM TBB
#endif
#include "Minuit2/FunctionMinimum.h"
#include "Minuit2/MnUserParameterState.h"
#include "Minuit2/MnPrint.h"
#include "Minuit2/MnMigrad.h"
#include "Minuit2/MnMinimize.h"
#include <TROOT.h>
#include <TH1D.h>
#include <TApplication.h>
#include <TCanvas.h>
void fit_johnson(
size_t nentries=500000 )
{
TH1D* hist_johnson_d =
new TH1D(
"johnson_d",
"johnson", 100,
min,
max);
TH1D* hist_fitted_johnson_d =
new TH1D(
"fitted_johnson_d",
"johnson", 100,
min,
max);
{
std::cout<< std::endl<< "Generated data:"<< std::endl;
for(size_t i=0; i<10; i++)
std::cout << "[" << i << "] :" << dataset[i] << std::endl;
return (x >
min) && (x <
max );
});
std::cout<< std::endl<< "Filtered data:"<< std::endl;
for(size_t i=0; i<10; i++)
std::cout <<
"[" << i <<
"] :" <<
range[i] << std::endl;
ROOT::Minuit2::MnPrint::SetGlobalLevel(3);
std::cout<<
fcn.GetParameters().GetMnState()<<std::endl;
auto start_d = std::chrono::high_resolution_clock::now();
FunctionMinimum minimum_d = FunctionMinimum(
migrad_d(5000, 1));
auto end_d = std::chrono::high_resolution_clock::now();
std::chrono::duration<double, std::milli>
elapsed_d = end_d - start_d;
std::cout<<"minimum: "<<minimum_d<<std::endl;
std::cout << "-----------------------------------------" << std::endl;
std::cout <<
"| Device Time (ms) ="<<
elapsed_d.count() << std::endl;
std::cout << "-----------------------------------------" << std::endl;
for(size_t i=0; i<100; i++)
{
hist_johnson_d->SetBinContent(i+1,
Hist_Data.GetBinContent(i) );
}
hist_fitted_johnson_d->Sumw2();
for (size_t i=0 ; i<=100 ; i++)
{
double x = hist_fitted_johnson_d->GetBinCenter(i);
hist_fitted_johnson_d->SetBinContent(i,
fcn.GetPDF()(x) );
}
hist_fitted_johnson_d->Scale(hist_johnson_d->Integral()/hist_fitted_johnson_d->Integral() );
}
TCanvas* canvas_d = new TCanvas("canvas_d" ,"Distributions - Device", 500, 500);
hist_johnson_d->Draw("hist");
hist_fitted_johnson_d->SetLineColor(2);
hist_fitted_johnson_d->Draw("histsameC");
}