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