42 for(i = 0 ; i<nDim ; i++){
43 R1=
R1+(Xarg[i] -pos1)*(Xarg[i] -pos1);
44 R2=
R2+(Xarg[i] -pos2)*(Xarg[i] -pos2);
50 Fun1 =
exp(-(
R1*
R1)/(Gam1*Gam1))/xn1;
51 Fun2 =
exp(-(
R2*
R2)/(Gam2*Gam2))/xn2;
52 return 0.5e0*(Fun1+ Fun2);
60 TFile RootFile(
"foam_demo.root",
"RECREATE",
"histograms");
79 cout<<
"***** Demonstration Program for Foam version "<<FoamX->
GetVersion()<<
" *****"<<endl;
92 FoamX->
Write(
"FoamX");
95 cout <<
"====== Initialization done, entering MC loop" << endl;
100 TH1D *hst_Wt =
new TH1D(
"hst_Wt" ,
"Main weight of Foam",25,0,1.25);
103 for(loop=0; loop<NevTot; loop++){
109 hst_Wt->
Fill(MCwt,1.0);
111 cout<<
"MCwt= "<<MCwt<<
", ";
113 for (
Int_t k=0 ; k<kDim ; k++) cout<<MCvect[k]<<
" "; cout<< endl;
115 if( ((loop)%100000)==0 ){
116 cout<<
" loop= "<<loop<<endl;
122 cout <<
"====== Events generated, entering Finalize" << endl;
124 hst_Wt->
Print(
"all");
131 Effic=0;
if(WtMax>0) Effic=AveWt/WtMax;
132 cout <<
"================================================================" << endl;
133 cout <<
" MCresult= " << MCresult <<
" +- " << MCerror <<
" RelErr= "<< MCerror/MCresult << endl;
134 cout <<
" Dispersion/<wt>= " <<
Sigma/AveWt << endl;
135 cout <<
" <wt>/WtMax= " << Effic <<
", for epsilon = "<<eps << endl;
136 cout <<
" nCalls (initialization only) = " << nCalls << endl;
137 cout <<
"================================================================" << endl;
144 cout <<
"***** End of Demonstration Program *****" << endl;
#define ClassDef(name, id)
A ROOT file is an on-disk file, usually with extension .root, that stores objects in a file-system-li...
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 SetEvPerBin(Int_t EvPerBin)
virtual void Initialize()
Basic initialization of FOAM invoked by the user.
virtual void SetnSampl(Long_t nSampl)
virtual void GetIntegMC(Double_t &, Double_t &)
User method.
virtual const char * GetVersion() const
virtual void GetMCwt(Double_t &)
User may get weight MC weight using this method.
virtual void SetChat(Int_t Chat)
virtual void SetOptDrive(Int_t OptDrive)
virtual void SetnCells(Long_t nCells)
virtual Long_t GetnCalls() const
virtual void SetRho(TFoamIntegrand *Rho)
User may use this method to set the distribution object.
virtual void Finalize(Double_t &, Double_t &)
May be called optionally by the user after the MC run.
virtual void SetOptRej(Int_t OptRej)
virtual void SetPseRan(TRandom *PseRan)
virtual void SetnBin(Int_t nBin)
virtual void SetkDim(Int_t kDim)
virtual void GetWtParams(Double_t, Double_t &, Double_t &, Double_t &)
May be called optionally after the MC run.
1-D histogram with a double per channel (see TH1 documentation)
void Print(Option_t *option="") const override
Print some global quantities for this histogram.
virtual Int_t Fill(Double_t x)
Increment bin with abscissa X by 1.
virtual void Sumw2(Bool_t flag=kTRUE)
Create structure to store sum of squares of weights.
virtual Int_t Write(const char *name=nullptr, Int_t option=0, Int_t bufsize=0)
Write this object to the current directory.
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.
RVec< PromoteType< T > > exp(const RVec< T > &v)
VecExpr< UnaryOp< Sqrt< T >, VecExpr< A, T, D >, T >, T, D > sqrt(const VecExpr< A, T, D > &rhs)
constexpr Double_t Sigma()
Stefan-Boltzmann constant in : .
#define R1(v, w, x, y, z, i)
#define R2(v, w, x, y, z, i)