LCFIVertex  0.7.2
vertex.cpp
1 #include "../inc/vertex.h"
2 #include "../inc/track.h"
3 #include "../inc/event.h"
4 #include "../zvtop/include/candidatevertex.h"
5 #include "../inc/trackstate.h"
6 
7 namespace vertex_lcfi
8 {
9 using namespace util;
10 
11  Vertex::Vertex(Event* Event, const std::vector<Track*> & Tracks, const Vector3 & Position, const SymMatrix3x3 & PosError,bool IsPrimary, double Chi2, double Probability, std::map<Track*,double> ChiTrack)
12  :_Event(Event),_Tracks(Tracks),_Position(Position),_PosError(PosError),_IsPrimary(IsPrimary), _Chi2(Chi2), _Probability(Probability),_ChiSquaredOfTrack(ChiTrack)
13  {}
14 
15  Vertex::Vertex(Event* Event, const std::vector<Track*> & Tracks, const Vector3 & Position, const SymMatrix3x3 & PosError,bool IsPrimary, double Chi2, double Probability)
16  :_Event(Event),_Tracks(Tracks),_Position(Position),_PosError(PosError),_IsPrimary(IsPrimary), _Chi2(Chi2), _Probability(Probability)
17  {}
18 
20  :_Event(Event),_Position(CandidateVertex->position()),_PosError(CandidateVertex->positionError())
21  {
22  for (std::vector<TrackState*>::const_iterator iTrack = CandidateVertex->trackStateList().begin();
23  iTrack != CandidateVertex->trackStateList().end(); ++iTrack)
24  {
25  _Tracks.push_back((*iTrack)->parentTrack());
26  _ChiSquaredOfTrack[(*iTrack)->parentTrack()] = CandidateVertex->chiSquaredOfTrack(*iTrack);
27  }
28  if (CandidateVertex->interactionPoint())
29  _IsPrimary = 1;
30  else
31  _IsPrimary = 0;
32  _Chi2=CandidateVertex->chiSquaredOfFit();
33  _Probability=0;
34 
35  }
36 
37  bool Vertex::removeTrack(Track* RTrack)
38  {
39  std::vector<Track*>::iterator position = std::find(_Tracks.begin(), _Tracks.end(), RTrack);
40  if (position!=_Tracks.end()) //Found
41  {
42  _Tracks.erase(position);
43  return 1;
44  }
45  else
46  return 0;
47  }
48 
49  bool Vertex::hasTrack(Track* HTrack) const
50  {
51  if (find(_Tracks.begin(), _Tracks.end(), HTrack) != _Tracks.end()) //Found
52  {
53  return 1;
54  }
55  else
56  return 0;
57  }
58 
60  {
61  Vector3 result;
62  for (std::vector<Track*>::const_iterator iTrack = _Tracks.begin();iTrack!=_Tracks.end();++iTrack)
63  {
64  result = result.add((*iTrack)->momentum());
65  }
66 
67  return result;
68  }
69 
70  double Vertex::charge() const
71  {
72  double result=0;
73  for (std::vector<Track*>::const_iterator iTrack = _Tracks.begin();iTrack!=_Tracks.end();++iTrack)
74  {
75  result += (*iTrack)->charge();
76  }
77  return result;
78  }
79 
80  double Vertex::radius(Projection Proj) const
81  {
82  return this->position().subtract(this->event()->interactionPoint()).mag(Proj);
83  }
84 
85  /*double Vertex::radiusError(Projection Proj) const
86  {
87  //TODO - copy from the track sig
88  }*/
89 
90  double Vertex::distanceToVertex(Vertex* FarVertex,Projection Proj) const
91  {
92  return this->position().subtract(FarVertex->position()).mag(Proj);
93  }
94 
95  double Vertex::distanceToVertexError(Vertex* FarVertex,Projection Proj) const
96  {
97 
98  //(ignoring the correlation terms
99  double FinalError =0;
100  SymMatrix3x3 TotalError ;
101  Vector3 TotalPosition ;
102 
103  switch (Proj)
104  {
105  case ThreeD:
106  TotalError = this-> positionError() + FarVertex->positionError();
107  TotalPosition = this->position().subtract(FarVertex->position());
108  FinalError = prec_inner_prod(trans(TotalPosition),(prec_prod( TotalError,TotalPosition )));
109  return sqrt(FinalError/this->position().subtract(FarVertex->position()).mag2(Proj));
110 
111  return 0;
112 
113  case RPhi:
114 
115  return 0;
116 
117  //to do throw error
118 
119  case Z:
120  //to do throw error
121 
122  return 0;
123  }
124  //TODO Throw Something
125  return 0;
126  }
127 }
bool removeTrack(Track *RTrack)
Remove Track.
Definition: vertex.cpp:37
double radius(Projection Proj) const
Radius.
Definition: vertex.cpp:80
Vector3 momentum() const
Momentum.
Definition: vertex.cpp:59
bool hasTrack(Track *HTrack) const
Does vertex contain this Track?
Definition: vertex.cpp:49
double chiSquaredOfTrack(TrackState *Track) const
Return the chi squared contribution of a trackstate in this vertex.
A collection of TrackState objects with a fit and vertex function maximum.
Event * event() const
Event.
double distanceToVertex(Vertex *FarVertex, Projection Proj) const
Distance to another vertex.
Definition: vertex.cpp:90
const Vector3 & position() const
Position.
const SymMatrix3x3 & positionError() const
Position.
InteractionPoint * interactionPoint() const
Return the InteractionPoint in this Vertex.
Unique Track representation.
double distanceToVertexError(Vertex *FarVertex, Projection Proj) const
Error of distance to another vertex.
Definition: vertex.cpp:95
const std::vector< TrackState * > & trackStateList() const
Return the TrackStates in this Vertex.
double chiSquaredOfFit() const
Return the chi squared of the fit.
double charge() const
Charge.
Definition: vertex.cpp:70