#ifndef SAMPLE_DISTRIBUTION_INL_
#define SAMPLE_DISTRIBUTION_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;
}
unsigned nrbins = 50;
double g = 0.0;
double mx_sq = (x -
mean); mx_sq *=mx_sq;
double x_sq = - 0.5*mx_sq/sx_sq;
double my_sq = (y -
mean); my_sq *=my_sq;
double y_sq = - 0.5*my_sq/sy_sq;
double mz_sq = (z -
mean); mz_sq *=mz_sq;
double z_sq = - 0.5*mz_sq/sz_sq;
g =
exp(x_sq + y_sq + z_sq);
return g;
});
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 histogram("histogram", "3D Gaussian",
nrbins,-6.0, 6.0, nrbins,-6.0, 6.0, nrbins,-6.0, 6.0 );
#endif //_ROOT_AVAILABLE_
{
auto start = std::chrono::high_resolution_clock::now();
auto end = std::chrono::high_resolution_clock::now();
std::cout << std::endl;
std::cout << std::endl;
std::cout << "----------------- Device ----------------"<< std::endl;
std::cout << "| Sampling 3D-Gaussian "<< std::endl;
std::cout <<
"| Number of events :"<<
nentries << std::endl;
std::cout <<
"| Time (ms) :"<<
elapsed.count() << std::endl;
std::cout << "-----------------------------------------"<< std::endl;
{nrbins,nrbins,nrbins}, {-6.0, -6.0, -6.0}, {6.0, 6.0, 6.0},
#ifdef _ROOT_AVAILABLE_
for(size_t i=0; i< nrbins; i++)
{
for(size_t j=0; j< nrbins; j++)
{
for(size_t k=0; k< nrbins; k++)
{
histogram.SetBinContent(i+1, j+1, k+1, Hist.GetBinContent({i,j,k}) );
}
}
}
#endif //_ROOT_AVAILABLE_
}
#ifdef _ROOT_AVAILABLE_
TApplication *myapp=new TApplication("myapp",0,0);
TCanvas canvas("canvas" ,"", 1000, 1000);
histogram.Draw("scatter");
histogram.SetFillColor(9);
myapp->Run();
#endif //_ROOT_AVAILABLE_
return 0;
}
#endif