CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
calculateVertexSharedTracks.cc
Go to the documentation of this file.
2 
3 unsigned int calculateVertexSharedTracks(const reco::Vertex& recoV, const TrackingVertex& simV, const reco::RecoToSimCollection& trackRecoToSimAssociation) {
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 }
24 
25 unsigned int calculateVertexSharedTracks(const TrackingVertex& simV, const reco::Vertex& recoV, const reco::SimToRecoCollection& trackSimToRecoAssociation) {
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
unsigned int calculateVertexSharedTracks(const reco::Vertex &recoV, const TrackingVertex &simV, const reco::RecoToSimCollection &trackRecoToSimAssociation)
trackRef_iterator tracks_begin() const
first iterator over tracks
Definition: Vertex.cc:39