cepgen is hosted by Hepforge, IPPP Durham
CepGen 1.2.5
Central exclusive processes event generator
Loading...
Searching...
No Matches
cepgenCardsConverter.cc
Go to the documentation of this file.
1/*
2 * CepGen: a central exclusive processes event generator
3 * Copyright (C) 2013-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#include "CepGen/Generator.h"
26
27using namespace std;
28
29int main(int argc, char* argv[]) {
30 string input_config, output_config;
31
32 cepgen::ArgumentsParser parser(argc, argv);
33 parser.addArgument("input,i", "input configuration", &input_config)
34 .addArgument("output,o", "output output", &output_config)
35 .parse();
36
38
39 try {
40 auto in_card = cepgen::CardsHandlerFactory::get().buildFromFilename(input_config);
41 in_card->parseFile(input_config);
42 auto out_card = cepgen::CardsHandlerFactory::get().buildFromFilename(output_config);
43 out_card->setRunParameters(in_card->runParameters().get());
44 out_card->write(output_config);
45 CG_LOG << "Successfully converted the \"" << cepgen::utils::fileExtension(input_config) << "\" card into a \""
46 << cepgen::utils::fileExtension(output_config) << "\" card.\n\t"
47 << "\"" << output_config << "\" file created.";
48
49 } catch (const cepgen::Exception& e) {
50 throw CG_FATAL("main") << "Failed to convert a \"" << cepgen::utils::fileExtension(input_config)
51 << "\" card into a \"" << cepgen::utils::fileExtension(output_config) << "\" card!\n"
52 << e.message();
53 }
54
55 return 0;
56}
#define CG_FATAL(mod)
Definition Exception.h:61
#define CG_LOG
Definition Message.h:212
A generic command line arguments parser.
ArgumentsParser & addArgument(Args &&... args)
Add a parameter required for the parser.
ArgumentsParser & parse()
Associate command-line arguments to parameters.
std::string message() const
Human-readable message.
Definition Message.h:158
std::string fileExtension(const std::string &file)
Small utility to retrieve the extension of a filename.
void initialise(bool safe_mode)
int main()
std::unique_ptr< card::Handler > buildFromFilename(const std::string &filename) const
Build one instance of a cards handler.
static CardsHandlerFactory & get()