#include <HistogramGenerator.h>
Public Member Functions | |
virtual double | function (double x) |
The probability density function implementation. | |
HistogramGenerator (TH1 *histo, const RandomEngine *engine) | |
Constructor : initialization of the Random Generator. | |
virtual | ~HistogramGenerator () |
Default destructor. | |
Private Member Functions | |
double | ersatzt (double x) |
Gamma Function. | |
Private Attributes | |
TH1 * | myHisto |
Pointer to the histogram. | |
int | nbins |
n bins | |
TAxis * | theXaxis |
the axis |
Definition at line 14 of file HistogramGenerator.h.
HistogramGenerator::HistogramGenerator | ( | TH1 * | histo, |
const RandomEngine * | engine | ||
) | [inline] |
Constructor : initialization of the Random Generator.
Definition at line 19 of file HistogramGenerator.h.
References function(), BaseNumericalRandomGenerator::initialize(), nbins, BaseNumericalRandomGenerator::xmax, and BaseNumericalRandomGenerator::xmin.
: BaseNumericalRandomGenerator(engine, histo->GetXaxis()->GetXmin(), histo->GetXaxis()->GetXmax(), 100000, 3), myHisto(histo), theXaxis(histo->GetXaxis()), nbins(histo->GetXaxis()->GetNbins()) { // std::cout << "Old xmin/xmax = " << xmin << " " << xmax << std::endl; // Drop lowest and highest empty bins double du = (xmax-xmin)/(float)nbins; // Restrict xmin to meaningful values while ( function(xmin) <= 0. ) xmin += du; // Restrict xmax to meaningful values while ( function(xmax) <= 0. ) xmax -= du; if ( xmin != histo->GetXaxis()->GetXmin() ) xmin -= du; if ( xmax != histo->GetXaxis()->GetXmax() ) xmax += du; // std::cout << "New xmin/xmax = " << xmin << " " << xmax << std::endl; // std::cout <<" Init " << std::endl; initialize(); }
virtual HistogramGenerator::~HistogramGenerator | ( | ) | [inline, virtual] |
double HistogramGenerator::ersatzt | ( | double | x | ) | [private] |
Gamma Function.
Definition at line 5 of file HistogramGenerator.cc.
References myHisto, nbins, and theXaxis.
Referenced by function().
{ int ibin=theXaxis->FindBin(x); // std::cout << x << " Bin " << ibin << std::endl; double x1=myHisto->GetBinLowEdge(ibin); double x2=x1+myHisto->GetBinWidth(ibin); double y1=myHisto->GetBinContent(ibin); double y2; if(ibin<nbins) y2=myHisto->GetBinContent(ibin+1); else y2=y1; // std::cout << " X1 " << x1 <<" X2 " << x2 << " Y1 " <<y1 << " Y2 " << y2 << std::endl; return y2 + (y1-y2)*(x2-x)/(x2-x1); }
virtual double HistogramGenerator::function | ( | double | x | ) | [inline, virtual] |
The probability density function implementation.
Implements BaseNumericalRandomGenerator.
Definition at line 51 of file HistogramGenerator.h.
References ersatzt().
Referenced by HistogramGenerator().
TH1* HistogramGenerator::myHisto [private] |
Pointer to the histogram.
Definition at line 55 of file HistogramGenerator.h.
Referenced by ersatzt().
int HistogramGenerator::nbins [private] |
n bins
Definition at line 61 of file HistogramGenerator.h.
Referenced by ersatzt(), and HistogramGenerator().
TAxis* HistogramGenerator::theXaxis [private] |