#ifndef DENSE_HISTOGRAM_INL_
#define DENSE_HISTOGRAM_INL_
#include <iostream>
#include <assert.h>
#include <time.h>
#include <chrono>
#include <tclap/CmdLine.h>
#ifdef _ROOT_AVAILABLE_
#include <TROOT.h>
#include <TH3D.h>
#include <TApplication.h>
#include <TCanvas.h>
#endif //_ROOT_AVAILABLE_
{
try {
TCLAP::CmdLine cmd("Command line arguments for ", '=');
TCLAP::ValueArg<size_t>
EArg(
"n",
"number-of-events",
"Number of events",
true, 10e6,
"size_t");
}
catch (TCLAP::ArgException &e) {
std::cerr << "error: " << e.error() << " for arg " << e.argId()
<< std::endl;
}
double mean1 = 1.0;
double sigma1 = 1.0;
{
double g = 1.0;
double X[3]{x,y,z};
for(size_t i=0; i<3; i++)
{
double m2 = (X[i] - mean1 );
m2=m2*m2;
double s2 = sigma1*sigma1;
g *=
exp(-m2/(2.0 * s2 ))/(
sqrt(2.0*s2*
PI));
}
return g;
});
double mean2 = 3.0;
double sigma2 = 1.0;
{
double g = 1.0;
double X[3]{x,y,z};
for(size_t i=0; i<3; i++)
{
double m2 = (X[i] - mean2 );
m2=m2*m2;
double s2 = sigma2*sigma2;
g *=
exp(-m2/(2.0 * s2 ))/(
sqrt(2.0*s2*
PI));
}
return g;
});
auto Gaussians = Gaussian1 + Gaussian2;
std::array<double, 3>
max{6.0, 6.0, 6.0};
std::array<double, 3>
min{-6.0, -6.0, -6.0};
#ifdef _ROOT_AVAILABLE_
TH3D hist_d("hist_d", "3D Double Gaussian - Device",
50, -6.0, 6.0,
50, -6.0, 6.0,
50, -6.0, 6.0 );
#endif //_ROOT_AVAILABLE_
{
auto start_d = std::chrono::high_resolution_clock::now();
auto end_d = std::chrono::high_resolution_clock::now();
std::chrono::duration<double, std::milli>
elapsed_d = end_d - start_d;
std::cout << "-----------------------------------------"<<std::endl;
std::cout <<
"| [Generation] Device Time (ms) ="<<
elapsed_d.count() <<std::endl;
std::cout << "-----------------------------------------"<<std::endl;
std::cout <<std::endl;
std::cout <<std::endl;
for(size_t i=0; i<10; i++)
std::cout <<
"< Random::Sample > [" << i <<
"] :" <<
range.begin()[i] << std::endl;
std::array<size_t, 3> nbins{50, 50, 50};
start_d = std::chrono::high_resolution_clock::now();
end_d = std::chrono::high_resolution_clock::now();
std::cout << "-----------------------------------------"<<std::endl;
std::cout <<
"| [ Histograming ] Device Time (ms) ="<<
elapsed_d.count() <<std::endl;
std::cout << "-----------------------------------------"<<std::endl;
#ifdef _ROOT_AVAILABLE_
{
for(size_t i=0; i<50; i++){
for(size_t j=0; j<50; j++){
for(size_t k=0; k<50; k++){
size_t bin[3]={i,j,k};
hist_d.SetBinContent(i+1,j+1,k+1,
_temp_hist.GetBinContent(bin ) );
}
}
}
}
#endif //_ROOT_AVAILABLE_
}
#ifdef _ROOT_AVAILABLE_
TApplication *myapp=new TApplication("myapp",0,0);
TCanvas canvas_d("canvas_d" ,"Distributions - Device", 1000, 1000);
hist_d.Draw("");
hist_d.SetFillColor(9);
myapp->Run();
#endif //_ROOT_AVAILABLE_
return 0;
}
#endif