File indexing completed on 2024-04-06 12:01:17
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #include <memory>
0014 #include <vector>
0015 #include <algorithm>
0016 #include <iostream>
0017
0018
0019 #include "FWCore/Framework/interface/Frameworkfwd.h"
0020 #include "FWCore/Framework/interface/one/EDProducer.h"
0021 #include "FWCore/Framework/interface/Event.h"
0022 #include "FWCore/Framework/interface/LuminosityBlock.h"
0023 #include "FWCore/Framework/interface/MakerMacros.h"
0024 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0025
0026 #include "DataFormats/Common/interface/MergeableCounter.h"
0027
0028 class EventCountProducer
0029 : public edm::one::EDProducer<edm::one::WatchLuminosityBlocks, edm::EndLuminosityBlockProducer> {
0030 public:
0031 explicit EventCountProducer(const edm::ParameterSet&);
0032 ~EventCountProducer() override;
0033
0034 private:
0035 void produce(edm::Event&, const edm::EventSetup&) override;
0036 void beginLuminosityBlock(const edm::LuminosityBlock&, const edm::EventSetup&) override;
0037 void endLuminosityBlock(edm::LuminosityBlock const&, const edm::EventSetup&) override;
0038 void endLuminosityBlockProduce(edm::LuminosityBlock&, const edm::EventSetup&) override;
0039
0040
0041
0042 unsigned int eventsProcessedInLumi_;
0043 };
0044
0045 using namespace edm;
0046 using namespace std;
0047
0048 EventCountProducer::EventCountProducer(const edm::ParameterSet& iConfig) {
0049 produces<edm::MergeableCounter, edm::Transition::EndLuminosityBlock>();
0050 }
0051
0052 EventCountProducer::~EventCountProducer() {}
0053
0054 void EventCountProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
0055 eventsProcessedInLumi_++;
0056 return;
0057 }
0058
0059 void EventCountProducer::beginLuminosityBlock(const LuminosityBlock& theLuminosityBlock, const EventSetup& theSetup) {
0060 eventsProcessedInLumi_ = 0;
0061 return;
0062 }
0063
0064 void EventCountProducer::endLuminosityBlock(LuminosityBlock const& theLuminosityBlock, const EventSetup& theSetup) {}
0065
0066 void EventCountProducer::endLuminosityBlockProduce(LuminosityBlock& theLuminosityBlock, const EventSetup& theSetup) {
0067 LogTrace("EventCounting") << "endLumi: adding " << eventsProcessedInLumi_ << " events" << endl;
0068
0069 unique_ptr<edm::MergeableCounter> numEventsPtr(new edm::MergeableCounter);
0070 numEventsPtr->value = eventsProcessedInLumi_;
0071 theLuminosityBlock.put(std::move(numEventsPtr));
0072
0073 return;
0074 }
0075
0076
0077 DEFINE_FWK_MODULE(EventCountProducer);