CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/HLTrigger/special/src/HLTDynamicPrescaler.cc

Go to the documentation of this file.
00001 #include "FWCore/Framework/interface/Frameworkfwd.h"
00002 #include "FWCore/Framework/interface/EDFilter.h"
00003 #include "FWCore/Framework/interface/EventSetup.h"
00004 #include "FWCore/Framework/interface/Event.h"
00005 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00006 
00007 class HLTDynamicPrescaler : public edm::EDFilter {
00008 public:
00009   explicit HLTDynamicPrescaler(edm::ParameterSet const & configuration);
00010   ~HLTDynamicPrescaler();
00011 
00012   bool filter(edm::Event & event, edm::EventSetup const & setup);
00013 
00014 private:
00015   unsigned int m_count;     // event counter
00016   unsigned int m_scale;     // accept one event every m_scale, which will change dynamically
00017 };
00018 
00019 HLTDynamicPrescaler::HLTDynamicPrescaler(edm::ParameterSet const & configuration) :
00020   m_count(0),
00021   m_scale(1) { 
00022 }
00023 
00024 HLTDynamicPrescaler::~HLTDynamicPrescaler() {
00025 }
00026 
00027 bool HLTDynamicPrescaler::filter(edm::Event & event, edm::EventSetup const & setup) {
00028   ++m_count;
00029 
00030   if (m_count % m_scale)
00031     return false;
00032 
00033   if (m_count == m_scale * 10)
00034     m_scale = m_count;
00035   
00036   return true;
00037 }
00038 
00039 #include "FWCore/Framework/interface/MakerMacros.h"
00040 DEFINE_FWK_MODULE(HLTDynamicPrescaler);