LCFIPlus  0.6.5
VertexFitterLCFI.h
Go to the documentation of this file.
1 // VertexFitterLCFI.h
2 
3 #ifndef VertexFitterLCFI_h
4 #define VertexFitterLCFI_h 1
5 
6 #include "lcfiplus.h"
7 #include "LcfiInterface.h"
8 
9 // ZVTOP includes
10 #include <zvtop/include/VertexFitterKalman.h>
11 #include <util/inc/util.h>
12 
13 using namespace std;
14 using namespace lcfiplus;
15 
16 namespace lcfiplus {
17 
18 template<class Iterator>
20  public:
21  Vertex* operator() (Iterator tracksBegin, Iterator tracksEnd, Vertex* pointConstraint = 0) {
22  LcfiInterface lcfi;
23 
24  vector<vertex_lcfi::TrackState*> trackStates;
25  map<vertex_lcfi::TrackState*, const Track*> trackMap;
26 
27  for (Iterator it = tracksBegin; it != tracksEnd; it++) {
28  vertex_lcfi::Track* ptr = lcfi.lcfiTrack(*it);
29  vertex_lcfi::TrackState* pstate = ptr->makeState();
30  trackStates.push_back(pstate);
31  trackMap[pstate] = *it;
32  }
33 
34  vertex_lcfi::ZVTOP::VertexFitterKalman kalman;
35 // void VertexFitterKalman::fitVertex(const std::vector<TrackState*> & Tracks,
36 // InteractionPoint* IP, Vector3 & Result,
37 // Matrix3x3 & ResultError,
38 // do uble & ChiSquaredOfFit,
39 // std::map<TrackState*,double> & ChiSquaredOfTrack,
40 // double & ChiSquaredOfIP);
41 
42  vertex_lcfi::util::Vector3 vtxpos;
43  vertex_lcfi::util::Matrix3x3 vtxerr;
44  double chi2fit;
45  double chi2ip;
46  map<vertex_lcfi::TrackState*, double> chi2map;
47 
48  vertex_lcfi::ZVTOP::InteractionPoint* ipConst = 0;
49  if (pointConstraint) {
50  vertex_lcfi::util::SymMatrix3x3 pcerr;
51  vertex_lcfi::util::Vector3 pc;
52 
53  pc(0) = pointConstraint->getX();
54  pc(1) = pointConstraint->getY();
55  pc(2) = pointConstraint->getZ();
56 
57  pcerr(0,0) = pointConstraint->getCov()[Vertex::xx];
58  pcerr(0,1) = pointConstraint->getCov()[Vertex::xy];
59  pcerr(0,2) = pointConstraint->getCov()[Vertex::xz];
60  pcerr(1,1) = pointConstraint->getCov()[Vertex::yy];
61  pcerr(1,2) = pointConstraint->getCov()[Vertex::yz];
62  pcerr(2,2) = pointConstraint->getCov()[Vertex::zz];
63 
64  ipConst = new vertex_lcfi::ZVTOP::InteractionPoint(pc,pcerr);
65  }
66 
67  kalman.fitVertex(trackStates,ipConst, vtxpos, vtxerr, chi2fit, chi2map, chi2ip);
68  if (ipConst)
69  chi2fit -= ipConst->chi2(vtxpos);
70  delete ipConst;
71 
72  double prob = vertex_lcfi::util::prob(chi2fit, trackStates.size() * 2 - 3);
73  double cov[6];
74  cov[0] = vtxerr(0,0);
75  cov[1] = vtxerr(0,1);
76  cov[2] = vtxerr(1,1);
77  cov[3] = vtxerr(0,2);
78  cov[4] = vtxerr(1,2);
79  cov[5] = vtxerr(2,2);
80 
81  /*
82  cout << "VertexFitterLCFI pos: " << scientific
83  << vtxpos(0) << " " << vtxpos(1) << " " << vtxpos(2) << fixed << endl;
84  cout << "VertexFitterLCFI cov: " << scientific
85  << cov[0] << " " << cov[1] << " " << cov[2] << " " << cov[3] << " " << cov[4] << " " << cov[5] << fixed << endl;
86  */
87 
88  Vertex* vtx = new Vertex(chi2fit, prob,vtxpos(0), vtxpos(1), vtxpos(2),cov, false);
89  for (unsigned int i=0; i<trackStates.size(); i++) {
90  vtx->add(trackMap[trackStates[i]], chi2map[trackStates[i]]);
91  }
92 
93  return vtx;
94  }
95 };
96 
99 }
100 
101 #endif
Definition: lcfiplus.h:771
VertexFitterLCFI< vector< const Track * >::const_iterator > VertexFitterLCFI_V
Definition: VertexFitterLCFI.h:97
VertexFitterLCFI< list< const Track * >::const_iterator > VertexFitterLCFI_L
Definition: VertexFitterLCFI.h:98
Definition: LcfiInterface.h:49
Definition: VertexFitterLCFI.h:19
void add(const Track *trk)
Definition: lcfiplus.cc:827
cov
Definition: lcfiplus.h:26