CMS 3D CMS Logo

SignedImpactParameter3D.cc
Go to the documentation of this file.
2 
8 
9 #include "CLHEP/Vector/ThreeVector.h"
10 #include "CLHEP/Vector/LorentzVector.h"
11 #include "CLHEP/Matrix/Vector.h"
12 #include <string>
13 
14 using namespace std;
15 using namespace reco;
16 
17 pair<bool, Measurement1D> SignedImpactParameter3D::apply(const TransientTrack& transientTrack,
18  const GlobalVector& direction,
19  const Vertex& vertex) const {
20  double theValue = 0.;
21  double theError = 0.;
22  bool theIsValid = false;
23 
25 
26  if (!TSOS.isValid()) {
27  cout << "====>>>> SignedImpactParameter3D::apply : TSOS not valid = " << TSOS.isValid() << endl;
28  return pair<bool, Measurement1D>(theIsValid, Measurement1D(0., 0.));
29  }
30 
32 
33  const GlobalVector& JetDirection(direction);
34 
35  TrajectoryStateOnSurface theTSOS = closestApproachToJet(*FTS, vertex, JetDirection, transientTrack.field());
36  theIsValid = theTSOS.isValid();
37 
38  if (theIsValid) {
39  GlobalVector D = distance(theTSOS, vertex, JetDirection);
40  GlobalVector J = JetDirection.unit();
41  GlobalPoint vertexPosition(vertex.x(), vertex.y(), vertex.z());
42  double theDistanceAlongJetAxis = J.dot(theTSOS.globalPosition() - vertexPosition);
43  theValue = D.mag() * (theDistanceAlongJetAxis / abs(theDistanceAlongJetAxis));
44 
45  GlobalVector DD = D.unit();
46  GlobalPoint T0 = theTSOS.globalPosition();
47  GlobalVector T1 = theTSOS.globalMomentum();
48  GlobalVector TT1 = T1.unit();
49  GlobalVector Xi(T0.x() - vertex.position().x(), T0.y() - vertex.position().y(), T0.z() - vertex.position().z());
50 
51  AlgebraicVector6 deriv;
52  AlgebraicVector3 deriv_v;
53 
54  deriv_v[0] = -DD.x();
55  deriv_v[1] = -DD.y();
56  deriv_v[2] = -DD.z();
57 
58  deriv[0] = DD.x();
59  deriv[1] = DD.y();
60  deriv[2] = DD.z();
61  deriv[3] = -(TT1.dot(Xi) * DD.x()) / T1.mag();
62  deriv[4] = -(TT1.dot(Xi) * DD.y()) / T1.mag();
63  deriv[5] = -(TT1.dot(Xi) * DD.z()) / T1.mag();
64 
65  double E1 = ROOT::Math::Similarity(deriv, theTSOS.cartesianError().matrix());
66  double E2 = ROOT::Math::Similarity(deriv_v, vertex.covariance());
67  // double E2 = RecoVertex::convertError(vertex.covariance()).matrix().similarity(deriv_v);
68  // double E2 = 0.; // no vertex error because of stupid use of hundreds of different types for same thing
69  theError = sqrt(E1 + E2);
70 
71  Measurement1D A(theValue, theError);
72 
73  return pair<bool, Measurement1D>(theIsValid, A);
74  } else {
75  return pair<bool, Measurement1D>(theIsValid, Measurement1D(0., 0.));
76  } // endif (isValid)
77 }
78 
80  const Vertex& vertex,
81  const GlobalVector& aJetDirection,
82  const MagneticField* field) {
83  GlobalVector J = aJetDirection.unit();
84 
87  Line Jet(pos, dir);
88 
90 
91  return TETL.extrapolate(aFTS, Jet);
92 }
93 
95  const Vertex& vertex,
96  const GlobalVector& aJetDirection) {
97  Line::PositionType pos2(aTSOS.globalPosition());
99  Line T(pos2, dir2);
100 
101  GlobalPoint X = GlobalPoint(vertex.x(), vertex.y(), vertex.z()); // aVertex.position();
102 
103  GlobalVector D = T.distance(X);
104 
105  return D;
106 }
107 
109  const GlobalVector& direction,
110  const Vertex& vertex) {
111  double theDistanceAlongJetAxis(0.);
112  double theDistanceToJetAxis(0.);
113  double theLDist_err(0.);
114  TrajectoryStateOnSurface TSOS = track.impactPointState();
115 
116  if (!TSOS.isValid()) {
117  cout << "====>>>> SignedImpactParameter3D::distanceWithJetAxis : TSOS not valid = " << TSOS.isValid() << endl;
118  return pair<double, Measurement1D>(theDistanceAlongJetAxis, Measurement1D(theDistanceToJetAxis, theLDist_err));
119  }
120 
122 
123  const GlobalVector& jetDirection(direction);
124 
125  //
126  // Check whether the track has been used in the vertex
127  //
128 
129  //FIXME
130  float weight = 0.; //vertex.trackWeight(aRecTrack);
131 
132  TrajectoryStateOnSurface stateAtOrigin = track.impactPointState();
133  TrajectoryStateOnSurface aTSOS = closestApproachToJet(*FTS, vertex, jetDirection, track.field());
134  bool isValid = stateAtOrigin.isValid();
135  // bool IsValid= aTSOS.isValid();
136 
137  if (isValid) {
138  //get the Track line at origin
139  Line::PositionType pos(stateAtOrigin.globalPosition());
140  Line::DirectionType dir((stateAtOrigin.globalMomentum()).unit());
141  Line track(pos, dir);
142  // get the Jet line
143  // Vertex vertex(vertex);
144  GlobalVector jetVector = jetDirection.unit();
145  Line::PositionType pos2(GlobalPoint(vertex.x(), vertex.y(), vertex.z()));
146  Line::DirectionType dir2(jetVector);
147  Line jet(pos2, dir2);
148  // now compute the distance between the two lines
149  // If the track has been used to refit the Primary vertex then sign it positively, otherwise negative
150 
151  theDistanceToJetAxis = (jet.distance(track)).mag();
152  if (weight < 1)
153  theDistanceToJetAxis = -theDistanceToJetAxis;
154 
155  // ... and the flight distance along the Jet axis.
156  GlobalPoint V = jet.position();
157  GlobalVector Q = dir - jetVector.dot(dir) * jetVector;
158  GlobalVector P = jetVector - jetVector.dot(dir) * dir;
159  theDistanceAlongJetAxis = P.dot(V - pos) / Q.dot(dir);
160 
161  //
162  // get the covariance matrix of the vertex and compute the error on theDistanceToJetAxis
163  //
164 
166 
167  // build the vector of closest approach between lines
168 
169  GlobalVector H((jetVector.cross(dir).unit()));
170 
171  CLHEP::HepVector Hh(3);
172  Hh[0] = H.x();
173  Hh[1] = H.y();
174  Hh[2] = H.z();
175 
176  // theLDist_err = sqrt(vertexError.similarity(Hh));
177 
178  // cout << "distance to jet axis : "<< theDistanceToJetAxis <<" and error : "<< theLDist_err<<endl;
179  // Now the impact parameter ...
180 
181  /* GlobalPoint T0 = track.position();
182  GlobalVector D = (T0-V)- (T0-V).dot(dir) * dir;
183  double IP = D.mag();
184  GlobalVector Dold = distance(aTSOS, aJet.vertex(), jetDirection);
185  double IPold = Dold.mag();
186 */
187  }
188  Measurement1D DTJA(theDistanceToJetAxis, theLDist_err);
189 
190  return pair<double, Measurement1D>(theDistanceAlongJetAxis, DTJA);
191 }
Vector3DBase
Definition: Vector3DBase.h:8
class-composition.H
H
Definition: class-composition.py:31
cms::cuda::V
cudaStream_t T uint32_t const T *__restrict__ const uint32_t *__restrict__ uint32_t int cudaStream_t V
Definition: HistoContainer.h:99
TrajectoryStateOnSurface.h
AlgebraicVector3
ROOT::Math::SVector< double, 3 > AlgebraicVector3
Definition: AlgebraicROOTObjects.h:12
TrajectoryStateOnSurface::freeTrajectoryState
FreeTrajectoryState const * freeTrajectoryState(bool withErrors=true) const
Definition: TrajectoryStateOnSurface.h:60
L1TDiffHarvesting_cfi.dir2
dir2
Definition: L1TDiffHarvesting_cfi.py:12
Measurement1D
Definition: Measurement1D.h:11
HLT_FULL_cff.track
track
Definition: HLT_FULL_cff.py:11779
TrajectoryStateOnSurface::cartesianError
const CartesianTrajectoryError cartesianError() const
Definition: TrajectoryStateOnSurface.h:71
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
X
#define X(str)
Definition: MuonsGrabber.cc:38
TrajectoryStateOnSurface::globalPosition
GlobalPoint globalPosition() const
Definition: TrajectoryStateOnSurface.h:65
gather_cfg.cout
cout
Definition: gather_cfg.py:144
SignedImpactParameter3D::closestApproachToJet
static TrajectoryStateOnSurface closestApproachToJet(const FreeTrajectoryState &, const reco::Vertex &, const GlobalVector &, const MagneticField *)
Definition: SignedImpactParameter3D.cc:79
pos
Definition: PixelAliasList.h:18
L1DTConfigTraco_cff.DD
DD
single HTRIG enabling on first/second tracks
Definition: L1DTConfigTraco_cff.py:9
Measurement1D.h
IPTools::closestApproachToJet
TrajectoryStateOnSurface closestApproachToJet(const TrajectoryStateOnSurface &state, const reco::Vertex &vertex, const GlobalVector &aJetDirection, const MagneticField *field)
Definition: IPTools.cc:182
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
TransientTrack.h
class-composition.Q
Q
Definition: class-composition.py:82
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
Vector3DBase::unit
Vector3DBase unit() const
Definition: Vector3DBase.h:54
Jet
Definition: Jet.py:1
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
L1TRate_cfi.Jet
Jet
Definition: L1TRate_cfi.py:43
Line.h
GlobalPoint
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
SignedImpactParameter3D::apply
std::pair< bool, Measurement1D > apply(const reco::TransientTrack &, const GlobalVector &direction, const reco::Vertex &vertex) const
Definition: SignedImpactParameter3D.cc:17
Point3DBase< float, GlobalTag >
bphysicsOniaDQM_cfi.vertex
vertex
Definition: bphysicsOniaDQM_cfi.py:7
SignedImpactParameter3D.h
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
reco::TransientTrack::impactPointState
TrajectoryStateOnSurface impactPointState() const
Definition: TransientTrack.h:98
Line
Definition: Line.h:10
Vector3DBase::cross
Vector3DBase< typename PreciseFloatType< T, U >::Type, FrameTag > cross(const Vector3DBase< U, FrameTag > &v) const
Definition: Vector3DBase.h:110
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
reco::TransientTrack::field
const MagneticField * field() const
Definition: TransientTrack.h:110
CartesianTrajectoryError::matrix
const AlgebraicSymMatrix66 & matrix() const
Definition: CartesianTrajectoryError.h:28
unit
Basic3DVector unit() const
Definition: Basic3DVectorLD.h:162
PV3DBase::mag
T mag() const
Definition: PV3DBase.h:64
TrajectoryStateOnSurface::globalMomentum
GlobalVector globalMomentum() const
Definition: TrajectoryStateOnSurface.h:66
mag
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
Definition: Basic3DVectorLD.h:127
MaterialEffects_cfi.A
A
Definition: MaterialEffects_cfi.py:11
funct::D
DecomposeProduct< arg, typename Div::arg > D
Definition: Factorize.h:141
std
Definition: JetResolutionObject.h:76
reco::TransientTrack
Definition: TransientTrack.h:19
FreeTrajectoryState
Definition: FreeTrajectoryState.h:27
SignedImpactParameter3D::distanceWithJetAxis
static std::pair< double, Measurement1D > distanceWithJetAxis(const reco::TransientTrack &transientTrack, const GlobalVector &direction, const reco::Vertex &vertex)
Definition: SignedImpactParameter3D.cc:108
T
long double T
Definition: Basic3DVectorLD.h:48
metsig::jet
Definition: SignAlgoResolutions.h:47
SignedImpactParameter3D::distance
static GlobalVector distance(const TrajectoryStateOnSurface &, const reco::Vertex &, const GlobalVector &)
Definition: SignedImpactParameter3D.cc:94
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
P
std::pair< OmniClusterRef, TrackingParticleRef > P
Definition: BDHadronTrackMonitoringAnalyzer.cc:202
HLT_FULL_cff.distance
distance
Definition: HLT_FULL_cff.py:7799
MagneticField
Definition: MagneticField.h:19
AnalyticalTrajectoryExtrapolatorToLine
Definition: AnalyticalTrajectoryExtrapolatorToLine.h:28
A
AnalyticalTrajectoryExtrapolatorToLine::extrapolate
TrajectoryStateOnSurface extrapolate(const FreeTrajectoryState &fts, const Line &L) const
extrapolation from FreeTrajectoryState
Definition: AnalyticalTrajectoryExtrapolatorToLine.cc:22
AnalyticalTrajectoryExtrapolatorToLine.h
weight
Definition: weight.py:1
reco::Vertex
Definition: Vertex.h:35
TrajectoryStateOnSurface::isValid
bool isValid() const
Definition: TrajectoryStateOnSurface.h:54
DeadROC_duringRun.dir
dir
Definition: DeadROC_duringRun.py:23