13 #ifndef ROOT_Fit_FitData 14 #define ROOT_Fit_FitData 69 explicit FitData(
unsigned int maxpoints = 0,
unsigned int dim = 1);
72 explicit FitData(
const DataOptions &opt,
unsigned int maxpoints = 0,
unsigned int dim = 1);
76 explicit FitData(
const DataRange &range,
unsigned int maxpoints = 0,
unsigned int dim = 1);
80 unsigned int maxpoints = 0,
unsigned int dim = 1);
83 FitData(
unsigned int n,
const double *dataX);
86 FitData(
unsigned int n,
const double *dataX,
const double *dataY);
89 FitData(
unsigned int n,
const double *dataX,
const double *dataY,
97 FitData(
const DataRange &range,
unsigned int maxpoints,
const double *dataX);
104 FitData(
const DataRange &range,
unsigned int maxpoints,
const double *dataX,
const double *dataY);
111 FitData(
const DataRange &range,
unsigned int maxpoints,
const double *dataX,
const double *dataY,
112 const double *dataZ);
121 template<
class Iterator>
122 FitData(
unsigned int n,
unsigned int dim, Iterator dataItr) :
125 fNPoints(fMaxPoints),
128 fpTmpCoordVector(
NULL)
131 for (
unsigned int i = 0; i < fDim; i++) {
132 fCoordsPtr[i] = *dataItr++;
135 if (fpTmpCoordVector) {
136 delete[] fpTmpCoordVector;
137 fpTmpCoordVector =
NULL;
140 fpTmpCoordVector =
new double [fDim];
148 template<
class Iterator>
149 FitData(
const DataRange &range,
unsigned int maxpoints,
unsigned int dim, Iterator dataItr) :
152 fMaxPoints(maxpoints),
155 fpTmpCoordVector(
NULL)
160 InitFromRange(dataItr);
170 void Append(
unsigned int newPoints,
unsigned int dim = 1);
182 fCoords.resize(fDim);
183 fCoordsPtr.resize(fDim);
185 for (
unsigned int i = 0; i < fDim; i++) {
186 fCoords[i].resize(fMaxPoints);
187 fCoordsPtr[i] = &fCoords[i].front();
190 if (fpTmpCoordVector) {
191 delete[] fpTmpCoordVector;
192 fpTmpCoordVector =
NULL;
195 fpTmpCoordVector =
new double [fDim];
198 template<
class Iterator>
201 for (
unsigned int i = 0; i < fMaxPoints; i++) {
202 bool isInside =
true;
203 Iterator tmpItr = dataItr;
205 for (
unsigned int j = 0; j < fDim; j++)
206 isInside &= fRange.IsInside((*tmpItr++)[i], j);
211 for (
unsigned int k = 0; k < fDim; k++)
212 fpTmpCoordVector[k] = (*tmpItr++)[i];
214 Add(fpTmpCoordVector);
230 assert(ipoint < fMaxPoints);
231 assert(icoord < fDim);
232 assert(fCoordsPtr.size() == fDim);
233 assert(fCoordsPtr[icoord]);
234 assert(fCoords.empty() || &fCoords[icoord].front() == fCoordsPtr[icoord]);
236 return &fCoordsPtr[icoord][ipoint];
245 const double *
Coords(
unsigned int ipoint)
const 247 assert(fpTmpCoordVector);
248 assert(ipoint < fMaxPoints);
250 for (
unsigned int i = 0; i < fDim; i++) {
251 assert(fCoordsPtr[i]);
252 assert(fCoords.empty() || &fCoords[i].front() == fCoordsPtr[i]);
254 fpTmpCoordVector[i] = fCoordsPtr[i][ipoint];
257 return fpTmpCoordVector;
266 assert(!fCoordsPtr.empty() && fCoordsPtr.size() == 1 && fCoordsPtr[0]);
268 assert(fNPoints < fMaxPoints);
270 fCoords[0][ fNPoints ] =
x;
281 assert(!fCoordsPtr.empty() && fCoordsPtr.size() == fDim);
282 assert(fNPoints < fMaxPoints);
284 for (
unsigned int i = 0; i < fDim; i++) {
285 fCoords[i][ fNPoints ] = x[i];
348 assert(fCoords.empty());
350 fCoords.resize(fDim);
351 for (
unsigned int i = 0; i < fDim; i++) {
352 assert(fCoordsPtr[i]);
353 fCoords[i].resize(fNPoints);
354 std::copy(fCoordsPtr[i], fCoordsPtr[i] + fNPoints, fCoords[i].begin());
355 fCoordsPtr[i] = &fCoords[i].front();
double * fpTmpCoordVector
Namespace for new ROOT classes and functions.
FitData(unsigned int n, unsigned int dim, Iterator dataItr)
constructor for multi-dim external data (data are not copied inside) Uses as argument an iterator of ...
const std::vector< const double *> & GetCoordDataPtrs() const
direct access to coord data ptrs
Base class for all the fit data types: Stores the coordinates and the DataOptions.
std::vector< std::vector< double > > fCoords
This vector stores the vectorizable data: The inner vectors contain the coordinates data fCoords[0] i...
const double * Coords(unsigned int ipoint) const
return a pointer to the coordinates data for the given fit point
void Add(const double *x)
add multi-dim coordinate data with only value
const double * GetCoordComponent(unsigned int ipoint, unsigned int icoord) const
returns a single coordinate component of a point.
unsigned int Size() const
return number of fit points
FitData(const DataRange &range, unsigned int maxpoints, unsigned int dim, Iterator dataItr)
constructor for multi-dim external data and a range (data are copied inside according to the range) U...
void InitCoordsVector()
initializer routines to set the corresponding pointers right The vectors must NOT be resized after th...
DataOptions : simple structure holding the options on how the data are filled.
void Add(double x)
add one dim data with only coordinate and values
const DataOptions & Opt() const
access to options
void Add(THist< DIMENSIONS, PRECISION_TO, STAT_TO... > &to, const THist< DIMENSIONS, PRECISION_FROM, STAT_FROM... > &from)
Add two histograms.
std::vector< const double *> fCoordsPtr
class describing the range in the coordinates it supports multiple range in a coordinate.
TFitResultPtr Fit(FitObject *h1, TF1 *f1, Foption_t &option, const ROOT::Math::MinimizerOptions &moption, const char *goption, ROOT::Fit::DataRange &range)
Binding & operator=(OUT(*fun)(void))
void InitFromRange(Iterator dataItr)
unsigned int NPoints() const
return number of fit points
unsigned int NDim() const
return coordinate data dimension
const DataRange & Range() const
access to range