CMS 3D CMS Logo

EDFilterObjectWrapper.h
Go to the documentation of this file.
1 #ifndef PhysicsTools_UtilAlgos_interface_EDFilterObjectWrapper_h
2 #define PhysicsTools_UtilAlgos_interface_EDFilterObjectWrapper_h
3 
44 #include <boost/shared_ptr.hpp>
45 
46 namespace edm {
47 
48  template<class T, class C>
50 
51  public:
53  typename C::iterator iterator;
54  typename C::const_iterator const_iterator;
55 
57  FilterObjectWrapper(const edm::ParameterSet& cfg) : src_( consumes<C>(cfg.getParameter<edm::InputTag>("src")))
58  {
59  filter_ = boost::shared_ptr<T>( new T(cfg.getParameter<edm::ParameterSet>("filterParams")) );
60  if ( cfg.exists("filter") ) {
61  doFilter_ = cfg.getParameter<bool>("filter");
62  } else {
63  doFilter_ = false;
64  }
65  produces<C>();
66  }
68  ~FilterObjectWrapper() override{}
70  bool filter(edm::Event& event, const edm::EventSetup& eventSetup) override {
71  // create a collection of the objects to put into the event
72  auto objsToPut = std::make_unique<C>();
73  // get the handle to the objects in the event.
74  edm::Handle<C> h_c;
75  event.getByToken( src_, h_c );
76  // loop through and add passing value_types to the output vector
77  for ( typename C::const_iterator ibegin = h_c->begin(), iend = h_c->end(), i = ibegin; i != iend; ++i ){
78  if ( (*filter_)(*i) ){
79  objsToPut->push_back( *i );
80  }
81  }
82  // put objs in the event
83  bool pass = !objsToPut->empty();
84  event.put(std::move(objsToPut));
85  if ( doFilter_ )
86  return pass;
87  else
88  return true;
89  }
90 
91  protected:
95  boost::shared_ptr<T> filter_;
97  bool doFilter_;
98  };
99 
100 }
101 
102 #endif
bool doFilter_
whether or not to filter based on size
~FilterObjectWrapper() override
default destructor
T getParameter(std::string const &) const
C::iterator iterator
some convenient typedefs. Recall that C is a container class.
C::const_iterator const_iterator
FilterObjectWrapper(const edm::ParameterSet &cfg)
default contructor. Declares the output (type "C") and the filter (of type T, operates on C::value_ty...
boost::shared_ptr< T > filter_
shared pointer to analysis class of type BasicAnalyzer
bool exists(std::string const &parameterName) const
checks if a parameter exists
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::EDGetTokenT< C > src_
InputTag of the input source.
bool filter(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...
HLT enums.
long double T
def move(src, dest)
Definition: eostools.py:511
Definition: event.py:1