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

#include <UnbinnedDataSet.h>

Inheritance diagram for GooFit::UnbinnedDataSet:
GooFit::DataSet

Public Member Functions

 UnbinnedDataSet (const Observable &var, std::string n="")
 
 UnbinnedDataSet (const std::vector< Observable > &vars, std::string n="")
 
 UnbinnedDataSet (const std::set< Observable > &vars, std::string n="")
 
 UnbinnedDataSet (std::initializer_list< Observable > vars, std::string n="")
 
 ~UnbinnedDataSet () override=default
 
void addEvent () override
 
void fillWithGrid ()
 Replace the current dataset with a grid. More...
 
fptype getValue (const Observable &var, size_t idx) const
 Get the value at a specific variable and event number. More...
 
void loadEvent (size_t idx)
 Set all the variables to the current event values. More...
 
void setValueForAllEvents (const Observable &var)
 Set all entries to a constant value (note: this is kind of ugly) More...
 
template<typename M >
void from_matrix (const M &input, bool filter=false)
 Input an eigen matrix. More...
 
template<typename M >
to_matrix () const
 Produce an eigen Matrix. More...
 
- 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
 
virtual void addWeightedEvent (fptype weight)
 
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 13 of file UnbinnedDataSet.h.

Constructor & Destructor Documentation

◆ UnbinnedDataSet() [1/4]

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

Definition at line 11 of file UnbinnedDataSet.cpp.

12  : DataSet(var, n) {
13  data.resize(1);
14 }
DataSet(const Observable &var, std::string n="")
Definition: DataSet.cpp:11

◆ UnbinnedDataSet() [2/4]

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

Definition at line 16 of file UnbinnedDataSet.cpp.

17  : DataSet(vars, n) {
18  data.resize(vars.size());
19 }
DataSet(const Observable &var, std::string n="")
Definition: DataSet.cpp:11

◆ UnbinnedDataSet() [3/4]

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

Definition at line 21 of file UnbinnedDataSet.cpp.

22  : DataSet(vars, n) {
23  data.resize(vars.size());
24 }
DataSet(const Observable &var, std::string n="")
Definition: DataSet.cpp:11

◆ UnbinnedDataSet() [4/4]

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

Definition at line 26 of file UnbinnedDataSet.cpp.

27  : DataSet(vars, n) {
28  data.resize(vars.size());
29 }
DataSet(const Observable &var, std::string n="")
Definition: DataSet.cpp:11

◆ ~UnbinnedDataSet()

GooFit::UnbinnedDataSet::~UnbinnedDataSet ( )
overridedefault

Member Function Documentation

◆ addEvent()

void GooFit::UnbinnedDataSet::addEvent ( )
overridevirtual

Implements GooFit::DataSet.

Definition at line 58 of file UnbinnedDataSet.cpp.

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

Referenced by GooFit::DalitzPlotter::DalitzPlotter(), GooFit::DalitzPlotter::fillDataSetMC(), from_matrix(), getToyData(), main(), make1BinSigmaMap(), make4BinSigmaMap(), GooFit::make_a_grid(), makeDalitzPlots(), makeSigmaMap(), makeToyDalitzPlots(), runEfficiencyFit(), runGeneratedMCFit(), and runSigmaFit().

58  {
59  checkAllVars();
60  size_t i = 0;
61  for(const Observable &v : observables)
62  data.at(i++).push_back(v.getValue());
64 }
std::vector< Observable > observables
Definition: DataSet.h:66
void checkAllVars() const
Throw an error if any variables are out of range, call in addEvent.
Definition: DataSet.cpp:71
size_t numEventsAdded
Definition: DataSet.h:54

◆ fillWithGrid()

void GooFit::UnbinnedDataSet::fillWithGrid ( )

Replace the current dataset with a grid.

Definition at line 91 of file UnbinnedDataSet.cpp.

References GooFit::DataSet::getObservables(), and GooFit::make_a_grid().

Referenced by GooFit::fillDataSetMC1D().

91  {
92  for(const auto &dat : data)
93  if(!dat.empty())
94  throw GeneralError("The dataset must be empty to fill with grid!");
95 
96  std::vector<Observable> ret = getObservables();
97 
98  Observable *evt_num = nullptr;
99 
100  for(Observable &val : ret)
101  if(val.isEventNumber())
102  evt_num = &val;
103 
104  make_a_grid(ret, this, evt_num);
105 }
const std::vector< Observable > & getObservables() const
Definition: DataSet.cpp:49
void make_a_grid(std::vector< Observable > ret, UnbinnedDataSet *grid, Observable *eventNum)

