diff --git a/algo/ca/TrackingChain.cxx b/algo/ca/TrackingChain.cxx index 4708b99553de33cc5e249c69a747cf3602163c6a..c960c0f3c30c92a5478f95f259eb4f4f32378027 100644 --- a/algo/ca/TrackingChain.cxx +++ b/algo/ca/TrackingChain.cxx @@ -19,9 +19,9 @@ #include <boost/archive/binary_oarchive.hpp> #include <fstream> -#include <fmt/format.h> #include <unordered_map> +#include <fmt/format.h> #include <xpu/host.h> using namespace cbm::algo; @@ -199,8 +199,8 @@ TrackingChain::Output_t TrackingChain::PrepareOutput() } fCaMonitorData.StopTimer(ca::ETimer::TrackingChain); - - if constexpr (kDEBUG) { // Monitor data per TS + + if constexpr (kDEBUG) { // Monitor data per TS if (fCaFramework.GetNofThreads() == 1 && fCaFramework.GetNofThreads() == 10) { int tsIndex = fCaMonitor.GetCounterValue(ca::ECounter::TrackingCall); auto fileName = fmt::format("./ca_monitor_nth_{}_ts{}.dat", fCaFramework.GetNofThreads(), tsIndex); diff --git a/core/qa/CMakeLists.txt b/core/qa/CMakeLists.txt index 65783ad554c6cdead7ada990c35f83bc33c80c3b..db91d744b8152e83bf0e31ec72b80a91c83923ec 100644 --- a/core/qa/CMakeLists.txt +++ b/core/qa/CMakeLists.txt @@ -24,7 +24,9 @@ set(SRCS checker/CbmQaCheckerProfile1DHandler.cxx checker/CbmQaCheckerObjectDB.cxx report/CbmQaReportBuilder.cxx + report/CbmQaReportBeamerEngine.cxx report/CbmQaReportLatexEngine.cxx + report/CbmQaReportLatexFormat.cxx report/CbmQaReportHtmlEngine.cxx report/CbmQaReportSection.cxx report/CbmQaReportTable.cxx @@ -83,6 +85,7 @@ Install(FILES report/CbmQaReportDefines.h report/CbmQaReportBuilder.h report/CbmQaReportLatexEngine.h + report/CbmQaReportBeamerEngine.h report/CbmQaReportHtmlEngine.h report/CbmQaReportSection.h report/CbmQaReportTable.h diff --git a/core/qa/report/CbmQaReportBeamerEngine.cxx b/core/qa/report/CbmQaReportBeamerEngine.cxx new file mode 100644 index 0000000000000000000000000000000000000000..02dde8dd227f3574255eb9571fd42f0f30393468 --- /dev/null +++ b/core/qa/report/CbmQaReportBeamerEngine.cxx @@ -0,0 +1,74 @@ +/* Copyright (C) 2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Sergei Zharko [committer] */ + +/// \file CbmQaReportLatexEngine.h +/// \brief LaTeX Beamer engine for the cbm::qa::report (source) +/// \author Sergei Zharko <s.zharko@gsi.de> +/// \since 28.03.2024 + +#include "CbmQaReportBeamerEngine.h" + +#include "CbmQaReportFigure.h" +#include "CbmQaReportHeader.h" +#include "CbmQaReportSection.h" +#include "CbmQaReportTable.h" +#include "CbmQaReportTail.h" +#include "Logger.h" + +#include <chrono> +#include <ctime> +#include <iomanip> +#include <regex> +#include <sstream> + +using cbm::qa::report::BeamerEngine; +using cbm::qa::report::Figure; +using cbm::qa::report::Header; +using cbm::qa::report::Section; +using cbm::qa::report::Table; +using cbm::qa::report::Tail; + +// --------------------------------------------------------------------------------------------------------------------- +// +std::string BeamerEngine::FigureBody(const Figure& figure) const +{ + std::stringstream out; + return out.str(); +} + +// --------------------------------------------------------------------------------------------------------------------- +// +std::string BeamerEngine::HeaderBody(const Header& header) const +{ + std::stringstream out; + return out.str(); +} + +// --------------------------------------------------------------------------------------------------------------------- +// +std::string BeamerEngine::SectionBody(const Section& section) const +{ + std::stringstream out; + return out.str(); +} + +// --------------------------------------------------------------------------------------------------------------------- +// +std::string BeamerEngine::TableBody(const Table& table) const +{ + std::stringstream out; + return out.str(); +} + +// --------------------------------------------------------------------------------------------------------------------- +// +std::string BeamerEngine::TailBody(const Tail& figure) const +{ + std::stringstream out; + return out.str(); +} + +// --------------------------------------------------------------------------------------------------------------------- +// +void BeamerEngine::Compile(const std::string& source) const {} diff --git a/core/qa/report/CbmQaReportBeamerEngine.h b/core/qa/report/CbmQaReportBeamerEngine.h new file mode 100644 index 0000000000000000000000000000000000000000..95d5db3491e753aaf980673fb7e00f099c4e9865 --- /dev/null +++ b/core/qa/report/CbmQaReportBeamerEngine.h @@ -0,0 +1,68 @@ +/* Copyright (C) 2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Sergei Zharko [committer] */ + +/// \file CbmQaReportBeamerEngine.h +/// \brief LaTeX Beamer engine for the cbm::qa::report (header) +/// \author Sergei Zharko <s.zharko@gsi.de> +/// \since 28.03.2024 + +#pragma once + +#include "CbmQaReportEngine.h" + +#include <string> +#include <string_view> + +namespace cbm::qa::report +{ + /// \class BeamerEngine + /// \brief Plain LaTeX document engine + class BeamerEngine : public Engine { + public: + /// \brief Creates a body for figure + /// \param figure Reference to figure + /// \return Figure body + std::string FigureBody(const Figure& figure) const override; + + /// \brief Creates a body for header + /// \param header Reference to header + /// \return Header body + std::string HeaderBody(const Header& header) const override; + + /// \brief Creates a body for section + /// \param section Reference to section + /// \return Section body + std::string SectionBody(const Section& section) const override; + + /// \brief Creates a body for table + /// \param table Reference to table + /// \return Table body + std::string TableBody(const Table& table) const override; + + /// \brief Creates a body for tail + /// \param tail Reference to tail + /// \return Figure body + std::string TailBody(const Tail& tail) const override; + + /// \brief Returns script extention + std::string ScriptExtention() const override { return "tex"; }; + + /// \brief Returns engine name + std::string MyName() const override { return "LaTeX beamer presentation engine"; } + + /// \brief Compiles source + /// \param source Source path + void Compile(const std::string& source) const override; + + /// \brief Sets the LaTeX compilation program name + /// \param latexCompiler A LaTeX compiler + /// \note The compiler can contain options + void SetLatexCompiler(std::string_view latexCompiler) { fsLatexCompiler = latexCompiler; } + + private: + static constexpr double kFigureWidth = 1.0; ///< Figure width [in textwidth] + + std::string fsLatexCompiler = "pdflatex -interaction=nonstopmode"; + }; +} // namespace cbm::qa::report diff --git a/core/qa/report/CbmQaReportElement.h b/core/qa/report/CbmQaReportElement.h index 7ce9595a73acdd09fd682678a6caac4f7511bd42..81c99468f7701bdc76d1e34ee0f19f514c196e94 100644 --- a/core/qa/report/CbmQaReportElement.h +++ b/core/qa/report/CbmQaReportElement.h @@ -25,8 +25,9 @@ namespace cbm::qa::report class Element { public: /// \brief Constructor - /// \param label Label of section - Element(std::string_view label) : fsLabel(label) {} + /// \param label Element label + /// \param title Element title + Element(std::string_view label, std::string_view title) : fsLabel(label), fsTitle(title) {} /// \brief Default constructor Element() = default; @@ -41,12 +42,19 @@ namespace cbm::qa::report /// \brief Gets label const std::string& GetLabel() const { return fsLabel; } + /// \brief Gets name + const std::string& GetTitle() const { return fsTitle; } + /// \brief Sets label void SetLabel(std::string_view label) { fsLabel = label; } + /// \brief Sets name + void SetTitle(std::string_view title) { fsTitle = title; } + private: // TODO: Add check for multiple label definition std::string fsLabel = ""; ///< Label for referencing + std::string fsTitle = ""; ///< Title of the element }; /// \class CollapsibleElement diff --git a/core/qa/report/CbmQaReportFigure.h b/core/qa/report/CbmQaReportFigure.h index 03d93018be6a72afa4e6772e5152d31147758990..b152ae98205b33a2b4ba18ef99cf55ca9a0a92f5 100644 --- a/core/qa/report/CbmQaReportFigure.h +++ b/core/qa/report/CbmQaReportFigure.h @@ -20,7 +20,11 @@ namespace cbm::qa::report public: /// \brief Constructor /// \param label Label of the element - Figure(std::string_view label) : Element(std::string("fig:") + std::string(label)) {} + /// \param title Title + Figure(std::string_view label, std::string_view title = "") + : Element(std::string("fig:") + std::string(label), title) + { + } /// \brief Destructor virtual ~Figure() = default; diff --git a/core/qa/report/CbmQaReportLatexEngine.cxx b/core/qa/report/CbmQaReportLatexEngine.cxx index 9b5214189ba7ea23b9e8b8c4efa1cf63a79908cd..b2e95e626244ff4e670f36dc4962eeeb8066c232 100644 --- a/core/qa/report/CbmQaReportLatexEngine.cxx +++ b/core/qa/report/CbmQaReportLatexEngine.cxx @@ -11,6 +11,7 @@ #include "CbmQaReportFigure.h" #include "CbmQaReportHeader.h" +#include "CbmQaReportLatexFormat.h" #include "CbmQaReportSection.h" #include "CbmQaReportTable.h" #include "CbmQaReportTail.h" @@ -31,22 +32,6 @@ using cbm::qa::report::Table; using cbm::qa::report::Tail; -// --------------------------------------------------------------------------------------------------------------------- -// -std::string LatexFormat::Apply(std::string_view input) -{ - auto output = std::string(input); - - // Replace all underscores with "\_" - // TODO: ignore replacing in LaTeX formulas - { - std::regex rex("_"); - output = std::regex_replace(output, rex, "\\_"); - } - - return output; -} - // --------------------------------------------------------------------------------------------------------------------- // std::string LatexEngine::FigureBody(const Figure& figure) const diff --git a/core/qa/report/CbmQaReportLatexEngine.h b/core/qa/report/CbmQaReportLatexEngine.h index 0eeeb5573191fae04c39e97eda9fcc41c09a1e50..e81a9bb3c8a87b4b34c68c5c0021385cacf37ccd 100644 --- a/core/qa/report/CbmQaReportLatexEngine.h +++ b/core/qa/report/CbmQaReportLatexEngine.h @@ -16,14 +16,6 @@ namespace cbm::qa::report { - // Latex formatting collection - /// \class LatexFormat - class LatexFormat { - public: - /// \brief Applies a LaTeX-friendly formatting - static std::string Apply(std::string_view input); - }; - /// \class LatexEngine /// \brief Plain LaTeX document engine class LatexEngine : public Engine { diff --git a/core/qa/report/CbmQaReportLatexFormat.cxx b/core/qa/report/CbmQaReportLatexFormat.cxx new file mode 100644 index 0000000000000000000000000000000000000000..5e06cfc549659344a30ddcee41a9ff716a3a0e0a --- /dev/null +++ b/core/qa/report/CbmQaReportLatexFormat.cxx @@ -0,0 +1,30 @@ +/* Copyright (C) 2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Sergei Zharko [committer] */ + +/// \file CbmQaReportLatexFormat.cxx +/// \brief Common LaTeX utilities (source) +/// \author Sergei Zharko <s.zharko@gsi.de> +/// \since 28.03.2024 + +#include "CbmQaReportLatexFormat.h" + +#include <regex> + +using cbm::qa::report::LatexFormat; + +// --------------------------------------------------------------------------------------------------------------------- +// +std::string LatexFormat::Apply(std::string_view input) +{ + auto output = std::string(input); + + // Replace all underscores with "\_" + // TODO: ignore replacing in LaTeX formulas + { + std::regex rex("_"); + output = std::regex_replace(output, rex, "\\_"); + } + + return output; +} diff --git a/core/qa/report/CbmQaReportLatexFormat.h b/core/qa/report/CbmQaReportLatexFormat.h index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..afdfc157cc82164142459c213e01571b11c16998 100644 --- a/core/qa/report/CbmQaReportLatexFormat.h +++ b/core/qa/report/CbmQaReportLatexFormat.h @@ -0,0 +1,24 @@ +/* Copyright (C) 2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Sergei Zharko [committer] */ + +/// \file CbmQaReportLatexFormat.h +/// \brief Common LaTeX utilities (header) +/// \author Sergei Zharko <s.zharko@gsi.de> +/// \since 28.03.2024 + +#pragma once + +#include <string> +#include <string_view> + +namespace cbm::qa::report +{ + // Latex formatting collection + /// \class LatexFormat + class LatexFormat { + public: + /// \brief Applies a LaTeX-friendly formatting + static std::string Apply(std::string_view input); + }; +} // namespace cbm::qa::report \ No newline at end of file diff --git a/core/qa/report/CbmQaReportSection.cxx b/core/qa/report/CbmQaReportSection.cxx index f55ea983bd8938943c714858fdf79a7e2b2639d1..e0ad268e71d9ee6aa6d9f499315e357f1c4cd5bf 100644 --- a/core/qa/report/CbmQaReportSection.cxx +++ b/core/qa/report/CbmQaReportSection.cxx @@ -16,8 +16,7 @@ using cbm::qa::report::Section; // --------------------------------------------------------------------------------------------------------------------- // Section::Section(std::string_view label, std::string_view title) - : CollapsibleElement(std::string("section") + std::string(label)) - , fsTitle(title) + : CollapsibleElement(std::string("section") + std::string(label), title) { } diff --git a/core/qa/report/CbmQaReportSection.h b/core/qa/report/CbmQaReportSection.h index 0f50ab69b7e02229ac79a2c37ec200a412009ab5..4a38eda5ffe840c3174623939ccbe708888e4827 100644 --- a/core/qa/report/CbmQaReportSection.h +++ b/core/qa/report/CbmQaReportSection.h @@ -42,12 +42,6 @@ namespace cbm::qa::report /// \brief Gets level of the section int GetLevel() const { return fLevel; } - /// \brief Gets title - const std::string& GetTitle() const { return fsTitle; } - - /// \brief Sets title - void SetTitle(std::string_view title) { fsTitle = title; } - protected: /// \brief Sets level of the section /// \param level Level of the section (is it section, subsection etc.) @@ -55,7 +49,6 @@ namespace cbm::qa::report void SetLevel(int level) { fLevel = level; } private: - std::string fsTitle = ""; ///< Title of the section int fLevel = 0; ///< Level of the section }; } // namespace cbm::qa::report diff --git a/core/qa/report/CbmQaReportTable.cxx b/core/qa/report/CbmQaReportTable.cxx index 581ee5462ac7747f907a5d4b4706a112ff359ef0..894d39c56ed1d0ce52b60724849892b5b6e013e1 100644 --- a/core/qa/report/CbmQaReportTable.cxx +++ b/core/qa/report/CbmQaReportTable.cxx @@ -19,12 +19,12 @@ using cbm::qa::report::Table; // --------------------------------------------------------------------------------------------------------------------- // -Table::Table(std::string_view label) : Table(label, 0, 0) {} +Table::Table(std::string_view label, std::string_view title) : Table(label, 0, 0, title) {} // --------------------------------------------------------------------------------------------------------------------- // -Table::Table(std::string_view label, int nRows, int nCols) - : Element(std::string("tab:") + std::string(label)) +Table::Table(std::string_view label, int nRows, int nCols, std::string_view title) + : Element(std::string("tab:") + std::string(label), title) , fNofRows(nRows) , fNofCols(nCols) { diff --git a/core/qa/report/CbmQaReportTable.h b/core/qa/report/CbmQaReportTable.h index 1d65d3bdb51e89c0cdaa42f46362538121122ec8..3af892ea60a16182183e131e25b07a297003c678 100644 --- a/core/qa/report/CbmQaReportTable.h +++ b/core/qa/report/CbmQaReportTable.h @@ -25,13 +25,15 @@ namespace cbm::qa::report public: /// \brief Constructor /// \param label Label of the element - explicit Table(std::string_view label); + /// \param title Title + explicit Table(std::string_view label, std::string_view title = ""); /// \brief Constructor /// \param label Label of the element /// \param nRows Number of rows /// \param nCols Number of columns - Table(std::string_view label, int nRows, int nCols); + /// \param title Title + Table(std::string_view label, int nRows, int nCols, std::string_view title = ""); /// \brief Destructor virtual ~Table(){};