Functions
test_mc_rejection_method_lin.C File Reference
#include <iostream>
#include <TRandom.h>
#include <TF1.h>
#include <TH1D.h>

Go to the source code of this file.

Functions

void test_mc_rejection_method_lin ()
 

Function Documentation

void test_mc_rejection_method_lin ( )

Definition at line 14 of file test_mc_rejection_method_lin.C.

15 {
16  const int N = 500000;
17  const int nbins = 300;
18  const double ymax = 1.1;
19  const double xmin = 0;
20  const double xmax = 10;
21  const double dx = xmax-xmin;
22 
23  TRandom rg;
24 
25  TF1 * func = new TF1 ("func","1/(x+1)",0,10);
26  TH1D * hgen = new TH1D ("hgen","generated",nbins,xmin,xmax);
27 
28  for(int i=0; i<N; i++) {
29  cout << "..................." << i << endl;
30  bool selected=false;
31  while(1) {
32  double xg = xmin + rg.Uniform() * dx;
33  double yg = ymax * rg.Uniform();
34  double yc = func->Eval(xg);
35  selected = (yg<yc);
36  if(selected) {
37  hgen->Fill(xg);
38  break;
39  }
40  }
41  }
42 
43  double IF = func->Integral(xmin,xmax);
44  double IH = hgen->Integral("width");
45  double sc = IF/IH;
46  hgen->Scale(sc);
47 
48  hgen->Draw();
49  func->Draw("same");
50 }
size_t i(0)
the ParameterSet object passed in for the configuration of a destination should be the only source that can affect the behavior of that destination This is to eliminate the dependencies of configuring a destination from multiple mostly from the defaults It suppresses possible glitches about changing the configuration file somewhere outside of a destination segament might still affect the behavior of that destination In the previous configuration for a specific the value of a certain e may come from following and have been suppressed It the configuring ParameterSet object for each destination will be required to carry a parameter list as complete as possible If a parameter still cannot be found in the ParameterSet the configuration code will go look for a hardwired default directly The model is a great simplicity comparing with the previous especially when looking for default values Another great advantage is most of the parameters now have very limited places that allows to appear Usually they can only appear at one certain level in a configuration file For in the old configuring model or in a default ParameterSet object inside of a or in a category or in a severity object This layout of multiple sources for a single parameter brings great confusion in both writing a configuration and in processing the configuration file Under the new the only allowed place for the parameter limit to appear is inside of a category which is inside of a destination object Other improvements simplify the meaning of a destination name In the old a destination name has multiple folds of meanings the e cout and cerr have the special meaning of logging messages to standard output or standard error the name also serves as the output filename if the destination is a file these names are also references to look up for detailed configurations in configuring the MessageFacility The multi purpose of the destination name might cause some unwanted behavior in either writing or parsing the configuration file To amend in the new model the destination name is now merely a name for a which might represent the literal purpose of this or just an id All other meanings of the destinations names now go into the destination ParameterSet as individual such as the type parameter and filename parameter Following is the deatiled rule for the new configuring Everything that is related with MessageFacility configuration must be wrapped in a single ParameterSet object with the name MessageFacility The MessageFacility ParameterSet object contains a series of top level parameters These parameters can be chosen a vector of string listing the name of debug enabled models Or use *to enable debug messages in all modules a vector of string a vector of string a vector of string a ParameterSet object containing the list of all destinations The destinations ParameterSet object is a combination of ParameterSet objects for individual destinations There are two types of destinations that you can insert in the destinations ParameterSet ordinary including cout
double func(double x, double y)