This example shows how to use the Hydra's phase space Monte Carlo algorithms to generate a sample of B0 -> J/psi K pi and plot the Dalitz plot.
#ifndef PHSP_REWEIGHTING_INL_
#define PHSP_REWEIGHTING_INL_
#include <iostream>
#include <assert.h>
#include <time.h>
#include <array>
#include <chrono>
#include <tclap/CmdLine.h>
#ifdef _ROOT_AVAILABLE_
#include <TROOT.h>
#include <TH1D.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_Flat("Dalitz_Flat",
"PHSP;"
"M^{2}(AB) [GeV^{2}/c^{4}];"
"M^{2}(BC) [GeV^{2}/c^{4}]",
TH2D Dalitz_Resonant("Dalitz_Resonant",
"Resonance;"
"M^{2}(AB) [GeV^{2}/c^{4}];"
"M^{2}(BC) [GeV^{2}/c^{4}]",
#endif
});
return resonance( (b+c).
mass());
} );
{
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;
auto dalitz_flat_weights = Events | Events.GetEventWeightFunctor();
auto dalitz_resonant_weights = Events | Events.GetEventWeightFunctor(
breit_wigner);
{100,100},
dalitz_variables, dalitz_flat_weights);
{100,100},
dalitz_variables, dalitz_resonant_weights);
#ifdef _ROOT_AVAILABLE_
for(size_t i=0; i< 100; i++){
for(size_t j=0; j< 100; j++){
Dalitz_Flat.SetBinContent(i+1, j+1, Hist_Dalitz_Flat.GetBinContent({i,j}) );
Dalitz_Resonant.SetBinContent(i+1, j+1, Hist_Dalitz_Resonant.GetBinContent({i,j}) );
}
}
#endif
}
#ifdef _ROOT_AVAILABLE_
TApplication *m_app=new TApplication("myapp",0,0);
TCanvas canvas_d1("canvas_d1", "Phase-space Device", 500, 500);
Dalitz_Flat.Draw("colz");
TCanvas canvas_d2("canvas_d2", "Phase-space Device", 500, 500);
Dalitz_Resonant.Draw("colz");
m_app->Run();
#endif
return 0;
}
#endif