CMS 3D CMS Logo

JetTrackAssociator.h

Go to the documentation of this file.
00001 #ifndef JetProducers_JetTrackAssociator_h
00002 #define JetProducers_JetTrackAssociator_h
00003 
00008 
00009 #include "FWCore/Utilities/interface/Exception.h"
00010 #include "DataFormats/JetReco/interface/JetTrackMatch.h"
00011 
00012 
00013 template <typename JetC>
00014 class JetTrackAssociator {
00015  public:
00016   typedef edm::Ref<JetC> JetRef;
00017   typedef reco::TrackCollection TrackC;
00018   typedef edm::Ref<TrackC> TrackRef;
00019   typedef reco::JetTrackMatch<JetC> MatchMap;
00020   JetTrackAssociator () {}
00021   virtual ~JetTrackAssociator () {}
00022 
00024   virtual bool associate (const JetRef& fJet, const TrackRef& fTrack) const = 0;
00025 
00027   virtual bool goodTrack (const TrackRef& fTrack) const {return true;}
00028 
00030   void buildMap (const edm::Handle<JetC>& fJets, const edm::Handle<TrackC>& fTracks, MatchMap* fMap) const {
00031     if (!fMap) {
00032       throw cms::Exception ("JetTrackAssociator") << " Invalid supplied matching map pointer" << std::endl;
00033     }
00034     for (unsigned iJet = 0; iJet < fJets->size(); ++iJet) {
00035       typename MatchMap::JetRef jetRef (fJets, iJet);  
00036       bool orphanJet = true;
00037       for (unsigned iTrack = 0; iTrack < fTracks->size(); ++iTrack) {
00038         typename MatchMap::TrackRef trackRef (fTracks, iTrack); 
00039         if (goodTrack (trackRef) && associate (jetRef, trackRef)) {
00040           fMap->insert (jetRef, trackRef);
00041           orphanJet = false;
00042         }
00043       }
00044       if (orphanJet) fMap->insert (jetRef);
00045     }
00046   }
00047 };
00048 
00049 #endif

Generated on Tue Jun 9 17:43:38 2009 for CMSSW by  doxygen 1.5.4