13 #include "msdevstudio/MSconfig.h" 30 using std::not_equal_to;
39 m_has_errors ( false ),
77 unsigned int size = ntuple -> columns ();
78 vector < int > indices ( size );
80 for (
unsigned int i = 0; i <
size; i++ ) {
91 const std::vector < int > & indices )
101 unsigned int dim = (
m_indices.size() -2 ) / 2;
114 unsigned int cols =
m_ntuple -> columns ();
116 const vector < double > & errors =
m_ntuple -> getColumn ( ie );
118 if ( errors.empty() )
return false;
120 vector < double >::const_iterator first
121 = find_if ( errors.begin(), errors.end (),
122 bind2nd ( not_equal_to < double > (), 0.0 ) );
124 yes = first != errors.end ();
162 const vector < double > & errors =
m_ntuple -> getColumn ( ie );
163 int number_points = errors.size();
165 int zeros = count ( errors.begin(), errors.end(), 0.0 );
166 number_points -= zeros;
169 vector< double > free_parms;
175 reset ( std::vector < std::vector < double > > & alpha,
176 std::vector < double > & beta,
180 beta.resize ( size, 0.0 );
182 alpha.resize ( size );
184 for (
unsigned int i = 0; i < alpha.size (); i++ ) {
186 alpha[i].resize ( size, 0.0 );
195 std::vector < double > & beta )
201 reset ( alpha, beta, num_parms );
203 unsigned int rows =
m_ntuple -> rows ();
204 for (
unsigned int i = 0; i < rows; i++ ) {
206 const vector < double > & row =
m_ntuple -> getRow ( i );
208 double err = ie < 0 ? 0. : row [ ie ];
212 double x = row [ ix ];
213 double y = row [ iy ];
216 vector < double > derives;
219 for (
unsigned int j = 0; j < num_parms; j++ ) {
220 double t = derives[j] / ( err * err );
222 for (
unsigned int k = 0; k <= j; k++ ) {
223 alpha[j][k] = alpha[j][k] + t * derives[k];
226 beta[j] += t * y_diff;
242 cut -> setColumn ( ix );
virtual void copyFrom(const StatedFCN *other)
Makes a copy of the relevant attributes from other object.
FunctionBase * m_function
The flags to indicated which parameters are to be held fixed during minimization of this objective fu...
void fillFreeDerivatives(std::vector< double > &, double x)
Clears and fills the vector with the derivatives of the function a coordinate value x...
hippodraw::NTupleFCN class interface
virtual double operator()(const std::vector< double > &parms) const
Sets the model function parameters to parms and returns the objective value.
A derived class of StatedFCN This class gets its data points from a DataSource.
void setDataSource(const DataSource *source)
Sets the data source.
bool m_fit_range
Set to true if the fitting range is turn on.
virtual bool setUseErrors(bool yes=true)
Sets the use of errors on the data point.
virtual bool getUseErrors() const
Gets the use of errors.
TupleCut * m_fit_cut
The cut that manages the range on X to be used for fitting.
The class expresses a cut on a DataSource, i.e.
bool m_has_errors
Error use flag.
hippodraw::DataSource class interface.
NTupleFCN()
The default constructor.
std::vector< int > m_indices
The indexes into the DataSource.
A namespace to set the standard for indexing into 3 dimension data point tuple.
unsigned int getNumberFreeParms() const
Returns the number of free parameters.
virtual void setFitRange(bool yes=true)
Sets use of a fitting range on or off.
const DataSource * m_ntuple
The data source containing the data points for the fitter.
hippodraw::TupleCut class interface
void reset(std::vector< std::vector< double > > &alpha, std::vector< double > &beta, unsigned int size)
Resets the matrix alpha and the vector beta.
int getErrorColumn() const
Returns the index to the column containing error on the value coordinate.
virtual void copyFrom(const StatedFCN *)
Makes a copy of the relevant attributes from other object.
hippodraw::FunctionBase class interface
hippodraw::DataPointTuple namespace interface
virtual void calcAlphaBeta(std::vector< std::vector< double > > &alpha, std::vector< double > &beta)
Calculates alpha and beta.
intp size(numeric::array arr)
A namespace to set the standard for indexing into 2 dimension data point tuple.
A derived class for FCNBase class.
virtual void setFitCut(TupleCut *cut)
Sets the cut to limit range of fitting.
bool acceptRow(unsigned int row) const
Returns true if the DataSource row row is within the fit Range.
virtual int degreesOfFreedom() const
Calculates the number of degrees of freedom.
bool hasErrors() const
Examines state of error bars.
Base class for DataSource.