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
5#include "DigiTriggerConfig.h"
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 = ToCbmModuleIdCaseInsensitive(detector.as<std::string>());
22
23 auto window = config["window"];
24 if (!window) throw std::runtime_error("trigger window is not specified");
25 fWindow = window.as<double>();
26
27 auto threshold = config["threshold"];
28 if (!threshold) throw std::runtime_error("trigger threshold is not specified");
29 fThreshold = threshold.as<size_t>();
30
31 auto deadTime = config["deadtime"];
32 if (!deadTime) throw std::runtime_error("trigger dead time is not specified");
33 fDeadTime = deadTime.as<double>();
34
35 fIsSet = true;
36 }
37 // --------------------------------------------------------------------------
38
39
40 // ----- Save to YAML ---------------------------------------------------
41 YAML::Node DigiTriggerConfig::ToYaml() const
42 {
43 YAML::Node result;
44 result["detector"] = ToString(fDetector);
45 result["window"] = fWindow;
46 result["threshold"] = fThreshold;
47 result["deadtime"] = fDeadTime;
48 return result;
49 }
50 // --------------------------------------------------------------------------
51
52
53} // namespace cbm::algo::evbuild
ECbmModuleId ToCbmModuleIdCaseInsensitive(std::string modIdStr)
Definition CbmDefs.cxx:86
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::string_view ToString(T t)
Definition EnumDict.h:64