cepgen is hosted by Hepforge, IPPP Durham
CepGen 1.2.5
Central exclusive processes event generator
Loading...
Searching...
No Matches
python_parse.cc
Go to the documentation of this file.
1/*
2 * CepGen: a central exclusive processes event generator
3 * Copyright (C) 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
23#include "CepGen/Utils/Test.h"
24
25using namespace std;
26
27int main(int argc, char* argv[]) {
28 cepgen::ArgumentsParser(argc, argv).parse();
29
30 auto card = cepgen::CardsHandlerFactory::get().build(".py");
31 card->parseCommands({R"(import Config.Core as cepgen
32lim = (42.42, 420.420)
33vec_lim = [(0., 1.), (1., 2.)]
34)"});
35
36 // retrieve all parameters parsed from Python commands
37 const auto& parsed_params = card->parameters().get<cepgen::ParametersList>("parsed");
38
39 const auto lim = cepgen::Limits{42.42, 420.420};
40 CG_TEST_EQUAL(parsed_params.get<cepgen::Limits>("lim"), lim, "limits");
41 const vector<cepgen::Limits> vec_lim = {{0., 1.}, {1., 2.}};
42 CG_TEST_EQUAL(parsed_params.get<vector<cepgen::Limits> >("vec_lim"), vec_lim, "vector of limits");
43
45}
#define CG_TEST_SUMMARY
Definition Test.h:127
#define CG_TEST_EQUAL(var1, var2, name)
Definition Test.h:45
A generic command line arguments parser.
ArgumentsParser & parse()
Associate command-line arguments to parameters.
Validity interval for a variable.
Definition Limits.h:28
int main()
static CardsHandlerFactory & get()