GooFit  v2.1.3
Public Member Functions | List of all members
GooFit::BinnedDataSet Class Reference

#include <BinnedDataSet.h>

Inheritance diagram for GooFit::BinnedDataSet:
GooFit::DataSet

Public Member Functions

 BinnedDataSet (const Observable &var, std::string n="")
 
 BinnedDataSet (const std::vector< Observable > &vars, std::string n="")
 
 BinnedDataSet (const std::set< Observable > &vars, std::string n="")
 
 BinnedDataSet (std::initializer_list< Observable > vars, std::string n="")
 
 ~BinnedDataSet () override=default
 
void addEvent () override
 
void addWeightedEvent (double weight) override
 
fptype getBinContent (size_t bin) const
 Get the content of a bin. More...
 
fptype getBinCenter (size_t ivar, size_t bin) const
 
fptype getBinCenter (const Observable &var, size_t bin) const
 
fptype getBinSize (size_t ivar) const
 Get the size of a bin. More...
 
size_t getBinNumber () const
 
fptype getBinVolume (size_t bin) const
 
fptype getBinError (size_t bin) const
 
std::vector< size_t > getDiminsions () const
 Get the size of each diminsion. More...
 
size_t getNumBins () const
 
fptype getNumWeightedEvents () const
 This includes weights. More...
 
void setBinContent (unsigned int bin, fptype value)
 
void setBinError (unsigned int bin, fptype value)
 
- Public Member Functions inherited from GooFit::DataSet
 DataSet (const Observable &var, std::string n="")
 
 DataSet (const std::vector< Observable > &vars, std::string n="")
 
 DataSet (const std::set< Observable > &vars, std::string n="")
 
 DataSet (std::initializer_list< Observable > vars, std::string n="")
 
virtual ~DataSet ()=default
 
template<typename... Args>
void addEvent (fptype value, Args... args)
 This is a helper that allows multiple values to be passed in instead of relying on the content of the Variables. More...
 
const std::vector< Observable > & getObservables () const
 
size_t numVariables () const
 
size_t getNumEvents () const
 
std::string getName () const
 

Additional Inherited Members

- Protected Member Functions inherited from GooFit::DataSet
std::vector< fptypegetCurrentValues () const
 
size_t indexOfVariable (const Observable &var) const
 
void checkAllVars () const
 Throw an error if any variables are out of range, call in addEvent. More...
 
- Protected Attributes inherited from GooFit::DataSet
size_t numEventsAdded {0}
 
std::vector< Observableobservables
 

Detailed Description

Definition at line 10 of file BinnedDataSet.h.

Constructor & Destructor Documentation

◆ BinnedDataSet() [1/4]

GooFit::BinnedDataSet::BinnedDataSet ( const Observable var,
std::string  n = "" 
)

Definition at line 12 of file BinnedDataSet.cpp.

References getNumBins().

13  : DataSet(var, n) {
14  collectBins();
15  binvalues.resize(getNumBins());
16 }
DataSet(const Observable &var, std::string n="")
Definition: DataSet.cpp:11
size_t getNumBins() const

◆ BinnedDataSet() [2/4]

GooFit::BinnedDataSet::BinnedDataSet ( const std::vector< Observable > &  vars,
std::string  n = "" 
)

Definition at line 18 of file BinnedDataSet.cpp.

References getNumBins().

19  : DataSet(vars, n) {
20  collectBins();
21  binvalues.resize(getNumBins());
22 }
DataSet(const Observable &var, std::string n="")
Definition: DataSet.cpp:11
size_t getNumBins() const

◆ BinnedDataSet() [3/4]

GooFit::BinnedDataSet::BinnedDataSet ( const std::set< Observable > &  vars,
std::string  n = "" 
)

Definition at line 24 of file BinnedDataSet.cpp.

References getNumBins().

