CMS 3D CMS Logo

SignedTransverseImpactParameter.cc
Go to the documentation of this file.
2 
9 
10 #include "CLHEP/Vector/ThreeVector.h"
11 #include "CLHEP/Vector/LorentzVector.h"
12 #include "CLHEP/Matrix/Vector.h"
13 #include <string>
14 
16 
17 using namespace std;
18 using namespace reco;
19 
21  const GlobalVector& direction,
22  const Vertex& vertex) const {
23  TrajectoryStateOnSurface stateOnSurface = track.impactPointState();
24 
25  const FreeTrajectoryState* FTS = stateOnSurface.freeState(); //aRecTrack.stateAtFirstPoint().freeTrajectoryState());
26 
27  GlobalPoint vertexPosition(vertex.x(), vertex.y(), vertex.z());
28 
29  double theValue = 0.;
30  double theError = 0.;
32  TrajectoryStateOnSurface TSOS = TIPE.extrapolate(*FTS, vertexPosition);
33 
34  if (!TSOS.isValid()) {
35  theValue = 0.;
36  theError = 0.;
37  } else {
39 
40  GlobalVector DD0(D0.x() - vertex.x(), D0.y() - vertex.y(), 0.);
41  const GlobalVector& JetDir(direction);
42  double ps = DD0.dot(JetDir);
43  theValue = DD0.mag() * (ps / abs(ps));
44 
45  //error calculation
46 
47  AlgebraicVector6 deriv;
48  AlgebraicVector3 deriv_v;
49  GlobalVector dd0 = DD0.unit(); //check
50 
51  deriv_v[0] = -dd0.x();
52  deriv_v[1] = -dd0.y();
53  deriv_v[2] = -dd0.z();
54 
55  deriv[0] = dd0.x();
56  deriv[1] = dd0.y();
57  deriv[2] = dd0.z();
58  deriv[3] = 0.;
59  deriv[4] = 0.;
60  deriv[5] = 0.;
61  //cout << TSOS.cartesianError().matrix() << endl;
62  //cout << deriv << endl;
63  double E1 = ROOT::Math::Similarity(deriv, TSOS.cartesianError().matrix());
64  double E2 = ROOT::Math::Similarity(deriv_v, vertex.covariance());
65  // (aJet.vertex().positionError().matrix()).similarity(deriv_v);
66  theError = sqrt(E1 + E2);
67  LogDebug("BTagTools") << "Tk error : " << E1 << " , Vtx error : " << E2 << " tot : " << theError;
68 
69  } //end if
70 
71  bool x = true;
72 
73  Measurement1D A(theValue, theError);
74  return pair<bool, Measurement1D>(x, A);
75 } // end constructor declaration
76 
78  const GlobalVector& direction,
79  const Vertex& vertex) const {
81  TrajectoryStateOnSurface TSOS = track.impactPointState();
82 
83  if (!TSOS.isValid()) {
84  LogDebug("BTagTools") << "====>>>> SignedTransverseImpactParameter::zImpactParameter : TSOS not valid";
85  return pair<bool, Measurement1D>(false, Measurement1D(0.0, 0.0));
86  }
87 
88  GlobalPoint PV(vertex.x(), vertex.y(), vertex.z());
89  TrajectoryStateOnSurface statePCA = TIPE.extrapolate(TSOS, PV);
90 
91  if (!statePCA.isValid()) {
92  LogDebug("BTagTools") << "====>>>> SignedTransverseImpactParameter::zImpactParameter : statePCA not valid";
93  return pair<bool, Measurement1D>(false, Measurement1D(0.0, 0.0));
94  }
95 
96  GlobalPoint PCA = statePCA.globalPosition();
97 
98  // sign as in rphi
99  GlobalVector PVPCA(PCA.x() - PV.x(), PCA.y() - PV.y(), 0.);
100  const GlobalVector& JetDir(direction);
101  double sign = PVPCA.dot(JetDir);
102  sign /= fabs(sign);
103 
104  // z IP
105  double deltaZ = fabs(PCA.z() - PV.z()) * sign;
106 
107  // error
108  double errPvZ2 = vertex.covariance()(2, 2);
109  //CW cout << "CW number or rows and columns : " << statePCA.cartesianError().matrix().num_row() << " , "
110  //CW << statePCA.cartesianError().matrix().num_col() << endl ;
111  double errTrackZ2 = statePCA.cartesianError().matrix()(2, 2);
112  double errZ = sqrt(errPvZ2 + errTrackZ2);
113 
114  // CW alt. -> gives the same!!
115  // double errTZAlt = statePCA.localError().matrix()[4][4] ;
116  //CW
117 
118  return pair<bool, Measurement1D>(true, Measurement1D(deltaZ, errZ));
119 }
T z() const
Definition: PV3DBase.h:61
PreciseFloatType< T, U >::Type dot(const Vector3DBase< U, FrameTag > &v) const
Definition: Vector3DBase.h:99
Divides< arg, void > D0
Definition: Factorize.h:135
const CartesianTrajectoryError cartesianError() const
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
GlobalPoint globalPosition() const
T sqrt(T t)
Definition: SSEVec.h:23
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::pair< bool, Measurement1D > zImpactParameter(const reco::TransientTrack &, const GlobalVector &, const reco::Vertex &) const
std::pair< bool, Measurement1D > apply(const reco::TransientTrack &, const GlobalVector &, const reco::Vertex &) const
fixed size matrix
ROOT::Math::SVector< double, 3 > AlgebraicVector3
const AlgebraicSymMatrix66 & matrix() const
FreeTrajectoryState const * freeState(bool withErrors=true) const
ROOT::Math::SVector< double, 6 > AlgebraicVector6
float x
Definition: APVGainStruct.h:7
Vector3DBase unit() const
Definition: Vector3DBase.h:54
Definition: PV.py:1
#define LogDebug(id)