This example shows how to use the Hydra's phase space Monte Carlo generation and integration algorithms to generate a sample of B0 -> J/psi K pi and unweights to produce a B0-> K*(892) J/psi and fits a Breit-Wigner shape.
#ifndef PHSP_BASIC_INL_
#define PHSP_BASIC_INL_
#include <iostream>
#include <assert.h>
#include <time.h>
#include <vector>
#include <array>
#include <chrono>
#include <tclap/CmdLine.h>
#ifdef _ROOT_AVAILABLE_
#include <TROOT.h>
#include <TH1D.h>
#include <TF1.h>
#include <TH2D.h>
#include <TApplication.h>
#include <TCanvas.h>
#include <TColor.h>
#include <TString.h>
#include <TStyle.h>
#endif //_ROOT_AVAILABLE_
{
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;
}
#ifdef _ROOT_AVAILABLE_
TH2D Dalitz_d("Dalitz_d",
"3-body phase-space;"
"M^{2}(A B) [GeV^{2}/c^{4}];"
"M^{2}(B C) [GeV^{2}/c^{4}]",
#endif
});
{
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 << "| P -> A B C" << std::endl;
std::cout <<
"| Number of events :"<<
nentries << std::endl;
std::cout <<
"| Time (ms) :"<<
elapsed.count() << std::endl;
std::cout << "-----------------------------------------"<< std::endl;
std::cout << "\n\n|~~~~> Events (Vector4R, Vector4R, Vector4R):\n " << std::endl;
for( size_t i=0; i<10; i++ )
std::cout << Events[i] << std::endl;
auto dalitz_weights = Events | Events.GetEventWeightFunctor();
std::cout << "\n\n|~~~~> Dalitz plot {weight, (m^sq_ab, m^sq_bc)}:\n" << std::endl;
for( size_t i=0; i<10; i++ )
std::cout << "{ "
<< dalitz_weights[i] << ", "
<< dalitz_variables[i] << " }"<< std::endl;
start = std::chrono::high_resolution_clock::now();
{100,100},
dalitz_variables, dalitz_weights);
end = std::chrono::high_resolution_clock::now();
std::cout << "----------------- Device ----------------"<< std::endl;
std::cout << "| Histogram " << std::endl;
std::cout <<
"| Time (ms) :"<<
elapsed.count() << std::endl;
std::cout << "-----------------------------------------"<< std::endl;
#ifdef _ROOT_AVAILABLE_
for(size_t i=0; i< 100; i++){
for(size_t j=0; j< 100; j++){
Dalitz_d.SetBinContent(i+1, j+1, Hist_Dalitz.GetBinContent({i,j}) );
}
}
#endif
}
#ifdef _ROOT_AVAILABLE_
TApplication *m_app=new TApplication("myapp",0,0);
TCanvas canvas_d("canvas_d", "Phase-space Device", 500, 500);
Dalitz_d.Draw("colz");
canvas_d.Print("plots/phsp_basic_d.png");
m_app->Run();
#endif
return 0;
}
#endif