EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GaussianRegGradHessian.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file GaussianRegGradHessian.h
1 #ifndef FITNEWTON_GAUSSIANREGGRADHESSIAN_H
2 #define FITNEWTON_GAUSSIANREGGRADHESSIAN_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  GaussianRegGradHessian(FunctionGradHessian* func_instance, double sig, 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 
29  void setPoints(const std::vector<std::vector<double> >& POINTS);
30  void setData(const std::vector<double>& DATA);
31  void setErrors(const std::vector<double>& ERROR);
32 
33  void setPointsThread1(void* arg);
34  void setErrorsThread1(void* arg);
35  void setDataThread1(void* arg);
36 
37 
39 
41 
42  bool calcValGradHessian(const Eigen::VectorXd& x, double& val, Eigen::VectorXd& grad, Eigen::MatrixXd& hessian);
43  void calcValGradHessianThread1(void* arg);
44 
45  void getCovariance(Eigen::MatrixXd& cov);
46 
47  FunctionGradHessian* Clone() const;
48 
49  void setWidth(double sig){sigma = sig;}
50 
51  //set if errors are really just inverse weights of the data points
52  void setErrorsAreWeights(bool e_a_w){errors_are_weights = e_a_w;}
53 
54  void computeCovariance(const double& val, const Eigen::MatrixXd& hessian);
55 
56 
57  private:
59  const std::vector<std::vector<double> >* points;
60  const std::vector<double>* data;
61  const std::vector<double>* data_errors;
62 
63  std::vector<std::vector<std::vector<double> >* > thread_points;
64  std::vector<std::vector<double>* > thread_data;
65  std::vector<std::vector<double>* > thread_data_errors;
66 
67  const Eigen::VectorXd* current_eval;
68 
69  double* val_output;
70  Eigen::VectorXd* grad_output;
71  Eigen::MatrixXd* hessian_output;
72 
73  Eigen::MatrixXd covariance;
74 
77 
78  std::vector<SeamStress::Seamstress*> *vssp;
79  std::vector<SeamStress::Seamstress> vss;
81  unsigned long int nthreads;
82 
83  unsigned long int thread_tot;
84  unsigned long int niter;
85  pthread_mutex_t mutex;
86  pthread_mutexattr_t mattr;
87 
88  double sigma;
89  };
90 }
91 
92 
93 
94 #endif
95