CbmRoot
Loading...
Searching...
No Matches
DigiTriggerConfig.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) {
15 fIsSet = false;
16 return;
17 }
18
19 auto detector = config["detector"];
20 if (!detector) throw std::runtime_error("trigger detector is not specified");
21 fDetector = util::FromString<ECbmModuleId>(detector.as<std::string>(), false).value_or(ECbmModuleId::kNotExist);
23 throw std::runtime_error("DigiTriggerConfig: invalid trigger detector " + detector.as<std::string>());
24 }
25
26 auto window = config["window"];
27 if (!window) throw std::runtime_error("trigger window is not specified");
28 fWindow = window.as<double>();
29
30 auto threshold = config["threshold"];
31 if (!threshold) throw std::runtime_error("trigger threshold is not specified");
32 fThreshold = threshold.as<size_t>();
33
34 auto deadTime = config["deadtime"];
35 if (!deadTime) throw std::runtime_error("trigger dead time is not specified");
36 fDeadTime = deadTime.as<double>();
37
38 fIsSet = true;
39 }
40 // --------------------------------------------------------------------------
41
42
43 // ----- Save to YAML ---------------------------------------------------
44 YAML::Node DigiTriggerConfig::ToYaml() const
45 {
46 YAML::Node result;
47 result["detector"] = std::string(util::ToString(fDetector));
48 result["window"] = fWindow;
49 result["threshold"] = fThreshold;
50 result["deadtime"] = fDeadTime;
51 return result;
52 }
53 // --------------------------------------------------------------------------
54
55
56} // namespace cbm::algo::evbuild
@ kNotExist
If not found.
Definition CbmDefs.h:68
DigiTriggerConfig(ECbmModuleId detector, double window, size_t threshold, double deadTime)
Constructor with parameters.
double fDeadTime
Minimal time between two trigger [ns].
bool fIsSet
Flag config being properly set.
YAML::Node ToYaml() const
Save to YAML.
ECbmModuleId fDetector
Trigger detector.
size_t fThreshold
Minimum number if digis in trigger window.
double fWindow
Trigger window size [ns].
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