52 virtual ~FoamFunction() {}
53 double Density(
int nDim,
double *
x) {
54 return Camel2(nDim,
x);
64Int_t run_foam(
int nev){
65 cout<<
"--- kanwa started ---"<<endl;
67 TH2D *hst_xy =
new TH2D(
"foam_hst_xy" ,
"FOAM x-y plot", 50,0,1.0, 50,0,1.0);
77 FoamX->
SetRho(
new FoamFunction() );
91 for(
long loop=0; loop<nev; loop++){
101 hst_xy->
Draw(
"lego2");
107 double time = w.
CpuTime()*1.E9/nev;
108 cout <<
"Time using FOAM \t\t " <<
" \t=\t " << time <<
"\tns/call" << endl;
111 hst_xy->
Draw(
"lego2");
115 cout <<
" MCresult= " << MCresult <<
" +- " << MCerror <<endl;
116 cout<<
"--- kanwa ended ---"<<endl;
123double UCamel2(
double *
x,
double *) {
127int run_unuran(
int nev, std::string method =
"hitro") {
130 std::cout <<
"run unuran " << std::endl;
134 TH2D *
h1 =
new TH2D(
"unr_hst_xy" ,
"UNURAN x-y plot", 50,0,1.0, 50,0,1.0);
137 TF2 *
f =
new TF2(
"f",UCamel2,0,1,0,1,0);
152 bool ret = unr.Init(
dist,method);
154 std::cerr <<
"Error initializing unuran with method " << unr.MethodName() << endl;
159 for (
int i = 0; i < nev; ++i) {
167 double time = w.
CpuTime()*1.E9/nev;
168 cout <<
"Time using Unuran " << unr.MethodName() <<
" \t=\t " << time <<
"\tns/call" << endl;
173Int_t unuranFoamTest(){
176 TCanvas *cKanwa =
new TCanvas(
"cKanwa",
"Canvas for plotting",600,1000);
182 run_unuran(
n,
"hitro");
191 std::cout <<
"\nChi2 Test Results (UNURAN-FOAM):\t";
#define ClassDef(name, id)
R__EXTERN TSystem * gSystem
virtual void Update()
Update canvas pad buffers.
TVirtualPad * cd(Int_t subpadnumber=0)
Set current canvas & pad.
A 2-Dim function with parameters.
Abstract class representing n-dimensional real positive integrand function.
virtual Double_t Density(Int_t ndim, Double_t *)=0
TFoam is the main class of the multi-dimensional general purpose Monte Carlo event generator (integra...
virtual void GetMCvect(Double_t *)
User may get generated MC point/vector with help of this method.
virtual void MakeEvent()
User method.
virtual void Initialize()
Basic initialization of FOAM invoked by the user.
virtual void GetIntegMC(Double_t &, Double_t &)
User method.
virtual void SetnCells(Long_t nCells)
virtual void SetRho(TFoamIntegrand *Rho)
User may use this method to set the distribution object.
virtual void SetPseRan(TRandom *PseRan)
virtual void SetkDim(Int_t kDim)
virtual Double_t Chi2Test(const TH1 *h2, Option_t *option="UU", Double_t *res=0) const
test for comparing weighted and unweighted histograms
virtual Int_t Fill(Double_t x)
Increment bin with abscissa X by 1.
virtual void Draw(Option_t *option="")
Draw this histogram with options.
2-D histogram with a double per channel (see TH1 documentation)}
Service class for 2-Dim histogram classes.
Int_t Fill(Double_t)
Invalid Fill method.
virtual void Divide(Int_t nx=1, Int_t ny=1, Float_t xmargin=0.01, Float_t ymargin=0.01, Int_t color=0)
Automatic pad generation by division.
Random number generator class based on M.
This is the base class for the ROOT Random number generators.
virtual void SetSeed(ULong_t seed=0)
Set the random generator seed.
void Start(Bool_t reset=kTRUE)
Start the stopwatch.
Double_t CpuTime()
Stop the stopwatch (if it is running) and return the cputime (in seconds) passed between the start an...
void Stop()
Stop the stopwatch.
virtual int Load(const char *module, const char *entry="", Bool_t system=kFALSE)
Load a shared library.
TUnuranMultiContDist class describing multi dimensional continuous distributions.
double Dist(void *xp, void *yp)
double dist(Rotation3D const &r1, Rotation3D const &r2)
VecExpr< UnaryOp< Sqr< T >, VecExpr< A, T, D >, T >, T, D > sqr(const VecExpr< A, T, D > &rhs)