/
githubmirror
/
cmssw
Обзор
Документация
Войти
/
githubmirror
/
cmssw
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
FWCore/Integration/plugins/PutOrMergeTestSource.cc
123 строки
4 KB
Chris Jones
Avoid type conversion in InputSource::ItemTypeInfo
17 апр 2026, 16:47
17 апр 2026, 16:47
0cec90e
Код
Авторство
О чём код?
// // PutOrMergeTestSource.cc // CMSSW // // Created by Chris Jones on 3/23/21. // #include "FWCore/Framework/interface/InputSource.h" #include "FWCore/Framework/interface/InputSourceMacros.h" #include "FWCore/Framework/interface/FileBlock.h" #include "FWCore/Framework/interface/RunPrincipal.h" #include "DataFormats/Provenance/interface/ProductRegistry.h" #include "DataFormats/Provenance/interface/ProcessHistory.h" #include "DataFormats/Provenance/interface/ProcessHistoryRegistry.h" #include "DataFormats/TestObjects/interface/Thing.h" #include "DataFormats/TestObjects/interface/ThingWithMerge.h" #include "DataFormats/TestObjects/interface/ThingWithIsEqual.h" #include <cassert> using namespace edm; namespace edmtest { class PutOrMergeTestSource : public InputSource { public: PutOrMergeTestSource(ParameterSet const&, InputSourceDescription const&); /// Register any produced products void registerProducts() final; private: ItemTypeInfo getNextItemType() final; std::shared_ptr<RunAuxiliary> readRunAuxiliary_() final; std::shared_ptr<LuminosityBlockAuxiliary> readLuminosityBlockAuxiliary_() final; std::shared_ptr<FileBlock> readFile_() final; void readRun_(RunPrincipal& runPrincipal) final; void readEvent_(EventPrincipal& eventPrincipal) final; int stage_; ProductDescription thingDesc_; ProductDescription thingWithMergeDesc_; ProductDescription thingWithEqualDesc_; ProcessHistoryID historyID_; }; } // namespace edmtest using namespace edmtest; PutOrMergeTestSource::PutOrMergeTestSource(ParameterSet const& iPS, InputSourceDescription const& iISD) : InputSource(iPS, iISD), stage_(0), thingDesc_(InRun, "thingWithMergeProducer", "PROD", "endRun", edm::TypeID(typeid(edmtest::Thing)), false, true), thingWithMergeDesc_( InRun, "thingWithMergeProducer", "PROD", "endRun", edm::TypeID(typeid(edmtest::ThingWithMerge)), false, true), thingWithEqualDesc_(InRun, "thingWithMergeProducer", "PROD", "endRun", edm::TypeID(typeid(edmtest::ThingWithIsEqual)), false, true) { edm::ParameterSet dummyPset; dummyPset.registerIt(); ProcessHistory history; history.emplace_back("PROD", dummyPset.id(), "RELVERSION", HardwareResourcesDescription()); processHistoryRegistry().registerProcessHistory(history); historyID_ = history.id(); } void PutOrMergeTestSource::registerProducts() { edm::ParameterSet dummyPset; dummyPset.registerIt(); thingDesc_.setIsProvenanceSetOnRead(); thingWithMergeDesc_.setIsProvenanceSetOnRead(); productRegistryUpdate().copyProduct(thingDesc_); productRegistryUpdate().copyProduct(thingWithMergeDesc_); productRegistryUpdate().copyProduct(thingWithEqualDesc_); productRegistryUpdate().setProcessOrder({"PROD"}); } InputSource::ItemTypeInfo PutOrMergeTestSource::getNextItemType() { switch (stage_) { case 0: { return ItemTypeInfo::isFile(); } case 1: { return ItemTypeInfo::isRun(); } case 2: { return ItemTypeInfo::isRun(); } default: return ItemTypeInfo::isStop(); } return ItemTypeInfo::isInvalid(); } std::shared_ptr<RunAuxiliary> PutOrMergeTestSource::readRunAuxiliary_() { auto id = std::make_shared<RunAuxiliary>(1, Timestamp::beginOfTime(), Timestamp::endOfTime()); id->setProcessHistoryID(historyID_); return id; } std::shared_ptr<LuminosityBlockAuxiliary> PutOrMergeTestSource::readLuminosityBlockAuxiliary_() { return {}; } std::shared_ptr<FileBlock> PutOrMergeTestSource::readFile_() { ++stage_; return std::make_shared<FileBlock>(); } void PutOrMergeTestSource::readRun_(RunPrincipal& runPrincipal) { runAuxiliary()->setProcessHistoryID(historyID_); runPrincipal.fillRunPrincipal(processHistoryRegistry()); ++stage_; runPrincipal.putOrMerge(thingDesc_, std::make_unique<Wrapper<edmtest::Thing>>(WrapperBase::Emplace{}, 100001)); runPrincipal.putOrMerge(thingWithMergeDesc_, std::make_unique<Wrapper<edmtest::ThingWithMerge>>(WrapperBase::Emplace{}, 100002)); runPrincipal.putOrMerge(thingWithEqualDesc_, std::make_unique<Wrapper<edmtest::ThingWithIsEqual>>(WrapperBase::Emplace{}, 100003)); } void PutOrMergeTestSource::readEvent_(EventPrincipal& eventPrincipal) { assert(false); } DEFINE_FWK_INPUT_SOURCE(PutOrMergeTestSource);