GooFit  v2.1.3
BinnedDataSet.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <map>
4 #include <vector>
5 
6 #include <goofit/DataSet.h>
7 
8 namespace GooFit {
9 
10 class BinnedDataSet : public DataSet {
11  // Class for rectangularly binned datasets - every bin the same size.
12 
13  public:
14  using DataSet::addEvent;
15 
16  BinnedDataSet(const Observable &var, std::string n = "");
17  BinnedDataSet(const std::vector<Observable> &vars, std::string n = "");
18  BinnedDataSet(const std::set<Observable> &vars, std::string n = "");
19  BinnedDataSet(std::initializer_list<Observable> vars, std::string n = "");
20  ~BinnedDataSet() override = default;
21 
22  void addEvent() override;
23  void addWeightedEvent(double weight) override;
24 
26  fptype getBinContent(size_t bin) const { return binvalues.at(bin); }
27  fptype getBinCenter(size_t ivar, size_t bin) const;
28  fptype getBinCenter(const Observable &var, size_t bin) const;
29 
31  fptype getBinSize(size_t ivar) const;
32 
33  size_t getBinNumber() const;
34  fptype getBinVolume(size_t bin) const;
35  fptype getBinError(size_t bin) const;
36 
38  std::vector<size_t> getDiminsions() const { return binsizes; }
39 
40  size_t getNumBins() const;
41 
44 
45  void setBinContent(unsigned int bin, fptype value) { binvalues.at(bin) = value; }
46  void setBinError(unsigned int bin, fptype value);
47 
48  private:
49  std::vector<size_t> convertValuesToBins(const std::vector<fptype> &vals) const;
50  size_t localToGlobal(const std::vector<size_t> &locals) const;
51  std::vector<size_t> globalToLocal(size_t global) const;
52 
54  void collectBins();
55 
56  std::vector<size_t> binsizes;
57  std::vector<fptype> binvalues;
58  std::vector<fptype> binerrors;
59 };
60 
61 } // namespace GooFit
double fptype
fptype getBinContent(size_t bin) const
Get the content of a bin.
Definition: BinnedDataSet.h:26
void addEvent() override
std::vector< size_t > getDiminsions() const
Get the size of each diminsion.
Definition: BinnedDataSet.h:38
fptype getBinSize(size_t ivar) const
Get the size of a bin.
Special class for observables. Used in DataSets.
Definition: Variable.h:109
void setBinContent(unsigned int bin, fptype value)
Definition: BinnedDataSet.h:45
BinnedDataSet(const Observable &var, std::string n="")
fptype getBinError(size_t bin) const
fptype getNumWeightedEvents() const
This includes weights.
fptype getBinCenter(size_t ivar, size_t bin) const
void addWeightedEvent(double weight) override
size_t getBinNumber() const
fptype getBinVolume(size_t bin) const
size_t getNumBins() const
virtual void addEvent()=0
void setBinError(unsigned int bin, fptype value)
~BinnedDataSet() override=default