CMS 3D CMS Logo

List of all members | Public Member Functions
ConversionHitChecker Class Reference

#include <ConversionHitChecker.h>

Public Member Functions

 ConversionHitChecker ()
 
std::pair< uint8_t, Measurement1DFloatnHitsBeforeVtx (const reco::TrackExtra &track, const reco::Vertex &vtx, float 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::ConversionHitChecker ( )
inline

Definition at line 33 of file ConversionHitChecker.h.

33 {}

◆ ~ConversionHitChecker()

ConversionHitChecker::~ConversionHitChecker ( )
inline

Definition at line 34 of file ConversionHitChecker.h.

34 {}

Member Function Documentation

◆ nHitsBeforeVtx()

std::pair< uint8_t, Measurement1DFloat > ConversionHitChecker::nHitsBeforeVtx ( const reco::TrackExtra track,
const reco::Vertex vtx,
float  sigmaTolerance = 3.0 
) const

Definition at line 8 of file ConversionHitChecker.cc.

References pv::closest(), listHistos::decayLength, dot(), h, dqmiolumiharvest::j, mag2(), nhits, position, rpcPointValidation_cfi::recHit, mathSSE::sqrt(), HLT_2024v12_cff::track, and L1BJetProducer_cff::vtx.

Referenced by ConversionProducer::buildCollection().

10  {
11  // track hits are always inout
12 
13  GlobalPoint vtxPos(vtx.x(), vtx.y(), vtx.z());
14 
15  auto const &trajParams = track.trajParams();
16 
17  //iterate inside out, when distance to vertex starts increasing, we are at the closest hit
18  // the first (and last, btw) hit is always valid... (apparntly not..., conversion is different????)
19  TrackingRecHit const *recHit = *track.recHits().begin();
20  unsigned int closest = 0;
21  for (auto const &hit : track.recHits()) {
22  if (hit->isValid()) {
23  recHit = hit;
24  break;
25  }
26  ++closest;
27  }
28  auto globalPosition = recHit->surface()->toGlobal(trajParams[closest].position());
29  auto distance2 = (vtxPos - globalPosition).mag2();
30  int nhits = 1;
31  for (unsigned int h = closest + 1; h < track.recHitsSize(); ++h) {
32  //check if next valid hit is farther away from vertex than existing closest
33  auto nextHit = track.recHit(h);
34  if (!nextHit->isValid())
35  continue;
36  globalPosition = nextHit->surface()->toGlobal(trajParams[h].position());
37  auto nextDistance2 = (vtxPos - globalPosition).mag2();
38  if (nextDistance2 > distance2)
39  break;
40 
41  distance2 = nextDistance2;
42  ++nhits;
43  closest = h;
44  }
45 
46  //compute signed decaylength significance for closest hit and check if it is before the vertex
47  //if not then we need to subtract it from the count of hits before the vertex, since it has been implicitly included
48  recHit = track.recHit(closest).get();
49  auto momDir = recHit->surface()->toGlobal(trajParams[closest].direction());
50  globalPosition = recHit->surface()->toGlobal(trajParams[closest].position());
51  float decayLengthHitToVtx = (vtxPos - globalPosition).dot(momDir);
52 
54  j[0] = momDir.x();
55  j[1] = momDir.y();
56  j[2] = momDir.z();
57  float vertexError2 = ROOT::Math::Similarity(j, vtx.covariance());
58  auto decayLenError = std::sqrt(vertexError2);
59 
60  Measurement1DFloat decayLength(decayLengthHitToVtx, decayLenError);
61 
62  if (decayLength.significance() <
63  sigmaTolerance) { //decay length is not (significantly) positive, so hit is consistent with the vertex position or late
64  //subtract it from wrong hits count
65  --nhits;
66  }
67 
68  return std::pair<unsigned int, Measurement1DFloat>(nhits, decayLength);
69 }
int closest(std::vector< int > const &vec, int value)
T dot(const Basic3DVector &v) const
Scalar product, or "dot" product, with a vector of same type.
T sqrt(T t)
Definition: SSEVec.h:19
T mag2() const
The vector magnitude squared. Equivalent to vec.dot(vec)
static int position[264][3]
Definition: ReadPGInfo.cc:289
ROOT::Math::SVector< double, 3 > AlgebraicVector3
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4

◆ nSharedHits()

uint8_t ConversionHitChecker::nSharedHits ( const reco::Track trk1,
const reco::Track trk2 
) const

Definition at line 71 of file ConversionHitChecker.cc.

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

Referenced by ConversionProducer::buildCollection().

71  {
72  uint8_t nShared = 0;
73 
74  for (trackingRecHit_iterator iHit1 = trk1.recHitsBegin(); iHit1 != trk1.recHitsEnd(); ++iHit1) {
75  const TrackingRecHit *hit1 = (*iHit1);
76  if (hit1->isValid()) {
77  for (trackingRecHit_iterator iHit2 = trk2.recHitsBegin(); iHit2 != trk2.recHitsEnd(); ++iHit2) {
78  const TrackingRecHit *hit2 = (*iHit2);
79  if (hit2->isValid() && hit1->sharesInput(hit2, TrackingRecHit::some)) {
80  ++nShared;
81  }
82  }
83  }
84  }
85 
86  return nShared;
87 }
virtual bool sharesInput(const TrackingRecHit *other, SharedInputType what) const
bool isValid() const
trackingRecHit_iterator recHitsEnd() const
Iterator to last hit on the track.
Definition: Track.h:91
trackingRecHit_iterator recHitsBegin() const
Iterator to first hit on the track.
Definition: Track.h:88