File indexing completed on 2024-04-06 12:12:37
0001 #include "ThingExtSource.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 ThingExtSource::ThingExtSource(edm::ParameterSet const& pset, edm::InputSourceDescription const& desc)
0010 : ProducerSourceFromFiles(pset, desc, true), 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 ThingExtSource::~ThingExtSource() {}
0020
0021
0022 bool ThingExtSource::setRunAndEventInfo(edm::EventID&, edm::TimeValue_t&, edm::EventAuxiliary::ExperimentType&) {
0023
0024 if (event() > 2)
0025 return false;
0026 return true;
0027 }
0028
0029 void ThingExtSource::produce(edm::Event& e) {
0030
0031
0032
0033 auto result = std::make_unique<ThingCollection>();
0034
0035
0036 alg_.run(*result);
0037
0038
0039 e.put(std::move(result));
0040 }
0041
0042
0043 void ThingExtSource::beginLuminosityBlock(edm::LuminosityBlock& lb) {
0044
0045
0046
0047 auto result = std::make_unique<ThingCollection>();
0048
0049
0050 alg_.run(*result);
0051
0052
0053 lb.put(std::move(result), "beginLumi");
0054
0055 endLuminosityBlock(lb);
0056 }
0057
0058 void ThingExtSource::endLuminosityBlock(edm::LuminosityBlock& lb) {
0059
0060
0061
0062 auto result = std::make_unique<ThingCollection>();
0063
0064
0065 alg_.run(*result);
0066
0067
0068 lb.put(std::move(result), "endLumi");
0069 }
0070
0071
0072 void ThingExtSource::beginRun(edm::Run& r) {
0073
0074
0075
0076 auto result = std::make_unique<ThingCollection>();
0077
0078
0079 alg_.run(*result);
0080
0081
0082 r.put(std::move(result), "beginRun");
0083
0084 endRun(r);
0085 }
0086
0087 void ThingExtSource::endRun(edm::Run& r) {
0088
0089
0090
0091 auto result = std::make_unique<ThingCollection>();
0092
0093
0094 alg_.run(*result);
0095
0096
0097 r.put(std::move(result), "endRun");
0098 }
0099
0100 void ThingExtSource::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0101 edm::ParameterSetDescription desc;
0102 desc.setComment("Creates ThingCollections from a file for testing.");
0103 edm::ProducerSourceFromFiles::fillDescription(desc);
0104 descriptions.add("source", desc);
0105 }
0106
0107 }
0108 using edmtest::ThingExtSource;
0109 DEFINE_FWK_INPUT_SOURCE(ThingExtSource);