Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-01-04 23:06:07

0001 // -*- C++ -*-
0002 //
0003 // Package:    HLTEventNumberFilter
0004 // Class:      HLTEventNumberFilter
0005 //
0006 /**\class HLTEventNumberFilter HLTEventNumberFilter.cc filter/HLTEventNumberFilter/src/HLTEventNumberFilter.cc
0007 
0008 Description: 
0009 
0010 Implementation:
0011 <Notes on implementation>
0012 */
0013 //
0014 // Original Author:  Martin Grunewald
0015 //         Created:  Tue Jan 22 13:55:00 CET 2008
0016 //
0017 //
0018 
0019 // system include files
0020 #include <string>
0021 #include <iostream>
0022 #include <memory>
0023 
0024 // user include files
0025 #include "HLTEventNumberFilter.h"
0026 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0027 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0028 
0029 //
0030 // constructors and destructor
0031 //
0032 HLTEventNumberFilter::HLTEventNumberFilter(const edm::ParameterSet& iConfig) {
0033   //now do what ever initialization is needed
0034 
0035   period_ = iConfig.getParameter<unsigned int>("period");
0036   invert_ = iConfig.getParameter<bool>("invert");
0037 }
0038 
0039 void HLTEventNumberFilter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0040   edm::ParameterSetDescription desc;
0041   desc.add<int>("period", 4096);
0042   desc.add<bool>("invert", true);
0043   descriptions.add("hltEventNumberFilter", desc);
0044 }
0045 
0046 //
0047 // member functions
0048 //
0049 
0050 // ------------ method called on each new Event  ------------
0051 bool HLTEventNumberFilter::filter(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const {
0052   using namespace edm;
0053 
0054   if (iEvent.isRealData()) {
0055     bool accept(false);
0056     if (period_ != 0)
0057       accept = (((iEvent.id().event()) % period_) == 0);
0058     if (invert_)
0059       accept = !accept;
0060     return accept;
0061   } else {
0062     return true;
0063   }
0064 }
0065 
0066 // declare this class as a framework plugin
0067 #include "FWCore/Framework/interface/MakerMacros.h"
0068 DEFINE_FWK_MODULE(HLTEventNumberFilter);