File indexing completed on 2024-04-06 12:12:37
0001 #include "ThingProducer.h"
0002 #include "FWCore/Framework/interface/Event.h"
0003 #include "FWCore/Framework/interface/LuminosityBlock.h"
0004 #include "FWCore/Framework/interface/Run.h"
0005 #include "FWCore/Framework/interface/MakerMacros.h"
0006
0007 namespace edmtest {
0008 ThingProducer::ThingProducer(edm::ParameterSet const& iConfig)
0009 : alg_(iConfig.getParameter<int>("offsetDelta"),
0010 iConfig.getParameter<int>("nThings"),
0011 iConfig.getParameter<bool>("grow")),
0012 noPut_(iConfig.getUntrackedParameter<bool>("noPut"))
0013 {
0014 evToken_ = produces<ThingCollection>();
0015 blToken_ = produces<ThingCollection, edm::Transition::BeginLuminosityBlock>("beginLumi");
0016 elToken_ = produces<ThingCollection, edm::Transition::EndLuminosityBlock>("endLumi");
0017 brToken_ = produces<ThingCollection, edm::Transition::BeginRun>("beginRun");
0018 erToken_ = produces<ThingCollection, edm::Transition::EndRun>("endRun");
0019 }
0020
0021
0022 ThingProducer::~ThingProducer() {}
0023
0024
0025 void ThingProducer::produce(edm::StreamID, edm::Event& e, edm::EventSetup const&) const {
0026
0027
0028
0029 ThingCollection result;
0030
0031
0032 alg_.run(result);
0033
0034
0035 if (!noPut_)
0036 e.emplace(evToken_, std::move(result));
0037 }
0038
0039
0040 void ThingProducer::globalBeginLuminosityBlockProduce(edm::LuminosityBlock& lb, edm::EventSetup const&) const {
0041
0042
0043
0044 ThingCollection result;
0045
0046
0047 alg_.run(result);
0048
0049
0050 if (!noPut_)
0051 lb.emplace(blToken_, std::move(result));
0052 }
0053
0054 void ThingProducer::globalEndLuminosityBlockProduce(edm::LuminosityBlock& lb, edm::EventSetup const&) const {
0055
0056
0057
0058 ThingCollection result;
0059
0060
0061 alg_.run(result);
0062
0063
0064 if (!noPut_)
0065 lb.emplace(elToken_, std::move(result));
0066 }
0067
0068
0069 void ThingProducer::globalBeginRunProduce(edm::Run& r, edm::EventSetup const&) const {
0070
0071
0072
0073 ThingCollection result;
0074
0075
0076 alg_.run(result);
0077
0078
0079 if (!noPut_)
0080 r.emplace(brToken_, std::move(result));
0081 }
0082
0083 void ThingProducer::globalEndRunProduce(edm::Run& r, edm::EventSetup const&) const {
0084
0085
0086
0087 ThingCollection result;
0088
0089
0090 alg_.run(result);
0091
0092
0093 if (!noPut_)
0094 r.emplace(erToken_, std::move(result));
0095 }
0096
0097 void ThingProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0098 edm::ParameterSetDescription desc;
0099 desc.add<int>("offsetDelta", 0)
0100 ->setComment(
0101 "How much extra to increment the value used when creating Things for a new container. E.g. the last value "
0102 "used to create Thing from the previous event is incremented by 'offsetDelta' to compute the value to use "
0103 "of the first Thing created in the next Event.");
0104 desc.add<int>("nThings", 20)->setComment("How many Things to put in each collection.");
0105 desc.add<bool>("grow", false)
0106 ->setComment("If true, multiply 'nThings' by the value of offset for each run of the algorithm.");
0107 desc.addUntracked<bool>("noPut", false)
0108 ->setComment("If true, data is not put into the Principal. This is used to test missing products.");
0109 descriptions.add("thingProd", desc);
0110 }
0111
0112 }
0113 using edmtest::ThingProducer;
0114 DEFINE_FWK_MODULE(ThingProducer);