ROOT  6.06/09
Reference Guide
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Attributes | List of all members
ROOT::Fit::BinData Class Reference

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.

Definition at line 61 of file BinData.h.

Public Types

enum  ErrorType { kNoError, kValueError, kCoordError, kAsymError }
 

Public Member Functions

ErrorType GetErrorType () const
 
 BinData (unsigned int maxpoints=0, unsigned int dim=1, ErrorType err=kValueError)
 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 More...
 
 BinData (const DataOptions &opt, unsigned int maxpoints=0, unsigned int dim=1, ErrorType err=kValueError)
 constructor from option and default range More...
 
 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 More...
 
 BinData (unsigned int n, const double *dataX, const double *val, const double *ex, const double *eval)
 constructurs using external data More...
 
 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 More...
 
 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 More...
 
 BinData (const BinData &)
 copy constructors More...
 
BinDataoperator= (const BinData &)
 assignment operator More...
 
virtual ~BinData ()
 destructor More...
 
void Initialize (unsigned int maxpoints, 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. More...
 
unsigned int PointSize () const
 return the size of a fit point (is the coordinate dimension + 1 for the value and eventually the number of all errors More...
 
unsigned int DataSize () const
 return the size of internal data (number of fit points) if data are not copied in but used externally the size is 0 More...
 
bool HaveCoordErrors () const
 flag to control if data provides error on the coordinates More...
 
bool HaveAsymErrors () const
 flag to control if data provides asymmetric errors on the value More...
 
void Add (double x, double y)
 add one dim data with only coordinate and values More...
 
void 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) More...
 
void 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 More...
 
void 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 More...
 
void Add (const double *x, double val)
 add multi-dim coordinate data with only value (no errors) More...
 
void Add (const double *x, double val, double eval)
 add multi-dim coordinate data with only error in value More...
 
void Add (const double *x, double val, const double *ex, double eval)
 add multi-dim coordinate data with both error in coordinates and value More...
 
void 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 More...
 
const doubleCoords (unsigned int ipoint) const
 return a pointer to the coordinates data for the given fit point More...
 
double Value (unsigned int ipoint) const
 return the value for the given fit point More...
 
double Error (unsigned int ipoint) const
 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) More...
 
double InvError (unsigned int ipoint) const
 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. More...
 
const doubleCoordErrors (unsigned int ipoint) const
 Return a pointer to the errors in the coordinates for the given fit point. More...
 
const doubleGetPoint (unsigned int ipoint, double &value) const
 retrieve at the same time a pointer to the coordinate data and the fit value More efficient than calling Coords(i) and Value(i) More...
 
const doubleGetPoint (unsigned int ipoint, double &value, double &invError) const
 retrieve in a single call a pointer to the coordinate data, value and inverse error for the given fit point. More...
 
const doubleGetPointError (unsigned int ipoint, double &errvalue) const
 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. More...
 
const doubleGetPointError (unsigned int ipoint, double &errlow, double &errhigh) const
 Get errors on the point (coordinate errors and asymmetric value errors) for the given fit point. More...
 
void Resize (unsigned int npoints)
 resize the vector to the new given npoints if vector does not exists is created using existing point size More...
 
unsigned int NPoints () const
 return number of fit points More...
 
unsigned int Size () const
 return number of fit points More...
 
unsigned int NDim () const
 return coordinate data dimension More...
 
BinDataLogTransform ()
 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. More...
 
const doubleBinUpEdge (unsigned int icoord) const
 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 More...
 
bool HasBinEdges () const
 query if the data store the bin edges instead of the center More...
 
void AddBinUpEdge (const double *xup)
 add the bin width data, a pointer to an array with the bin upper edge information. More...
 
double RefVolume () const
 retrieve the reference volume used to normalize the data when the option bin volume is set More...
 
void SetRefVolume (double value)
 set the reference volume used to normalize the data when the option bin volume is set More...
 
double SumOfContent () const
 compute the total sum of the data content (sum of weights in cse of weighted data set) More...
 
double SumOfError2 () const
 compute the total sum of the error square (sum of weight square in case of a weighted data set) More...
 
- Public Member Functions inherited from ROOT::Fit::FitData
 FitData ()
 construct with default option and data range More...
 
virtual ~FitData ()
 dummy virtual destructor More...
 
 FitData (const DataOptions &opt)
 construct passing options and default data range More...
 
 FitData (const DataRange &range)
 construct passing range and default options More...
 
 FitData (const DataOptions &opt, const DataRange &range)
 construct passing options and data range More...
 
const DataOptionsOpt () const
 access to options More...
 
DataOptionsOpt ()
 
const DataRangeRange () const
 access to range More...
 

Static Public Member Functions

static unsigned int GetPointSize (ErrorType err, unsigned int dim)
 
