GooFit  v2.1.3
Classes | Public Member Functions | Protected Attributes | Friends | List of all members
GooFit::Variable Class Reference

#include <Variable.h>

Inheritance diagram for GooFit::Variable:
GooFit::Indexable

Classes

class  Key
 This provides a key for some special classes to access blind info (passkey) More...
 

Public Member Functions

 Variable (const Variable &)=default
 
 Variable (Variable &&)=default
 
 Variable (std::string n, fptype v)
 This is a constant variable. More...
 
 Variable (std::string n, fptype v, fptype dn, fptype up)
 This is a normal variable, with value and upper/lower limits. More...
 
 Variable (std::string n, fptype v, fptype e, fptype dn, fptype up, bool fix=false)
 This is a full variable with error scale as well (Fix added to allow single interface to fixed/free vars) More...
 
 ~Variable () override=default
 
Variableoperator= (const Variable &)=delete
 
fptype getError () const
 Get the error. More...
 
void setError (fptype val)
 Set the error. More...
 
int getFitterIndex () const
 Get the index from the fitter. More...
 
void setFitterIndex (int value)
 Set the index (should be done by the fitter) More...
 
bool getChanged () const
 Check to see if the value has changed this iteration (always true the first time) More...
 
bool IsFixed () const
 Check to see if this is a constant. More...
 
void setFixed (bool fix)
 Set the fixedness of a variable. More...
 
void setChanged (bool val=true)
 Check to see if this has been changed since last iteration. More...
 
void setBlind (fptype val)
 Hides the number; the real value is the result minus this value. Cannot be retreived once set. More...
 
fptype getBlind (const Key &)
 Protected by special locked key, only a few classes have access to create a Key. More...
 
const Variableoperator= (const fptype &val)
 Support var = 3. More...
 
- Public Member Functions inherited from GooFit::Indexable
 Indexable (std::string n, fptype val=0)
 
 Indexable (std::string n, fptype val, fptype lowerlimit, fptype upperlimit)
 
Indexableoperator= (const Indexable &)=delete
 
virtual ~Indexable ()
 
int getIndex () const
 Get the GooFit index. More...
 
void setIndex (int value)
 Set the GooFit index. More...
 
const std::string & getName () const
 Get the name. More...
 
fptype getValue () const
 Get the value. More...
 
void setValue (fptype val)
 Set the value. More...
 
fptype getUpperLimit () const
 Get the upper limit. More...
 
void setUpperLimit (fptype val)
 Set the upper limit. More...
 
fptype getLowerLimit () const
 Get the lower limit. More...
 
void setLowerLimit (fptype val)
 Set the lower limit. More...
 
const Indexableoperator= (const fptype &val)
 Support var = 3. More...
 
 operator fptype () const
 Support fptype val = var. More...
 
bool operator< (const Indexable &other) const
 Support for using as key in map - Notice this does NOT sort by index! More...
 
bool operator== (const Indexable &other) const
 Support for comparison - only if really the same object, not just the same value. More...
 
bool operator!= (const Indexable &other) const
 Support for comparison - only if really the same object, not just the same value. More...
 
 operator bool () const
 Check to see if in range. More...
 

Protected Attributes

std::shared_ptr< fptypeerror
 The error. More...
 
std::shared_ptr< fptypeblind {std::make_shared<fptype>(0)}
 A blinding value to add. More...
 
std::shared_ptr< bool > changed_ {std::make_shared<bool>(true)}
 True if the value was unchanged since the last iteration. More...
 
std::shared_ptr< bool > fixed {std::make_shared<bool>(false)}
 This "fixes" the variable (constant) More...
 
std::shared_ptr< int > fitter_index {std::make_shared<int>(-1)}
 The fitter index, -1 if unset. More...
 
- Protected Attributes inherited from GooFit::Indexable
std::string name
 The variable name. Should be unique. More...
 
std::shared_ptr< fptypevalue
 The value of the variable. More...
 
std::shared_ptr< fptypelowerlimit {std::make_shared<fptype>(0)}
 The lower limit. More...
 
