1 |
gpetrucc |
1.1 |
#include "FWCore/Framework/interface/Frameworkfwd.h"
|
2 |
|
|
#include "FWCore/Framework/interface/EDAnalyzer.h"
|
3 |
|
|
|
4 |
|
|
#include "FWCore/Framework/interface/MakerMacros.h"
|
5 |
|
|
|
6 |
|
|
#include "FWCore/ParameterSet/interface/ParameterSet.h"
|
7 |
|
|
|
8 |
|
|
#include "DataFormats/Common/interface/MergeableCounter.h"
|
9 |
|
|
|
10 |
|
|
#include "FWCore/MessageLogger/interface/MessageLogger.h"
|
11 |
|
|
|
12 |
|
|
class TotalEventCounter : public edm::EDAnalyzer {
|
13 |
|
|
public:
|
14 |
|
|
explicit TotalEventCounter(const edm::ParameterSet&);
|
15 |
|
|
~TotalEventCounter();
|
16 |
|
|
|
17 |
|
|
protected:
|
18 |
|
|
virtual void analyze(const edm::Event &, const edm::EventSetup&);
|
19 |
|
|
virtual void beginLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup&);
|
20 |
|
|
virtual void endJob() ;
|
21 |
|
|
|
22 |
|
|
edm::InputTag src_;
|
23 |
|
|
uint64_t events_;
|
24 |
|
|
};
|
25 |
|
|
|
26 |
|
|
TotalEventCounter::TotalEventCounter(const edm::ParameterSet & iConfig) :
|
27 |
|
|
src_(iConfig.getParameter<edm::InputTag>("src")),
|
28 |
|
|
events_(0)
|
29 |
|
|
{
|
30 |
|
|
}
|
31 |
|
|
|
32 |
|
|
TotalEventCounter::~TotalEventCounter()
|
33 |
|
|
{
|
34 |
|
|
}
|
35 |
|
|
|
36 |
|
|
void
|
37 |
|
|
TotalEventCounter::analyze(const edm::Event & iEvent, const edm::EventSetup & iSetup)
|
38 |
|
|
{
|
39 |
|
|
}
|
40 |
|
|
|
41 |
|
|
void
|
42 |
|
|
TotalEventCounter::beginLuminosityBlock(const edm::LuminosityBlock & iLumi, const edm::EventSetup & iSetup)
|
43 |
|
|
{
|
44 |
|
|
edm::Handle<edm::MergeableCounter> mc;
|
45 |
|
|
iLumi.getByLabel(src_, mc);
|
46 |
|
|
//std::cout << "Found " << mc->value << " events in run " << iLumi.run() << ", lumi " << iLumi.luminosityBlock() << std::endl;
|
47 |
|
|
events_ += mc->value;
|
48 |
|
|
}
|
49 |
|
|
|
50 |
|
|
void
|
51 |
|
|
TotalEventCounter::endJob()
|
52 |
|
|
{
|
53 |
|
|
edm::LogSystem("EventCount") << "Found " << events_ << " events in total.\n";
|
54 |
|
|
}
|
55 |
|
|
|
56 |
|
|
DEFINE_FWK_MODULE(TotalEventCounter);
|