CbmRoot
Loading...
Searching...
No Matches
QaData.h
Go to the documentation of this file.
1/* Copyright (C) 2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Sergei Zharko [committer] */
4
9
10#pragma once
11
13#include "CanvasConfig.h"
14#include "HistogramContainer.h"
15#include "HistogramSender.h"
16
17#include <boost/serialization/forward_list.hpp>
18
19#include <memory>
20#include <string_view>
21#include <type_traits>
22#include <vector>
23
24namespace cbm::algo::qa
25{
28 class Data {
29 public:
32 Data(std::string_view name) : fsName(name) {}
33
35 Data(const Data&) = default;
36
38 Data(Data&&) = default;
39
41 Data& operator=(const Data&) = default;
42
44 Data& operator=(Data&&) = default;
45
47 ~Data() = default;
48
51 void AddCanvasConfig(const CanvasConfig& canvas) { fvsCanvCfgs.push_back(canvas.ToString()); }
52
54 std::string_view GetName() const { return fsName; }
55
58 void Init(std::shared_ptr<HistogramSender> histoSender);
59
61 template<class Obj, typename... Args>
62 Obj* MakeObj(Args... args);
63
65 void Reset() { fHistograms.Reset(); }
66
70 void Send(std::shared_ptr<HistogramSender> histoSender);
71
74 void SetTimesliceId(uint64_t timesliceId) { fHistograms.fTimesliceId = timesliceId; }
75
76 private:
77 std::string fsName;
79 std::vector<std::string> fvsCanvCfgs = {};
80 };
81
82 // -------------------------------------------------------------------------------------------------------------------
83 //
84 template<class Obj, typename... Args>
85 Obj* Data::MakeObj(Args... args)
86 {
87 if constexpr (std::is_same_v<Obj, cbm::algo::qa::H1D>) {
88 return &(fHistograms.fvH1.emplace_front(args...));
89 }
90 else if constexpr (std::is_same_v<Obj, cbm::algo::qa::H2D>) {
91 return &(fHistograms.fvH2.emplace_front(args...));
92 }
93 else if constexpr (std::is_same_v<Obj, cbm::algo::qa::Prof1D>) {
94 return &(fHistograms.fvP1.emplace_front(args...));
95 }
96 else if constexpr (std::is_same_v<Obj, cbm::algo::qa::Prof2D>) {
97 return &(fHistograms.fvP2.emplace_front(args...));
98 }
99 return nullptr;
100 }
101} // namespace cbm::algo
A class representing a canvas in the message for the Histogram server.
A histogram container for the histogram server (header)
A canvas configuration for the histogram server.
std::string ToString() const
Returns message config.
Class to handle QA-objects in the online reconstruction.
Definition QaData.h:28
void AddCanvasConfig(const CanvasConfig &canvas)
Adds a canvas to the canvas config list.
Definition QaData.h:51
Data(const Data &)=default
Copy constructor.
std::string_view GetName() const
Gets module name.
Definition QaData.h:54
~Data()=default
Destructor.
Data & operator=(Data &&)=default
Move assignment operator.
void Send(std::shared_ptr< HistogramSender > histoSender)
Sends QA data to the HistogramSender.
Definition QaData.cxx:72
void Init(std::shared_ptr< HistogramSender > histoSender)
Sends QA initialization information to the HistogramSender.
Definition QaData.cxx:18
void SetTimesliceId(uint64_t timesliceId)
Updates the timeslice index.
Definition QaData.h:74
std::string fsName
Name of the QA module (used as a directory name)
Definition QaData.h:77
void Reset()
Resets the histograms.
Definition QaData.h:65
Data & operator=(const Data &)=default
Copy assignment operator.
Data(Data &&)=default
Move constructor.
Obj * MakeObj(Args... args)
Creates a QA-object and returns the pointer to it.
Definition QaData.h:85
qa::HistogramContainer fHistograms
Histograms container.
Definition QaData.h:78
std::vector< std::string > fvsCanvCfgs
Vector of canvas configs.
Definition QaData.h:79
Data(std::string_view name)
Constructor.
Definition QaData.h:32
Structure to keep the histograms for sending them on the histogram server.
void Reset()
Resets the histograms.
std::forward_list< qa::Prof1D > fvP1
List of 1D-profiles.
std::forward_list< qa::Prof2D > fvP2
List of 2D-profiles.
std::forward_list< qa::H1D > fvH1
List of 1D-histograms.
uint64_t fTimesliceId
Index of the timeslice.
std::forward_list< qa::H2D > fvH2
List of 2D-histograms.