Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:30:49

0001 #include "SimTracker/VertexAssociation/interface/calculateVertexSharedTracks.h"
0002 
0003 unsigned int calculateVertexSharedTracks(const reco::Vertex &recoV,
0004                                          const TrackingVertex &simV,
0005                                          const reco::RecoToSimCollection &trackRecoToSimAssociation) {
0006   unsigned int sharedTracks = 0;
0007   for (auto iTrack = recoV.tracks_begin(); iTrack != recoV.tracks_end(); ++iTrack) {
0008     auto found = trackRecoToSimAssociation.find(*iTrack);
0009 
0010     if (found == trackRecoToSimAssociation.end())
0011       continue;
0012 
0013     // matched TP equal to any TP of sim vertex => increase counter
0014     for (const auto &tp : found->val) {
0015       if (std::find_if(simV.daughterTracks_begin(), simV.daughterTracks_end(), [&](const TrackingParticleRef &vtp) {
0016             return tp.first == vtp;
0017           }) != simV.daughterTracks_end()) {
0018         sharedTracks += 1;
0019         break;
0020       }
0021     }
0022   }
0023 
0024   return sharedTracks;
0025 }
0026 
0027 unsigned int calculateVertexSharedTracks(const TrackingVertex &simV,
0028                                          const reco::Vertex &recoV,
0029                                          const reco::SimToRecoCollection &trackSimToRecoAssociation) {
0030   unsigned int sharedTracks = 0;
0031   for (auto iTP = simV.daughterTracks_begin(); iTP != simV.daughterTracks_end(); ++iTP) {
0032     auto found = trackSimToRecoAssociation.find(*iTP);
0033 
0034     if (found == trackSimToRecoAssociation.end())
0035       continue;
0036 
0037     // matched track equal to any track of reco vertex => increase counter
0038     for (const auto &tk : found->val) {
0039       if (std::find_if(recoV.tracks_begin(), recoV.tracks_end(), [&](const reco::TrackBaseRef &vtk) {
0040             return tk.first == vtk;
0041           }) != recoV.tracks_end()) {
0042         sharedTracks += 1;
0043         break;
0044       }
0045     }
0046   }
0047 
0048   return sharedTracks;
0049 }