NTupleChiSqFCN.cxx
Go to the documentation of this file.
1 
12 #ifdef _MSC_VER
13 #include "msdevstudio/MSconfig.h"
14 #endif
15 
16 #include "NTupleChiSqFCN.h"
17 
18 #include "functions/FunctionBase.h"
19 
21 #include "datasrcs/DataSource.h"
22 
23 using std::vector;
24 
25 using namespace hippodraw;
26 
29 {
30 }
31 
34  : NTupleFCN ( fcn )
35 {
36 }
37 
38 StatedFCN *
40 clone () const
41 {
42  return new NTupleChiSqFCN ( *this );
43 }
44 
45 double
47 #ifdef HAVE_MINUIT2
48 Up () const
49 #else
50 up () const
51 #endif
52 {
53  return 1.0;
54 }
55 
58 
59 double
62 {
63  double result = 0.0;
64 
65  unsigned int dim = ( m_indices.size() - 2 ) / 2;
66 
67  if ( dim == 1 ) {
68  int ix = m_indices [ dp2::X ];
69  int iy = m_indices [ dp2::Y ];
70  int ie = m_indices [ dp2::YERR ];
71 
72  unsigned int rows = m_ntuple -> rows ();
73 
74  for ( unsigned int i = 0; i < rows; i++ ) {
75  if ( acceptRow ( i ) ) {
76  const vector < double > & row = m_ntuple -> getRow ( i );
77  double err = ie < 0 ? 0. : row [ ie ];
78  if ( err == 0.0 && m_has_errors ) continue;
79  if ( m_has_errors == false ) err = 1.0;
80 
81  double diff = m_function -> operator () ( row [ ix ] ) - row [ iy ];
82  result += diff * diff / ( err * err );
83  }
84  }
85  }
86  else {
87  vector < double > coord ( dim );
88  int iv = m_indices [ dim ];
89  int ie = getErrorColumn ();
90 
91  unsigned int rows = m_ntuple -> rows ();
92 
93  for ( unsigned int i = 0; i < rows; i++ ) {
94  if ( acceptRow ( i ) ) {
95  const vector < double > & row = m_ntuple -> getRow ( i );
96 
97  double err = ie < 0 ? 0. : row [ ie ];
98  if ( err == 0.0 && m_has_errors ) continue;
99  if ( m_has_errors == false ) err = 1.0;
100 
101  for ( unsigned int j = 0; j < dim; j++ ) {
102  coord [ j ] = row [ m_indices [ j ] ];
103  }
104 
105  double diff = m_function -> operator () ( coord ) - row [ iv ];
106  result += diff * diff / ( err * err );
107  }
108  }
109  }
110 
111  return result;
112 }
113 
114 bool
117 {
118  return false;
119 }
hippodraw::FunctionBase class interface
A namespace to set the standard for indexing into 2 dimension data point tuple.
hippodraw::NTupleChiSqFCN class interface
virtual bool needsIntegrated() const
Returns true if data points were integrated.
virtual double up() const
bool acceptRow(unsigned int row) const
Returns true if the DataSource row row is within the fit Range.
Definition: NTupleFCN.cxx:255
Namespace for HippoDraw.
Definition: AxesType.cxx:21
virtual double operator()(const std::vector< double > &parms) const
Sets the model function parameters to parms and returns the objective value.
Definition: StatedFCN.cxx:185
const DataSource * m_ntuple
The data source containing the data points for the fitter.
Definition: NTupleFCN.h:64
A derived class for FCNBase class.
Definition: StatedFCN.h:70
A derived class of StatedFCN This class gets its data points from a DataSource.
Definition: NTupleFCN.h:31
virtual double objectiveValue() const
Calculates and returns the Chi-Squared.
hippodraw::DataSource class interface.
FunctionBase * m_function
The flags to indicated which parameters are to be held fixed during minimization of this objective fu...
Definition: StatedFCN.h:90
virtual StatedFCN * clone() const
Makes a copy of the object.
hippodraw::DataPointTuple namespace interface
A Chi-squared functor class.
A namespace to set the standard for indexing into 3 dimension data point tuple.
NTupleChiSqFCN()
The default constructor.
bool m_has_errors
Error use flag.
Definition: NTupleFCN.h:71
int getErrorColumn() const
Returns the index to the column containing error on the value coordinate.
Definition: NTupleFCN.cxx:99
std::vector< int > m_indices
The indexes into the DataSource.
Definition: NTupleFCN.h:60

Generated for HippoDraw Class Library by doxygen