File indexing completed on 2024-04-06 12:19:05
0001
0002
0003 #include "PoolSource.h"
0004 #include "FWCore/Framework/interface/InputSourceMacros.h"
0005 #include "FWCore/Framework/interface/LuminosityBlockPrincipal.h"
0006 #include "FWCore/Framework/interface/EventPrincipal.h"
0007
0008 #include "DataFormats/Provenance/interface/ProductRegistry.h"
0009 #include "FWCore/Framework/interface/HistoryAppender.h"
0010
0011 namespace edm {
0012
0013 class OneLumiPoolSource : public PoolSource {
0014 public:
0015 explicit OneLumiPoolSource(ParameterSet const& pset, InputSourceDescription const& desc);
0016
0017 private:
0018 ItemTypeInfo getNextItemType() override;
0019 std::shared_ptr<LuminosityBlockAuxiliary> readLuminosityBlockAuxiliary_() override;
0020
0021 void readEvent_(EventPrincipal& eventPrincipal) override {
0022 PoolSource::readEvent_(eventPrincipal);
0023 eventPrincipal.setRunAndLumiNumber(eventPrincipal.run(), 1);
0024 }
0025
0026 bool seenFirstLumi_ = false;
0027 };
0028
0029 OneLumiPoolSource::OneLumiPoolSource(ParameterSet const& pset, InputSourceDescription const& desc)
0030 : PoolSource(pset, desc) {}
0031
0032 std::shared_ptr<LuminosityBlockAuxiliary> OneLumiPoolSource::readLuminosityBlockAuxiliary_() {
0033 auto ret = PoolSource::readLuminosityBlockAuxiliary_();
0034 auto hist = ret->processHistoryID();
0035 *ret = LuminosityBlockAuxiliary(ret->run(), 1, ret->beginTime(), ret->endTime());
0036 ret->setProcessHistoryID(hist);
0037 return ret;
0038 }
0039
0040 InputSource::ItemTypeInfo OneLumiPoolSource::getNextItemType() {
0041 auto type = PoolSource::getNextItemType();
0042 if (type == ItemType::IsLumi) {
0043 if (seenFirstLumi_) {
0044 do {
0045 edm::HistoryAppender historyAppender;
0046 auto prodReg = std::make_shared<edm::ProductRegistry>();
0047 prodReg->setFrozen();
0048 edm::ProcessConfiguration procConfig;
0049
0050 LuminosityBlockPrincipal temp(prodReg, procConfig, &historyAppender, 0);
0051 readLuminosityBlock_(temp);
0052 type = PoolSource::getNextItemType();
0053 } while (type == ItemType::IsLumi);
0054 } else {
0055 seenFirstLumi_ = true;
0056 }
0057 }
0058 return type;
0059 }
0060 }
0061 using namespace edm;
0062
0063 DEFINE_FWK_INPUT_SOURCE(OneLumiPoolSource);