CMS 3D CMS Logo

HistogramGenerator.h
Go to the documentation of this file.
1 #ifndef HistogramGenerator_H
2 #define HistogramGenerator_H
4 
5 #include "TH1.h"
6 
11 class RandomEngine;
12 class TAxis;
13 
15 {
16  public:
17 
20  BaseNumericalRandomGenerator(histo->GetXaxis()->GetXmin(),
21  histo->GetXaxis()->GetXmax(),
22  100000,
23  3),
24  myHisto(histo),
25  theXaxis(histo->GetXaxis()),
26  nbins(histo->GetXaxis()->GetNbins())
27  {
28 
29  // std::cout << "Old xmin/xmax = " << xmin << " " << xmax << std::endl;
30  // Drop lowest and highest empty bins
31  double du = (xmax-xmin)/(float)nbins;
32  // Restrict xmin to meaningful values
33  while ( function(xmin) <= 0. ) xmin += du;
34  // Restrict xmax to meaningful values
35  while ( function(xmax) <= 0. ) xmax -= du;
36 
37  if ( xmin != histo->GetXaxis()->GetXmin() ) xmin -= du;
38  if ( xmax != histo->GetXaxis()->GetXmax() ) xmax += du;
39 
40  // std::cout << "New xmin/xmax = " << xmin << " " << xmax << std::endl;
41 
42  // std::cout <<" Init " << std::endl;
43  initialize();
44  }
45 
47  virtual ~HistogramGenerator() {}
48 
50  virtual double function(double x) { return ersatzt(x); }
51 
52  private:
54  TH1 * myHisto;
55 
57  TAxis * theXaxis;
58 
60  int nbins;
61 
63  double ersatzt(double x);
64 };
65 #endif
TH1 * myHisto
Pointer to the histogram.
void initialize()
The initialization (numerical integarion, inversion)
TAxis * theXaxis
the axis
HistogramGenerator(TH1 *histo)
Constructor : initialization of the Random Generator.
virtual ~HistogramGenerator()
Default destructor.
double ersatzt(double x)
Gamma Function.