std::shared_ptr< fptypeupperlimit {std::make_shared<fptype>(0)}
 The upper limit. More...
 
std::shared_ptr< int > index {std::make_shared<int>(-1)}
 The goofit index, -1 if unset. More...
 

Friends

std::ostream & operator<< (std::ostream &o, const Variable &var)
 Nice print of Variable. More...
 

Detailed Description

Contains information about a parameter allowed to vary in MINUIT, or an observable passed to a data set. The index can refer either to cudaArray or to an event.

Definition at line 149 of file Variable.h.

Constructor & Destructor Documentation

◆ Variable() [1/5]

GooFit::Variable::Variable ( const Variable )
default

◆ Variable() [2/5]

GooFit::Variable::Variable ( Variable &&  )
default

◆ Variable() [3/5]

GooFit::Variable::Variable ( std::string  n,
fptype  v 
)
inline

This is a constant variable.

Definition at line 167 of file Variable.h.

168  : Indexable(n, v, v + 0.01, v - 0.01)
169  , error(std::make_shared<fptype>(0.002)) {
170  *fixed = true;
171  }
Indexable(std::string n, fptype val=0)
Definition: Variable.h:40
std::shared_ptr< fptype > error
The error.
Definition: Variable.h:224
std::shared_ptr< bool > fixed
This "fixes" the variable (constant)
Definition: Variable.h:233

◆ Variable() [4/5]

GooFit::Variable::Variable ( std::string  n,
fptype  v,
fptype  dn,
fptype  up 
)
inline

This is a normal variable, with value and upper/lower limits.

Definition at line 174 of file Variable.h.

175  : Indexable(n, v, dn, up)
176  , error(std::make_shared<fptype>(0.1 * (up - dn))) {}
Indexable(std::string n, fptype val=0)
Definition: Variable.h:40
std::shared_ptr< fptype > error
The error.
Definition: Variable.h:224

◆ Variable() [5/5]

GooFit::Variable::Variable ( std::string  n,
fptype  v,
fptype  e,
fptype  dn,
fptype  up,
bool  fix = false 
)
inline

This is a full variable with error scale as well (Fix added to allow single interface to fixed/free vars)

Definition at line 179 of file Variable.h.

References GooFit::Indexable::operator=().

180  : Indexable(n, v, dn, up)
181  , error(std::make_shared<fptype>(e))
182  , fixed(std::make_shared<bool>(fix)) {}
Indexable(std::string n, fptype val=0)
Definition: Variable.h:40
std::shared_ptr< fptype > error
The error.
Definition: Variable.h:224
std::shared_ptr< bool > fixed
This "fixes" the variable (constant)
Definition: Variable.h:233

◆ ~Variable()

GooFit::Variable::~Variable ( )
overridedefault

Member Function Documentation

◆ getBlind()

fptype GooFit::Variable::getBlind ( const Key )
inline

Protected by special locked key, only a few classes have access to create a Key.

Definition at line 214 of file Variable.h.

214 { return *blind; }
std::shared_ptr< fptype > blind
A blinding value to add.
Definition: Variable.h:227

◆ getChanged()

bool GooFit::Variable::getChanged ( ) const
inline

Check to see if the value has changed this iteration (always true the first time)

Definition at line 199 of file Variable.h.

Referenced by GooFit::PdfBase::parametersChanged().

199 { return *changed_; }
std::shared_ptr< bool > changed_
True if the value was unchanged since the last iteration.
Definition: Variable.h:230

◆ getError()

fptype GooFit::Variable::getError ( ) const
inline

Get the error.

Definition at line 189 of file Variable.h.

Referenced by GooFit::operator<<(), runCanonicalFit(), and runGeneratedMCFit().

189 { return *error; }
std::shared_ptr< fptype > error
The error.
Definition: Variable.h:224

◆ getFitterIndex()

int GooFit::Variable::getFitterIndex ( ) const
inline

Get the index from the fitter.

Definition at line 194 of file Variable.h.

