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
14 
17 
19 
21 
25 
26 template <class OColl>
28 public:
29  explicit HLTCountNumberOfObject(const edm::ParameterSet& iConfig)
30  : HLTFilter(iConfig),
31  src_(iConfig.getParameter<edm::InputTag>("src")),
32  minN_(iConfig.getParameter<int>("MinN")),
33  maxN_(iConfig.getParameter<int>("MaxN")) {
34  srcToken_ = consumes<OColl>(src_);
35  }
36 
38 
39  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
42  desc.add<edm::InputTag>("src", edm::InputTag(""));
43  desc.add<int>("MinN", 0);
44  desc.add<int>("MaxN", 99999);
46  }
47 
48 private:
50  const edm::EventSetup&,
51  trigger::TriggerFilterObjectWithRefs& filterproduct) const override {
52  edm::Handle<OColl> oHandle;
53  iEvent.getByToken(srcToken_, oHandle);
54  int s = oHandle->size();
55  bool answer = true;
56  if (minN_ != -1)
57  answer = answer && (s >= minN_);
58  if (maxN_ != -1)
59  answer = answer && (s <= maxN_);
60  LogDebug("HLTCountNumberOfObject") << module(iEvent) << " sees: " << s
61  << " objects. Filtere answer is: " << (answer ? "true" : "false");
62 
63  return answer;
64  }
65 
68  int minN_, maxN_;
69 };
70 
71 #endif
#define LogDebug(id)
edm::EDGetTokenT< OColl > srcToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
std::string defaultModuleLabel()
int iEvent
Definition: GenABIO.cc:224
bool hltFilter(edm::Event &iEvent, const edm::EventSetup &, trigger::TriggerFilterObjectWithRefs &filterproduct) const override
int module(edm::Event const &) const
Definition: HLTFilter.cc:47
ParameterDescriptionBase * add(U const &iLabel, T const &value)
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.
answer
Definition: submit.py:45