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
19using std::string;
20
21namespace 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 ------------------------------------------
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")
59 else
61 }
62 // ----------------------------------------------------------------------------
63
64
65 // ----- ECbmRecoMode to string -------------------------------------------
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
Reconstruct the full time slice or event-by-event.
Definition CbmDefs.h:162
void LoadYaml(const std::string &filename)
Load from YAML file.
ECbmRecoMode ToCbmRecoMode(std::string tag)