LCFIVertex  0.7.2
track.cpp
1 #include "../inc/track.h"
2 #include "../inc/trackstate.h"
3 #include "../inc/event.h"
4 #include "../inc/jet.h"
5 #include "../util/inc/helixrep.h"
6 #include "../util/inc/matrix.h"
7 #include "../util/inc/memorymanager.h"
8 #include "../util/inc/projection.h"
9 
10 namespace vertex_lcfi
11 {
12  using namespace vertex_lcfi::util;
13 
15  {}
16 
17  Track::Track(Event* Event, const HelixRep & H,const Vector3 & Momentum,const double & cha, const SymMatrix5x5 & cov, std::vector<int> hits, void* trackNum)
18  : _Event(Event),_H(H),_PMomentum(Momentum),_Charge(cha),_CovarianceMatrix(cov),_NumHitsSubDetector(hits),_TrackingNum(trackNum)
19  {
20  }
21 
23  {
24  return _Event;
25  }
26 
28  {
29  TrackState* ts = new TrackState(_H,_Charge,_CovarianceMatrix, (Track*)this);
30  MemoryManager<TrackState>::Event()->registerObject(ts);
31  return ts;
32  }
33  //Make TrackState at reference point with specified swimmer
34 
35  const HelixRep & Track::helixRep() const
36  {
37  return _H;
38  }
39 
41  {
42  return _H;
43  }
44  double Track::charge() const
45  {
46  return _Charge;
47  }
48 
49  const Vector3 & Track::momentum() const
50  {
51  return _PMomentum;
52  }
53 
55  {
56  return _CovarianceMatrix;
57  }
58 
59  double Track::significance(Projection Proj) const
60  {
61  //define some nice index numbers
62  short x=0;short y=1;//short z=2;
63  //Swim a trackstate to the point of closest approach to the events IP
64  TrackState* track = this->makeState();
65  const SymMatrix3x3 & IPErr =this->event()->interactionPointError();
66  //TODO Cope with case where track is used in IP fit?
67  switch (Proj)
68  {
69  case RPhi:
70  {
71  track->swimToStateNearestXY(this->event()->interactionPoint());
72  Vector3 POCAVector = track->position() - this->event()->interactionPoint();
73  double ErrorIP = (IPErr(x,x)*pow(POCAVector.x(),2.0) + 2.0*IPErr(x,y)*POCAVector.x()*POCAVector.y() + IPErr(y,y)*pow(POCAVector.y(),2.0)) / POCAVector.mag2(RPhi);
74  double ErrorTrack = this->covarianceMatrix()(0,0);
75  if (ErrorIP <= 0.0)
76  std::cerr << "-ve IP Error of " << ErrorIP << ": Track.cpp:77" << std::endl;
77  if (ErrorTrack <= 0.0)
78  std::cerr << "-ve Track Error of " << ErrorTrack << ": Track.cpp:79" << std::endl;
79  //std::cout << POCAVector.mag(RPhi)*1000.0 << " " << sqrt(ErrorIP)*1000.0 << " " << sqrt(ErrorTrack)*1000.0 << " " << POCAVector.mag(RPhi)/sqrt(ErrorIP+ErrorTrack) << " ";
80  return POCAVector.mag(RPhi)/sqrt(ErrorIP+ErrorTrack);
81  break;
82  }
83  case Z:
84  {
85  track->swimToStateNearestXY(this->event()->interactionPoint());
86  Vector3 POCAVector = track->position() - this->event()->interactionPoint();
87  double ErrorIP = determinant(IPErr)/(IPErr(x,x)*IPErr(y,y)-IPErr(x,y)*IPErr(x,y));//IPErr(z,z);
88  double ErrorTrack = this->covarianceMatrix()(3,3);
89  if (ErrorIP <= 0.0)
90  std::cerr << "-ve IP Error of " << ErrorIP << ": Track.cpp:91" << std::endl;
91  if (ErrorTrack <= 0.0)
92  std::cerr << "-ve Track Error of " << ErrorTrack << ": Track.cpp:93" << std::endl;
93  return POCAVector.mag(Z)/sqrt(ErrorIP+ErrorTrack);
94  break;
95  }
96  case ThreeD:
97  {
98  track->swimToStateNearest(this->event()->interactionPoint());
99  Vector3 POCAVector = track->position() - this->event()->interactionPoint();
100  double ErrorIP = prec_inner_prod(prec_prod(IPErr,POCAVector),POCAVector);
101  //double ErrorIP = (IPErr(x,x)*pow(POCAVector.x(),2.0) + 2*IPErr(x,y)*POCAVector.x()*POCAVector.y() + IPErr(y,y)*pow(POCAVector.y(),2.0) + IPErr(z,z)*pow(POCAVector.z(),2.0)+ 2*IPErr(x,z)*POCAVector.x()*POCAVector.z() +2*IPErr(z,y)*POCAVector.z()*POCAVector.y())/ POCAVector.mag2(ThreeD) ;
102  //this should probably be only 0,0+3,3 given the definition of the POCAVector in the Rphi case.
103  //ignore cross terms?
104  double ErrorTrack = this->covarianceMatrix()(0,0)+this->covarianceMatrix()(3,3)+ 2 * this->covarianceMatrix()(0,3) ;
105 
106  if (ErrorIP <= 0.0)
107  std::cerr << "-ve IP Error of " << ErrorIP << ": Track.cpp:108" << std::endl;
108 
109  if (ErrorTrack <= 0.0)
110  std::cerr << "-ve Track Error of " << ErrorTrack << ": Track.cpp:111" << std::endl;
111 
112  return POCAVector.mag(ThreeD)/sqrt(ErrorIP+ErrorTrack);
113  break;
114  }
115  }
116  std::cerr << "Unsupported Significance: Track.cpp:117" << std::endl;
117  return 1;
118  }
119  double Track::signedSignificance(Projection Proj, Jet *MyJet) const
120  {
121 
122  TrackState* track = this->makeState();
123  track->swimToStateNearestXY(this->event()->interactionPoint());
124  Vector3 POCAVector = track->position() - this->event()->interactionPoint();
125  switch (Proj)
126  {
127  case RPhi:
128  { //Sign the significances relative to the jet so if the track and jet cross in front of IP the significance is positive
129  double d0significance = this->significance(RPhi);
130 
131  if (((POCAVector.x()*MyJet->momentum().x())+(POCAVector.y()*MyJet->momentum().y())) < 0)
132  {
133  d0significance = -d0significance;
134  }
135 
136  return d0significance;
137  break;
138  }
139 
140  case Z:
141  {
142  double z0significance = this->significance(Z);
143  double TanlambdaJet = MyJet->momentum().z()/sqrt(pow(MyJet->momentum().x(),2.0)+pow(MyJet->momentum().y(),2.0));
144 
145  if(POCAVector.z()*(TanlambdaJet - this->helixRep().tanLambda()) < 0)
146  {
147  z0significance = -z0significance;
148  }
149 
150  return z0significance;
151  break;
152  }
153  case ThreeD:
154  {
155  return this->significance(ThreeD);
156  }
157  }
158  //No case used so projection was not found
159  std::cerr << "Unsupported Significance: Track.cpp:158" << std::endl;
160  return 1;
161  }
162 
163 
164  void* Track::trackingNum() const
165  {
166  return _TrackingNum;
167  }
168 }
double signedSignificance(Projection Proj, Jet *MyJet) const
Signed significance of the track.
Definition: track.cpp:119
Vector3 momentum() const
Momentum.
Track()
Default Constuctor.
Definition: track.cpp:14
TrackState * makeState() const
Create a TrackState of this track.
Definition: track.cpp:27
const SymMatrix5x5 & covarianceMatrix() const
Covariance Matrix.
Definition: track.cpp:54
void swimToStateNearestXY(const Vector3 &Point)
Swim to the point of closest approach in the XY plane to Point.
Definition: trackstate.cpp:280
void * trackingNum() const
Tracking Number.
Definition: track.cpp:164
static MemoryManager< T > * Event()
Returns the Event duration singleton instance of the MemoryManager for type T.
double significance(Projection Proj) const
Significance of the track.
Definition: track.cpp:59
Event * event() const
Event that this track belongs to.
Definition: track.cpp:22
const Vector3 & momentum() const
Track perigee momentum.
Definition: track.cpp:49
Unique Track representation.
const HelixRep & helixRep() const
Helix represenation of this track.
Definition: track.cpp:35
double charge() const
Track charge.
Definition: track.cpp:44
const SymMatrix3x3 & interactionPointError() const
Interaction Point position error.
Definition: event.cpp:55
const Vector3 & interactionPoint() const
Interaction Point position.
Definition: event.cpp:50
const Vector3 & position() const
Current position of the trackstate.
Definition: trackstate.cpp:440
void swimToStateNearest(const Vector3 &Point)
Swim to the point of closest approach to Point.
Definition: trackstate.cpp:46