- Static Public Member Functions inherited from ROOT::Fit::FitData
static unsigned int MaxSize ()
 define a max size to avoid allocating too large arrays More...
 

Protected Member Functions

void SetNPoints (unsigned int n)
 

Private Attributes

unsigned int fDim
 
unsigned int fPointSize
 
unsigned int fNPoints
 
double fSumContent
 
double fSumError2
 
double fRefVolume
 
DataVectorfDataVector
 
DataWrapperfDataWrapper
 
std::vector< doublefBinEdge
 

#include <Fit/BinData.h>

+ Inheritance diagram for ROOT::Fit::BinData:
+ Collaboration diagram for ROOT::Fit::BinData:

Constructor & Destructor Documentation

ROOT::Fit::BinData::BinData ( unsigned int  maxpoints = 0,
unsigned int  dim = 1,
ErrorType  err = kValueError 
)
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

Definition at line 27 of file BinData.cxx.

ROOT::Fit::BinData::BinData ( const DataOptions opt,
unsigned int  maxpoints = 0,
unsigned int  dim = 1,
ErrorType  err = kValueError 
)
explicit

constructor from option and default range

Definition at line 47 of file BinData.cxx.

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

Definition at line 69 of file BinData.cxx.

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

Definition at line 95 of file BinData.cxx.

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

Definition at line 116 of file BinData.cxx.

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

Definition at line 135 of file BinData.cxx.

ROOT::Fit::BinData::BinData ( const BinData rhs)

copy constructors

copy constructor

Definition at line 154 of file BinData.cxx.

ROOT::Fit::BinData::~BinData ( )
virtual

destructor

Definition at line 209 of file BinData.cxx.

Member Function Documentation

void ROOT::Fit::BinData::Add ( double  x,
double  y 
)
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)

Definition at line 281 of file BinData.cxx.

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

Definition at line 303 of file BinData.cxx.

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

Definition at line 325 of file BinData.cxx.

void ROOT::Fit::BinData::Add ( const double x,
double  val 
)

add multi-dim coordinate data with only value (no errors)

Definition at line 349 of file BinData.cxx.

void ROOT::Fit::BinData::Add ( const double x,
double  val,
double  eval 
)

add multi-dim coordinate data with only error in value

Definition at line 372 of file BinData.cxx.

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

Definition at line 398 of file BinData.cxx.

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

Definition at line 425 of file BinData.cxx.

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

Definition at line 451 of file BinData.cxx.

Referenced by TKDTreeBinning::FillBinData(), ROOT::Fit::FillData(), and ROOT::Fit::SparseData::GetBinDataIntegral().

const double* ROOT::Fit::BinData::BinUpEdge ( unsigned int  icoord) const
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 469 of file BinData.h.

Referenced by ROOT::Fit::FitUtil::EvaluateChi2(), ROOT::Fit::FitUtil::EvaluateChi2Gradient(), ROOT::Fit::FitUtil::EvaluateChi2Residual(), ROOT::Fit::FitUtil::EvaluatePoissonBinPdf(), ROOT::Fit::FitUtil::EvaluatePoissonLogL(), and ROOT::Fit::FitUtil::EvaluatePoissonLogLGradient().

const double* ROOT::Fit::BinData::CoordErrors ( unsigned int  ipoint) const
inline

Return a pointer to the errors in the coordinates for the given fit point.

Definition at line 291 of file BinData.h.

const double* ROOT::Fit::BinData::Coords ( unsigned int  ipoint) const
inline
unsigned int ROOT::Fit::BinData::DataSize ( ) const
inline

return the size of internal data (number of fit points) if data are not copied in but used externally the size is 0

Definition at line 158 of file BinData.h.

Referenced by Add(), and Resize().

double ROOT::Fit::BinData::Error ( unsigned int  ipoint) const
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 249 of file BinData.h.

Referenced by ROOT::Fit::FitUtil::EvaluatePoissonLogL(), printData(), and TLinearMinimizer::SetFunction().

ErrorType ROOT::Fit::BinData::GetErrorType ( ) const
inline
const double* ROOT::Fit::BinData::GetPoint ( unsigned int  ipoint,
double value 
) const
inline
const double* ROOT::Fit::BinData::GetPoint ( unsigned int  ipoint,
double value,
double invError 
) const
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 322 of file BinData.h.

const double* ROOT::Fit::BinData::GetPointError ( unsigned int  ipoint,
double errvalue 
) const
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 349 of file BinData.h.

Referenced by ROOT::Fit::FitUtil::EvaluateChi2Effective(), and printData().

const double* ROOT::Fit::BinData::GetPointError ( unsigned int  ipoint,
double errlow,
double errhigh 
) const
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 368 of file BinData.h.

static unsigned int ROOT::Fit::BinData::GetPointSize ( ErrorType  err,
unsigned int  dim 
)
inlinestatic

