CMS 3D CMS Logo

FilterValueMapWrapper.h
Go to the documentation of this file.
1 #ifndef PhysicsTools_UtilAlgos_interface_EDFilterValueMapWrapper_h
2 #define PhysicsTools_UtilAlgos_interface_EDFilterValueMapWrapper_h
3 
13 #include <boost/shared_ptr.hpp>
14 
15 namespace edm {
16 
17  template<class T, class C>
19 
20  public:
22  typename C::iterator iterator;
23  typename C::const_iterator const_iterator;
24 
26  FilterValueMapWrapper(const edm::ParameterSet& cfg) : src_( consumes<C>(cfg.getParameter<edm::InputTag>("src")))
27  {
28  filter_ = boost::shared_ptr<T>( new T(cfg.getParameter<edm::ParameterSet>("filterParams")) );
29  produces<edm::ValueMap<int>>();
30  }
34  void produce(edm::Event& event, const edm::EventSetup& eventSetup) override {
35  // create a collection of the objects to put into the event
36  auto objsToPut = std::make_unique<C>();
37  // get the handle to the objects in the event.
38  edm::Handle<C> h_c;
39  event.getByToken( src_, h_c );
40  std::vector<int> bitOut;
41  // loop through and add passing value_types to the output vector
42  for ( typename C::const_iterator ibegin = h_c->begin(), iend = h_c->end(), i = ibegin; i != iend; ++i ){
43  bitOut.push_back((*filter_)(*i));
44  }
45  std::unique_ptr<edm::ValueMap<int>> o(new edm::ValueMap<int>());
47  filler.insert(h_c,bitOut.begin(),bitOut.end());
48  filler.fill();
49  event.put(std::move(o));
50  }
51 
52  protected:
56  boost::shared_ptr<T> filter_;
57  };
58 
59 }
60 
61 #endif
T getParameter(std::string const &) const
void insert(const H &h, I begin, I end)
Definition: ValueMap.h:53
edm::EDGetTokenT< C > src_
InputTag of the input source.
FilterValueMapWrapper(const edm::ParameterSet &cfg)
default contructor. Declares the output (type "C") and the filter (of type T, operates on C::value_ty...
C::iterator iterator
some convenient typedefs. Recall that C is a container class.
void produce(edm::Event &event, const edm::EventSetup &eventSetup) override
everything which has to be done during the event loop. NOTE: We can&#39;t use the eventSetup in FWLite so...
boost::shared_ptr< T > filter_
shared pointer to analysis class of type BasicAnalyzer
HLT enums.
~FilterValueMapWrapper() override
default destructor
long double T
def move(src, dest)
Definition: eostools.py:511
Definition: event.py:1