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 }
Vector3DBase
Definition: Vector3DBase.h:8
fftjetvertexadder_cfi.errZ
errZ
Definition: fftjetvertexadder_cfi.py:39
TrajectoryStateOnSurface.h
AlgebraicVector3
ROOT::Math::SVector< double, 3 > AlgebraicVector3
Definition: AlgebraicROOTObjects.h:12
SignedTransverseImpactParameter::apply
std::pair< bool, Measurement1D > apply(const reco::TransientTrack &, const GlobalVector &, const reco::Vertex &) const
Definition: SignedTransverseImpactParameter.cc:20
Measurement1D
Definition: Measurement1D.h:11
HLT_FULL_cff.track
track
Definition: HLT_FULL_cff.py:11724
MessageLogger.h
TrajectoryStateOnSurface::cartesianError
const CartesianTrajectoryError cartesianError() const
Definition: TrajectoryStateOnSurface.h:71
funct::D0
Divides< arg, void > D0
Definition: Factorize.h:135
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
TrajectoryStateOnSurface::globalPosition
GlobalPoint globalPosition() const
Definition: TrajectoryStateOnSurface.h:65
Measurement1D.h
Validation_hcalonly_cfi.sign
sign
Definition: Validation_hcalonly_cfi.py:32
TransverseImpactPointExtrapolator
Definition: TransverseImpactPointExtrapolator.h:26
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:46
TransientTrack.h
nanoDQM_cfi.PV
PV
Definition: nanoDQM_cfi.py:576
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
Vector3DBase::unit
Vector3DBase unit() const
Definition: Vector3DBase.h:54
TrajectoryStateOnSurface::freeState
FreeTrajectoryState const * freeState(bool withErrors=true) const
Definition: TrajectoryStateOnSurface.h:58
SignedTransverseImpactParameter::zImpactParameter
std::pair< bool, Measurement1D > zImpactParameter(const reco::TransientTrack &, const GlobalVector &, const reco::Vertex &) const
Definition: SignedTransverseImpactParameter.cc:77
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
Line.h
Point3DBase< float, GlobalTag >
bphysicsOniaDQM_cfi.vertex
vertex
Definition: bphysicsOniaDQM_cfi.py:7
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
AlgebraicVector6
ROOT::Math::SVector< double, 6 > AlgebraicVector6
Definition: AlgebraicROOTObjects.h:15
Vector3DBase::dot
PreciseFloatType< T, U >::Type dot(const Vector3DBase< U, FrameTag > &v) const
Definition: Vector3DBase.h:99
CartesianTrajectoryError::matrix
const AlgebraicSymMatrix66 & matrix() const
Definition: CartesianTrajectoryError.h:28
MaterialEffects_cfi.A
A
Definition: MaterialEffects_cfi.py:11
std
Definition: JetResolutionObject.h:76
reco::TransientTrack
Definition: TransientTrack.h:19
L1TkHTMissProducer_cfi.deltaZ
deltaZ
Definition: L1TkHTMissProducer_cfi.py:13
FreeTrajectoryState
Definition: FreeTrajectoryState.h:27
TransverseImpactPointExtrapolator.h
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
A
AnalyticalTrajectoryExtrapolatorToLine.h
reco::Vertex
Definition: Vertex.h:35
TrajectoryStateOnSurface::isValid
bool isValid() const
Definition: TrajectoryStateOnSurface.h:54
SignedTransverseImpactParameter.h