1 #ifndef PhysicsTools_Utilities_HistoPdf_h 2 #define PhysicsTools_Utilities_HistoPdf_h 12 template <
typename Iterator>
17 for (
Iterator it = begin; it != end; ++it)
19 for (std::vector<double>::iterator
i =
y_.begin();
i !=
y_.end(); ++
i)
23 template <
typename Iterator>
28 unsigned int n = end - begin;
33 for (
Iterator it = begin; it != end; ++it)
35 for (std::vector<double>::iterator
i =
y_.begin();
i !=
y_.end(); ++
i)
39 if (x < xMin_ || x >
xMax_)
45 if (
y_.size() % r != 0)
47 <<
"HistoPdf: can't rebin histogram of " <<
y_.size() <<
" entries by " << r <<
"\n";
48 unsigned int n =
y_.size() / r;
49 std::vector<double> y(
n, 0);
50 for (
unsigned int i = 0,
j = 0;
i <
n; ++
i)
51 for (
unsigned int k = 0;
k < r; ++
k)
60 for (
unsigned int i = 0;
i !=
y_.size(); ++
i) {
63 std::cout <<
">>> pdf(" <<
x <<
") = " << y << std::endl;
66 std::cout <<
">>>: PDF normalization is " <<
s << std::endl;
71 std::vector<double>
y_;
78 std::vector<double> y;
80 double xMin =
histo.GetXaxis()->GetXmin();
81 double xMax =
histo.GetXaxis()->GetXmax();
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)
double operator()(double x) const
RootHistoPdf(const TH1 &histo, double fMin, double fMax)
void init(double xMin, double xMax, const Iterator &begin, const Iterator &end)
void rebin(unsigned int r)