CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 
23 
24 template <class OColl>
26 public:
28  : HLTFilter(iConfig),
29  src_(iConfig.getParameter<edm::InputTag>("src")),
30  minN_(iConfig.getParameter<int>("MinN")),
31  maxN_(iConfig.getParameter<int>("MaxN")) {
32  srcToken_ = consumes<OColl>(src_);
33  }
34 
36 
37  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
40  desc.add<edm::InputTag>("src", edm::InputTag(""));
41  desc.add<int>("MinN", 0);
42  desc.add<int>("MaxN", 99999);
44  }
45 
46 private:
48  const edm::EventSetup&,
49  trigger::TriggerFilterObjectWithRefs& filterproduct) const override {
50  edm::Handle<OColl> oHandle;
51  iEvent.getByToken(srcToken_, oHandle);
52  int s = oHandle->size();
53  bool answer = true;
54  if (minN_ != -1)
55  answer = answer && (s >= minN_);
56  if (maxN_ != -1)
57  answer = answer && (s <= maxN_);
58  LogDebug("HLTCountNumberOfObject") << module(iEvent) << " sees: " << s
59  << " objects. Filtere answer is: " << (answer ? "true" : "false");
60 
61  return answer;
62  }
63 
66  int minN_, maxN_;
67 };
68 
69 #endif
edm::EDGetTokenT< OColl > srcToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
std::string defaultModuleLabel()
int iEvent
Definition: GenABIO.cc:224
int module(edm::Event const &) const
Definition: HLTFilter.cc:47
bool hltFilter(edm::Event &iEvent, const edm::EventSetup &, trigger::TriggerFilterObjectWithRefs &filterproduct) const override
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)
#define LogDebug(id)