Referenced by GooFit::max_fitter_index(), and GooFit::operator<<().

194 { return *fitter_index; }
std::shared_ptr< int > fitter_index
The fitter index, -1 if unset.
Definition: Variable.h:236

◆ IsFixed()

bool GooFit::Variable::IsFixed ( ) const
inline

Check to see if this is a constant.

Definition at line 202 of file Variable.h.

Referenced by GooFit::operator<<().

202 { return *fixed; }
std::shared_ptr< bool > fixed
This "fixes" the variable (constant)
Definition: Variable.h:233

◆ operator=() [1/2]

Variable& GooFit::Variable::operator= ( const Variable )
delete

◆ operator=() [2/2]

const Variable& GooFit::Variable::operator= ( const fptype val)
inline

Support var = 3.

Definition at line 217 of file Variable.h.

References GooFit::Indexable::setValue().

217  {
218  setValue(val);
219  return *this;
220  }
void setValue(fptype val)
Set the value.
Definition: Variable.h:70

◆ setBlind()

void GooFit::Variable::setBlind ( fptype  val)
inline

Hides the number; the real value is the result minus this value. Cannot be retreived once set.

Definition at line 211 of file Variable.h.

Referenced by runCanonicalFit().

211 { *blind = val; }
std::shared_ptr< fptype > blind
A blinding value to add.
Definition: Variable.h:227

◆ setChanged()

void GooFit::Variable::setChanged ( bool  val = true)
inline

Check to see if this has been changed since last iteration.

Definition at line 208 of file Variable.h.

Referenced by GooFit::FCN::FCN().

208 { *changed_ = val; }
std::shared_ptr< bool > changed_
True if the value was unchanged since the last iteration.
Definition: Variable.h:230

◆ setError()

void GooFit::Variable::setError ( fptype  val)
inline

Set the error.

Definition at line 191 of file Variable.h.

Referenced by GooFit::readFromFile().

191 { *error = val; }
std::shared_ptr< fptype > error
The error.
Definition: Variable.h:224

◆ setFitterIndex()

void GooFit::Variable::setFitterIndex ( int  value)
inline

Set the index (should be done by the fitter)

Definition at line 196 of file Variable.h.

References GooFit::Indexable::value.

196 { *fitter_index = value; }
std::shared_ptr< fptype > value
The value of the variable.
Definition: Variable.h:28
std::shared_ptr< int > fitter_index
The fitter index, -1 if unset.
Definition: Variable.h:236

◆ setFixed()

void GooFit::Variable::setFixed ( bool  fix)
inline

Set the fixedness of a variable.

Definition at line 205 of file Variable.h.

Referenced by main(), makeMikhailJSU_gg(), makeSignalJSU_gg(), and makeSignalPdf().

205 { *fixed = fix; }
std::shared_ptr< bool > fixed
This "fixes" the variable (constant)
Definition: Variable.h:233

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  o,
const Variable var 
)
friend

Nice print of Variable.

Definition at line 36 of file Variable.cpp.

36  {
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 }

Member Data Documentation

◆ blind

std::shared_ptr<fptype> GooFit::Variable::blind {std::make_shared<fptype>(0)}
protected

A blinding value to add.

Definition at line 227 of file Variable.h.

Referenced by GooFit::operator<<().

◆ changed_

std::shared_ptr<bool> GooFit::Variable::changed_ {std::make_shared<bool>(true)}
protected

True if the value was unchanged since the last iteration.

Definition at line 230 of file Variable.h.

◆ error

std::shared_ptr<fptype> GooFit::Variable::error
protected

The error.

Definition at line 224 of file Variable.h.

◆ fitter_index

std::shared_ptr<int> GooFit::Variable::fitter_index {std::make_shared<int>(-1)}
protected

The fitter index, -1 if unset.

Definition at line 236 of file Variable.h.

◆ fixed

std::shared_ptr<bool> GooFit::Variable::fixed {std::make_shared<bool>(false)}
protected

This "fixes" the variable (constant)

Definition at line 233 of file Variable.h.


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