CbmRoot
Loading...
Searching...
No Matches
DigiEventQa.h
Go to the documentation of this file.
1/* Copyright (C) 2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Volker Friese [committer], P.-A. Loizeau */
4
5#ifndef ALGO_QA_DIGIEVENTQA_H
6#define ALGO_QA_DIGIEVENTQA_H 1
7
8#include "CbmDefs.h"
9#include "DigiData.h"
10#include "HistogramContainer.h"
12
13#include <gsl/span>
14#include <unordered_map>
15#include <vector>
16
17
18namespace cbm::algo::evbuild
19{
20
28 std::unordered_map<ECbmModuleId, qa::H1D*> fDigiTimeHistos = {};
29 size_t fNumEvents = 0;
30 };
31
32
39 uint32_t fNumBins;
40 double fMinValue;
41 double fMaxValue;
42 std::string ToString() const
43 {
44 std::stringstream ss;
45 ss << "nbins " << fNumBins << " min " << fMinValue << " max " << fMaxValue << "\n";
46 return ss.str();
47 }
48 };
49
50
57 std::map<ECbmModuleId, DigiEventQaDetConfig> fData;
58 std::string ToString() const
59 {
60 std::stringstream ss;
61 for (const auto& entry : fData)
62 ss << "\n Subsystem " << ::ToString(entry.first) << " " << entry.second.ToString();
63 return ss.str();
64 }
65 DigiEventQaConfig() = default;
66 DigiEventQaConfig(const EventBuilderConfig& evbuildConfig, double borderSize, uint32_t numBins)
67 {
68 for (const auto& entry : evbuildConfig.fWindows) {
69 auto detector = entry.first;
70 double tmin = entry.second.first - borderSize;
71 double tmax = entry.second.second + borderSize;
72 fData[detector] = {numBins, tmin, tmax};
73 }
74 }
75 static std::string GetDigiTimeHistoName(const ECbmModuleId& subsystem)
76 {
77 return "digi_time_" + ::ToString(subsystem);
78 }
79 std::vector<std::pair<std::string, std::string>> GetHistosConfigs() const
80 {
81 std::vector<std::pair<std::string, std::string>> cfg{};
82 for (const auto& entry : fData) {
83 cfg.push_back(std::pair<std::string, std::string>(GetDigiTimeHistoName(entry.first), "DigiEvtQa"));
84 }
85 return cfg;
86 }
87 std::vector<std::pair<std::string, std::string>> GetCanvasConfigs() const
88 {
93
94 // --- Canvas of all Time in event per system
95 std::pair<std::string, std::string> cfgDigiTimeAll{"digiEvtTimeQaCanv", "digiEvtTimeQaCanv;"};
96 cfgDigiTimeAll.second += "Digi time in Events per subsystem;";
97 cfgDigiTimeAll.second += std::to_string(fData.size() / 2 + fData.size() % 2) + ";2;";
98 for (const auto& entry : fData) {
99 cfgDigiTimeAll.second += std::string("1,1,0,1,0,(") + GetDigiTimeHistoName(entry.first) + ",hist);";
100 }
101 if (fData.size() % 2) { // Empty pad if odd number of systems
102 cfgDigiTimeAll.second += std::string("1,1,0,1,0,;");
103 }
104 return std::vector<std::pair<std::string, std::string>>{cfgDigiTimeAll};
105 }
106 };
107
108
115 public:
117 DigiEventQa(const DigiEventQaConfig& config) : fConfig(config){};
118
120 virtual ~DigiEventQa() = default;
121
126 DigiEventQaData operator()(const std::vector<DigiEvent>& events) const;
127
129 std::string ToString() const;
130
132 const DigiEventQaConfig& GetConfig() const { return fConfig; }
133
134
135 private: // methods
143 template<class Digi>
144 void FillDeltaT(gsl::span<const Digi> digis, double eventTime, qa::H1D* histo) const
145 {
146 for (const Digi& digi : digis)
147 histo->Fill(digi.GetTime() - eventTime);
148 }
149
155 void QaDigiTimeInEvent(const DigiEvent& event, ECbmModuleId system, qa::H1D* histo) const;
156
157
158 private: // members
160 };
161
162
163} // namespace cbm::algo::evbuild
164
165#endif /* ALGO_QA_DIGIEVENTQA_H */
ECbmModuleId
Definition CbmDefs.h:39
A histogram container for the histogram server (header)
QA for CbmDigiEvent objects.
DigiEventQaData operator()(const std::vector< DigiEvent > &events) const
Execution.
DigiEventQa(const DigiEventQaConfig &config)
Constructor.
std::string ToString() const
Info to string.
virtual ~DigiEventQa()=default
Destructor.
const DigiEventQaConfig & GetConfig() const
Const access to Qa config.
void QaDigiTimeInEvent(const DigiEvent &event, ECbmModuleId system, qa::H1D *histo) const
Fill histogram with digi time within event.
void FillDeltaT(gsl::span< const Digi > digis, double eventTime, qa::H1D *histo) const
Fill histogram with digi time within event.
Configuration of the EventBuilder class.
std::map< ECbmModuleId, std::pair< double, double > > fWindows
Key: detector; value: [tmin, tmax].
1D-histogram
int Fill(double x, double w=1.)
Fills histogram.
Definition Histogram.h:473
Event data with event number and trigger time.
Definition DigiData.h:79
Configuration data for the QA of CbmDigiEvents.
Definition DigiEventQa.h:56
std::map< ECbmModuleId, DigiEventQaDetConfig > fData
Definition DigiEventQa.h:57
std::vector< std::pair< std::string, std::string > > GetHistosConfigs() const
Definition DigiEventQa.h:79
DigiEventQaConfig(const EventBuilderConfig &evbuildConfig, double borderSize, uint32_t numBins)
Definition DigiEventQa.h:66
static std::string GetDigiTimeHistoName(const ECbmModuleId &subsystem)
Definition DigiEventQa.h:75
std::vector< std::pair< std::string, std::string > > GetCanvasConfigs() const
Definition DigiEventQa.h:87
QA results for CbmDigiEvent objects.
Definition DigiEventQa.h:26
qa::HistogramContainer fHistContainer
Definition DigiEventQa.h:27
std::unordered_map< ECbmModuleId, qa::H1D * > fDigiTimeHistos
Definition DigiEventQa.h:28
Configuration data for the QA of CbmDigiEvents for a given detector.
Definition DigiEventQa.h:38
Structure to keep the histograms for sending them on the histogram server.