BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
ROOT::Fit::UnBinData Class Reference

Description

Class describing the unbinned data sets (just x coordinates values) of any dimensions

       There is the option to construct UnBindata 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 using external 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.

      @ingroup  FitData

Definition at line 42 of file UnBinData.h.

Inheritance diagram for ROOT::Fit::UnBinData:
[legend]
Collaboration diagram for ROOT::Fit::UnBinData:
[legend]

Public Member Functions

 UnBinData (const DataOptions &opt, const DataRange &range, unsigned int maxpoints=0, unsigned int dim=1, bool isWeighted=false)
 
 UnBinData (const DataRange &range, unsigned int maxpoints=0, unsigned int dim=1, bool isWeighted=false)
 
 UnBinData (unsigned int maxpoints, const double *dataX, const DataRange &range)
 
 UnBinData (unsigned int maxpoints, const double *dataX, const double *dataY, const DataRange &range, bool isWeighted=false)
 
 UnBinData (unsigned int maxpoints, const double *dataX, const double *dataY, const double *dataZ, const DataRange &range, bool isWeighted=false)
 
template<class Iterator >
 UnBinData (unsigned int maxpoints, unsigned int dim, Iterator dataItr, const DataRange &range, bool isWeighted=false)
 
 UnBinData (unsigned int maxpoints=0, unsigned int dim=1, bool isWeighted=false)
 
 UnBinData (unsigned int n, const double *dataX)
 
 UnBinData (unsigned int n, const double *dataX, const double *dataY, bool isWeighted=false)
 
 UnBinData (unsigned int n, const double *dataX, const double *dataY, const double *dataZ, bool isWeighted=false)
 
template<class Iterator >
 UnBinData (unsigned int n, unsigned int dim, Iterator dataItr, bool isWeighted=false)
 
virtual ~UnBinData ()
 
void Add (const double *x)
 
void Add (const double *x, double w)
 
void Add (double x)
 
void Add (double x, double y)
 
void Add (double x, double y, double z)
 
void Append (unsigned int newPoints, unsigned int dim=1, bool isWeighted=false)
 
bool IsWeighted () const
 
unsigned int NDim () const
 
double Weight (unsigned int ipoint) const
 
const double * WeightsPtr (unsigned int ipoint) const
 

Private Member Functions

 UnBinData (const UnBinData &)
 copy constructor (private) More...
 
UnBinDataoperator= (const UnBinData &)
 assignment operator (private) More...
 

Private Attributes

bool fWeighted
 

Constructor & Destructor Documentation

◆ UnBinData() [1/12]

ROOT::Fit::UnBinData::UnBinData ( unsigned int  maxpoints = 0,
unsigned int  dim = 1,
bool  isWeighted = false 
)
inlineexplicit

constructor from dimension of point and max number of points (to pre-allocate vector)

Definition at line 50 of file UnBinData.h.

51  :
52  FitData( maxpoints, isWeighted ? dim + 1 : dim ),
53  fWeighted(isWeighted)
54  {
55  assert( dim >= 1 );
56  assert( !fWeighted || dim >= 2 );
57  }

References fWeighted.

◆ UnBinData() [2/12]

ROOT::Fit::UnBinData::UnBinData ( const DataRange range,
unsigned int  maxpoints = 0,
unsigned int  dim = 1,
bool  isWeighted = false 
)
inlineexplicit

constructor from range and default option

Definition at line 63 of file UnBinData.h.

64  :
65  FitData( range, maxpoints, isWeighted ? dim + 1 : dim ),
66  fWeighted(isWeighted)
67  {
68  assert( dim >= 1 );
69  assert( !fWeighted || dim >= 2 );
70  }

References fWeighted.

◆ UnBinData() [3/12]

ROOT::Fit::UnBinData::UnBinData ( const DataOptions opt,
const DataRange range,
unsigned int  maxpoints = 0,
unsigned int  dim = 1,
bool  isWeighted = false 
)
inline

constructor from options and range

Definition at line 75 of file UnBinData.h.

76  :
77  FitData( opt, range, maxpoints, isWeighted ? dim + 1 : dim ),
78  fWeighted(isWeighted)
79  {
80  assert( dim >= 1 );
81  assert( !fWeighted || dim >= 2 );
82  }

References fWeighted.

◆ UnBinData() [4/12]

ROOT::Fit::UnBinData::UnBinData ( unsigned int  n,
const double *  dataX 
)
inline

constructor for 1D external data (data are not copied inside)

