CMS 3D CMS Logo

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
13 
16 
18 
22 
23 template <class OColl>
25 public:
26  explicit HLTCountNumberOfObject(const edm::ParameterSet& iConfig)
27  : HLTFilter(iConfig),
28  src_(iConfig.getParameter<edm::InputTag>("src")),
29  minN_(iConfig.getParameter<int>("MinN")),
30  maxN_(iConfig.getParameter<int>("MaxN")) {
31  srcToken_ = consumes<OColl>(src_);
32  }
33 
35 
36  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
39  desc.add<edm::InputTag>("src", edm::InputTag(""));
40  desc.add<int>("MinN", 0);
41  desc.add<int>("MaxN", 99999);
43  }
44 
45 private:
47  const edm::EventSetup&,
48  trigger::TriggerFilterObjectWithRefs& filterproduct) const override {
49  edm::Handle<OColl> oHandle;
50  iEvent.getByToken(srcToken_, oHandle);
51  int s = oHandle->size();
52  bool answer = true;
53  if (minN_ != -1)
54  answer = answer && (s >= minN_);
55  if (maxN_ != -1)
56  answer = answer && (s <= maxN_);
57  LogDebug("HLTCountNumberOfObject") << module(iEvent) << " sees: " << s
58  << " objects. Filtere answer is: " << (answer ? "true" : "false");
59 
60  return answer;
61  }
62 
65  int minN_, maxN_;
66 };
67 
68 #endif
edm::EDGetTokenT< OColl > srcToken_
int module(edm::Event const &) const
Definition: HLTFilter.cc:47
std::string defaultModuleLabel()
int iEvent
Definition: GenABIO.cc:224
bool hltFilter(edm::Event &iEvent, const edm::EventSetup &, trigger::TriggerFilterObjectWithRefs &filterproduct) const override
static void makeHLTFilterDescription(edm::ParameterSetDescription &desc)
Definition: HLTFilter.cc:25
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
HLTCountNumberOfObject(const edm::ParameterSet &iConfig)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
HLT enums.
#define LogDebug(id)