CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/PhysicsTools/SelectorUtils/interface/PVSelector.h

Go to the documentation of this file.
00001 #ifndef Analysis_AnalysisFilters_interface_PVSelector_h
00002 #define Analysis_AnalysisFilters_interface_PVSelector_h
00003 
00004 #include "FWCore/Common/interface/EventBase.h"
00005 #include "DataFormats/Common/interface/Handle.h"
00006 
00007 #include "PhysicsTools/SelectorUtils/interface/EventSelector.h"
00008 #include "PhysicsTools/SelectorUtils/interface/PVObjectSelector.h"
00009 
00010 
00011 // make a selector for this selection
00012 class PVSelector : public Selector<edm::EventBase> {
00013 public:
00014 
00015   PVSelector() {}
00016 
00017  PVSelector( edm::ParameterSet const & params ) :
00018   pvSrc_ (params.getParameter<edm::InputTag>("pvSrc") ),
00019   pvSel_ (params) 
00020   {
00021     retInternal_ = getBitTemplate();
00022   }
00023   
00024   bool operator() ( edm::EventBase const & event,  pat::strbitset & ret ) {
00025     event.getByLabel(pvSrc_, h_primVtx);
00026 
00027     // check if there is a good primary vertex
00028 
00029     if ( h_primVtx->size() < 1 ) return false;
00030 
00031     reco::Vertex const & pv = h_primVtx->at(0);
00032 
00033     return pvSel_( pv );
00034   }
00035 
00036   using EventSelector::operator();
00037 
00038   edm::Handle<std::vector<reco::Vertex> > const & vertices() const { return h_primVtx; }
00039 
00040 private:
00041   edm::InputTag                           pvSrc_;
00042   PVObjectSelector                        pvSel_;
00043   edm::Handle<std::vector<reco::Vertex> > h_primVtx;
00044 };
00045 
00046 #endif