Back to home page

Project CMSSW displayed by LXR

 
 

    


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   // Virtual destructor needed.
0019   ThingSource::~ThingSource() {}
0020 
0021   // Functions that gets called by framework every event
0022   void ThingSource::produce(edm::Event& e) {
0023     // Step A: Get Inputs
0024 
0025     // Step B: Create empty output
0026     auto result = std::make_unique<ThingCollection>();  //Empty
0027 
0028     // Step C: Invoke the algorithm, passing in inputs (NONE) and getting back outputs.
0029     alg_.run(*result);
0030 
0031     // Step D: Put outputs into event
0032     e.put(std::move(result));
0033   }
0034 
0035   // Functions that gets called by framework every luminosity block
0036   void ThingSource::beginLuminosityBlock(edm::LuminosityBlock& lb) {
0037     // Step A: Get Inputs
0038 
0039     // Step B: Create empty output
0040     auto result = std::make_unique<ThingCollection>();  //Empty
0041 
0042     // Step C: Invoke the algorithm, passing in inputs (NONE) and getting back outputs.
0043     alg_.run(*result);
0044 
0045     // Step D: Put outputs into lumi block
0046     lb.put(std::move(result), "beginLumi");
0047 
0048     endLuminosityBlock(lb);
0049   }
0050 
0051   void ThingSource::endLuminosityBlock(edm::LuminosityBlock& lb) {
0052     // Step A: Get Inputs
0053 
0054     // Step B: Create empty output
0055     auto result = std::make_unique<ThingCollection>();  //Empty
0056 
0057     // Step C: Invoke the algorithm, passing in inputs (NONE) and getting back outputs.
0058     alg_.run(*result);
0059 
0060     // Step D: Put outputs into lumi block
0061     lb.put(std::move(result), "endLumi");
0062   }
0063 
0064   // Functions that gets called by framework every run
0065   void ThingSource::beginRun(edm::Run& r) {
0066     // Step A: Get Inputs
0067 
0068     // Step B: Create empty output
0069     auto result = std::make_unique<ThingCollection>();  //Empty
0070 
0071     // Step C: Invoke the algorithm, passing in inputs (NONE) and getting back outputs.
0072     alg_.run(*result);
0073 
0074     // Step D: Put outputs into event
0075     r.put(std::move(result), "beginRun");
0076 
0077     endRun(r);
0078   }
0079 
0080   void ThingSource::endRun(edm::Run& r) {
0081     // Step A: Get Inputs
0082 
0083     // Step B: Create empty output
0084     auto result = std::make_unique<ThingCollection>();  //Empty
0085 
0086     // Step C: Invoke the algorithm, passing in inputs (NONE) and getting back outputs.
0087     alg_.run(*result);
0088 
0089     // Step D: Put outputs into event
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 }  // namespace edmtest
0101 using edmtest::ThingSource;
0102 DEFINE_FWK_INPUT_SOURCE(ThingSource);