Definition at line 87 of file UnBinData.h.

87  :
88  FitData( n, dataX ),
89  fWeighted( false )
90  {
91  }

◆ UnBinData() [5/12]

ROOT::Fit::UnBinData::UnBinData ( unsigned int  n,
const double *  dataX,
const double *  dataY,
bool  isWeighted = false 
)
inline

constructor for 2D external data (data are not copied inside) or 1D data with a weight (if isWeighted = true)

Definition at line 97 of file UnBinData.h.

98  :
99  FitData( n, dataX, dataY ),
100  fWeighted( isWeighted )
101  {
102  }

◆ UnBinData() [6/12]

ROOT::Fit::UnBinData::UnBinData ( unsigned int  n,
const double *  dataX,
const double *  dataY,
const double *  dataZ,
bool  isWeighted = false 
)
inline

constructor for 3D external data (data are not copied inside) or 2D data with a weight (if isWeighted = true)

Definition at line 108 of file UnBinData.h.

109  :
110  FitData( n, dataX, dataY, dataZ ),
111  fWeighted( isWeighted )
112  {
113  }

◆ UnBinData() [7/12]

template<class Iterator >
ROOT::Fit::UnBinData::UnBinData ( unsigned int  n,
unsigned int  dim,
Iterator  dataItr,
bool  isWeighted = false 
)
inline

constructor for multi-dim external data (data are not copied inside) Uses as argument an iterator of a list (or vector) containing the const double * of the data An example could be the std::vector<const double *>::begin In case of weighted data, the external data must have a dim+1 lists of data The apssed dim refers just to the coordinate size

Definition at line 123 of file UnBinData.h.

124  :
125  FitData( n, isWeighted ? dim + 1 : dim, dataItr ),
126  fWeighted( isWeighted )
127  {
128  assert( dim >= 1 );
129  assert( !fWeighted || dim >= 2 );
130  }

References fWeighted.

◆ UnBinData() [8/12]

ROOT::Fit::UnBinData::UnBinData ( unsigned int  maxpoints,
const double *  dataX,
const DataRange range 
)
inline

constructor for 1D data and a range (data are copied inside according to the given range)

Definition at line 135 of file UnBinData.h.

135  :
136  FitData( range, maxpoints, dataX ),
137  fWeighted( false )
138  {
139  }

◆ UnBinData() [9/12]

ROOT::Fit::UnBinData::UnBinData ( unsigned int  maxpoints,
const double *  dataX,
const double *  dataY,
const DataRange range,
bool  isWeighted = false 
)
inline

constructor for 2D data and a range (data are copied inside according to the given range) or 1 1D data set + weight. If is weighted dataY is the pointer to the list of the weights

Definition at line 146 of file UnBinData.h.

147  :
148  FitData( range, maxpoints, dataX, dataY ),
149  fWeighted( isWeighted )
150  {
151  }

◆ UnBinData() [10/12]

ROOT::Fit::UnBinData::UnBinData ( unsigned int  maxpoints,
const double *  dataX,
const double *  dataY,
const double *  dataZ,
const DataRange range,
bool  isWeighted = false 
)
inline

constructor for 3D data and a range (data are copied inside according to the given range) or a 2D data set + weights. If is weighted dataZ is the pointer to the list of the weights

Definition at line 157 of file UnBinData.h.

158  :
159  FitData( range, maxpoints, dataX, dataY, dataZ ),
160  fWeighted( isWeighted )
161  {
162  }

◆ UnBinData() [11/12]

template<class Iterator >
ROOT::Fit::UnBinData::UnBinData ( unsigned int  maxpoints,
unsigned int  dim,
Iterator  dataItr,
const DataRange range,
bool  isWeighted = false 
)
inline

constructor for multi-dim external data and a range (data are copied inside according to the range) Uses as argument an iterator of a list (or vector) containing the const double * of the data An example could be the std::vector<const double *>::begin

Definition at line 170 of file UnBinData.h.

170  :
171  FitData( range, maxpoints, dim, dataItr ),
172  fWeighted( isWeighted )
173  {
174  }

◆ UnBinData() [12/12]

ROOT::Fit::UnBinData::UnBinData ( const UnBinData )
inlineprivate

copy constructor (private)

Definition at line 178 of file UnBinData.h.

178 : FitData() { assert(false); }

◆ ~UnBinData()

virtual ROOT::Fit::UnBinData::~UnBinData ( )
inlinevirtual

destructor, delete pointer to internal data or external data wrapper

