File indexing completed on 2023-03-17 10:45:38
0001 #ifndef RecoAlgos_SingleElementCollectionSelectorPlusEvent_h
0002 #define RecoAlgos_SingleElementCollectionSelectorPlusEvent_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #include "FWCore/Framework/interface/ConsumesCollector.h"
0016 #include "CommonTools/UtilAlgos/interface/SelectionAdderTrait.h"
0017 #include "CommonTools/UtilAlgos/interface/StoreContainerTrait.h"
0018 #include "CommonTools/UtilAlgos/interface/ParameterAdapter.h"
0019 #include "CommonTools/UtilAlgos/interface/SelectedOutputCollectionTrait.h"
0020
0021 namespace edm {
0022 class Event;
0023 class EventSetup;
0024 }
0025
0026 template <typename InputCollection,
0027 typename Selector,
0028 typename OutputCollection = typename helper::SelectedOutputCollectionTrait<InputCollection>::type,
0029 typename StoreContainer = typename helper::StoreContainerTrait<OutputCollection>::type,
0030 typename RefAdder = typename helper::SelectionAdderTrait<InputCollection, StoreContainer>::type>
0031 struct SingleElementCollectionSelectorPlusEvent {
0032 typedef InputCollection collection;
0033 typedef StoreContainer container;
0034 typedef typename container::const_iterator const_iterator;
0035 SingleElementCollectionSelectorPlusEvent(const edm::ParameterSet &cfg, edm::ConsumesCollector &&iC)
0036 : select_(reco::modules::make<Selector>(cfg, iC)) {}
0037 const_iterator begin() const { return selected_.begin(); }
0038 const_iterator end() const { return selected_.end(); }
0039 void select(const edm::Handle<InputCollection> &c, const edm::Event &ev, const edm::EventSetup &) {
0040 selected_.clear();
0041 for (size_t idx = 0; idx < c->size(); ++idx) {
0042 if (select_(edm::Ref<InputCollection>(c, idx), ev))
0043 addRef_(selected_, c, idx);
0044 }
0045 }
0046
0047 private:
0048 StoreContainer selected_;
0049 Selector select_;
0050 RefAdder addRef_;
0051 };
0052
0053 #endif