ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ChiSquareGradHessian.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file ChiSquareGradHessian.h
1 #ifndef FITNEWTON_CHISQUAREGRADHESSIAN_H
2 #define FITNEWTON_CHISQUAREGRADHESSIAN_H
3 
4 #include "FunctionGradHessian.h"
5 #include "Seamstress.h"
6 
7 #include <Eigen/Core>
8 
9 #include <cstddef>
10 #include <pthread.h>
11 #include <vector>
12 
13 namespace SeamStress { template <class TClass> class Pincushion; }
14 
15 namespace FitNewton
16 {
18  {
19  public:
20  ChiSquareGradHessian(FunctionGradHessian* func_instance, unsigned long int numthreads=1);
21 
22 
24 
25  void setPoints(const std::vector<std::vector<double> >& POINTS){points = &POINTS;}
26  void setData(const std::vector<double>& DATA){data = &DATA;}
27  void setErrors(const std::vector<double>& ERROR){data_errors = &ERROR;data_has_errors=true;}
28 
30 
32 
33  bool calcValGradHessian(const Eigen::VectorXd& x, double& val, Eigen::VectorXd& grad, Eigen::MatrixXd& hessian);
34  void calcValGradHessianThread1(void* arg);
35 
36  bool calcValGrad(const Eigen::VectorXd& x, double& val, Eigen::VectorXd& grad);
37  void calcValGradThread1(void* arg);
38 
39  void getCovariance(Eigen::MatrixXd& cov);
40 
41  FunctionGradHessian* Clone() const;
42 
43  //set if errors are really just inverse weights of the data points
44  void setErrorsAreWeights(bool e_a_w){errors_are_weights = e_a_w;}
45 
46  void computeCovariance(const double& val, const Eigen::MatrixXd& hessian);
47 
48 
49  private:
51  const std::vector<std::vector<double> >* points;
52  const std::vector<double>* data;
53  const std::vector<double>* data_errors;
54 
55  const Eigen::VectorXd* current_eval;
56 
57  double* val_output;
58  Eigen::VectorXd* grad_output;
59  Eigen::MatrixXd* hessian_output;
60 
61  Eigen::MatrixXd covariance;
62 
65 
66  std::vector<SeamStress::Seamstress*> *vssp;
67  std::vector<SeamStress::Seamstress> vss;
69  unsigned long int nthreads;
70 
71  unsigned long int thread_tot;
72  unsigned long int niter;
73  pthread_mutex_t mutex;
74  pthread_mutexattr_t mattr;
75  };
76 }
77 
78 
79 
80 #endif
81