Go to the documentation of this file.00001 #ifndef RecoAlgos_SingleElementCollectionSelectorPlusEvent_h
00002 #define RecoAlgos_SingleElementCollectionSelectorPlusEvent_h
00003
00015 #include "CommonTools/UtilAlgos/interface/SelectionAdderTrait.h"
00016 #include "CommonTools/UtilAlgos/interface/StoreContainerTrait.h"
00017 #include "CommonTools/UtilAlgos/interface/ParameterAdapter.h"
00018
00019 template<typename InputCollection, typename Selector,
00020 typename OutputCollection = typename helper::SelectedOutputCollectionTrait<InputCollection>::type,
00021 typename StoreContainer = typename helper::StoreContainerTrait<OutputCollection>::type,
00022 typename RefAdder = typename helper::SelectionAdderTrait<InputCollection, StoreContainer>::type>
00023 struct SingleElementCollectionSelectorPlusEvent {
00024 typedef InputCollection collection;
00025 typedef StoreContainer container;
00026 typedef typename container::const_iterator const_iterator;
00027 SingleElementCollectionSelectorPlusEvent( const edm::ParameterSet & cfg ) :
00028 select_( reco::modules::make<Selector>( cfg ) ) { }
00029 const_iterator begin() const { return selected_.begin(); }
00030 const_iterator end() const { return selected_.end(); }
00031 void select(const edm::Handle<InputCollection> & c, const edm::Event &ev, const edm::EventSetup &) {
00032 selected_.clear();
00033 for(size_t idx = 0; idx < c->size(); ++ idx) {
00034 if(select_((*c)[idx], ev))
00035 addRef_(selected_, c, idx);
00036 }
00037 }
00038 private:
00039 StoreContainer selected_;
00040 Selector select_;
00041 RefAdder addRef_;
00042 };
00043
00044 #endif