CbmRoot
Loading...
Searching...
No Matches
analysis/common/analysis_tree_converter/steer/Config.cxx
Go to the documentation of this file.
1
/* Copyright (C) 2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2
SPDX-License-Identifier: GPL-3.0-only
3
Authors: Frederic Linz [committer], Volker Friese */
4
11
#include "
Config.h
"
12
13
#include <Logger.h>
14
15
#include <fstream>
16
17
#include <yaml-cpp/yaml.h>
18
19
using
std::string;
20
21
namespace
cbm::atconverter
22
{
23
24
25
// ----- Load settings from YAML file -------------------------------------
26
void
Config::LoadYaml
(
const
string
& fileName)
27
{
28
29
LOG(info) <<
"Config: Reading configuration from "
<< fileName;
30
YAML::Node settings = YAML::LoadFile(fileName);
31
32
// --- Global settings
33
f_glb_logLevel
= settings[
"global"
][
"log_level"
].as<
string
>();
34
f_glb_logVerbose
= settings[
"global"
][
"log_verbose"
].as<
string
>();
35
f_glb_logColor
= settings[
"global"
][
"log_color"
].as<
string
>();
36
f_glb_mode
=
ToCbmRecoMode
(settings[
"global"
][
"mode"
].as<string>());
37
f_glb_numTs
= settings[
"global"
][
"nTimeslices"
].as<
int
>();
38
f_glb_firstTs
= settings[
"global"
][
"firstTimeslice"
].as<
int
>();
39
f_glb_tslength
= settings[
"global"
][
"timeslicelength"
].as<
float
>();
40
f_glb_system
= settings[
"global"
][
"collisionSystem"
].as<
string
>();
41
f_glb_beamMom
= settings[
"global"
][
"beamMomentum"
].as<
float
>();
42
f_glb_trackMatching
= settings[
"global"
][
"trackMatching"
].as<
bool
>();
43
44
// --- Fsd hits converter settings
45
f_fsd_minChi2match
= settings[
"fsdhits"
][
"gtrackmatch_minChi2"
].as<
double
>();
46
f_fsd_maxChi2match
= settings[
"fsdhits"
][
"gtrackmatch_maxChi2"
].as<
double
>();
47
}
48
// ----------------------------------------------------------------------------
49
50
51
// ------ String to ECbmRecoMode ------------------------------------------
52
ECbmRecoMode
Config::ToCbmRecoMode
(
string
choice)
53
{
54
string
temp = choice;
55
std::transform(temp.begin(), temp.end(), temp.begin(), [](
unsigned
char
c) { return std::tolower(c); });
56
if
(temp ==
"timeslice"
)
return
ECbmRecoMode::Timeslice
;
57
else
if
(temp ==
"event"
)
58
return
ECbmRecoMode::EventByEvent
;
59
else
60
return
ECbmRecoMode::Undefined
;
61
}
62
// ----------------------------------------------------------------------------
63
64
65
// ----- ECbmRecoMode to string -------------------------------------------
66
string
Config::ToString
(
ECbmRecoMode
mode)
67
{
68
if
(mode ==
ECbmRecoMode::Timeslice
)
return
"timeslice"
;
69
else
if
(mode ==
ECbmRecoMode::EventByEvent
)
70
return
"event"
;
71
else
72
return
"undefined"
;
73
}
74
// ----------------------------------------------------------------------------
75
76
77
// ----- Save settings to YAML node ---------------------------------------
78
YAML::Node
Config::ToYaml
()
79
{
80
YAML::Node settings;
81
82
// --- Global settings
83
settings[
"global"
][
"log_level"
] =
f_glb_logLevel
;
84
settings[
"global"
][
"log_verbose"
] =
f_glb_logVerbose
;
85
settings[
"global"
][
"log_color"
] =
f_glb_logColor
;
86
settings[
"global"
][
"mode"
] =
ToString
(
f_glb_mode
);
87
settings[
"global"
][
"nTimeslices"
] =
f_glb_numTs
;
88
settings[
"global"
][
"firstTimeslice"
] =
f_glb_firstTs
;
89
settings[
"global"
][
"timeslicelength"
] =
f_glb_tslength
;
90
settings[
"global"
][
"collisionSystem"
] =
f_glb_system
;
91
settings[
"global"
][
"beamMomentum"
] =
f_glb_beamMom
;
92
settings[
"global"
][
"trackMatching"
] =
f_glb_trackMatching
;
93
94
// --- Fsd hits converter settings
95
settings[
"fsdhits"
][
"gtrackmatch_minChi2"
] =
f_fsd_minChi2match
;
96
settings[
"fsdhits"
][
"gtrackmatch_maxChi2"
] =
f_fsd_maxChi2match
;
97
98
return
settings;
99
}
100
// ----------------------------------------------------------------------------
101
102
}
// namespace cbm::atconverter
ECbmRecoMode
ECbmRecoMode
Reconstruct the full time slice or event-by-event.
Definition
CbmDefs.h:162
ECbmRecoMode::EventByEvent
@ EventByEvent
ECbmRecoMode::Timeslice
@ Timeslice
ECbmRecoMode::Undefined
@ Undefined
Config.h
cbm::atconverter::Config::f_fsd_minChi2match
float f_fsd_minChi2match
Definition
analysis/common/analysis_tree_converter/steer/Config.h:102
cbm::atconverter::Config::ToString
std::string ToString()
String output (YAML format)
Definition
analysis/common/analysis_tree_converter/steer/Config.h:57
cbm::atconverter::Config::f_glb_firstTs
int f_glb_firstTs
Definition
analysis/common/analysis_tree_converter/steer/Config.h:90
cbm::atconverter::Config::ToYaml
YAML::Node ToYaml()
Save to YAML node.
Definition
analysis/common/analysis_tree_converter/steer/Config.cxx:78
cbm::atconverter::Config::f_glb_numTs
int f_glb_numTs
Definition
analysis/common/analysis_tree_converter/steer/Config.h:89
cbm::atconverter::Config::LoadYaml
void LoadYaml(const std::string &filename)
Load from YAML file.
cbm::atconverter::Config::f_glb_logColor
std::string f_glb_logColor
Definition
analysis/common/analysis_tree_converter/steer/Config.h:87
cbm::atconverter::Config::f_glb_system
std::string f_glb_system
Definition
analysis/common/analysis_tree_converter/steer/Config.h:93
cbm::atconverter::Config::f_glb_mode
ECbmRecoMode f_glb_mode
Definition
analysis/common/analysis_tree_converter/steer/Config.h:88
cbm::atconverter::Config::f_glb_tslength
float f_glb_tslength
Definition
analysis/common/analysis_tree_converter/steer/Config.h:91
cbm::atconverter::Config::f_glb_trackMatching
bool f_glb_trackMatching
Definition
analysis/common/analysis_tree_converter/steer/Config.h:96
cbm::atconverter::Config::ToCbmRecoMode
ECbmRecoMode ToCbmRecoMode(std::string tag)
cbm::atconverter::Config::f_glb_logVerbose
std::string f_glb_logVerbose
Definition
analysis/common/analysis_tree_converter/steer/Config.h:86
cbm::atconverter::Config::f_glb_logLevel
std::string f_glb_logLevel
Definition
analysis/common/analysis_tree_converter/steer/Config.h:85
cbm::atconverter::Config::f_glb_beamMom
float f_glb_beamMom
Definition
analysis/common/analysis_tree_converter/steer/Config.h:94
cbm::atconverter::Config::f_fsd_maxChi2match
float f_fsd_maxChi2match
Definition
analysis/common/analysis_tree_converter/steer/Config.h:103
cbm::atconverter
Definition
analysis/common/analysis_tree_converter/app/Application.cxx:17
analysis
common
analysis_tree_converter
steer
Config.cxx
Generated on Sun Dec 22 2024 23:04:05 for CbmRoot by
1.12.0