CMS 3D CMS Logo

JetTrackMatch.h

Go to the documentation of this file.
00001 #ifndef JetReco_JetTrackMatch_h
00002 #define JetReco_JetTrackMatch_h
00003 
00034 #include "DataFormats/Common/interface/AssociationMap.h"
00035 #include "DataFormats/TrackReco/interface/Track.h"
00036 #include "DataFormats/TrackReco/interface/TrackFwd.h"
00037 
00038 namespace reco {
00039   template <typename JetC>
00040     class JetTrackMatch {
00041     public:
00042     typedef edm::Ref<JetC> JetRef;
00043     typedef edm::Ref<reco::TrackCollection> TrackRef;
00044     typedef edm::AssociationMap<edm::OneToMany<JetC, reco::TrackCollection> > Map;
00045     private:
00046     Map mMap;
00047 
00048     public:
00049     JetTrackMatch () {}
00050     ~JetTrackMatch () {}
00051 
00053     void insert (const JetRef& fJet) {
00054       mMap.insert (fJet, TrackRef());
00055     }
00056 
00058     void insert (const JetRef& fJet, const TrackRef& fTrack) {
00059       mMap.insert (fJet, fTrack);
00060     }
00061 
00063     std::vector <JetRef> allJets () const {
00064       std::vector <JetRef> result;
00065       typename Map::const_iterator it = mMap.begin ();
00066       for (; it != mMap.end(); ++it) {
00067         result.push_back (it->key);
00068       }
00069       return result;
00070     }
00072     std::vector <TrackRef> getTracks (const JetRef& mJet) const {
00073       std::vector <TrackRef> result;
00074       reco::TrackRefVector tracks = mMap [mJet];
00075       int i = tracks.size();
00076       while (--i >= 0) {
00077         if (!tracks [i].isNull ()) result.push_back (tracks [i]);
00078       }
00079       return result;
00080     }
00081   };
00082 }
00083 
00084 #endif

Generated on Tue Jun 9 17:31:07 2009 for CMSSW by  doxygen 1.5.4