CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_7_hltpatch1/src/CommonTools/UtilAlgos/interface/OverlapExclusionSelector.h

Go to the documentation of this file.
00001 #ifndef CommonTools_UtilAlgos_OverlapExclusionSelector_h
00002 #define CommonTools_UtilAlgos_OverlapExclusionSelector_h
00003 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00004 #include "FWCore/Utilities/interface/InputTag.h"
00005 #include "FWCore/Framework/interface/Event.h"
00006 #include "DataFormats/Common/interface/Handle.h"
00007 
00008 namespace edm { class EventSetup; }
00009 
00010 template<typename C, typename T, typename O>
00011 class OverlapExclusionSelector {
00012 public:
00013   OverlapExclusionSelector(const edm::ParameterSet&);
00014   void newEvent(const edm::Event&, const edm::EventSetup&) const;
00015   bool operator()(const T&) const;
00016 private:
00017   edm::InputTag src_;
00018   mutable typename C::const_iterator begin_, end_;
00019   O overlap_;
00020 };
00021 
00022 template<typename C, typename T, typename O>
00023 OverlapExclusionSelector<C, T, O>::OverlapExclusionSelector(const edm::ParameterSet& cfg) :
00024   src_(cfg.template getParameter<edm::InputTag>("overlap")),
00025   overlap_(cfg) {
00026 }
00027 
00028 template<typename C, typename T, typename O>
00029        void OverlapExclusionSelector<C, T, O>::newEvent(const edm::Event& evt, const edm::EventSetup&) const {
00030   edm::Handle<C> h;
00031   evt.getByLabel(src_, h);
00032   begin_ = h->begin();
00033   end_ = h->end();
00034 }
00035 
00036 template<typename C, typename T, typename O>
00037 bool OverlapExclusionSelector<C, T, O>::operator()(const T& t) const {
00038   bool noOverlap = true;
00039   for(typename C::const_iterator i = begin_; i != end_; ++i) {
00040     if(overlap_(*i, t)) {
00041       noOverlap = false;
00042       break;
00043     } 
00044   }
00045   return noOverlap;
00046 }
00047 
00048 #include "CommonTools/UtilAlgos/interface/EventSetupInitTrait.h"
00049 
00050 EVENTSETUP_STD_INIT_T3(OverlapExclusionSelector);
00051 
00052 #endif