CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
funct::HistoPdf Class Reference

#include <HistoPdf.h>

Inheritance diagram for funct::HistoPdf:
funct::RootHistoPdf

Public Member Functions

void dump ()
 
 HistoPdf ()
 
template<typename Iterator >
 HistoPdf (double xMin, double xMax, const Iterator &begin, const Iterator &end)
 
template<typename Iterator >
void init (double xMin, double xMax, const Iterator &begin, const Iterator &end)
 
double operator() (double x) const
 
void rebin (unsigned int r)
 

Private Attributes

double binSize_
 
double delta_
 
double xMax_
 
double xMin_
 
std::vector< double > y_
 

Detailed Description

Definition at line 10 of file HistoPdf.h.

Constructor & Destructor Documentation

◆ HistoPdf() [1/2]

template<typename Iterator >
funct::HistoPdf::HistoPdf ( double  xMin,
double  xMax,
const Iterator begin,
const Iterator end 
)
inline

Definition at line 13 of file HistoPdf.h.

15  double s = 0;
16  unsigned int i = 0;
17  for (Iterator it = begin; it != end; ++it)
18  s += (y_[i++] = *it);
19  for (std::vector<double>::iterator i = y_.begin(); i != y_.end(); ++i)
20  *i /= s;
21  }

References begin, end, mps_fire::i, alignCSCRings::s, and y_.

◆ HistoPdf() [2/2]

funct::HistoPdf::HistoPdf ( )
inline

Definition at line 22 of file HistoPdf.h.

22 {}

Member Function Documentation

◆ dump()

void funct::HistoPdf::dump ( void  )
inline

Definition at line 56 of file HistoPdf.h.

56  {
57  std::cout << ">>> range: [" << xMin_ << ", " << xMax_ << "], bin size: " << delta_ << "/" << y_.size() << " = "
58  << binSize_ << std::endl;
59  double s = 0;
60  for (unsigned int i = 0; i != y_.size(); ++i) {
61  double x = xMin_ + (0.5 + i) * binSize_;
62  double y = operator()(x);
63  std::cout << ">>> pdf(" << x << ") = " << y << std::endl;
64  s += y * binSize_;
65  }
66  std::cout << ">>>: PDF normalization is " << s << std::endl;
67  }

References binSize_, gather_cfg::cout, delta_, mps_fire::i, operator()(), alignCSCRings::s, xMax_, xMin_, and y_.

◆ init()

template<typename Iterator >
void funct::HistoPdf::init ( double  xMin,
double  xMax,
const Iterator begin,
const Iterator end 
)
inline

Definition at line 24 of file HistoPdf.h.

24  {
25  xMin_ = xMin;
26  xMax_ = xMax;
27  delta_ = xMax - xMin;
28  unsigned int n = end - begin;
29  binSize_ = delta_ / n;
30  y_.resize(n);
31  double s = 0;
32  unsigned int i = 0;
33  for (Iterator it = begin; it != end; ++it)
34  s += (y_[i++] = *it);
35  for (std::vector<double>::iterator i = y_.begin(); i != y_.end(); ++i)
36  *i /= s;
37  }

References begin, binSize_, delta_, end, mps_fire::i, dqmiodumpmetadata::n, alignCSCRings::s, multiplicitycorr_cfi::xMax, xMax_, photonAnalyzer_cfi::xMin, xMin_, and y_.

Referenced by funct::RootHistoPdf::RootHistoPdf().

◆ operator()()

double funct::HistoPdf::operator() ( double  x) const
inline

Definition at line 38 of file HistoPdf.h.

38  {
39  if (x < xMin_ || x > xMax_)
40  return 0;
41  double pdf = y_[static_cast<unsigned int>(((x - xMin_) / delta_) * y_.size())] / binSize_;
42  return pdf;
43  }

References binSize_, delta_, xMax_, xMin_, and y_.

Referenced by dump().

◆ rebin()

void funct::HistoPdf::rebin ( unsigned int  r)
inline

Definition at line 44 of file HistoPdf.h.

44  {
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)
52  y[i] += y_[j++];
53  y_ = y;
54  binSize_ *= r;
55  }

References binSize_, edm::errors::Configuration, mps_fire::i, dqmiolumiharvest::j, dqmdumpme::k, dqmiodumpmetadata::n, alignCSCRings::r, and y_.

Member Data Documentation

◆ binSize_

double funct::HistoPdf::binSize_
private

Definition at line 70 of file HistoPdf.h.

Referenced by dump(), init(), operator()(), and rebin().

◆ delta_

double funct::HistoPdf::delta_
private

Definition at line 70 of file HistoPdf.h.

Referenced by dump(), init(), and operator()().

◆ xMax_

double funct::HistoPdf::xMax_
private

Definition at line 70 of file HistoPdf.h.

Referenced by dump(), init(), and operator()().

◆ xMin_

double funct::HistoPdf::xMin_
private

Definition at line 70 of file HistoPdf.h.

Referenced by dump(), init(), and operator()().

◆ y_

std::vector<double> funct::HistoPdf::y_
private

Definition at line 71 of file HistoPdf.h.

Referenced by dump(), HistoPdf(), init(), operator()(), and rebin().

DDAxes::y
mps_fire.i
i
Definition: mps_fire.py:355
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
funct::HistoPdf::operator()
double operator()(double x) const
Definition: HistoPdf.h:38
gather_cfg.cout
cout
Definition: gather_cfg.py:144
DDAxes::x
Iterator
Definition: DQMStoreStats.h:94
end
#define end
Definition: vmac.h:39
edm::Exception
Definition: EDMException.h:77
photonAnalyzer_cfi.xMin
xMin
Definition: photonAnalyzer_cfi.py:82
alignCSCRings.s
s
Definition: alignCSCRings.py:92
funct::HistoPdf::binSize_
double binSize_
Definition: HistoPdf.h:70
funct::HistoPdf::xMin_
double xMin_
Definition: HistoPdf.h:70
dqmdumpme.k
k
Definition: dqmdumpme.py:60
funct::HistoPdf::delta_
double delta_
Definition: HistoPdf.h:70
funct::HistoPdf::xMax_
double xMax_
Definition: HistoPdf.h:70
funct::HistoPdf::y_
std::vector< double > y_
Definition: HistoPdf.h:71
alignCSCRings.r
r
Definition: alignCSCRings.py:93
multiplicitycorr_cfi.xMax
xMax
Definition: multiplicitycorr_cfi.py:5
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
edm::errors::Configuration
Definition: EDMException.h:36
begin
#define begin
Definition: vmac.h:32