GooFit  v2.1.3
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
GooFit::DataSet Class Referenceabstract

#include <DataSet.h>

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

Public Member Functions

 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 addEvent ()=0
 
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
 

Protected Member Functions

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

size_t numEventsAdded {0}
 
std::vector< Observableobservables
 

Detailed Description

Definition at line 15 of file DataSet.h.

Constructor & Destructor Documentation

◆ DataSet() [1/4]

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

Definition at line 11 of file DataSet.cpp.

12  : name(std::move(n))
13  , observables({var}) {
14  generateName();
15 }
std::vector< Observable > observables
Definition: DataSet.h:66

◆ DataSet() [2/4]

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

Definition at line 17 of file DataSet.cpp.

18  : name(std::move(n))
19  , observables(vars) {
20  generateName();
21 }
std::vector< Observable > observables
Definition: DataSet.h:66

◆ DataSet() [3/4]

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

Definition at line 23 of file DataSet.cpp.

24  : name(std::move(n))
25  , observables(std::begin(vars), std::end(vars)) {
26  generateName();
27 }
std::vector< Observable > observables
Definition: DataSet.h:66

◆ DataSet() [4/4]

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

Definition at line 29 of file DataSet.cpp.

30  : name(std::move(n))
31  , observables(vars) {
32  generateName();
33 }
std::vector< Observable > observables
Definition: DataSet.h:66

◆ ~DataSet()

virtual GooFit::DataSet::~DataSet ( )
virtualdefault

Member Function Documentation

◆ addEvent() [1/2]

virtual void GooFit::DataSet::addEvent ( )
pure virtual

◆ addEvent() [2/2]

template<typename... Args>
void GooFit::DataSet::addEvent ( fptype  value,
Args...  args 
)
inline

This is a helper that allows multiple values to be passed in instead of relying on the content of the Variables.

Definition at line 31 of file DataSet.h.

References addEvent(), getObservables(), and observables.

31  {
32  std::vector<fptype> values{value, static_cast<fptype>(args)...};
33 
34  if(values.size() != observables.size())
35  throw GooFit::GeneralError("You must pass the correct number of values ({}) to addEvent",
36  observables.size());
37 
38  for(size_t i = 0; i < values.size(); i++)
39  observables[i].setValue(values[i]);
40  addEvent();
41  }
Thrown when a general error is encountered.
Definition: Error.h:10
double fptype
std::vector< Observable > observables
Definition: DataSet.h:66
virtual void addEvent()=0

◆ addWeightedEvent()

void GooFit::DataSet::addWeightedEvent ( fptype  weight)
virtual

Reimplemented in GooFit::BinnedDataSet.

Definition at line 35 of file DataSet.cpp.

35  {
36  throw GooFit::GeneralError("AddWeightedEvent not implemented for this type of DataSet");
37 }
Thrown when a general error is encountered.
Definition: Error.h:10

◆ checkAllVars()

void GooFit::DataSet::checkAllVars ( ) const
protected

Throw an error if any variables are out of range, call in addEvent.

Definition at line 71 of file DataSet.cpp.

References observables.

Referenced by GooFit::BinnedDataSet::addEvent(), GooFit::UnbinnedDataSet::addEvent(), and GooFit::BinnedDataSet::addWeightedEvent().

71  {
72  for(const Observable &v : observables) {
73  if(!v)
74  throw GooFit::OutOfRange(v.getName(), v.getValue(), v.getLowerLimit(), v.getUpperLimit());
75  }
76 }
std::vector< Observable > observables
Definition: DataSet.h:66

◆ getCurrentValues()

std::vector< fptype > GooFit::DataSet::getCurrentValues ( ) const
protected

Definition at line 39 of file DataSet.cpp.

References observables.

Referenced by GooFit::BinnedDataSet::getBinNumber(), and getName().

39  {
40  std::vector<fptype> values;
41 
42  for(const Observable &v : observables) {
43  values.push_back(v.getValue());
44  }
45 
46  return values;
47 }
std::vector< Observable > observables
Definition: DataSet.h:66

◆ getName()

std::string GooFit::DataSet::getName ( ) const
inline

Definition at line 49 of file DataSet.h.

References getCurrentValues(), and indexOfVariable().

Referenced by GooFit::BinnedDataSet::getNumWeightedEvents().

49 { return name; }

◆ getNumEvents()

size_t GooFit::DataSet::getNumEvents ( ) const
inline

◆ getObservables()

const std::vector< Observable > & GooFit::DataSet::getObservables ( ) const

Definition at line 49 of file DataSet.cpp.

References observables.

Referenced by addEvent(), GooFit::UnbinnedDataSet::fillWithGrid(), getToyData(), and runGeneratedMCFit().

49 { return observables; }
std::vector< Observable > observables
Definition: DataSet.h:66

◆ indexOfVariable()

size_t GooFit::DataSet::indexOfVariable ( const Observable var) const
protected

Definition at line 51 of file DataSet.cpp.

References observables.

Referenced by GooFit::BinnedDataSet::getBinCenter(), getName(), GooFit::UnbinnedDataSet::getValue(), and GooFit::UnbinnedDataSet::setValueForAllEvents().

51  {
52  for(size_t i = 0; i < observables.size(); ++i)
53  if(var == observables[i])
54  return i;
55 
56  throw GooFit::GeneralError("Invalid variable access into dataset!");
57 }
Thrown when a general error is encountered.
Definition: Error.h:10
std::vector< Observable > observables
Definition: DataSet.h:66

◆ numVariables()

size_t GooFit::DataSet::numVariables ( ) const
inline

Definition at line 45 of file DataSet.h.

References observables.

45 { return observables.size(); }
std::vector< Observable > observables
Definition: DataSet.h:66

Member Data Documentation

◆ numEventsAdded

size_t GooFit::DataSet::numEventsAdded {0}
protected

◆ observables

std::vector<Observable> GooFit::DataSet::observables
protected

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