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
19
#include "
CepGen/Cards/Handler.h
"
20
#include "
CepGen/Core/Exception.h
"
21
#include "
CepGen/Core/RunParameters.h
"
22
#include "
CepGen/Generator.h
"
23
#include "
CepGen/Modules/CardsHandlerFactory.h
"
24
#include "
CepGen/Utils/ArgumentsParser.h
"
25
#include "
CepGen/Utils/Filesystem.h
"
26
27
using namespace
std;
28
29
int
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
37
cepgen::initialise
();
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
}
ArgumentsParser.h
CardsHandlerFactory.h
Exception.h
CG_FATAL
#define CG_FATAL(mod)
Definition
Exception.h:61
Filesystem.h
Generator.h
Handler.h
CG_LOG
#define CG_LOG
Definition
Message.h:212
RunParameters.h
cepgen::ArgumentsParser
A generic command line arguments parser.
Definition
ArgumentsParser.h:31
cepgen::ArgumentsParser::addArgument
ArgumentsParser & addArgument(Args &&... args)
Add a parameter required for the parser.
Definition
ArgumentsParser.h:39
cepgen::ArgumentsParser::parse
ArgumentsParser & parse()
Associate command-line arguments to parameters.
Definition
ArgumentsParser.cpp:106
cepgen::Exception
Definition
Exception.h:25
cepgen::LoggedMessage::message
std::string message() const
Human-readable message.
Definition
Message.h:158
cepgen::utils::fileExtension
std::string fileExtension(const std::string &file)
Small utility to retrieve the extension of a filename.
Definition
Filesystem.cpp:29
cepgen::initialise
void initialise(bool safe_mode)
Definition
GlobalFunctions.cpp:91
main
int main()
Definition
pythia6_decay.cc:9
cepgen::CardsHandlerFactory::buildFromFilename
std::unique_ptr< card::Handler > buildFromFilename(const std::string &filename) const
Build one instance of a cards handler.
Definition
CardsHandlerFactory.cpp:30
cepgen::CardsHandlerFactory::get
static CardsHandlerFactory & get()
Definition
CardsHandlerFactory.cpp:25
src
utils
cepgenCardsConverter.cc
Generated on Mon Jul 29 2024 for CepGen by
1.9.7