CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions
calculateVertexSharedTracks.h File Reference
#include "DataFormats/RecoCandidate/interface/TrackAssociation.h"
#include "DataFormats/VertexReco/interface/Vertex.h"
#include "SimDataFormats/TrackingAnalysis/interface/TrackingVertex.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

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

Definition at line 3 of file calculateVertexSharedTracks.cc.

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().

Referenced by VertexAssociatorByPositionAndTracks::associateRecoToSim(), VertexAssociatorByPositionAndTracks::associateSimToReco(), and PrimaryVertexAnalyzer4PUSlimmed::matchReco2SimVertices().

3  {
4  unsigned int sharedTracks = 0;
5  for(auto iTrack = recoV.tracks_begin(); iTrack != recoV.tracks_end(); ++iTrack) {
6  auto found = trackRecoToSimAssociation.find(*iTrack);
7 
8  if(found == trackRecoToSimAssociation.end())
9  continue;
10 
11  // matched TP equal to any TP of sim vertex => increase counter
12  for(const auto& tp: found->val) {
13  if(std::find_if(simV.daughterTracks_begin(), simV.daughterTracks_end(), [&](const TrackingParticleRef& vtp) {
14  return tp.first == vtp;
15  }) != simV.daughterTracks_end()) {
16  sharedTracks += 1;
17  break;
18  }
19  }
20  }
21 
22  return sharedTracks;
23 }
tp_iterator daughterTracks_begin() const
trackRef_iterator tracks_end() const
last iterator over tracks
Definition: Vertex.cc:44
const_iterator end() const
last iterator over the map (read only)
const_iterator find(const key_type &k) const
find element with specified reference key
tp_iterator daughterTracks_end() const
trackRef_iterator tracks_begin() const
first iterator over tracks
Definition: Vertex.cc:39
unsigned int calculateVertexSharedTracks ( const TrackingVertex simV,
const reco::Vertex recoV,
const reco::SimToRecoCollection trackSimToRecoAssociation 
)

Definition at line 25 of file calculateVertexSharedTracks.cc.

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().

25  {
26  unsigned int sharedTracks = 0;
27  for(auto iTP = simV.daughterTracks_begin(); iTP != simV.daughterTracks_end(); ++iTP) {
28  auto found = trackSimToRecoAssociation.find(*iTP);
29 
30  if(found == trackSimToRecoAssociation.end())
31  continue;
32 
33  // matched track equal to any track of reco vertex => increase counter
34  for(const auto& tk: found->val) {
35  if(std::find_if(recoV.tracks_begin(), recoV.tracks_end(), [&](const reco::TrackBaseRef& vtk) {
36  return tk.first == vtk;
37  }) != recoV.tracks_end()) {
38  sharedTracks += 1;
39  break;
40  }
41  }
42  }
43 
44  return sharedTracks;
45 }
tp_iterator daughterTracks_begin() const
trackRef_iterator tracks_end() const
last iterator over tracks
Definition: Vertex.cc:44
const_iterator end() const
last iterator over the map (read only)
const_iterator find(const key_type &k) const
find element with specified reference key
tp_iterator daughterTracks_end() const
trackRef_iterator tracks_begin() const
first iterator over tracks
Definition: Vertex.cc:39