Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
FitData.cxx
Go to the documentation of this file.
1// @(#)root/mathcore:$Id: FitData.cxx 45049 2012-07-13 12:31:59Z mborinsk $
2// Author: M. Borinsky
3
4
5/**********************************************************************
6 * *
7 * Copyright (c) 2006 LCG ROOT Math Team, CERN/PH-SFT *
8 * *
9 * *
10 **********************************************************************/
11
12
13#include "Fit/FitData.h"
14
15// Implementation file for class FitData
16
17namespace ROOT {
18
19 namespace Fit {
20 FitData::FitData(unsigned int maxpoints, unsigned int dim) :
21 fWrapped(false),
22 fMaxPoints(maxpoints),
23 fNPoints(0),
24 fDim(dim),
25 fpTmpCoordVector(nullptr)
26 {
27 assert(fDim >= 1);
29 }
30
31 /// construct passing options and default data range
32 FitData::FitData(const DataOptions &opt, unsigned int maxpoints, unsigned int dim) :
33 fWrapped(false),
34 fOptions(opt),
35 fMaxPoints(maxpoints),
36 fNPoints(0),
37 fDim(dim),
38 fpTmpCoordVector(nullptr)
39 {
40 assert(fDim >= 1);
42 }
43
44
45 /// construct passing range and default options
46 FitData::FitData(const DataRange &range, unsigned int maxpoints, unsigned int dim) :
47 fWrapped(false),
48 fRange(range),
49 fMaxPoints(maxpoints),
50 fNPoints(0),
51 fDim(dim),
52 fpTmpCoordVector(nullptr)
53 {
54 assert(fDim >= 1);
56 }
57
58 /// construct passing options and data range
59 FitData::FitData(const DataOptions &opt, const DataRange &range,
60 unsigned int maxpoints, unsigned int dim) :
61 fWrapped(false),
62 fOptions(opt),
63 fRange(range),
64 fMaxPoints(maxpoints),
65 fNPoints(0),
66 fDim(dim),
67 fCoords(fDim),
68 fCoordsPtr(fDim),
69 fpTmpCoordVector(nullptr)
70 {
71 assert(fDim >= 1);
73 }
74
75 /// constructor from external data for 1D data
76 FitData::FitData(unsigned int n, const double *dataX) :
77 fWrapped(true),
78 fMaxPoints(n),
79 fNPoints(n),
80 fDim(1),
81 fCoordsPtr(fDim),
82 fpTmpCoordVector(nullptr)
83 {
84 assert(dataX);
85 fCoordsPtr[0] = dataX;
86
87 if (fpTmpCoordVector) {
88 delete[] fpTmpCoordVector;
89 fpTmpCoordVector = nullptr;
90 }
91
92 fpTmpCoordVector = new double [fDim];
93 }
94
95 /// constructor from external data for 2D data
96 FitData::FitData(unsigned int n, const double *dataX, const double *dataY) :
97 fWrapped(true),
98 fMaxPoints(n),
99 fNPoints(n),
100 fDim(2),
101 fCoordsPtr(fDim),
102 fpTmpCoordVector(nullptr)
103 {
104 assert(dataX && dataY);
105 fCoordsPtr[0] = dataX;
106 fCoordsPtr[1] = dataY;
107
108 if (fpTmpCoordVector) {
109 delete[] fpTmpCoordVector;
110 fpTmpCoordVector = nullptr;
111 }
112
113 fpTmpCoordVector = new double [fDim];
114 }
115
116 /// constructor from external data for 3D data
117 FitData::FitData(unsigned int n, const double *dataX, const double *dataY,
118 const double *dataZ) :
119 fWrapped(true),
120 fMaxPoints(n),
121 fNPoints(fMaxPoints),
122 fDim(3),
123 fCoordsPtr(fDim),
124 fpTmpCoordVector(nullptr)
125 {
126 assert(dataX && dataY && dataZ);
127 fCoordsPtr[0] = dataX;
128 fCoordsPtr[1] = dataY;
129 fCoordsPtr[2] = dataZ;
130
131 if (fpTmpCoordVector) {
132 delete[] fpTmpCoordVector;
133 fpTmpCoordVector = nullptr;
134 }
135
136 fpTmpCoordVector = new double [fDim];
137 }
138
139 /**
140 constructor for multi-dim external data and a range (data are copied inside according to the range)
141 Uses as argument an iterator of a list (or vector) containing the const double * of the data
142 An example could be the std::vector<const double *>::begin
143 */
144 FitData::FitData(const DataRange &range, unsigned int maxpoints, const double *dataX) :
145 fWrapped(false),
146 fRange(range),
147 fMaxPoints(maxpoints),
148 fNPoints(0),
149 fDim(1),
150 fpTmpCoordVector(nullptr)
151 {
153
154 const double *ptrList[] = { dataX };
155
156 InitFromRange(ptrList);
157 }
158
159 /**
160 constructor for multi-dim external data and a range (data are copied inside according to the range)
161 Uses as argument an iterator of a list (or vector) containing the const double * of the data
162 An example could be the std::vector<const double *>::begin
163 */
164 FitData::FitData(const DataRange &range, unsigned int maxpoints, const double *dataX, const double *dataY) :
165 fWrapped(false),
166 fRange(range),
167 fMaxPoints(maxpoints),
168 fNPoints(0),
169 fDim(2),
170 fpTmpCoordVector(nullptr)
171 {
173
174 const double *ptrList[] = { dataX, dataY };
175
176 InitFromRange(ptrList);
177 }
178
179 /**
180 constructor for multi-dim external data and a range (data are copied inside according to the range)
181 Uses as argument an iterator of a list (or vector) containing the const double * of the data
182 An example could be the std::vector<const double *>::begin
183 */
184 FitData::FitData(const DataRange &range, unsigned int maxpoints, const double *dataX, const double *dataY,
185 const double *dataZ) :
186 fWrapped(false),
187 fRange(range),
188 fMaxPoints(maxpoints),
189 fNPoints(0),
190 fDim(3),
191 fpTmpCoordVector(nullptr)
192 {
194
195 const double *ptrList[] = { dataX, dataY, dataZ };
196
197 InitFromRange(ptrList);
198 }
199
200 /// dummy virtual destructor
202 {
203 assert(fWrapped == fCoords.empty());
204 for (unsigned int i = 0; i < fDim; i++) {
205 assert(fWrapped || fCoords[i].empty() || &fCoords[i].front() == fCoordsPtr[i]);
206 }
208
209 }
210
212 : fWrapped(false), fMaxPoints(0), fNPoints(0), fDim(0),
213 fpTmpCoordVector(nullptr)
214 {
215 *this = rhs;
216 }
217
219 {
220 fWrapped = rhs.fWrapped;
221 fOptions = rhs.fOptions;
222 fRange = rhs.fRange;
224 fNPoints = rhs.fNPoints;
225 fDim = rhs.fDim;
226
227 if (fWrapped) {
228 fCoords.clear();
229
231 } else {
232 fCoords = rhs.fCoords;
233
234 fCoordsPtr.resize(fDim);
235
236 for (unsigned int i = 0; i < fDim; i++) {
237 fCoordsPtr[i] = fCoords[i].empty() ? nullptr : &fCoords[i].front();
238 }
239 }
240
241 if (fpTmpCoordVector) {
242 delete[] fpTmpCoordVector;
243 fpTmpCoordVector = nullptr;
244 }
245
246 fpTmpCoordVector = new double [fDim];
247
248 return *this;
249 }
250
251 void FitData::Append(unsigned int newPoints, unsigned int dim)
252 {
253 assert(!fWrapped);
254
255 fMaxPoints = fMaxPoints + newPoints;
256 fDim = dim;
257
259 }
260
261 } // end namespace Fit
262
263} // end namespace ROOT
class describing the range in the coordinates it supports multiple range in a coordinate.
Definition DataRange.h:35
Base class for all the fit data types: Stores the coordinates and the DataOptions.
Definition FitData.h:56
double * fpTmpCoordVector
Definition FitData.h:406
FitData(unsigned int maxpoints=0, unsigned int dim=1)
construct with default option and data range
Definition FitData.cxx:20
void InitCoordsVector()
initializer routines to set the corresponding pointers right The vectors must NOT be resized after th...
Definition FitData.h:171
DataRange fRange
Definition FitData.h:381
void Append(unsigned int newPoints, unsigned int dim=1)
Definition FitData.cxx:251
std::vector< std::vector< double > > fCoords
This vector stores the vectorizable data: The inner vectors contain the coordinates data fCoords[0] i...
Definition FitData.h:403
unsigned int fMaxPoints
Definition FitData.h:384
std::vector< const double * > fCoordsPtr
Definition FitData.h:404
void InitFromRange(Iterator dataItr)
Definition FitData.h:190
DataOptions fOptions
Definition FitData.h:380
unsigned int fDim
Definition FitData.h:386
FitData & operator=(const FitData &rhs)
Definition FitData.cxx:218
unsigned int fNPoints
Definition FitData.h:385
virtual ~FitData()
dummy virtual destructor
Definition FitData.cxx:201
const Int_t n
Definition legend1.C:16
TFitResultPtr Fit(FitObject *h1, TF1 *f1, Foption_t &option, const ROOT::Math::MinimizerOptions &moption, const char *goption, ROOT::Fit::DataRange &range)
Definition HFitImpl.cxx:133
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
DataOptions : simple structure holding the options on how the data are filled.
Definition DataOptions.h:28