25  : DataSet(vars, n) {
26  collectBins();
27  binvalues.resize(getNumBins());
28 }
DataSet(const Observable &var, std::string n="")
Definition: DataSet.cpp:11
size_t getNumBins() const

◆ BinnedDataSet() [4/4]

GooFit::BinnedDataSet::BinnedDataSet ( std::initializer_list< Observable vars,
std::string  n = "" 
)

Definition at line 30 of file BinnedDataSet.cpp.

References getNumBins().

31  : DataSet(vars, n) {
32  collectBins();
33  binvalues.resize(getNumBins());
34 }
DataSet(const Observable &var, std::string n="")
Definition: DataSet.cpp:11
size_t getNumBins() const

◆ ~BinnedDataSet()

GooFit::BinnedDataSet::~BinnedDataSet ( )
overridedefault

Member Function Documentation

◆ addEvent()

void GooFit::BinnedDataSet::addEvent ( )
overridevirtual

Implements GooFit::DataSet.

Definition at line 36 of file BinnedDataSet.cpp.

References GooFit::DataSet::checkAllVars(), getBinNumber(), and GooFit::DataSet::numEventsAdded.

Referenced by makeBackgroundHistogram(), and makeBkg3Eff().

36  {
37  checkAllVars();
38  size_t ibin = getBinNumber();
39  binvalues.at(ibin) += 1;
41 }
void checkAllVars() const
Throw an error if any variables are out of range, call in addEvent.
Definition: DataSet.cpp:71
size_t getBinNumber() const
size_t numEventsAdded
Definition: DataSet.h:54

◆ addWeightedEvent()

void GooFit::BinnedDataSet::addWeightedEvent ( double  weight)
overridevirtual

Reimplemented from GooFit::DataSet.

Definition at line 43 of file BinnedDataSet.cpp.

References GooFit::DataSet::checkAllVars(), getBinNumber(), GooFit::DataSet::numEventsAdded, and GooFit::DataSet::observables.

Referenced by loadDataFile().

43  {
44  checkAllVars();
45  size_t ibin = getBinNumber();
46  binvalues.at(ibin) += weight;
48 }
void checkAllVars() const
Throw an error if any variables are out of range, call in addEvent.
Definition: DataSet.cpp:71
size_t getBinNumber() const
size_t numEventsAdded
Definition: DataSet.h:54

◆ getBinCenter() [1/2]

fptype GooFit::BinnedDataSet::getBinCenter ( size_t  ivar,
size_t  bin 
) const

Definition at line 92 of file BinnedDataSet.cpp.

References getBinSize(), and GooFit::DataSet::observables.

Referenced by getBinCenter(), and getBinContent().

92  {
93  std::vector<size_t> locals = globalToLocal(bin);
94  size_t localBin = locals.at(ivar);
95 
96  fptype ret = getBinSize(ivar);
97  ret *= (localBin + 0.5);
98  ret += observables[ivar].getLowerLimit();
99  return ret;
100 }
double fptype
std::vector< Observable > observables
Definition: DataSet.h:66
fptype getBinSize(size_t ivar) const
Get the size of a bin.

◆ getBinCenter() [2/2]

fptype GooFit::BinnedDataSet::getBinCenter ( const Observable var,
size_t  bin 
) const

Definition at line 102 of file BinnedDataSet.cpp.

References getBinCenter(), and GooFit::DataSet::indexOfVariable().

102  {
103  size_t ivar = indexOfVariable(var);
104  return getBinCenter(ivar, bin);
105 }
size_t indexOfVariable(const Observable &var) const
Definition: DataSet.cpp:51
fptype getBinCenter(size_t ivar, size_t bin) const

◆ getBinContent()

fptype GooFit::BinnedDataSet::getBinContent ( size_t  bin) const
inline

Get the content of a bin.

Definition at line 26 of file BinnedDataSet.h.

References getBinCenter(), getBinError(), getBinNumber(), getBinSize(), and getBinVolume().

Referenced by makeBackgroundHistogram().

26 { return binvalues.at(bin); }

