00001 // -*- C++ -*- 00002 // 00003 // Package: NMaxPerLumi 00004 // Class: NMaxPerLumi 00005 // 00013 // 00014 // Original Author: Jean-Roch Vlimant,40 3-A28,+41227671209, 00015 // Created: Fri Apr 9 18:54:59 CEST 2010 00016 // $Id: NMaxPerLumi.cc,v 1.3 2010/10/03 10:15:07 elmer Exp $ 00017 // 00018 // 00019 00020 00021 // system include files 00022 #include <memory> 00023 00024 // user include files 00025 #include "FWCore/Framework/interface/Frameworkfwd.h" 00026 #include "FWCore/Framework/interface/EDFilter.h" 00027 00028 #include "FWCore/Framework/interface/Event.h" 00029 #include "FWCore/Framework/interface/MakerMacros.h" 00030 00031 #include "FWCore/ParameterSet/interface/ParameterSet.h" 00032 00033 // 00034 // class declaration 00035 // 00036 00037 class NMaxPerLumi : public edm::EDFilter { 00038 public: 00039 explicit NMaxPerLumi(const edm::ParameterSet&); 00040 ~NMaxPerLumi(); 00041 00042 private: 00043 virtual void beginJob() ; 00044 virtual bool filter(edm::Event&, const edm::EventSetup&); 00045 virtual void endJob() ; 00046 00047 // ----------member data --------------------------- 00048 std::map< unsigned int , std::map < unsigned int, unsigned int > > counters; 00049 unsigned int nMaxPerLumi_; 00050 }; 00051 00052 // 00053 // constants, enums and typedefs 00054 // 00055 00056 // 00057 // static data member definitions 00058 // 00059 00060 // 00061 // constructors and destructor 00062 // 00063 NMaxPerLumi::NMaxPerLumi(const edm::ParameterSet& iConfig) 00064 { 00065 //now do what ever initialization is needed 00066 00067 nMaxPerLumi_ = iConfig.getParameter<unsigned int>("nMaxPerLumi"); 00068 } 00069 00070 00071 NMaxPerLumi::~NMaxPerLumi() 00072 { 00073 00074 // do anything here that needs to be done at desctruction time 00075 // (e.g. close files, deallocate resources etc.) 00076 00077 } 00078 00079 00080 // 00081 // member functions 00082 // 00083 00084 // ------------ method called on each new Event ------------ 00085 bool 00086 NMaxPerLumi::filter(edm::Event& iEvent, const edm::EventSetup& iSetup) 00087 { 00088 00089 const edm::EventID & id = iEvent.id(); 00090 00091 if (counters[id.run()][id.luminosityBlock()]>=nMaxPerLumi_) 00092 return false; 00093 else{ 00094 counters[id.run()][id.luminosityBlock()]++; 00095 return true; 00096 } 00097 } 00098 00099 // ------------ method called once each job just before starting event loop ------------ 00100 void 00101 NMaxPerLumi::beginJob() 00102 { 00103 } 00104 00105 // ------------ method called once each job just after ending the event loop ------------ 00106 void 00107 NMaxPerLumi::endJob() { 00108 } 00109 00110 //define this as a plug-in 00111 DEFINE_FWK_MODULE(NMaxPerLumi);