CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
NMaxPerLumi.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: NMaxPerLumi
4 // Class: NMaxPerLumi
5 //
13 //
14 // Original Author: Jean-Roch Vlimant,40 3-A28,+41227671209,
15 // Created: Fri Apr 9 18:54:59 CEST 2010
16 // $Id: NMaxPerLumi.cc,v 1.3 2010/10/03 10:15:07 elmer Exp $
17 //
18 //
19 
20 
21 // system include files
22 #include <memory>
23 
24 // user include files
27 
30 
32 
33 //
34 // class declaration
35 //
36 
37 class NMaxPerLumi : public edm::EDFilter {
38  public:
39  explicit NMaxPerLumi(const edm::ParameterSet&);
40  ~NMaxPerLumi();
41 
42  private:
43  virtual void beginJob() override ;
44  virtual bool filter(edm::Event&, const edm::EventSetup&) override;
45  virtual void endJob() override ;
46 
47  // ----------member data ---------------------------
48  std::map< unsigned int , std::map < unsigned int, unsigned int > > counters;
49  unsigned int nMaxPerLumi_;
50 };
51 
52 //
53 // constants, enums and typedefs
54 //
55 
56 //
57 // static data member definitions
58 //
59 
60 //
61 // constructors and destructor
62 //
64 {
65  //now do what ever initialization is needed
66 
67  nMaxPerLumi_ = iConfig.getParameter<unsigned int>("nMaxPerLumi");
68 }
69 
70 
72 {
73 
74  // do anything here that needs to be done at desctruction time
75  // (e.g. close files, deallocate resources etc.)
76 
77 }
78 
79 
80 //
81 // member functions
82 //
83 
84 // ------------ method called on each new Event ------------
85 bool
87 {
88 
89  const edm::EventID & id = iEvent.id();
90 
91  if (counters[id.run()][id.luminosityBlock()]>=nMaxPerLumi_)
92  return false;
93  else{
94  counters[id.run()][id.luminosityBlock()]++;
95  return true;
96  }
97 }
98 
99 // ------------ method called once each job just before starting event loop ------------
100 void
102 {
103 }
104 
105 // ------------ method called once each job just after ending the event loop ------------
106 void
108 }
109 
110 //define this as a plug-in
virtual bool filter(edm::Event &, const edm::EventSetup &) override
Definition: NMaxPerLumi.cc:86
T getParameter(std::string const &) const
std::map< unsigned int, std::map< unsigned int, unsigned int > > counters
Definition: NMaxPerLumi.cc:48
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
int iEvent
Definition: GenABIO.cc:230
unsigned int nMaxPerLumi_
Definition: NMaxPerLumi.cc:49
virtual void endJob() override
Definition: NMaxPerLumi.cc:107
NMaxPerLumi(const edm::ParameterSet &)
Definition: NMaxPerLumi.cc:63
virtual void beginJob() override
Definition: NMaxPerLumi.cc:101
edm::EventID id() const
Definition: EventBase.h:60