Definition at line 186 of file UnBinData.h.

186  {
187  }

Member Function Documentation

◆ Add() [1/5]

void ROOT::Fit::UnBinData::Add ( const double *  x)
inline

add multi-dim coordinate data

Definition at line 235 of file UnBinData.h.

236  {
237  FitData::Add( x );
238  }

◆ Add() [2/5]

void ROOT::Fit::UnBinData::Add ( const double *  x,
double  w 
)
inline

add multi-dim coordinate data + weight

Definition at line 243 of file UnBinData.h.

244  {
245  assert( fWeighted );
246 
247  std::vector<double> tmpVec(fDim);
248  std::copy( x, x + fDim - 1, tmpVec.begin() );
249  tmpVec[fDim-1] = w;
250 
251  FitData::Add( &tmpVec.front() );
252  }

References fWeighted.

◆ Add() [3/5]

void ROOT::Fit::UnBinData::Add ( double  x)
inline

preallocate a data set given size and dimension of the coordinates if a vector already exists with correct dimension (point size) extend the existing one to a total size of maxpoints (equivalent to a Resize) add one dim coordinate data (unweighted)

Definition at line 200 of file UnBinData.h.

201  {
202  assert( !fWeighted );
203 
204  FitData::Add( x );
205  }

References fWeighted.

◆ Add() [4/5]

void ROOT::Fit::UnBinData::Add ( double  x,
double  y 
)
inline

add 2-dim coordinate data can also be used to add 1-dim data with a weight

Definition at line 212 of file UnBinData.h.

213  {
214  assert( fDim == 2 );
215  double dataTmp[] = { x, y };
216 
217  FitData::Add( dataTmp );
218  }

◆ Add() [5/5]

void ROOT::Fit::UnBinData::Add ( double  x,
double  y,
double  z 
)
inline

add 3-dim coordinate data can also be used to add 2-dim data with a weight

Definition at line 224 of file UnBinData.h.

225  {
226  assert( fDim == 3 );
227  double dataTmp[] = { x, y, z };
228 
229  FitData::Add( dataTmp );
230  }

◆ Append()

void ROOT::Fit::UnBinData::Append ( unsigned int  newPoints,
unsigned int  dim = 1,
bool  isWeighted = false 
)
inline

Definition at line 288 of file UnBinData.h.

289  {
290  assert( !fWrapped );
291 
292  fWeighted = isWeighted;
293 
294  FitData::Append( newPoints, dim );
295  }

References fWeighted.

◆ IsWeighted()

bool ROOT::Fit::UnBinData::IsWeighted ( ) const
inline

Definition at line 283 of file UnBinData.h.

284  {
285  return fWeighted;
286  }

References fWeighted.

◆ NDim()

unsigned int ROOT::Fit::UnBinData::NDim ( ) const
inline

return coordinate data dimension

Definition at line 280 of file UnBinData.h.

281  { return fWeighted ? fDim -1 : fDim; }

References fWeighted.

◆ operator=()

UnBinData& ROOT::Fit::UnBinData::operator= ( const UnBinData )
inlineprivate

assignment operator (private)

Definition at line 180 of file UnBinData.h.

180 { assert(false); return *this; }

◆ Weight()

double ROOT::Fit::UnBinData::Weight ( unsigned int  ipoint) const
inline

return weight

Definition at line 257 of file UnBinData.h.

258  {
259  assert( ipoint < fNPoints );
260 
261  if ( !fWeighted ) return 1.0;
262  return *GetCoordComponent(ipoint, fDim-1);
263  }

References fWeighted.

◆ WeightsPtr()

const double* ROOT::Fit::UnBinData::WeightsPtr ( unsigned int  ipoint) const
inline

Definition at line 265 of file UnBinData.h.

266  {
267  assert( ipoint < fNPoints );
268 
269  if ( !fWeighted ){
270  MATH_ERROR_MSG("UnBinData::WeightsPtr","The function is unweighted!");
271  return nullptr;
272  }
273  return GetCoordComponent(ipoint, fDim-1);
274  }
#define MATH_ERROR_MSG(loc, str)
Definition: Error.h:50

References fWeighted, and MATH_ERROR_MSG.

Member Data Documentation

◆ fWeighted

bool ROOT::Fit::UnBinData::fWeighted
private

Definition at line 298 of file UnBinData.h.

Referenced by UnBinData(), Add(), Append(), IsWeighted(), NDim(), Weight(), and WeightsPtr().


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