1 #ifndef PhysicsTools_Utilities_HistoPdf_h 2 #define PhysicsTools_Utilities_HistoPdf_h 12 template<
typename Iterator>
20 for(std::vector<double>::iterator i =
y_.begin(); i !=
y_.end(); ++
i)
24 template<
typename Iterator>
30 unsigned int n = end -
begin;
37 for(std::vector<double>::iterator i =
y_.begin(); i !=
y_.end(); ++
i)
41 if (x < xMin_ || x >
xMax_)
return 0;
46 if(
y_.size() % r != 0)
48 "HistoPdf: can't rebin histogram of " <<
y_.size() <<
" entries by " << r <<
"\n";
49 unsigned int n =
y_.size() /
r;
50 std::vector<double> y(n, 0);
51 for(
unsigned int i = 0, j = 0;
i <
n; ++
i)
52 for(
unsigned int k = 0;
k <
r; ++
k)
61 for(
unsigned int i = 0;
i !=
y_.size(); ++
i) {
64 std::cout <<
">>> pdf(" << x <<
") = " << y << std::endl;
67 std::cout <<
">>>: PDF normalization is " << s << std::endl;
71 std::vector<double>
y_;
77 unsigned int nBins = histo.GetNbinsX();
78 std::vector<double> y;
80 double xMin = histo.GetXaxis()->GetXmin();
81 double xMax = histo.GetXaxis()->GetXmax();
82 double deltaX =(xMax -
xMin) / nBins;
83 for(
unsigned int i = 0;
i != nBins; ++
i) {
84 double x = xMin + (
i + .5) * deltaX;
85 if(x > fMin && x < fMax) {
86 y.push_back(histo.GetBinContent(
i+1));
89 init(fMin, fMax, y.begin(), y.end());
HistoPdf(double xMin, double xMax, const Iterator &begin, const Iterator &end)
RootHistoPdf(const TH1 &histo, double fMin, double fMax)
double operator()(double x) const
void init(double xMin, double xMax, const Iterator &begin, const Iterator &end)
void rebin(unsigned int r)