File indexing completed on 2025-02-05 23:51:10
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 "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0017 #include "CommonTools/UtilAlgos/interface/SelectionAdderTrait.h"
0018 #include "CommonTools/UtilAlgos/interface/StoreContainerTrait.h"
0019 #include "CommonTools/UtilAlgos/interface/ParameterAdapter.h"
0020 #include "CommonTools/UtilAlgos/interface/SelectedOutputCollectionTrait.h"
0021
0022 namespace edm {
0023 class Event;
0024 class EventSetup;
0025 }
0026
0027 template <typename InputCollection,
0028 typename Selector,
0029 typename OutputCollection = typename helper::SelectedOutputCollectionTrait<InputCollection>::type,
0030 typename StoreContainer = typename helper::StoreContainerTrait<OutputCollection>::type,
0031 typename RefAdder = typename helper::SelectionAdderTrait<InputCollection, StoreContainer>::type>
0032 struct SingleElementCollectionSelectorPlusEvent {
0033 typedef InputCollection collection;
0034 typedef StoreContainer container;
0035 typedef typename container::const_iterator const_iterator;
0036 SingleElementCollectionSelectorPlusEvent(const edm::ParameterSet &cfg, edm::ConsumesCollector &&iC)
0037 : select_(reco::modules::make<Selector>(cfg, iC)) {}
0038 const_iterator begin() const { return selected_.begin(); }
0039 const_iterator end() const { return selected_.end(); }
0040 void select(const edm::Handle<InputCollection> &c, const edm::Event &ev, const edm::EventSetup &) {
0041 selected_.clear();
0042 for (size_t idx = 0; idx < c->size(); ++idx) {
0043 if (select_(edm::Ref<InputCollection>(c, idx), ev))
0044 addRef_(selected_, c, idx);
0045 }
0046 }
0047
0048 static void fillPSetDescription(edm::ParameterSetDescription &desc) { Selector::fillPSetDescription(desc); };
0049
0050 private:
0051 StoreContainer selected_;
0052 Selector select_;
0053 RefAdder addRef_;
0054 };
0055
0056 #endif