/
githubmirror
/
cmssw
Обзор
Документация
Войти
/
githubmirror
/
cmssw
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
FWCore/Framework/src/ModuleMaker.cc
102 строки
4 KB
Eric Cano
Use emit() for framework signals emission instead of operator().
15 дек 2025, 11:58
15 дек 2025, 11:58
84bd5b4
Код
Авторство
О чём код?
#include "FWCore/Framework/interface/maker/ModuleMaker.h" #include "FWCore/Framework/interface/SignallingProductRegistryFiller.h" #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" #include "FWCore/ParameterSet/interface/Registry.h" #include "DataFormats/Provenance/interface/ModuleDescription.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Utilities/interface/ConvertException.h" #include "FWCore/Utilities/interface/Exception.h" #include "FWCore/Utilities/interface/EDMException.h" #include "FWCore/Utilities/interface/thread_safety_macros.h" #include <sstream> #include <exception> namespace edm { ModuleMakerBase::~ModuleMakerBase() {} ModuleDescription ModuleMakerBase::createModuleDescription(MakeModuleParams const& p) const { ParameterSet const& conf = *p.pset_; ModuleDescription md(conf.id(), conf.getParameter<std::string>("@module_type"), conf.getParameter<std::string>("@module_label"), p.processConfiguration_.get(), ModuleDescription::getUniqueID()); return md; } void ModuleMakerBase::throwValidationException(MakeModuleParams const& p, cms::Exception& iException) const { ParameterSet const& conf = *p.pset_; std::string moduleName = conf.getParameter<std::string>("@module_type"); std::string moduleLabel = conf.getParameter<std::string>("@module_label"); std::ostringstream ost; ost << "Validating configuration of module: class=" << moduleName << " label='" << moduleLabel << "'"; iException.addContext(ost.str()); throw; } void ModuleMakerBase::throwConfigurationException(ModuleDescription const& md, cms::Exception& iException) const { std::ostringstream ost; ost << "Constructing module: class=" << md.moduleName() << " label='" << md.moduleLabel() << "'"; iException.addContext(ost.str()); throw; } void ModuleMakerBase::validateEDMType(std::string const& edmType, MakeModuleParams const& p) const { std::string expected = p.pset_->getParameter<std::string>("@module_edm_type"); if (edmType != expected) { throw Exception(errors::Configuration) << "The base type in the python configuration is " << expected << ", but the base type\n" << "for the module's C++ class is " << edmType << ". " << "Please fix the configuration.\n" << "It must use the same base type as the C++ class.\n"; } } std::shared_ptr<maker::ModuleHolder> ModuleMakerBase::makeModule( MakeModuleParams const& p, signalslot::Signal<void(ModuleDescription const&)>& pre, signalslot::Signal<void(ModuleDescription const&)>& post) const { ConfigurationDescriptions descriptions(baseType(), p.pset_->getParameter<std::string>("@module_type")); fillDescriptions(descriptions); try { convertException::wrap([&]() { descriptions.validate(*p.pset_, p.pset_->getParameter<std::string>("@module_label")); validateEDMType(baseType(), p); }); } catch (cms::Exception& iException) { throwValidationException(p, iException); } p.pset_->registerIt(); //Need to be certain top level untracked parameters are stored in // the registry even if another PSet already exists in the // registry from a previous process //NOTE: a better implementation would be to change ParameterSet::registerIt // but that would require rebuilding much more code so will be done at // a later date. edm::pset::Registry::instance()->insertMapped(*(p.pset_), true); ModuleDescription md = createModuleDescription(p); std::shared_ptr<maker::ModuleHolder> module; bool postCalled = false; try { convertException::wrap([&]() { pre.emit(md); module = makeModule(*(p.pset_)); module->finishModuleInitialization(md, *p.preallocate_, p.reg_); // if exception then post will be called in the catch block postCalled = true; post.emit(md); }); } catch (cms::Exception& iException) { if (!postCalled) { CMS_SA_ALLOW try { post.emit(md); } catch (...) { // If post throws an exception ignore it because we are already handling another exception } } throwConfigurationException(md, iException); } return module; } } // namespace edm