CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
19  HistogramGenerator(TH1 * histo, const RandomEngine* engine) :
21  histo->GetXaxis()->GetXmin(),
22  histo->GetXaxis()->GetXmax(),
23  100000,
24  3),
25  myHisto(histo),
26  theXaxis(histo->GetXaxis()),
27  nbins(histo->GetXaxis()->GetNbins())
28  {
29 
30  // std::cout << "Old xmin/xmax = " << xmin << " " << xmax << std::endl;
31  // Drop lowest and highest empty bins
32  double du = (xmax-xmin)/(float)nbins;
33  // Restrict xmin to meaningful values
34  while ( function(xmin) <= 0. ) xmin += du;
35  // Restrict xmax to meaningful values
36  while ( function(xmax) <= 0. ) xmax -= du;
37 
38  if ( xmin != histo->GetXaxis()->GetXmin() ) xmin -= du;
39  if ( xmax != histo->GetXaxis()->GetXmax() ) xmax += du;
40 
41  // std::cout << "New xmin/xmax = " << xmin << " " << xmax << std::endl;
42 
43  // std::cout <<" Init " << std::endl;
44  initialize();
45  }
46 
48  virtual ~HistogramGenerator() {}
49 
51  virtual double function(double x) { return ersatzt(x); }
52 
53  private:
55  TH1 * myHisto;
56 
58  TAxis * theXaxis;
59 
61  int nbins;
62 
64  double ersatzt(double x);
65 
66 
67 };
68 
69 #endif
HistogramGenerator(TH1 *histo, const RandomEngine *engine)
Constructor : initialization of the Random Generator.
TH1 * myHisto
Pointer to the histogram.
void initialize()
The initialization (numerical integarion, inversion)
TAxis * theXaxis
the axis
virtual ~HistogramGenerator()
Default destructor.
x
Definition: VDTMath.h:216
double ersatzt(double x)
Gamma Function.