diff --git a/algo/CMakeLists.txt b/algo/CMakeLists.txt index 32adb41db81c5b2f9df632f88ce9619185de867d..59e4d431644146d57de67fd882d39bd328a301d5 100644 --- a/algo/CMakeLists.txt +++ b/algo/CMakeLists.txt @@ -73,6 +73,7 @@ set(SRCS base/Options.cxx base/MainConfig.cxx base/RecoParams.cxx + base/util/StlUtils.cxx base/util/TimingsFormat.cxx data/sts/HitfinderPars.cxx data/sts/LandauTable.cxx diff --git a/algo/base/util/StlUtils.cxx b/algo/base/util/StlUtils.cxx new file mode 100644 index 0000000000000000000000000000000000000000..e8db142cc35e418609999a2cb94a1d3a546685f9 --- /dev/null +++ b/algo/base/util/StlUtils.cxx @@ -0,0 +1,21 @@ +/* Copyright (C) 2024 FIAS Frankfurt Institute for Advanced Studies, Frankfurt / Main + SPDX-License-Identifier: GPL-3.0-only + Authors: Felix Weiglhofer [committer] */ + +#include "StlUtils.h" + +using namespace cbm; + +std::string cbm::Capitalize(std::string_view str) +{ + if (str.empty()) { + return std::string(str); + } + + std::string result(str); + result[0] = std::toupper(result[0]); + for (size_t i = 1; i < result.size(); ++i) + result[i] = std::tolower(result[i]); + + return result; +} diff --git a/algo/base/util/StlUtils.h b/algo/base/util/StlUtils.h index e84898ccdbf38dd293b1c21c717327f811952897..61c0846b314dfd6bc71d9e5fbb68ede8bc2b2ca1 100644 --- a/algo/base/util/StlUtils.h +++ b/algo/base/util/StlUtils.h @@ -11,6 +11,8 @@ */ #include <algorithm> +#include <string> +#include <string_view> namespace cbm { @@ -21,4 +23,9 @@ namespace cbm return std::find(container.begin(), container.end(), value) != container.end(); } + /** + * @brief Capitalize the first letter of a string. The rest of the string is made lowercase. + */ + std::string Capitalize(std::string_view str); + } // namespace cbm diff --git a/algo/global/Reco.cxx b/algo/global/Reco.cxx index d61d7f755336333099c56d8b9d5c3e9681fd09e9..e793f22184db6a5f86891425bbf12938bb1ff8a2 100644 --- a/algo/global/Reco.cxx +++ b/algo/global/Reco.cxx @@ -357,7 +357,7 @@ void Reco::QueueUnpackerMetricsDet(const UnpackMonitor<MSMonitor>& monitor) std::string_view det = ToString(monitor.system); - auto MkKey = [&](std::string_view key) { return fmt::format("{}{}", det, key); }; + auto MkKey = [&](std::string_view key) { return fmt::format("{}{}", key, Capitalize(det)); }; GetMonitor().QueueMetric("cbmreco", {{"hostname", fles::system::current_hostname()}, {"child", Opts().ChildId()}}, {