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) : HLTFilter(iConfig),
30  src_(iConfig.getParameter<edm::InputTag>("src")),
31  minN_(iConfig.getParameter<int>("MinN")),
32  maxN_(iConfig.getParameter<int>("MaxN"))
33  {
34  srcToken_ = consumes<OColl>(src_);
35  }
36 
38 
40  {
43  desc.add<edm::InputTag>("src",edm::InputTag(""));
44  desc.add<int>("MinN",0);
45  desc.add<int>("MaxN",99999);
47  }
48 
49 private:
50  virtual bool hltFilter(edm::Event& iEvent, const edm::EventSetup&, trigger::TriggerFilterObjectWithRefs & filterproduct) const override
51  {
52  edm::Handle<OColl> oHandle;
53  iEvent.getByToken(srcToken_, oHandle);
54  int s=oHandle->size();
55  bool answer=true;
56  if (minN_!=-1) answer = answer && (s>=minN_);
57  if (maxN_!=-1) answer = answer && (s<=maxN_);
58  LogDebug("HLTCountNumberOfObject")<<module(iEvent)<<" sees: "<<s<<" objects. Filtere answer is: "<<(answer?"true":"false");
59 
60  return answer;
61  }
62 
65  int minN_,maxN_;
66 };
67 
68 
69 #endif
#define LogDebug(id)
std::string defaultModuleLabel()
virtual bool hltFilter(edm::Event &iEvent, const edm::EventSetup &, trigger::TriggerFilterObjectWithRefs &filterproduct) const override
edm::EDGetTokenT< OColl > srcToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
int iEvent
Definition: GenABIO.cc:230
int module(edm::Event const &) const
Definition: HLTFilter.cc:52
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)
HLT enums.
answer
Definition: submit.py:44