CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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  }
70  virtual bool filter(edm::Event& event, const edm::EventSetup& eventSetup) override {
71  // create a collection of the objects to put into the event
72  std::auto_ptr<C> objsToPut( new 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->size() > 0;
84  event.put(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
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
C::iterator iterator
some convenient typedefs. Recall that C is a container class.
C::const_iterator const_iterator
tuple cfg
Definition: looper.py:293
FilterObjectWrapper(const edm::ParameterSet &cfg)
default contructor. Declares the output (type &quot;C&quot;) 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.
virtual 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...
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
virtual ~FilterObjectWrapper()
default destructor
long double T
produces< C >()