CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HLTCountNumberOfObject.h
Go to the documentation of this file.
1 #ifndef HLTrigger_HLTCountNumberOfObject_H
2 
8 // system include files
9 #include <memory>
10 
11 // user include files
14 
17 
19 
21 
24 
25 template <class OColl>
27 public:
28  explicit HLTCountNumberOfObject(const edm::ParameterSet& iConfig) :
29  src_(iConfig.getParameter<edm::InputTag>("src")),
30  minN_(iConfig.getParameter<int>("MinN")),
31  maxN_(iConfig.getParameter<int>("MaxN"))
32  {
33  produces<trigger::TriggerFilterObjectWithRefs>();
34  };
35 
37 
38 private:
39  virtual bool filter(edm::Event& iEvent, const edm::EventSetup&)
40  {
41  // The filtered object. which is put empty.
42  std::auto_ptr<trigger::TriggerFilterObjectWithRefs> filterproduct (new trigger::TriggerFilterObjectWithRefs(path(),module()));
43 
44  edm::Handle<OColl> oHandle;
45  iEvent.getByLabel(src_, oHandle);
46  int s=oHandle->size();
47  bool answer=true;
48  if (minN_!=-1) answer = answer && (s>=minN_);
49  if (maxN_!=-1) answer = answer && (s<=maxN_);
50  LogDebug("HLTCountNumberOfObject")<<module()<<" sees: "<<s<<" objects. Filtere answer is: "<<(answer?"true":"false");
51 
52  iEvent.put(filterproduct);
53  return answer;
54  }
55  virtual void endJob(){};
56 
58  int minN_,maxN_;
59 };
60 
61 
62 #endif
#define LogDebug(id)
answer
Definition: submit.py:44
int module() const
Definition: HLTadd.h:12
int path() const
Definition: HLTadd.h:3
int iEvent
Definition: GenABIO.cc:243
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:84
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:359
HLTCountNumberOfObject(const edm::ParameterSet &iConfig)
string s
Definition: asciidump.py:422
virtual bool filter(edm::Event &iEvent, const edm::EventSetup &)