CbmRoot
Loading...
Searching...
No Matches
DigiEventSelectorConfig.cxx
Go to the documentation of this file.
1/* Copyright (C) 2022 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Shreya Roy. Pierre-Alain Loizeau, Volker Friese [committer], Dominik Smith */
4
6
8
9
10namespace cbm::algo::evbuild
11{
12
13 // ----- Constructor from YAML ------------------------------------------
15 {
16 if (!config) return;
17 if (auto numDigis = config["minDigis"]) {
18 for (YAML::const_iterator it = numDigis.begin(); it != numDigis.end(); it++) {
19 auto det = ToCbmModuleIdCaseInsensitive(it->first.as<std::string>());
20 auto value = it->second.as<size_t>();
21 if (value > 0)
22 fMinNumDigis[det] = value;
23 else
24 L_(warning) << "DigiEventSelectorConfig: Ignoring minimum 0 for digis in " << ::ToString(det);
25 }
26 }
27 if (auto numLayers = config["minLayers"]) {
28 for (YAML::const_iterator it = numLayers.begin(); it != numLayers.end(); it++) {
29 auto det = ToCbmModuleIdCaseInsensitive(it->first.as<std::string>());
30 auto value = it->second.as<size_t>();
31 if (value > 0)
32 fMinNumLayers[det] = value;
33 else
34 L_(warning) << "DigiEventSelectorConfig: Ignoring minimum 0 for layers in " << ::ToString(det);
35 }
36 }
37 }
38 // --------------------------------------------------------------------------
39
40
41 // ----- Save to YAML ---------------------------------------------------
43 {
44 YAML::Node result;
45 for (const auto& entry : fMinNumDigis) {
46 auto det = ToString(entry.first);
47 result["minDigis"][det] = entry.second;
48 }
49 for (const auto& entry : fMinNumLayers) {
50 auto det = ToString(entry.first);
51 result["minLayers"][det] = entry.second;
52 }
53 return result;
54 }
55 // --------------------------------------------------------------------------
56
57
58} // namespace cbm::algo::evbuild
#define L_(level)
ECbmModuleId ToCbmModuleIdCaseInsensitive(std::string modIdStr)
Definition CbmDefs.cxx:86
std::map< ECbmModuleId, size_t > fMinNumLayers
Key: detector, value: Minimal number of layers.
std::map< ECbmModuleId, size_t > fMinNumDigis
Key: detector, value: minimal number of digis.
DigiEventSelectorConfig(YAML::Node config)
Constructor from YAML.
std::string_view ToString(T t)
Definition EnumDict.h:64