Definition at line 67 of file BinData.h.

Referenced by Initialize().

bool ROOT::Fit::BinData::HasBinEdges ( ) const
inline
bool ROOT::Fit::BinData::HaveAsymErrors ( ) const
inline

flag to control if data provides asymmetric errors on the value

Definition at line 174 of file BinData.h.

Referenced by ROOT::Fit::FitUtil::EvaluateChi2Effective().

bool ROOT::Fit::BinData::HaveCoordErrors ( ) const
inline

flag to control if data provides error on the coordinates

Definition at line 166 of file BinData.h.

Referenced by ROOT::Fit::FitUtil::EvaluateChi2Effective(), and ROOT::Fit::FitUtil::EvaluateChi2Gradient().

void ROOT::Fit::BinData::Initialize ( unsigned int  maxpoints,
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)

Definition at line 215 of file BinData.cxx.

Referenced by ROOT::Fit::DoFillData(), TKDTreeBinning::FillBinData(), ROOT::Fit::FillData(), ROOT::Math::DistSampler::Generate(), ROOT::Fit::SparseData::GetBinData(), ROOT::Fit::SparseData::GetBinDataIntegral(), ROOT::Fit::SparseData::GetBinDataNoZeros(), and Resize().

double ROOT::Fit::BinData::InvError ( unsigned int  ipoint) const
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 272 of file BinData.h.

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

Definition at line 479 of file BinData.cxx.

unsigned int ROOT::Fit::BinData::NDim ( ) const
inline
unsigned int ROOT::Fit::BinData::NPoints ( ) const
inline
BinData & ROOT::Fit::BinData::operator= ( const BinData rhs)

assignment operator

Definition at line 173 of file BinData.cxx.

unsigned int ROOT::Fit::BinData::PointSize ( ) const
inline

return the size of a fit point (is the coordinate dimension + 1 for the value and eventually the number of all errors

Definition at line 150 of file BinData.h.

Referenced by Add(), ROOT::Fit::FillData(), and printData().

double ROOT::Fit::BinData::RefVolume ( ) const
inline
void ROOT::Fit::BinData::Resize ( unsigned int  npoints)

resize the vector to the new given npoints if vector does not exists is created using existing point size

Definition at line 245 of file BinData.cxx.

Referenced by LogTransform().

void ROOT::Fit::BinData::SetNPoints ( unsigned int  n)
inlineprotected

Definition at line 515 of file BinData.h.

void ROOT::Fit::BinData::SetRefVolume ( double  value)
inline

set the reference volume used to normalize the data when the option bin volume is set

Definition at line 497 of file BinData.h.

unsigned int ROOT::Fit::BinData::Size ( ) const
inline
double ROOT::Fit::BinData::SumOfContent ( ) const
inline

compute the total sum of the data content (sum of weights in cse of weighted data set)

Definition at line 504 of file BinData.h.

Referenced by ROOT::Fit::FitUtil::EvaluateChi2(), and ROOT::Fit::FitUtil::EvaluateChi2Residual().

double ROOT::Fit::BinData::SumOfError2 ( ) const
inline

compute the total sum of the error square (sum of weight square in case of a weighted data set)

Definition at line 510 of file BinData.h.

Referenced by ROOT::Fit::FitUtil::EvaluateChi2(), and ROOT::Fit::FitUtil::EvaluateChi2Residual().

double ROOT::Fit::BinData::Value ( unsigned int  ipoint) const
inline

Member Data Documentation

std::vector<double> ROOT::Fit::BinData::fBinEdge
private

Definition at line 530 of file BinData.h.

Referenced by AddBinUpEdge(), BinUpEdge(), HasBinEdges(), Initialize(), and operator=().

DataVector* ROOT::Fit::BinData::fDataVector
private
DataWrapper* ROOT::Fit::BinData::fDataWrapper
private
unsigned int ROOT::Fit::BinData::fDim
private
unsigned int ROOT::Fit::BinData::fNPoints
private

Definition at line 522 of file BinData.h.

Referenced by Add(), AddBinUpEdge(), HasBinEdges(), LogTransform(), NPoints(), operator=(), SetNPoints(), and Size().

unsigned int ROOT::Fit::BinData::fPointSize
private
double ROOT::Fit::BinData::fRefVolume
private

Definition at line 525 of file BinData.h.

Referenced by AddBinUpEdge(), operator=(), RefVolume(), and SetRefVolume().

double ROOT::Fit::BinData::fSumContent
private

Definition at line 523 of file BinData.h.

Referenced by Add(), LogTransform(), operator=(), and SumOfContent().

double ROOT::Fit::BinData::fSumError2
private

Definition at line 524 of file BinData.h.

Referenced by Add(), LogTransform(), operator=(), and SumOfError2().


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