cepgen is hosted by Hepforge, IPPP Durham
CepGen 1.2.5
Central exclusive processes event generator
Loading...
Searching...
No Matches
cepgenEventConverter.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/Generator.h"
28#include "CepGen/Utils/String.h"
29
30using namespace std;
31
32int main(int argc, char* argv[]) {
33 string input_file, output_file;
34
35 cepgen::ArgumentsParser parser(argc, argv);
36 parser.addArgument("input,i", "input event file", &input_file)
37 .addArgument("output,o", "output event file", &output_file)
38 .parse();
39
41
42 auto params = cepgen::RunParameters{};
43
44 auto reader = cepgen::EventImporterFactory::get().build(input_file);
45 reader->initialise(params);
46 auto writer = cepgen::EventExporterFactory::get().build(output_file);
47 writer->initialise(params);
48
49 writer->setCrossSection(reader->crossSection());
50
51 cepgen::Event buf;
52 size_t num_events_converted = 0;
53 while ((*reader) >> buf) {
54 (*writer) << buf;
55 ++num_events_converted;
56 }
57
58 CG_LOG << "Successfully converted " << cepgen::utils::s("event", num_events_converted, true) << ".";
59
60 return 0;
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.
Container for the information on the in- and outgoing particles' kinematics.
Definition Event.h:28
List of parameters used to start and run the simulation job.
std::string s(const std::string &word, float num, bool show_number)
Add a trailing "s" when needed.
Definition String.cpp:228
void initialise(bool safe_mode)
int main()