GooFit  v2.1.3
Variable.cpp
Go to the documentation of this file.
1 #include <goofit/Error.h>
2 #include <goofit/Variable.h>
3 
4 #include <algorithm>
5 
6 namespace GooFit {
7 
8 int max_index(const std::vector<Variable> &vars) {
9  if(vars.empty())
10  return -1;
11  const Variable &max_ind_ptr
12  = *std::max_element(std::begin(vars), std::end(vars), [](const Variable &a, const Variable &b) {
13  return a.getIndex() < b.getIndex();
14  });
15  return max_ind_ptr.getIndex();
16 }
17 
18 int max_index(const std::vector<Observable> &vars) {
19  if(vars.empty())
20  return -1;
21  const Observable &max_ind_ptr
22  = *std::max_element(std::begin(vars), std::end(vars), [](const Observable &a, const Observable &b) {
23  return a.getIndex() < b.getIndex();
24  });
25  return max_ind_ptr.getIndex();
26 }
27 
28 int max_fitter_index(const std::vector<Variable> &vars) {
29  const Variable max_ind_ptr
30  = *std::max_element(std::begin(vars), std::end(vars), [](const Variable &a, const Variable &b) {
31  return a.getFitterIndex() < b.getFitterIndex();
32  });
33  return max_ind_ptr.getFitterIndex();
34 }
35 
36 std::ostream &operator<<(std::ostream &o, const GooFit::Variable &var) {
37  o << var.getName() << ": " << var.getValue() << " +/- " << var.getError();
38  if(!var.IsFixed())
39  o << " [" << var.getLowerLimit() << ", " << var.getUpperLimit() << "]";
40  if(var.getIndex() >= 0)
41  o << " GooFit index: " << var.getIndex();
42  if(var.getFitterIndex() >= 0)
43  o << " Fitter index: " << var.getFitterIndex();
44  if(*var.blind != 0)
45  o << " Blinded";
46 
47  return o;
48 }
49 
50 std::ostream &operator<<(std::ostream &o, const GooFit::Observable &var) {
51  o << var.getName() << ": " << var.getValue() << " (" << var.getNumBins() << " bins)";
52  o << " [" << var.getLowerLimit() << ", " << var.getUpperLimit() << "]";
53  if(var.getIndex() >= 0)
54  o << " GooFit index: " << var.getIndex();
55 
56  return o;
57 }
58 
59 std::istream &operator>>(std::istream &i, GooFit::Observable &var) { return i >> *var.value; }
60 
61 } // namespace GooFit
int getFitterIndex() const
Get the index from the fitter.
Definition: Variable.h:194
std::shared_ptr< fptype > value
The value of the variable.
Definition: Variable.h:28
Special class for observables. Used in DataSets.
Definition: Variable.h:109
size_t getNumBins() const
Get the number of bins.
Definition: Variable.h:130
int max_fitter_index(const std::vector< Variable > &vars)
Get the max fitter index of a variable from a list.
Definition: Variable.cpp:28
int getIndex() const
Get the GooFit index.
Definition: Variable.h:58
std::shared_ptr< fptype > blind
A blinding value to add.
Definition: Variable.h:227
fptype getLowerLimit() const
Get the lower limit.
Definition: Variable.h:78
int max_index(const std::vector< Variable > &vars)
Get the max index of a variable from a list.
Definition: Variable.cpp:8
fptype getValue() const
Get the value.
Definition: Variable.h:68
fptype getUpperLimit() const
Get the upper limit.
Definition: Variable.h:73
bool IsFixed() const
Check to see if this is a constant.
Definition: Variable.h:202
std::istream & operator>>(std::istream &i, GooFit::Observable &var)
Allow Observable to be read in.
Definition: Variable.cpp:59
std::ostream & operator<<(std::ostream &stream, Uncertain value)
Simple << output.
Definition: Uncertain.h:96
fptype getError() const
Get the error.
Definition: Variable.h:189
const std::string & getName() const
Get the name.
Definition: Variable.h:63