CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/CommonTools/RecoAlgos/interface/RecoTrackRefSelector.h

Go to the documentation of this file.
00001 #ifndef RecoSelectors_RecoTrackRefSelector_h
00002 #define RecoSelectors_RecoTrackRefSelector_h
00003 /* \class RecoTrackRefSelector
00004  *
00005  * \author Ian Tomalin, RAL
00006  *
00007  *  $Date: 2010/02/11 00:10:49 $
00008  *  $Revision: 1.2 $
00009  *
00010  */
00011 #include "DataFormats/TrackReco/interface/Track.h"
00012 #include "DataFormats/TrackReco/interface/TrackFwd.h"
00013 #include "DataFormats/BeamSpot/interface/BeamSpot.h"
00014 #include "FWCore/Utilities/interface/InputTag.h"
00015 #include "CommonTools/RecoAlgos/interface/RecoTrackSelector.h"
00016 
00017 class RecoTrackRefSelector : public RecoTrackSelector {
00018 
00019   // Would be better for RecoTrackRefSelector and RecoTrackSelector to inherit from common base class,
00020   // since this doesn't needed the "selected_" data member from the base class.
00021   // To do in future ...
00022 
00023  public:
00024   typedef reco::TrackRefVector ref_container;
00025   typedef ref_container::const_iterator const_ref_iterator;
00026 
00028   RecoTrackRefSelector() {}
00029 
00030   RecoTrackRefSelector ( const edm::ParameterSet & cfg ) : RecoTrackSelector(cfg) {}
00031   
00032   RecoTrackRefSelector ( double ptMin, double minRapidity, double maxRapidity,
00033                          double tip, double lip, int minHit, int min3DHit, double maxChi2, 
00034                          std::vector<std::string> quality , std::vector<std::string> algorithm ) :
00035           RecoTrackSelector ( ptMin, minRapidity, maxRapidity,
00036                               tip, lip, minHit, min3DHit, maxChi2, 
00037                               quality , algorithm ) {}
00038 
00039   const_ref_iterator begin() const { return ref_selected_.begin(); }
00040   const_ref_iterator end() const { return ref_selected_.end(); }
00041   
00042   void select( const edm::Handle<collection>& c, const edm::Event & event, const edm::EventSetup&) {
00043     ref_selected_.clear();
00044     edm::Handle<reco::BeamSpot> beamSpot;
00045     event.getByLabel(bsSrc_,beamSpot);
00046     for (unsigned int i = 0; i < c->size(); i++) {
00047 
00048       edm::Ref<collection> trk(c, i);
00049  
00050       if ( operator()(*trk,beamSpot.product()) ) {
00051         ref_selected_.push_back( trk );
00052       }
00053     }
00054   }
00055 
00056   size_t size() const { return ref_selected_.size(); }
00057   
00058  private:
00059   ref_container ref_selected_;
00060 };
00061 
00062 #endif