/
githubmirror
/
cmssw
Обзор
Документация
Войти
/
githubmirror
/
cmssw
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
FastSimulation/Utilities/interface/HistogramGenerator.h
62 строки
2 KB
Cms Build
Clang-Format
24 май 2019, 00:14
24 май 2019, 00:14
740c44a
Код
Авторство
О чём код?
#ifndef HistogramGenerator_H #define HistogramGenerator_H #include "FastSimulation/Utilities/interface/BaseNumericalRandomGenerator.h" #include "TH1.h" /** Numerical Random Generator for Gamma distribution. * Copy of LandauFluctuations */ class RandomEngine; class TAxis; class HistogramGenerator : public BaseNumericalRandomGenerator { public: /// Constructor : initialization of the Random Generator HistogramGenerator(TH1* histo) : BaseNumericalRandomGenerator(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(); } /// Default destructor ~HistogramGenerator() override {} /// The probability density function implementation double function(double x) override { return ersatzt(x); } private: /// Pointer to the histogram TH1* myHisto; /// the axis TAxis* theXaxis; /// n bins int nbins; /// Gamma Function double ersatzt(double x); }; #endif