CMS 3D CMS Logo

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 // system include files
21 #include <memory>
22 
23 // user include files
26 
29 
31 
32 //
33 // class declaration
34 //
35 
37 public:
38  explicit NMaxPerLumi(const edm::ParameterSet&);
39  ~NMaxPerLumi() override;
40 
41 private:
42  bool filter(edm::Event&, const edm::EventSetup&) override;
43 
44  // ----------member data ---------------------------
45  std::map<unsigned int, std::map<unsigned int, unsigned int> > counters;
46  unsigned int nMaxPerLumi_;
47 };
48 
49 //
50 // constants, enums and typedefs
51 //
52 
53 //
54 // static data member definitions
55 //
56 
57 //
58 // constructors and destructor
59 //
61  //now do what ever initialization is needed
62 
63  nMaxPerLumi_ = iConfig.getParameter<unsigned int>("nMaxPerLumi");
64 }
65 
67  // do anything here that needs to be done at desctruction time
68  // (e.g. close files, deallocate resources etc.)
69 }
70 
71 //
72 // member functions
73 //
74 
75 // ------------ method called on each new Event ------------
77  const edm::EventID& id = iEvent.id();
78 
79  if (counters[id.run()][id.luminosityBlock()] >= nMaxPerLumi_)
80  return false;
81  else {
82  counters[id.run()][id.luminosityBlock()]++;
83  return true;
84  }
85 }
86 
87 //define this as a plug-in
bool filter(edm::Event &, const edm::EventSetup &) override
Definition: NMaxPerLumi.cc:76
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
~NMaxPerLumi() override
Definition: NMaxPerLumi.cc:66
std::map< unsigned int, std::map< unsigned int, unsigned int > > counters
Definition: NMaxPerLumi.cc:45
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
int iEvent
Definition: GenABIO.cc:224
unsigned int nMaxPerLumi_
Definition: NMaxPerLumi.cc:46
NMaxPerLumi(const edm::ParameterSet &)
Definition: NMaxPerLumi.cc:60