◆ getBinError()

fptype GooFit::BinnedDataSet::getBinError ( size_t  bin) const

Definition at line 121 of file BinnedDataSet.cpp.

Referenced by getBinContent().

121  {
122  if(0 == binerrors.size())
123  return sqrt(binvalues.at(bin));
124 
125  return binerrors.at(bin);
126 }

◆ getBinNumber()

size_t GooFit::BinnedDataSet::getBinNumber ( ) const

Definition at line 58 of file BinnedDataSet.cpp.

References GooFit::DataSet::getCurrentValues(), and GooFit::DataSet::observables.

Referenced by addEvent(), addWeightedEvent(), and getBinContent().

58  {
59  std::vector<fptype> vals = getCurrentValues();
60  std::vector<size_t> locals = convertValuesToBins(vals);
61  return localToGlobal(locals);
62 }
std::vector< fptype > getCurrentValues() const
Definition: DataSet.cpp:39

◆ getBinSize()

fptype GooFit::BinnedDataSet::getBinSize ( size_t  ivar) const

Get the size of a bin.

Definition at line 107 of file BinnedDataSet.cpp.

References GooFit::DataSet::observables.

Referenced by getBinCenter(), getBinContent(), getBinVolume(), and getNumWeightedEvents().

107  {
108  return (observables.at(ivar).getUpperLimit() - observables[ivar].getLowerLimit()) / binsizes[ivar];
109 }
std::vector< Observable > observables
Definition: DataSet.h:66

◆ getBinVolume()

fptype GooFit::BinnedDataSet::getBinVolume ( size_t  bin) const

Definition at line 111 of file BinnedDataSet.cpp.

References getBinSize(), and GooFit::DataSet::observables.

Referenced by getBinContent().

111  {
112  fptype ret = 1;
113 
114  for(size_t i = 0; i < observables.size(); i++) {
115  ret *= getBinSize(i);
116  }
117 
118  return ret;
119 }
double fptype
std::vector< Observable > observables
Definition: DataSet.h:66
fptype getBinSize(size_t ivar) const
Get the size of a bin.

◆ getDiminsions()

std::vector<size_t> GooFit::BinnedDataSet::getDiminsions ( ) const
inline

Get the size of each diminsion.

Definition at line 38 of file BinnedDataSet.h.

References getNumBins(), and getNumWeightedEvents().

38 { return binsizes; }

◆ getNumBins()

size_t GooFit::BinnedDataSet::getNumBins ( ) const

Definition at line 135 of file BinnedDataSet.cpp.

Referenced by BinnedDataSet(), getDiminsions(), and makeBackgroundHistogram().

135  {
136  return std::accumulate(std::begin(binsizes), std::end(binsizes), 1, std::multiplies<size_t>());
137 }

◆ getNumWeightedEvents()

fptype GooFit::BinnedDataSet::getNumWeightedEvents ( ) const

This includes weights.

Definition at line 139 of file BinnedDataSet.cpp.

References getBinSize(), GooFit::DataSet::getName(), GOOFIT_INFO, and GooFit::DataSet::observables.

Referenced by getDiminsions().

139  {
140  return std::accumulate(std::begin(binvalues), std::end(binvalues), 0);
141 }

◆ setBinContent()

void GooFit::BinnedDataSet::setBinContent ( unsigned int  bin,
fptype  value 
)
inline

Definition at line 45 of file BinnedDataSet.h.

References setBinError().

Referenced by makeBackgroundHistogram().

45 { binvalues.at(bin) = value; }

◆ setBinError()

void GooFit::BinnedDataSet::setBinError ( unsigned int  bin,
fptype  value 
)

Definition at line 128 of file BinnedDataSet.cpp.

Referenced by setBinContent().

128  {
129  if(0 == binerrors.size())
130  binerrors.resize(binvalues.size());
131 
132  binerrors.at(bin) = error;
133 }

The documentation for this class was generated from the following files: