File indexing completed on 2024-04-06 12:12:37
0001 #include "ThingSource.h"
0002 #include "DataFormats/TestObjects/interface/ThingCollection.h"
0003 #include "FWCore/Framework/interface/Event.h"
0004 #include "FWCore/Framework/interface/LuminosityBlock.h"
0005 #include "FWCore/Framework/interface/Run.h"
0006 #include "FWCore/Framework/interface/InputSourceMacros.h"
0007
0008 namespace edmtest {
0009 ThingSource::ThingSource(edm::ParameterSet const& pset, edm::InputSourceDescription const& desc)
0010 : ProducerSourceBase(pset, desc, false), alg_() {
0011 produces<ThingCollection>();
0012 produces<ThingCollection, edm::Transition::BeginLuminosityBlock>("beginLumi");
0013 produces<ThingCollection, edm::Transition::BeginLuminosityBlock>("endLumi");
0014 produces<ThingCollection, edm::Transition::BeginRun>("beginRun");
0015 produces<ThingCollection, edm::Transition::BeginRun>("endRun");
0016 }
0017
0018
0019 ThingSource::~ThingSource() {}
0020
0021
0022 void ThingSource::produce(edm::Event& e) {
0023
0024
0025
0026 auto result = std::make_unique<ThingCollection>();
0027
0028
0029 alg_.run(*result);
0030
0031
0032 e.put(std::move(result));
0033 }
0034
0035
0036 void ThingSource::beginLuminosityBlock(edm::LuminosityBlock& lb) {
0037
0038
0039
0040 auto result = std::make_unique<ThingCollection>();
0041
0042
0043 alg_.run(*result);
0044
0045
0046 lb.put(std::move(result), "beginLumi");
0047
0048 endLuminosityBlock(lb);
0049 }
0050
0051 void ThingSource::endLuminosityBlock(edm::LuminosityBlock& lb) {
0052
0053
0054
0055 auto result = std::make_unique<ThingCollection>();
0056
0057
0058 alg_.run(*result);
0059
0060
0061 lb.put(std::move(result), "endLumi");
0062 }
0063
0064
0065 void ThingSource::beginRun(edm::Run& r) {
0066
0067
0068
0069 auto result = std::make_unique<ThingCollection>();
0070
0071
0072 alg_.run(*result);
0073
0074
0075 r.put(std::move(result), "beginRun");
0076
0077 endRun(r);
0078 }
0079
0080 void ThingSource::endRun(edm::Run& r) {
0081
0082
0083
0084 auto result = std::make_unique<ThingCollection>();
0085
0086
0087 alg_.run(*result);
0088
0089
0090 r.put(std::move(result), "endRun");
0091 }
0092
0093 void ThingSource::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0094 edm::ParameterSetDescription desc;
0095 desc.setComment("Creates ThingCollections for testing.");
0096 edm::ProducerSourceBase::fillDescription(desc);
0097 descriptions.add("source", desc);
0098 }
0099
0100 }
0101 using edmtest::ThingSource;
0102 DEFINE_FWK_INPUT_SOURCE(ThingSource);