◆ from_matrix()

template<typename M >
void GooFit::UnbinnedDataSet::from_matrix ( const M &  input,
bool  filter = false 
)
inline

Input an eigen matrix.

Definition at line 42 of file UnbinnedDataSet.h.

References addEvent(), GooFit::DataSet::getNumEvents(), and GooFit::DataSet::observables.

42  {
43  size_t optional_index = getNumEvents(); // Only used if index not included
44 
45  if(observables.size() != input.rows() && observables.size() != input.rows() + 1)
46  throw GeneralError(
47  "The wrong number of rows, expected {}, but matrix had {}", observables.size(), input.rows());
48 
49  for(int i = 0; i < input.cols(); i++) { // Loop over events
50  for(int j = 0; j < input.rows(); j++) { // Loop over variables
51  observables.at(j).setValue(input(j, i));
52  }
53 
54  // Special override for counting variables (final param)
55  if(observables.size() == input.rows() + 1)
56  observables.at(input.rows()).setValue(optional_index++);
57 
58  if(!filter
59  || std::all_of(std::begin(observables), std::end(observables), [](Observable var) { return bool(var); }))
60  addEvent();
61  }
62  }
size_t getNumEvents() const
Definition: DataSet.h:47
std::vector< Observable > observables
Definition: DataSet.h:66

◆ getValue()

fptype GooFit::UnbinnedDataSet::getValue ( const Observable var,
size_t  idx 
) const

Get the value at a specific variable and event number.

Definition at line 31 of file UnbinnedDataSet.cpp.

References GooFit::Indexable::getName(), GooFit::DataSet::getNumEvents(), and GooFit::DataSet::indexOfVariable().

Referenced by GooFit::DalitzPlotter::fillDataSetMC(), GooFit::fillDataSetMC1D(), GooFit::DalitzPlotter::getXval(), GooFit::DalitzPlotter::getYval(), make1BinSigmaMap(), make4BinSigmaMap(), makeDalitzPlots(), makeSigmaMap(), makeToyDalitzPlots(), plotFit(), runEfficiencyFit(), and runSigmaFit().

31  {
32  if(idx >= getNumEvents()) {
33  throw GooFit::GeneralError("UnbinnedDataSet: Attepted to find {} in event {} when only {} events exits",
34  var.getName(),
35  idx,
36  getNumEvents());
37  }
38 
39  size_t var_idx = indexOfVariable(var);
40 
41  return data[var_idx].at(idx);
42 }
Thrown when a general error is encountered.
Definition: Error.h:10
size_t getNumEvents() const
Definition: DataSet.h:47
size_t indexOfVariable(const Observable &var) const
Definition: DataSet.cpp:51

◆ loadEvent()

void GooFit::UnbinnedDataSet::loadEvent ( size_t  idx)

Set all the variables to the current event values.

Definition at line 44 of file UnbinnedDataSet.cpp.

References GooFit::DataSet::observables.

Referenced by fitAndPlot(), main(), makeTimePlots(), and runGeneratedMCFit().

44  {
45  size_t i = 0;
46  for(Observable &v : observables) {
47  v.setValue(data.at(i++).at(idx));
48  }
49 }
std::vector< Observable > observables
Definition: DataSet.h:66

◆ setValueForAllEvents()

void GooFit::UnbinnedDataSet::setValueForAllEvents ( const Observable var)

Set all entries to a constant value (note: this is kind of ugly)

Definition at line 51 of file UnbinnedDataSet.cpp.

References GooFit::DataSet::getNumEvents(), GooFit::Indexable::getValue(), and GooFit::DataSet::indexOfVariable().

Referenced by makeDalitzPlots().

51  {
52  size_t ivar = indexOfVariable(var);
53  for(size_t i = 0; i < getNumEvents(); i++) {
54  data[ivar][i] = var.getValue();
55  }
56 }
size_t getNumEvents() const
Definition: DataSet.h:47
size_t indexOfVariable(const Observable &var) const
Definition: DataSet.cpp:51

◆ to_matrix()

template<typename M >
M GooFit::UnbinnedDataSet::to_matrix ( ) const
inline

Produce an eigen Matrix.

Definition at line 66 of file UnbinnedDataSet.h.

66  {
67  size_t rows = data.size();
68  size_t cols = data.at(0).size();
69  M mat(rows, cols);
70  for(int i = 0; i < rows; i++) {
71  for(int j = 0; j < cols; j++)
72  mat(i, j) = data[i].at(j);
73  }
74  return mat;
75  }

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