cepgen is hosted by Hepforge, IPPP Durham
CepGen 1.2.5
Central exclusive processes event generator
Loading...
Searching...
No Matches
MadGraphProcessFactory.cpp
Go to the documentation of this file.
1/*
2 * CepGen: a central exclusive processes event generator
3 * Copyright (C) 2023-2024 Laurent Forthomme
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
22
23namespace cepgen {
24 template class ModuleFactory<MadGraphProcess>;
25
26 template <>
27 ModuleFactory<MadGraphProcess>::ModuleFactory(const std::string& desc) : description_(desc) {}
28
29 template <>
30 std::vector<std::string> ModuleFactory<MadGraphProcess>::modules() const {
31 std::vector<std::string> out;
32 std::transform(map_.begin(), map_.end(), std::back_inserter(out), [](const auto& val) { return val.first; });
33 std::sort(out.begin(), out.end());
34 return out;
35 }
36
37 template <>
38 std::unique_ptr<MadGraphProcess> ModuleFactory<MadGraphProcess>::build(const std::string& mod_name,
39 const ParametersList& params) const {
40 if (map_.count(mod_name) == 0)
41 throw CG_FATAL("ModuleFactory") << "Failed to build a mg5_aMC process with name '" << mod_name << "'.\n"
42 << "Registered modules: " << modules() << ".";
43 return map_.at(mod_name)(params_map_.at(mod_name).validate(params));
44 }
45} // namespace cepgen
#define CG_FATAL(mod)
Definition Exception.h:61
std::unique_ptr< T > build(const ParametersList &) const
Build one instance of a named module.
ModuleFactory(const ModuleFactory &)=delete
Disabled copy constructor.
std::vector< std::string > modules() const
List of modules registred in the database.
Common namespace for this Monte Carlo generator.