CMS 3D CMS Logo

Functions
calculateVertexSharedTracks.cc File Reference
#include "SimTracker/VertexAssociation/interface/calculateVertexSharedTracks.h"

Go to the source code of this file.

Functions

unsigned int calculateVertexSharedTracks (const reco::Vertex &recoV, const TrackingVertex &simV, const reco::RecoToSimCollection &trackRecoToSimAssociation)
 
unsigned int calculateVertexSharedTracks (const TrackingVertex &simV, const reco::Vertex &recoV, const reco::SimToRecoCollection &trackSimToRecoAssociation)
 

Function Documentation

◆ calculateVertexSharedTracks() [1/2]

unsigned int calculateVertexSharedTracks ( const reco::Vertex recoV,
const TrackingVertex simV,
const reco::RecoToSimCollection trackRecoToSimAssociation 
)

Definition at line 3 of file calculateVertexSharedTracks.cc.

5  {
6  unsigned int sharedTracks = 0;
7  for (auto iTrack = recoV.tracks_begin(); iTrack != recoV.tracks_end(); ++iTrack) {
8  auto found = trackRecoToSimAssociation.find(*iTrack);
9 
10  if (found == trackRecoToSimAssociation.end())
11  continue;
12 
13  // matched TP equal to any TP of sim vertex => increase counter
14  for (const auto &tp : found->val) {
15  if (std::find_if(simV.daughterTracks_begin(), simV.daughterTracks_end(), [&](const TrackingParticleRef &vtp) {
16  return tp.first == vtp;
17  }) != simV.daughterTracks_end()) {
18  sharedTracks += 1;
19  break;
20  }
21  }
22  }
23 
24  return sharedTracks;
25 }

References TrackingVertex::daughterTracks_begin(), TrackingVertex::daughterTracks_end(), edm::AssociationMap< Tag >::end(), edm::AssociationMap< Tag >::find(), newFWLiteAna::found, cmsswSequenceInfo::tp, reco::Vertex::tracks_begin(), and reco::Vertex::tracks_end().

◆ calculateVertexSharedTracks() [2/2]

unsigned int calculateVertexSharedTracks ( const TrackingVertex simV,
const reco::Vertex recoV,
const reco::SimToRecoCollection trackSimToRecoAssociation 
)

Definition at line 27 of file calculateVertexSharedTracks.cc.

29  {
30  unsigned int sharedTracks = 0;
31  for (auto iTP = simV.daughterTracks_begin(); iTP != simV.daughterTracks_end(); ++iTP) {
32  auto found = trackSimToRecoAssociation.find(*iTP);
33 
34  if (found == trackSimToRecoAssociation.end())
35  continue;
36 
37  // matched track equal to any track of reco vertex => increase counter
38  for (const auto &tk : found->val) {
39  if (std::find_if(recoV.tracks_begin(), recoV.tracks_end(), [&](const reco::TrackBaseRef &vtk) {
40  return tk.first == vtk;
41  }) != recoV.tracks_end()) {
42  sharedTracks += 1;
43  break;
44  }
45  }
46  }
47 
48  return sharedTracks;
49 }

References TrackingVertex::daughterTracks_begin(), TrackingVertex::daughterTracks_end(), edm::AssociationMap< Tag >::end(), edm::AssociationMap< Tag >::find(), newFWLiteAna::found, reco::Vertex::tracks_begin(), and reco::Vertex::tracks_end().

edm::AssociationMap::find
const_iterator find(const key_type &k) const
find element with specified reference key
Definition: AssociationMap.h:173
TrackingVertex::daughterTracks_begin
tp_iterator daughterTracks_begin() const
Definition: TrackingVertex.cc:42
TrackingVertex::daughterTracks_end
tp_iterator daughterTracks_end() const
Definition: TrackingVertex.cc:43
newFWLiteAna.found
found
Definition: newFWLiteAna.py:118
edm::Ref< TrackingParticleCollection >
edm::AssociationMap::end
const_iterator end() const
last iterator over the map (read only)
Definition: AssociationMap.h:171
reco::Vertex::tracks_end
trackRef_iterator tracks_end() const
last iterator over tracks
Definition: Vertex.cc:73
cmsswSequenceInfo.tp
tp
Definition: cmsswSequenceInfo.py:17
reco::Vertex::tracks_begin
trackRef_iterator tracks_begin() const
first iterator over tracks
Definition: Vertex.cc:71
edm::RefToBase< reco::Track >