R3BROOT
R3B analysis software
Toggle main menu visibility
Loading...
Searching...
No Matches
SteerWriter.h
Go to the documentation of this file.
1
/******************************************************************************
2
* Copyright (C) 2019 GSI Helmholtzzentrum für Schwerionenforschung GmbH *
3
* Copyright (C) 2019-2023 Members of R3B Collaboration *
4
* *
5
* This software is distributed under the terms of the *
6
* GNU General Public Licence (GPL) version 3, *
7
* copied verbatim in the file "LICENSE". *
8
* *
9
* In applying this license GSI does not waive the privileges and immunities *
10
* granted to it by virtue of its status as an Intergovernmental Organization *
11
* or submit itself to any jurisdiction. *
12
******************************************************************************/
13
14
#pragma once
15
16
#include <cstdint>
17
#include <fmt/core.h>
18
#include <fmt/format.h>
19
#include <fstream>
20
#include <map>
21
#include <string>
22
#include <string_view>
23
#include <unordered_map>
24
#include <utility>
25
#include <vector>
26
27
constexpr
auto
DEFAULT_MILLEPEDE_PARAMETER_FILE
=
"parameters.txt"
;
28
constexpr
auto
DEFAULT_STEER_FILENAME
=
"steer.txt"
;
29
constexpr
auto
DEFAULT_DATA_FILENAME
=
"data.bin"
;
30
31
namespace
R3B
32
{
33
class
SteerWriter
34
{
35
public
:
36
enum class
Method
: uint8_t
37
{
38
inversion,
39
diagonalization,
40
fullGORES,
41
sparseGMRES,
42
cholesky,
43
bandchooseby,
44
HIP
45
};
46
47
SteerWriter
() =
default
;
48
void
set_filepath
(std::string_view filepath) {
filepath_
= filepath; }
49
void
set_data_filepath
(std::string_view filepath) {
data_filepath_
= filepath; }
50
void
set_parameter_file
(std::string_view filename) {
parameter_file_
= filename; }
51
void
set_working_dir
(std::string_view dir) {
working_dir_
= dir; }
52
53
void
add_parameter_default
(
int
par_num,
const
std::pair<float, float>& values);
54
void
add_method
(
Method
method,
const
std::pair<float, float>& values);
55
void
add_other_options
(std::vector<std::string> options);
56
57
void
write
();
58
59
static
constexpr
auto
convert_method_to_str
(
Method
) -> std::string_view;
60
61
private
:
62
std::map<Method, std::pair<float, float>>
methods_
;
63
std::string
filepath_
=
DEFAULT_STEER_FILENAME
;
64
std::string
parameter_file_
=
DEFAULT_MILLEPEDE_PARAMETER_FILE
;
65
std::string
data_filepath_
=
DEFAULT_DATA_FILENAME
;
66
std::unordered_map<int, std::pair<float, float>>
parameter_defaults_
;
67
std::vector<std::vector<std::string>>
other_options_
;
68
std::string
working_dir_
=
"."
;
69
70
void
write_parameter_defaults
();
71
void
write_data_file
(std::ofstream& ofile);
72
void
write_methods
(std::ofstream& ofile);
73
void
write_others
(std::ofstream& ofile);
74
};
75
76
}
// namespace R3B
77
78
template
<>
79
class
fmt::formatter<
R3B
::SteerWriter::Method>
80
{
81
public
:
82
static
constexpr
auto
parse
(format_parse_context& ctx) {
return
ctx.end(); }
83
template
<
typename
FmtContent>
84
constexpr
auto
format
(
const
R3B::SteerWriter::Method
& method, FmtContent& ctn)
const
85
{
86
return
fmt::format_to(ctn.out(),
"{}"
,
R3B::SteerWriter::convert_method_to_str
(method));
87
}
88
};
DEFAULT_STEER_FILENAME
constexpr auto DEFAULT_STEER_FILENAME
Definition
SteerWriter.h:28
DEFAULT_MILLEPEDE_PARAMETER_FILE
constexpr auto DEFAULT_MILLEPEDE_PARAMETER_FILE
Definition
SteerWriter.h:27
DEFAULT_DATA_FILENAME
constexpr auto DEFAULT_DATA_FILENAME
Definition
SteerWriter.h:29
R3B::SteerWriter::data_filepath_
std::string data_filepath_
Definition
SteerWriter.h:65
R3B::SteerWriter::set_data_filepath
void set_data_filepath(std::string_view filepath)
Definition
SteerWriter.h:49
R3B::SteerWriter::set_working_dir
void set_working_dir(std::string_view dir)
Definition
SteerWriter.h:51
R3B::SteerWriter::other_options_
std::vector< std::vector< std::string > > other_options_
Definition
SteerWriter.h:67
R3B::SteerWriter::parameter_file_
std::string parameter_file_
Definition
SteerWriter.h:64
R3B::SteerWriter::write_data_file
void write_data_file(std::ofstream &ofile)
Definition
SteerWriter.cxx:76
R3B::SteerWriter::add_method
void add_method(Method method, const std::pair< float, float > &values)
Definition
SteerWriter.cxx:45
R3B::SteerWriter::write
void write()
Definition
SteerWriter.cxx:59
R3B::SteerWriter::write_parameter_defaults
void write_parameter_defaults()
Definition
SteerWriter.cxx:84
R3B::SteerWriter::methods_
std::map< Method, std::pair< float, float > > methods_
Definition
SteerWriter.h:62
R3B::SteerWriter::Method
Method
Definition
SteerWriter.h:37
R3B::SteerWriter::set_parameter_file
void set_parameter_file(std::string_view filename)
Definition
SteerWriter.h:50
R3B::SteerWriter::filepath_
std::string filepath_
Definition
SteerWriter.h:63
R3B::SteerWriter::working_dir_
std::string working_dir_
Definition
SteerWriter.h:68
R3B::SteerWriter::add_other_options
void add_other_options(std::vector< std::string > options)
Definition
SteerWriter.cxx:54
R3B::SteerWriter::add_parameter_default
void add_parameter_default(int par_num, const std::pair< float, float > &values)
Definition
SteerWriter.cxx:35
R3B::SteerWriter::convert_method_to_str
static constexpr auto convert_method_to_str(Method) -> std::string_view
Definition
SteerWriter.cxx:30
R3B::SteerWriter::SteerWriter
SteerWriter()=default
R3B::SteerWriter::parameter_defaults_
std::unordered_map< int, std::pair< float, float > > parameter_defaults_
Definition
SteerWriter.h:66
R3B::SteerWriter::write_methods
void write_methods(std::ofstream &ofile)
Definition
SteerWriter.cxx:101
R3B::SteerWriter::set_filepath
void set_filepath(std::string_view filepath)
Definition
SteerWriter.h:48
R3B::SteerWriter::write_others
void write_others(std::ofstream &ofile)
Definition
SteerWriter.cxx:110
fmt::formatter< R3B::SteerWriter::Method >::format
constexpr auto format(const R3B::SteerWriter::Method &method, FmtContent &ctn) const
Definition
SteerWriter.h:84
fmt::formatter< R3B::SteerWriter::Method >::parse
static constexpr auto parse(format_parse_context &ctx)
Definition
SteerWriter.h:82
R3B
Definition
R3BNeulandAnalysisApp.cxx:44
neuland
calibration
mille
SteerWriter.h
Generated by
1.18.0