This example shows how to use the Hydra's phase space Monte Carlo algorithms to calculate the average value and corresponding variance of a functor over the phase space of the decay B0 -> J/psi K pi.
#ifndef PHSP_AVERAGING_FUNCTOR_INL_
#define PHSP_AVERAGING_FUNCTOR_INL_
#include <iostream>
#include <assert.h>
#include <time.h>
#include <vector>
#include <array>
#include <chrono>
#include <tclap/CmdLine.h>
{
try {
TCLAP::CmdLine cmd("Command line arguments for PHSP B0 -> J/psi K pi", '=');
TCLAP::ValueArg<size_t>
NArg(
"n",
"nevents",
"Number of events to generate. Default is [ 10e6 ].",
true, 10e6, "unsigned long");
}
catch (TCLAP::ArgException &e) {
std::cerr << "error: " << e.error() << " for arg " << e.argId()
<< std::endl;
}
return coshelang(a+b+c, b+c, c);
});
{
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 << "|< cos(theta_K) >(B0 -> J/psi K pi): "
<< device_result.first
<< " +- "
<< device_result.second
<< std::endl;
std::cout <<
"| Number of events :"<<
nentries << std::endl;
std::cout <<
"| Time (ms) :"<<
elapsed.count() << std::endl;
std::cout << "-----------------------------------------"<< std::endl;
}
return 0;
}
#endif