CbmRoot
Loading...
Searching...
No Matches
CbmQaOnlineInterface.cxx
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
11//#include "Histogram.h"
12
13#include "TH1D.h"
14#include "TH2D.h"
15#include "TProfile.h"
16#include "TProfile2D.h"
17
24
25// ---------------------------------------------------------------------------------------------------------------------
26//
27void OnlineInterface::AddSlice(const H1D& src, double value, TH2D* dst)
28{
29 auto* pDst = static_cast<RootHistogramAccessor<TH2D>*>(dst);
30 pDst->AddSliceFromQaHistogram<H1D>(src, value);
31}
32
33// ---------------------------------------------------------------------------------------------------------------------
34//
35void OnlineInterface::AddSlice(const Prof1D& src, double value, TProfile2D* dst)
36{
37 auto* pDst = static_cast<RootHistogramAccessor<TProfile2D>*>(dst);
38 pDst->AddSliceFromQaHistogram<Prof1D>(src, value);
39}
40
41// ---------------------------------------------------------------------------------------------------------------------
42//
44{
45 int nBins = hist.GetNbinsX();
46 double xMin = hist.GetMinX();
47 double xMax = hist.GetMaxX();
48 bool add = TH1::AddDirectoryStatus();
49 TH1::AddDirectory(false);
50 auto* pRes = new RootHistogramAccessor<TH1D>(hist.GetName().c_str(), hist.GetTitle().c_str(), nBins, xMin, xMax);
51 TH1::AddDirectory(add);
52 pRes->SetFromQaHistogram<H1D>(hist);
53 return pRes;
54}
55
56// ---------------------------------------------------------------------------------------------------------------------
57//
59{
60 int nBinsX = hist.GetNbinsX();
61 double xMin = hist.GetMinX();
62 double xMax = hist.GetMaxX();
63 int nBinsY = hist.GetNbinsY();
64 double yMin = hist.GetMinY();
65 double yMax = hist.GetMaxY();
66 bool add = TH1::AddDirectoryStatus();
67 TH1::AddDirectory(false);
68 auto* pRes = new RootHistogramAccessor<TH2D>(hist.GetName().c_str(), hist.GetTitle().c_str(), nBinsX, xMin, xMax,
69 nBinsY, yMin, yMax);
70 TH1::AddDirectory(add);
71 pRes->SetFromQaHistogram<H2D>(hist);
72 return pRes;
73}
74
75// ---------------------------------------------------------------------------------------------------------------------
76//
78{
79 const char* name = prof.GetName().c_str();
80 const char* titl = prof.GetTitle().c_str();
81 int nBinsX = prof.GetNbinsX();
82 double xMin = prof.GetMinX();
83 double xMax = prof.GetMaxX();
84 double yMin = prof.GetMinY();
85 double yMax = prof.GetMaxY();
86 bool add = TH1::AddDirectoryStatus();
87 TH1::AddDirectory(false);
88 auto* pRes = new RootHistogramAccessor<TProfile>(name, titl, nBinsX, xMin, xMax, yMin, yMax);
89 TH1::AddDirectory(add);
90 pRes->SetFromQaHistogram<Prof1D>(prof);
91 return pRes;
92}
93
94// ---------------------------------------------------------------------------------------------------------------------
95//
96TProfile2D* OnlineInterface::ROOTHistogram(const Prof2D& prof)
97{
98 const char* name = prof.GetName().c_str();
99 const char* titl = prof.GetTitle().c_str();
100 int nBinsX = prof.GetNbinsX();
101 double xMin = prof.GetMinX();
102 double xMax = prof.GetMaxX();
103 int nBinsY = prof.GetNbinsY();
104 double yMin = prof.GetMinY();
105 double yMax = prof.GetMaxY();
106 double zMin = prof.GetMinZ();
107 double zMax = prof.GetMaxZ();
108 bool add = TH1::AddDirectoryStatus();
109 TH1::AddDirectory(false);
110 auto* pRes = new RootHistogramAccessor<TProfile2D>(name, titl, nBinsX, xMin, xMax, nBinsY, yMin, yMax, zMin, zMax);
111 TH1::AddDirectory(add);
112 pRes->SetFromQaHistogram<Prof2D>(prof);
113 return pRes;
114}
Set of tools for online->ROOT QA-objects conversions (header)
1D-histogram
2D-histogram
const std::string & GetTitle() const
Gets title.
Definition Histogram.h:348
uint32_t GetNbinsY() const
Gets number of bins for y axis.
Definition Histogram.h:316
double GetMaxY() const
Gets y-axis lower bound.
Definition Histogram.h:330
const std::string & GetName() const
Gets name.
Definition Histogram.h:297
double GetMinY() const
Gets y-axis lower bound.
Definition Histogram.h:323
double GetMaxX() const
Gets x-axis lower bound.
Definition Histogram.h:312
double GetMinX() const
Gets x-axis lower bound.
Definition Histogram.h:309
uint32_t GetNbinsX() const
Gets number of bins for x axis.
Definition Histogram.h:306
double GetMaxY() const
Gets y-axis lower bound.
Definition Histogram.h:682
double GetMinY() const
Gets y-axis lower bound.
Definition Histogram.h:679
double GetMaxZ() const
Gets z-axis lower bound.
Definition Histogram.h:805
double GetMinZ() const
Gets z-axis lower bound.
Definition Histogram.h:802
A collection of tools for online QA object conversions.
static void AddSlice(const H1D &src, double value, TH2D *dst)
Fills a slice of a histogram of a higher dimension for a given value (....)
static TH1D * ROOTHistogram(const H1D &hist)
Converts histogram H1D to ROOT histogram TH1D.
Helper class to access protected fields of TH1, TH2, TProfile and TProfile2D.
void AddSliceFromQaHistogram(const SourceQaHistogram &histo, double val)
Sets slice from the lower-dimension histogram.