ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
VertexFitter.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file VertexFitter.cc
1 #include "VertexFitter.h"
2 
3 #include <HelixHough/NewtonMinimizerGradHessian.h>
4 #include <HelixHough/VertexFitFunc.h>
5 
6 // Eigen includes
7 #include <Eigen/Core>
8 
9 class SimpleTrack3D;
10 
11 using namespace std;
12 
13 //using namespace NewtonMinimizer;
14 using namespace FitNewton;
15 using namespace Eigen;
16 
18 {
19 
20 }
21 
30 bool VertexFitter::findVertex(vector<SimpleTrack3D>& tracks, vector<float>& vertex, float sigma, bool fix_xy)
31 {
32  vector<Matrix<float,5,5> > covariances;
33  return findVertex(tracks, covariances, vertex, sigma, fix_xy);
34 }
35 
36 bool VertexFitter::findVertex(vector<SimpleTrack3D>& tracks, vector<Matrix<float,5,5> >& covariances, vector<float>& vertex, float sigma, bool fix_xy)
37 {
38  VertexFitFunc _vertexfit;
39  //NewtonMinimizer::NewtonMinimizerGradHessian _minimizer;
41 
42  // setup function to minimize
43  // expo-dca2 => ~dca^2 w/ extreme outlier de-weighting
44  _vertexfit.setTracks(&tracks);
45  _vertexfit.setCovariances(&covariances);
46 
47  // setup the minimizer
48  // fast Newton gradient minimization
49  _minimizer.setFunction(&_vertexfit);
50 
51  // set an initial guess and uncertainties
52  VectorXd start_point = VectorXd::Zero(vertex.size()); // input initial guess
53  for(unsigned int i=0;i<vertex.size();++i)
54  {
55  start_point(i) = vertex[i];
56  }
57  if(fix_xy)
58  {
59  _minimizer.fixParameter(0);
60  _minimizer.fixParameter(1);
61  }
62  _vertexfit.setFixedPar(0, sigma); // index = 0 used for x,y,z uncertainties
63 
64  // output storage
65  VectorXd min_point = VectorXd::Zero(vertex.size()); // output vector for minimize method below
66 
67  // minimize
68  _minimizer.minimize(start_point, min_point, 1.0e-12, 48, 1.0e-18);
69 
70  // store output vertex spatial point
71  for(unsigned i=0; i<vertex.size(); i++)
72  {
73  vertex[i] = min_point(i);
74  }
75 
76  return true;
77 }