BornAgain
1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
|
Class describing the binned data sets : vectors of x coordinates, y values and optionally error on y values and error on coordinates The dimension of the coordinate is free There are 4 different options:
In addition there is the option to construct Bindata copying the data in (using the DataVector class) or using pointer to external data (DataWrapper) class. In general is found to be more efficient to copy the data. In case of really large data sets for limiting memory consumption then the other option can be used Specialized constructor exists for data up to 3 dimensions.
When the data are copying in the number of points can be set later (or re-set) using Initialize and the data are inserted one by one using the Add method. It is mandatory to set the size before using the Add method.
Public Types | |
enum | ErrorType { kNoError , kValueError , kCoordError , kAsymError } |
Public Member Functions | |
BinData (const BinData &rhs) | |
BinData (const DataOptions &opt, const DataRange &range, unsigned int maxpoints=0, unsigned int dim=1, ErrorType err=kValueError) | |
BinData (const DataOptions &opt, unsigned int maxpoints=0, unsigned int dim=1, ErrorType err=kValueError) | |
BinData (unsigned int maxpoints=0, unsigned int dim=1, ErrorType err=kValueError) | |
BinData (unsigned int n, const double *dataX, const double *dataY, const double *dataZ, const double *val, const double *ex, const double *ey, const double *ez, const double *eval) | |
BinData (unsigned int n, const double *dataX, const double *dataY, const double *val, const double *ex, const double *ey, const double *eval) | |
BinData (unsigned int n, const double *dataX, const double *val, const double *ex, const double *eval) | |
virtual | ~BinData () |
void | Add (const double *x, double val) |
void | Add (const double *x, double val, const double *ex, double elval, double ehval) |
void | Add (const double *x, double val, const double *ex, double eval) |
void | Add (const double *x, double val, double eval) |
void | Add (double x, double y) |
void | Add (double x, double y, double ex, double ey) |
void | Add (double x, double y, double ex, double eyl, double eyh) |
void | Add (double x, double y, double ey) |
void | AddBinUpEdge (const double *xup) |
void | Append (unsigned int newPoints, unsigned int dim=1, ErrorType err=kValueError) |
const double * | BinUpEdge (unsigned int ipoint) const |
const double * | CoordErrors (unsigned int ipoint) const |
double | Error (unsigned int ipoint) const |
const double * | ErrorPtr (unsigned int ipoint) const |
void | GetAsymError (unsigned int ipoint, double &lowError, double &highError) const |
double | GetBinUpEdgeComponent (unsigned int ipoint, unsigned int icoord) const |
double | GetCoordErrorComponent (unsigned int ipoint, unsigned int icoord) const |
ErrorType | GetErrorType () const |
const double * | GetPoint (unsigned int ipoint, double &value) const |
const double * | GetPoint (unsigned int ipoint, double &value, double &invError) const |
const double * | GetPointError (unsigned int ipoint, double &errlow, double &errhigh) const |
const double * | GetPointError (unsigned int ipoint, double &errvalue) const |
bool | HasBinEdges () const |
bool | HaveAsymErrors () const |
bool | HaveCoordErrors () const |
void | Initialize (unsigned int newPoints, unsigned int dim=1, ErrorType err=kValueError) |
double | InvError (unsigned int ipoint) const |
bool | IsWeighted () const |
BinData & | LogTransform () |
BinData & | operator= (const BinData &rhs) |
double | RefVolume () const |
void | SetRefVolume (double value) |
double | SumOfContent () const |
double | SumOfError2 () const |
double | Value (unsigned int ipoint) const |
const double * | ValuePtr (unsigned int ipoint) const |
Protected Member Functions | |
void | ComputeSums () |
void | InitBinEdge () |
void | InitDataVector () |
void | InitializeErrors () |
void | UnWrap () |
Private Attributes | |
std::vector< std::vector< double > > | fBinEdge |
std::vector< std::vector< double > > | fCoordErrors |
std::vector< const double * > | fCoordErrorsPtr |
std::vector< double > | fData |
std::vector< double > | fDataError |
std::vector< double > | fDataErrorHigh |
const double * | fDataErrorHighPtr |
std::vector< double > | fDataErrorLow |
const double * | fDataErrorLowPtr |
const double * | fDataErrorPtr |
const double * | fDataPtr |
ErrorType | fErrorType |
bool | fIsWeighted = false |
double * | fpTmpBinEdgeVector |
double * | fpTmpCoordErrorVector |
double | fRefVolume |
double | fSumContent = 0 |
double | fSumError2 = 0 |
|
explicit |
constructor from dimension of point and max number of points (to pre-allocate vector) Give a zero value and then use Initialize later one if the size is not known
|
explicit |
constructor from option and default range
ROOT::Fit::BinData::BinData | ( | const DataOptions & | opt, |
const DataRange & | range, | ||
unsigned int | maxpoints = 0 , |
||
unsigned int | dim = 1 , |
||
ErrorType | err = kValueError |
||
) |
constructor from options and range efault is 1D and value errors
ROOT::Fit::BinData::BinData | ( | unsigned int | n, |
const double * | dataX, | ||
const double * | val, | ||
const double * | ex, | ||
const double * | eval | ||
) |
constructurs using external data constructor from external data for 1D with errors on coordinate and value
ROOT::Fit::BinData::BinData | ( | unsigned int | n, |
const double * | dataX, | ||
const double * | dataY, | ||
const double * | val, | ||
const double * | ex, | ||
const double * | ey, | ||
const double * | eval | ||
) |
constructor from external data for 2D with errors on coordinate and value
ROOT::Fit::BinData::BinData | ( | unsigned int | n, |
const double * | dataX, | ||
const double * | dataY, | ||
const double * | dataZ, | ||
const double * | val, | ||
const double * | ex, | ||
const double * | ey, | ||
const double * | ez, | ||
const double * | eval | ||
) |
constructor from external data for 3D with errors on coordinate and value
|
virtual |
destructor
ROOT::Fit::BinData::BinData | ( | const BinData & | rhs | ) |
copy constructors
void ROOT::Fit::BinData::Add | ( | const double * | x, |
double | val | ||
) |
add multi-dim coordinate data with only value
void ROOT::Fit::BinData::Add | ( | const double * | x, |
double | val, | ||
const double * | ex, | ||
double | elval, | ||
double | ehval | ||
) |
add multi-dim coordinate data with both error in coordinates and value
void ROOT::Fit::BinData::Add | ( | const double * | x, |
double | val, | ||
const double * | ex, | ||
double | eval | ||
) |
add multi-dim coordinate data with both error in coordinates and value
void ROOT::Fit::BinData::Add | ( | const double * | x, |
double | val, | ||
double | eval | ||
) |
add multi-dim coordinate data with only error in value
void ROOT::Fit::BinData::Add | ( | double | x, |
double | y | ||
) |
add one dim data with only coordinate and values
void ROOT::Fit::BinData::Add | ( | double | x, |
double | y, | ||
double | ex, | ||
double | ey | ||
) |
add one dim data with error in the coordinate (x) in this case store the value (y) error and not the inverse
void ROOT::Fit::BinData::Add | ( | double | x, |
double | y, | ||
double | ex, | ||
double | eyl, | ||
double | eyh | ||
) |
add one dim data with error in the coordinate (x) and asymmetric errors in the value (y) in this case store the y errors and not the inverse
void ROOT::Fit::BinData::Add | ( | double | x, |
double | y, | ||
double | ey | ||
) |
add one dim data with no error in the coordinate (x) in this case store the inverse of the error in the value (y)
void ROOT::Fit::BinData::AddBinUpEdge | ( | const double * | xup | ) |
add the bin width data, a pointer to an array with the bin upper edge information. This is needed when fitting with integral options The information is added for the previously inserted point. BinData::Add must be called before
void ROOT::Fit::BinData::Append | ( | unsigned int | newPoints, |
unsigned int | dim = 1 , |
||
ErrorType | err = kValueError |
||
) |
preallocate a data set with given size , dimension and error type (to get the full point size) If the data set already exists and it is having the compatible point size space for the new points is created in the data sets, while if not compatible the old data are erased and new space of new size is allocated. (i.e if exists initialize is equivalent to a resize( NPoints() + maxpoints)
|
inline |
return an array containing the upper edge of the bin for coordinate i In case of empty bin they could be merged in a single larger bin Return a NULL pointer if the bin width is not stored
Definition at line 508 of file BinData.h.
References fBinEdge, and fpTmpBinEdgeVector.
|
protected |
|
inline |
Return a pointer to the errors in the coordinates for the given fit point
Definition at line 401 of file BinData.h.
References fCoordErrors, fCoordErrorsPtr, fErrorType, fpTmpCoordErrorVector, kAsymError, and kCoordError.
Referenced by GetPointError().
|
inline |
Definition at line 251 of file BinData.h.
References fDataError, fDataErrorHigh, fDataErrorHighPtr, fDataErrorLow, fDataErrorLowPtr, fDataErrorPtr, fErrorType, kAsymError, kCoordError, kNoError, and kValueError.
Referenced by GetPoint(), and GetPointError().
|
inline |
return error on the value for the given fit point Safe (but slower) method returning correctly the error on the value in case of asymm errors return the average 0.5(eu + el)
Definition at line 240 of file BinData.h.
References fDataErrorPtr, fErrorType, kAsymError, kCoordError, kNoError, and kValueError.
|
inline |
Definition at line 296 of file BinData.h.
References fDataError, fDataErrorHigh, fDataErrorHighPtr, fDataErrorLow, fDataErrorLowPtr, fDataErrorPtr, fErrorType, and kAsymError.
|
inline |
|
inline |
returns a single coordinate error component of a point. This function is threadsafe in contrast to Coords(...) and can easily get vectorized by the compiler in loops running over the ipoint-index.
Definition at line 384 of file BinData.h.
References fCoordErrors, and fCoordErrorsPtr.
|
inline |
|
inline |
retrieve at the same time a pointer to the coordinate data and the fit value More efficient than calling Coords(i) and Value(i)
Definition at line 370 of file BinData.h.
References Value().
Referenced by GetPoint().
|
inline |
retrieve in a single call a pointer to the coordinate data, value and inverse error for the given fit point. To be used only when type is kValueError or kNoError. In the last case the value 1 is returned for the error.
Definition at line 428 of file BinData.h.
References Error(), fErrorType, GetPoint(), kNoError, and kValueError.
|
inline |
Get errors on the point (coordinate errors and asymmetric value errors) for the given fit point. It must be called only when the coordinate errors and asymmetric errors are stored otherwise it will produce an assert.
Definition at line 469 of file BinData.h.
References CoordErrors(), fDataError, fDataErrorHigh, fDataErrorHighPtr, fDataErrorLow, fDataErrorLowPtr, fDataErrorPtr, fErrorType, and kAsymError.
|
inline |
Retrieve the errors on the point (coordinate and value) for the given fit point It must be called only when the coordinate errors are stored otherwise it will produce an assert.
Definition at line 451 of file BinData.h.
References CoordErrors(), Error(), fErrorType, kAsymError, and kCoordError.
|
inline |
|
inline |
flag to control if data provides asymmetric errors on the value
Definition at line 143 of file BinData.h.
References fErrorType, kAsymError, kCoordError, kNoError, and kValueError.
|
inline |
flag to control if data provides error on the coordinates
Definition at line 131 of file BinData.h.
References fErrorType, kAsymError, kCoordError, kNoError, and kValueError.
|
protected |
|
protected |
void ROOT::Fit::BinData::Initialize | ( | unsigned int | newPoints, |
unsigned int | dim = 1 , |
||
ErrorType | err = kValueError |
||
) |
|
protected |
|
inline |
Return the inverse of error on the value for the given fit point useful when error in the coordinates are not stored and then this is used directly this as the weight in the least square function
Definition at line 314 of file BinData.h.
References fDataError, fDataErrorHigh, fDataErrorHighPtr, fDataErrorLow, fDataErrorLowPtr, fDataErrorPtr, fErrorType, kAsymError, kCoordError, kNoError, and kValueError.
|
inline |
return true if the data set is weighted We cannot compute ourselfs because sometimes errors are filled with 1 instead of zero (as in ROOT::Fit::FillData )
Definition at line 567 of file BinData.h.
References fIsWeighted.
BinData& ROOT::Fit::BinData::LogTransform | ( | ) |
apply a Log transformation of the data values can be used for example when fitting an exponential or gaussian Transform the data in place need to copy if want to preserve original data The data sets must not contain negative values. IN case it does, an empty data set is returned
|
inline |
retrieve the reference volume used to normalize the data when the option bin volume is set
Definition at line 535 of file BinData.h.
References fRefVolume.
|
inline |
set the reference volume used to normalize the data when the option bin volume is set
Definition at line 540 of file BinData.h.
References fRefVolume.
|
inline |
compute the total sum of the data content (sum of weights in case of weighted data set)
Definition at line 554 of file BinData.h.
References fSumContent.
|
inline |
compute the total sum of the error square (sum of weight square in case of a weighted data set)
Definition at line 560 of file BinData.h.
References fSumError2.
|
protected |
|
inline |
return the value for the given fit point
Definition at line 217 of file BinData.h.
References fData, and fDataPtr.
Referenced by GetPoint().
|
inline |
|
private |
Definition at line 614 of file BinData.h.
Referenced by BinUpEdge(), GetBinUpEdgeComponent(), and HasBinEdges().
|
private |
Definition at line 598 of file BinData.h.
Referenced by CoordErrors(), and GetCoordErrorComponent().
|
private |
Definition at line 599 of file BinData.h.
Referenced by CoordErrors(), and GetCoordErrorComponent().
|
private |
|
private |
Definition at line 603 of file BinData.h.
Referenced by Error(), GetAsymError(), GetPointError(), and InvError().
|
private |
Definition at line 604 of file BinData.h.
Referenced by Error(), GetAsymError(), GetPointError(), and InvError().
|
private |
Definition at line 607 of file BinData.h.
Referenced by Error(), GetAsymError(), GetPointError(), and InvError().
|
private |
Definition at line 605 of file BinData.h.
Referenced by Error(), GetAsymError(), GetPointError(), and InvError().
|
private |
Definition at line 608 of file BinData.h.
Referenced by Error(), GetAsymError(), GetPointError(), and InvError().
|
private |
Definition at line 606 of file BinData.h.
Referenced by Error(), ErrorPtr(), GetAsymError(), GetPointError(), and InvError().
|
private |
Definition at line 596 of file BinData.h.
Referenced by Value(), and ValuePtr().
|
private |
Definition at line 585 of file BinData.h.
Referenced by CoordErrors(), Error(), ErrorPtr(), GetAsymError(), GetErrorType(), GetPoint(), GetPointError(), HaveAsymErrors(), HaveCoordErrors(), and InvError().
|
private |
Definition at line 586 of file BinData.h.
Referenced by IsWeighted().
|
private |
Definition at line 617 of file BinData.h.
Referenced by BinUpEdge().
|
private |
Definition at line 612 of file BinData.h.
Referenced by CoordErrors().
|
private |
Definition at line 587 of file BinData.h.
Referenced by RefVolume(), and SetRefVolume().
|
private |
Definition at line 588 of file BinData.h.
Referenced by SumOfContent().
|
private |
Definition at line 589 of file BinData.h.
Referenced by SumOfError2().