CbmRoot
Loading...
Searching...
No Matches
EventBuilderConfig.cxx
Go to the documentation of this file.
1/* Copyright (C) 2021 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Volker Friese [committer] */
4
6
7
8namespace cbm::algo::evbuild
9{
10
11 // ----- Constructor from YAML ------------------------------------------
13 {
14 if (!config) throw std::runtime_error("EventBuilderConfig: no configuration node");
15 for (YAML::const_iterator it = config.begin(); it != config.end(); ++it) {
16 auto det = util::FromString<ECbmModuleId>(it->first.as<std::string>(), false);
17 if (!det.has_value()) {
18 throw std::runtime_error("EventBuilderConfig: passing a non-existing moduleID: " + it->first.as<std::string>());
19 }
20 auto lower = it->second[0].as<double>();
21 auto upper = it->second[1].as<double>();
22 fWindows[det.value()] = std::make_pair(lower, upper);
23 }
24 // TODO: Check if complete (should the parameters be mandatory?)
25 }
26 // --------------------------------------------------------------------------
27
28
29 // ----- Save to YAML ---------------------------------------------------
30 YAML::Node EventBuilderConfig::ToYaml() const
31 {
32 YAML::Node result;
33 for (const auto& entry : fWindows) {
34 result[std::string(util::ToString(entry.first))] = entry.second;
35 }
36 return result;
37 }
38 // --------------------------------------------------------------------------
39
40
41} // namespace cbm::algo::evbuild
EventBuilderConfig(YAML::Node config)
Constructor from YAML.
YAML::Node ToYaml() const
Save to YAML.
std::map< ECbmModuleId, std::pair< double, double > > fWindows
Key: detector; value: [tmin, tmax].
std::optional< T > FromString(std::string_view str, bool caseSensitive=false)
Definition CbmEnumDict.h:50
std::string_view ToString(T t)
Definition CbmEnumDict.h:64