File indexing completed on 2023-03-17 10:53:45
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021 #include <memory>
0022
0023
0024 #include "FWCore/Framework/interface/Frameworkfwd.h"
0025 #include "FWCore/Framework/interface/stream/EDFilter.h"
0026
0027 #include "FWCore/Framework/interface/Event.h"
0028 #include "FWCore/Framework/interface/MakerMacros.h"
0029
0030 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0031
0032
0033
0034
0035
0036 class NMaxPerLumi : public edm::stream::EDFilter<> {
0037 public:
0038 explicit NMaxPerLumi(const edm::ParameterSet&);
0039 ~NMaxPerLumi() override;
0040
0041 private:
0042 bool filter(edm::Event&, const edm::EventSetup&) override;
0043
0044
0045 std::map<unsigned int, std::map<unsigned int, unsigned int> > counters;
0046 unsigned int nMaxPerLumi_;
0047 };
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060 NMaxPerLumi::NMaxPerLumi(const edm::ParameterSet& iConfig) {
0061
0062
0063 nMaxPerLumi_ = iConfig.getParameter<unsigned int>("nMaxPerLumi");
0064 }
0065
0066 NMaxPerLumi::~NMaxPerLumi() {
0067
0068
0069 }
0070
0071
0072
0073
0074
0075
0076 bool NMaxPerLumi::filter(edm::Event& iEvent, const edm::EventSetup& iSetup) {
0077 const edm::EventID& id = iEvent.id();
0078
0079 if (counters[id.run()][id.luminosityBlock()] >= nMaxPerLumi_)
0080 return false;
0081 else {
0082 counters[id.run()][id.luminosityBlock()]++;
0083 return true;
0084 }
0085 }
0086
0087
0088 DEFINE_FWK_MODULE(NMaxPerLumi);