CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions
ConversionHitChecker Class Reference

#include <ConversionHitChecker.h>

Public Member Functions

 ConversionHitChecker ()
 
std::pair< uint8_t,
Measurement1DFloat
nHitsBeforeVtx (const Trajectory &traj, const reco::Vertex &vtx, double sigmaTolerance=3.0) const
 
uint8_t nSharedHits (const reco::Track &trk1, const reco::Track &trk2) const
 
 ~ConversionHitChecker ()
 

Detailed Description

Author
J.Bendavid
Version
Check hits along a Trajectory and count how many are before the vertex position. (taking into account the uncertainty in the vertex and hit positions. Also returns a the signed decay length and uncertainty from the closest hit on the track to the vertex position.

Definition at line 31 of file ConversionHitChecker.h.

Constructor & Destructor Documentation

ConversionHitChecker::ConversionHitChecker ( )
inline

Definition at line 35 of file ConversionHitChecker.h.

35 {}
ConversionHitChecker::~ConversionHitChecker ( )
inline

Definition at line 36 of file ConversionHitChecker.h.

36 {}

Member Function Documentation

std::pair< uint8_t, Measurement1DFloat > ConversionHitChecker::nHitsBeforeVtx ( const Trajectory traj,
const reco::Vertex vtx,
double  sigmaTolerance = 3.0 
) const

Definition at line 12 of file ConversionHitChecker.cc.

References alongMomentum, reco::Vertex::covariance(), listHistos::decayLength, Trajectory::direction(), HLT_25ns14e33_v1_cff::distance, dot(), j, findQualityFiles::jj, mag(), Trajectory::measurements(), Measurement1DFloat::significance(), mathSSE::sqrt(), Vector3DBase< T, FrameTag >::unit(), PV3DBase< T, PVType, FrameType >::x(), reco::Vertex::x(), PV3DBase< T, PVType, FrameType >::y(), reco::Vertex::y(), PV3DBase< T, PVType, FrameType >::z(), and reco::Vertex::z().

Referenced by ConversionProducer::buildCollection().

12  {
13 
14  const std::vector<TrajectoryMeasurement> &measurements = traj.measurements();
15 
16  //protect for empty trajectory
17  if (measurements.size()==0) {
18  return std::pair<unsigned int,Measurement1DFloat>(0,Measurement1DFloat());
19  }
20 
21  //check ordering of measurements in trajectory
22  bool inout = (traj.direction() == alongMomentum);
23 
24  GlobalPoint vtxPos(vtx.x(),vtx.y(),vtx.z());
25 
26  uint8_t nhits = 0;
27 
28  std::vector<TrajectoryMeasurement>::const_iterator closest = measurements.begin();
29  double distance = 1e6;
30  //iterate inside out, when distance to vertex starts increasing, we are at the closest hit
31  for (std::vector<TrajectoryMeasurement>::const_iterator fwdit = measurements.begin(), revit = measurements.end()-1;
32  fwdit != measurements.end(); ++fwdit,--revit) {
33 
34  std::vector<TrajectoryMeasurement>::const_iterator it;
35  if (inout) {
36  it = fwdit;
37  }
38  else {
39  it = revit;
40  }
41 
42  //increment hit counter, compute distance and set iterator if this hit is valid
43  if (it->recHit() && it->recHit()->isValid()) {
44  ++nhits;
45  distance = (vtxPos - it->updatedState().globalPosition()).mag();
46  closest = it;
47  }
48 
49  if ( (measurements.end()-fwdit)==1) {
50  break;
51  }
52 
53  //check if next valid hit is farther away from vertex than existing closest
54  std::vector<TrajectoryMeasurement>::const_iterator nextit;
55  if (inout) {
56  nextit = it+1;
57  }
58  else {
59  nextit = it-1;
60  }
61 
62 
63  if ( nextit->recHit() && nextit->recHit()->isValid() ) {
64  double nextDistance = (vtxPos - nextit->updatedState().globalPosition()).mag();
65  if (nextDistance > distance) {
66  break;
67  }
68  }
69 
70  }
71 
72  //compute signed decaylength significance for closest hit and check if it is before the vertex
73  //if not then we need to subtract it from the count of hits before the vertex, since it has been implicitly included
74 
75  GlobalVector momDir = closest->updatedState().globalMomentum().unit();
76  double decayLengthHitToVtx = (vtxPos - closest->updatedState().globalPosition()).dot(momDir);
77 
79  j[0] = momDir.x();
80  j[1] = momDir.y();
81  j[2] = momDir.z();
83  jj[0] = momDir.x();
84  jj[1] = momDir.y();
85  jj[2] = momDir.z();
86  jj[3] =0.;
87  jj[4] =0.;
88  jj[5] =0.;
89 
90  //TODO: In principle the hit measurement position is correlated with the vertex fit
91  //at worst though we inflate the uncertainty by a factor of two
92  double trackError2 = ROOT::Math::Similarity(jj,closest->updatedState().cartesianError().matrix());
93  double vertexError2 = ROOT::Math::Similarity(j,vtx.covariance());
94  double decayLenError = sqrt(trackError2+vertexError2);
95 
96  Measurement1DFloat decayLength(decayLengthHitToVtx,decayLenError);
97 
98  if (decayLength.significance() < sigmaTolerance) { //decay length is not (significantly) positive, so hit is consistent with the vertex position or late
99  //subtract it from wrong hits count
100  --nhits;
101  }
102 
103  return std::pair<unsigned int,Measurement1DFloat>(nhits,decayLength);
104 
105 }
tuple decayLength
Definition: listHistos.py:101
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
double y() const
y coordinate
Definition: Vertex.h:110
T y() const
Definition: PV3DBase.h:63
double covariance(int i, int j) const
(i, j)-th element of error matrix, i, j = 0, ... 2
Definition: Vertex.h:123
ROOT::Math::SVector< double, 6 > AlgebraicVector6
PropagationDirection const & direction() const
Definition: Trajectory.cc:118
DataContainer const & measurements() const
Definition: Trajectory.h:203
T sqrt(T t)
Definition: SSEVec.h:48
T z() const
Definition: PV3DBase.h:64
ROOT::Math::SVector< double, 3 > AlgebraicVector3
int j
Definition: DBlmapReader.cc:9
double z() const
y coordinate
Definition: Vertex.h:112
Vector3DBase unit() const
Definition: Vector3DBase.h:57
double x() const
x coordinate
Definition: Vertex.h:108
T dot(const Basic3DVector &v) const
Scalar product, or &quot;dot&quot; product, with a vector of same type.
T x() const
Definition: PV3DBase.h:62
uint8_t ConversionHitChecker::nSharedHits ( const reco::Track trk1,
const reco::Track trk2 
) const

Definition at line 107 of file ConversionHitChecker.cc.

References TrackingRecHit::isValid(), reco::Track::recHitsBegin(), reco::Track::recHitsEnd(), TrackingRecHit::sharesInput(), and TrackingRecHit::some.

Referenced by ConversionProducer::buildCollection().

107  {
108 
109  uint8_t nShared = 0;
110 
111  for (trackingRecHit_iterator iHit1 = trk1.recHitsBegin(); iHit1 != trk1.recHitsEnd(); ++iHit1) {
112  const TrackingRecHit *hit1 = (*iHit1);
113  if (hit1->isValid()) {
114  for (trackingRecHit_iterator iHit2 = trk2.recHitsBegin(); iHit2 != trk2.recHitsEnd(); ++iHit2) {
115  const TrackingRecHit *hit2 = (*iHit2);
116  if (hit2->isValid() && hit1->sharesInput(hit2,TrackingRecHit::some)) {
117  ++nShared;
118  }
119  }
120  }
121  }
122 
123  return nShared;
124 
125 }
virtual bool sharesInput(const TrackingRecHit *other, SharedInputType what) const
trackingRecHit_iterator recHitsBegin() const
Iterator to first hit on the track.
Definition: Track.h:104
bool isValid() const
TrackingRecHitCollection::base::const_iterator trackingRecHit_iterator
iterator over a vector of reference to TrackingRecHit in the same collection
trackingRecHit_iterator recHitsEnd() const
Iterator to last hit on the track.
Definition: Track.h:109