diff --git a/algo/CMakeLists.txt b/algo/CMakeLists.txt index d107ef399801b3da755d1570265eb42a1c9784f0..dbb8289793b3aeed18deb52e33abccf7edebb082 100644 --- a/algo/CMakeLists.txt +++ b/algo/CMakeLists.txt @@ -11,6 +11,7 @@ set(DEVICE_SRCS set(SRCS ${DEVICE_SRCS} + base/ChainContext.cxx base/Options.cxx base/util/TimingsFormat.cxx data/sts/LandauTable.cxx diff --git a/algo/base/ChainContext.cxx b/algo/base/ChainContext.cxx new file mode 100644 index 0000000000000000000000000000000000000000..9e75e9d8077048b3c21a9d9ee9b2db542fe34cea --- /dev/null +++ b/algo/base/ChainContext.cxx @@ -0,0 +1,11 @@ +/* Copyright (C) 2023 FIAS Frankfurt Institute for Advanced Studies, Frankfurt / Main + SPDX-License-Identifier: GPL-3.0-only + Authors: Felix Weiglhofer [committer] */ +#include "ChainContext.h" + +#include <Monitor.hpp> + +using namespace cbm::algo; + +ChainContext::ChainContext() {} +ChainContext::~ChainContext() {} diff --git a/algo/base/ChainContext.h b/algo/base/ChainContext.h index 19f9e15fb6138e97806a35b87e3d1b19b78ad5b8..46da5b9d83760b11b6dc0594bca104b5d3d202ff 100644 --- a/algo/base/ChainContext.h +++ b/algo/base/ChainContext.h @@ -4,18 +4,30 @@ #ifndef CBM_ALGO_BASE_CHAINCONTEXT_H #define CBM_ALGO_BASE_CHAINCONTEXT_H -#include <Monitor.hpp> +#include <memory> #include <optional> #include "Options.h" #include "RecoParams.h" +namespace cbm +{ + // cbm::Monitor must be forward declared. This prevents an issue in older ROOT versions, + // where cling would crash upon parsing the header file (in some stl header) + class Monitor; +} // namespace cbm + namespace cbm::algo { struct ChainContext { + // default constructor / destructor + // But have to be defined in the .cxx file, because of forward declaration of cbm::Monitor + ChainContext(); + ~ChainContext(); + Options opts; RecoParams recoParams; - std::optional<cbm::Monitor> monitor; //! + std::unique_ptr<cbm::Monitor> monitor; //! Monitor }; } // namespace cbm::algo diff --git a/algo/base/SubChain.h b/algo/base/SubChain.h index b206247190e987cbd9470ae19e5a25caaef01d85..b23538e09ecc6bc59021d5c52f9e8dc8cf5b3753 100644 --- a/algo/base/SubChain.h +++ b/algo/base/SubChain.h @@ -18,12 +18,12 @@ namespace cbm::algo const Options& Opts() const { return gsl::make_not_null(fContext)->opts; } const RecoParams& Params() const { return gsl::make_not_null(fContext)->recoParams; } - bool HasMonitor() const { return gsl::make_not_null(fContext)->monitor.has_value(); } + bool HasMonitor() const { return gsl::make_not_null(fContext)->monitor != nullptr; } Monitor& GetMonitor() const { // Need Get-prefix to avoid conflict with Monitor-class name - return gsl::make_not_null(fContext)->monitor.value(); + return *gsl::make_not_null(fContext)->monitor; } private: diff --git a/algo/global/Reco.cxx b/algo/global/Reco.cxx index 9984134c9256a6303ad3d9ab790522095fdf6d57..e0ddaee20e8b3f27a15f347b147a3485ff087d65 100644 --- a/algo/global/Reco.cxx +++ b/algo/global/Reco.cxx @@ -3,6 +3,7 @@ Authors: Felix Weiglhofer [committer] */ #include "Reco.h" +#include <Monitor.hpp> #include <System.hpp> #include <xpu/host.h> @@ -30,7 +31,7 @@ void Reco::Init(const Options& opts) L_(info) << "Running CBM Reco on Device " << props.name(); if (!opts.MonitorUri().empty()) { - fContext.monitor.emplace(opts.MonitorUri()); + fContext.monitor = std::make_unique<cbm::Monitor>(opts.MonitorUri()); L_(info) << "Monitoring enabled, sending to " << opts.MonitorUri(); }