File indexing completed on 2024-12-21 03:54:41
0001 #include "FWCore/Framework/interface/Event.h"
0002 #include "FWCore/Framework/interface/InputSource.h"
0003 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0004 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0005 #include "FWCore/Sources/interface/IDGeneratorSourceBase.h"
0006
0007
0008
0009
0010
0011
0012
0013 class EmptySourceFromEventIDs : public edm::IDGeneratorSourceBase<edm::InputSource> {
0014 public:
0015 explicit EmptySourceFromEventIDs(edm::ParameterSet const&, edm::InputSourceDescription const&);
0016 ~EmptySourceFromEventIDs() override = default;
0017
0018 static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0019
0020 private:
0021 bool setRunAndEventInfo(edm::EventID& id, edm::TimeValue_t& time, edm::EventAuxiliary::ExperimentType& type) override;
0022 void readEvent_(edm::EventPrincipal& e) override;
0023
0024 std::vector<edm::EventID> events_;
0025 };
0026
0027
0028
0029 EmptySourceFromEventIDs::EmptySourceFromEventIDs(edm::ParameterSet const& config,
0030 edm::InputSourceDescription const& desc)
0031 : IDGeneratorSourceBase<InputSource>(config, desc, false),
0032 events_{config.getUntrackedParameter<std::vector<edm::EventID>>("events")}
0033 {
0034
0035 std::reverse(events_.begin(), events_.end());
0036 }
0037
0038 bool EmptySourceFromEventIDs::setRunAndEventInfo(edm::EventID& event,
0039 edm::TimeValue_t& time,
0040 edm::EventAuxiliary::ExperimentType& type) {
0041 if (events_.empty()) {
0042 return false;
0043 }
0044
0045 event = events_.back();
0046 events_.pop_back();
0047 return true;
0048 }
0049
0050 void EmptySourceFromEventIDs::readEvent_(edm::EventPrincipal& e) {
0051 doReadEvent(e, [](auto const&) {});
0052 }
0053
0054 void EmptySourceFromEventIDs::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0055 edm::ParameterSetDescription desc;
0056 desc.setComment("Creates runs, lumis and events (containing no products) based on the provided list of event ids.");
0057 edm::IDGeneratorSourceBase<edm::InputSource>::fillDescription(desc);
0058
0059 desc.addUntracked<std::vector<edm::EventID>>("events", {});
0060 descriptions.add("source", desc);
0061 }
0062
0063 #include "FWCore/Framework/interface/InputSourceMacros.h"
0064 DEFINE_FWK_INPUT_SOURCE(EmptySourceFromEventIDs);