From 267fedfbc15848d306dfb2bd5071d858c2221ac3 Mon Sep 17 00:00:00 2001 From: "s.zharko@gsi.de" <s.zharko@gsi.de> Date: Thu, 28 Mar 2024 14:30:35 +0100 Subject: [PATCH] qa: report: beamer class is introduced --- algo/ca/TrackingChain.cxx | 6 +- core/qa/CMakeLists.txt | 3 + core/qa/report/CbmQaReportBeamerEngine.cxx | 74 ++++++++++++++++++++++ core/qa/report/CbmQaReportBeamerEngine.h | 68 ++++++++++++++++++++ core/qa/report/CbmQaReportElement.h | 12 +++- core/qa/report/CbmQaReportFigure.h | 6 +- core/qa/report/CbmQaReportLatexEngine.cxx | 17 +---- core/qa/report/CbmQaReportLatexEngine.h | 8 --- core/qa/report/CbmQaReportLatexFormat.cxx | 30 +++++++++ core/qa/report/CbmQaReportLatexFormat.h | 24 +++++++ core/qa/report/CbmQaReportSection.cxx | 3 +- core/qa/report/CbmQaReportSection.h | 7 -- core/qa/report/CbmQaReportTable.cxx | 6 +- core/qa/report/CbmQaReportTable.h | 6 +- 14 files changed, 226 insertions(+), 44 deletions(-) create mode 100644 core/qa/report/CbmQaReportBeamerEngine.cxx create mode 100644 core/qa/report/CbmQaReportBeamerEngine.h create mode 100644 core/qa/report/CbmQaReportLatexFormat.cxx diff --git a/algo/ca/TrackingChain.cxx b/algo/ca/TrackingChain.cxx index 4708b99553..c960c0f3c3 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 65783ad554..db91d744b8 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 0000000000..02dde8dd22 --- /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 0000000000..95d5db3491 --- /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 7ce9595a73..81c99468f7 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 03d93018be..b152ae9820 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 9b5214189b..b2e95e6262 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 0eeeb55731..e81a9bb3c8 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 0000000000..5e06cfc549 --- /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 e69de29bb2..afdfc157cc 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 f55ea983bd..e0ad268e71 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 0f50ab69b7..4a38eda5ff 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 581ee5462a..894d39c56e 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 1d65d3bdb5..3af892ea60 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(){}; -- GitLab