CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/HLTrigger/special/interface/HLTCountNumberOfObject.h

Go to the documentation of this file.
00001 #ifndef HLTrigger_HLTCountNumberOfObject_H
00002 
00008 // system include files
00009 #include <memory>
00010 
00011 // user include files
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) :
00029     src_(iConfig.getParameter<edm::InputTag>("src")),
00030     minN_(iConfig.getParameter<int>("MinN")),
00031     maxN_(iConfig.getParameter<int>("MaxN"))
00032       {
00033         produces<trigger::TriggerFilterObjectWithRefs>();
00034       };
00035   
00036   ~HLTCountNumberOfObject(){};
00037   
00038 private:
00039   virtual bool filter(edm::Event& iEvent, const edm::EventSetup&)
00040   {
00041     // The filtered object. which is put empty.
00042     std::auto_ptr<trigger::TriggerFilterObjectWithRefs> filterproduct (new trigger::TriggerFilterObjectWithRefs(path(),module()));
00043 
00044     edm::Handle<OColl> oHandle;
00045     iEvent.getByLabel(src_, oHandle);
00046     int s=oHandle->size();
00047     bool answer=true;
00048     if (minN_!=-1) answer = answer && (s>=minN_);
00049     if (maxN_!=-1) answer = answer && (s<=maxN_);
00050     LogDebug("HLTCountNumberOfObject")<<module()<<" sees: "<<s<<" objects. Filtere answer is: "<<(answer?"true":"false");
00051 
00052     iEvent.put(filterproduct);
00053     return answer;
00054   }
00055   virtual void endJob(){};
00056  
00057   edm::InputTag src_;
00058   int minN_,maxN_;
00059 };
00060 
00061 
00062 #endif