Go to the documentation of this file.00001 #ifndef HLTrigger_HLTCountNumberOfObject_H
00002
00008
00009 #include <memory>
00010
00011
00012 #include "FWCore/Framework/interface/Frameworkfwd.h"
00013 #include "FWCore/Framework/interface/EDFilter.h"
00014
00015 #include "FWCore/Framework/interface/Event.h"
00016 #include "FWCore/Framework/interface/MakerMacros.h"
00017
00018 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00019
00020 #include "FWCore/MessageService/interface/MessageLogger.h"
00021
00022 #include "HLTrigger/HLTcore/interface/HLTFilter.h"
00023 #include "DataFormats/HLTReco/interface/TriggerFilterObjectWithRefs.h"
00024
00025 template <class OColl>
00026 class HLTCountNumberOfObject : public HLTFilter {
00027 public:
00028 explicit HLTCountNumberOfObject(const edm::ParameterSet& iConfig) : HLTFilter(iConfig),
00029 src_(iConfig.getParameter<edm::InputTag>("src")),
00030 minN_(iConfig.getParameter<int>("MinN")),
00031 maxN_(iConfig.getParameter<int>("MaxN"))
00032 { }
00033
00034 ~HLTCountNumberOfObject() { }
00035
00036 private:
00037 virtual bool hltFilter(edm::Event& iEvent, const edm::EventSetup&, trigger::TriggerFilterObjectWithRefs & filterproduct)
00038 {
00039 edm::Handle<OColl> oHandle;
00040 iEvent.getByLabel(src_, oHandle);
00041 int s=oHandle->size();
00042 bool answer=true;
00043 if (minN_!=-1) answer = answer && (s>=minN_);
00044 if (maxN_!=-1) answer = answer && (s<=maxN_);
00045 LogDebug("HLTCountNumberOfObject")<<module()<<" sees: "<<s<<" objects. Filtere answer is: "<<(answer?"true":"false");
00046
00047 return answer;
00048 }
00049
00050 edm::InputTag src_;
00051 int minN_,maxN_;
00052 };
00053
00054
00055 #endif