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) : HLTFilter(iConfig),
29  src_(iConfig.getParameter<edm::InputTag>("src")),
30  minN_(iConfig.getParameter<int>("MinN")),
31  maxN_(iConfig.getParameter<int>("MaxN"))
32  {
33  srcToken_ = consumes<OColl>(src_);
34  }
35 
37 
39  {
42  desc.add<edm::InputTag>("src",edm::InputTag(""));
43  desc.add<int>("MinN",0);
44  desc.add<int>("MaxN",99999);
45  descriptions.add(std::string("hlt")+std::string(typeid(HLTCountNumberOfObject<OColl>).name()),desc);
46  }
47 
48 private:
49  virtual bool hltFilter(edm::Event& iEvent, const edm::EventSetup&, trigger::TriggerFilterObjectWithRefs & filterproduct) const override
50  {
51  edm::Handle<OColl> oHandle;
52  iEvent.getByToken(srcToken_, oHandle);
53  int s=oHandle->size();
54  bool answer=true;
55  if (minN_!=-1) answer = answer && (s>=minN_);
56  if (maxN_!=-1) answer = answer && (s<=maxN_);
57  LogDebug("HLTCountNumberOfObject")<<module(iEvent)<<" sees: "<<s<<" objects. Filtere answer is: "<<(answer?"true":"false");
58 
59  return answer;
60  }
61 
64  int minN_,maxN_;
65 };
66 
67 
68 #endif
#define LogDebug(id)
edm::EDGetTokenT< OColl > srcToken_
answer
Definition: submit.py:44
virtual bool hltFilter(edm::Event &iEvent, const edm::EventSetup &, trigger::TriggerFilterObjectWithRefs &filterproduct) const override
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
int iEvent
Definition: GenABIO.cc:230
int module(edm::Event const &) const
Definition: HLTFilter.cc:53
ParameterDescriptionBase * add(U const &iLabel, T const &value)
static void makeHLTFilterDescription(edm::ParameterSetDescription &desc)
Definition: HLTFilter.cc:29
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
HLTCountNumberOfObject(const edm::ParameterSet &iConfig)
void add(std::string const &label, ParameterSetDescription const &psetDescription)