Logo ROOT  
Reference Guide
RHistStatBox.cxx
Go to the documentation of this file.
1/*************************************************************************
2 * Copyright (C) 1995-2020, Rene Brun and Fons Rademakers. *
3 * All rights reserved. *
4 * *
5 * For the licensing terms see $ROOTSYS/LICENSE. *
6 * For the list of contributors see $ROOTSYS/README/CREDITS. *
7 *************************************************************************/
8
10
11#include <string>
12
13using namespace ROOT::Experimental;
14using namespace std::string_literals;
15
16const std::vector<std::string> &RHistStatBoxBase::GetEntriesNames() const
17{
18 static const std::vector<std::string> sEntries = {"Title","Entries", "Mean","Deviation", "Ranges"};
19 return sEntries;
20}
21
22std::unique_ptr<RDisplayItem> RHistStatBoxBase::Display(const RDisplayContext &ctxt)
23{
25
26 auto frame = ctxt.GetPad()->GetFrame();
27 if (frame) frame->GetClientRanges(ctxt.GetConnId(), ranges);
28
29 std::vector<std::string> lines;
30
32 lines.emplace_back(GetTitle());
33
34 FillStatistic(fShowMask, ranges, lines);
35
36 // do not send stat box itself while it includes histogram which is not required on client side
37 return std::make_unique<RDisplayHistStat>(*this, fShowMask, GetEntriesNames(), lines);
38}
39
40void RHist1StatBox::FillStatistic(unsigned mask, const RFrame::RUserRanges &ranges, std::vector<std::string> &lines) const
41{
42 // TODO: need to implement statistic fill for RHist1
43
44 if (mask & kShowEntries)
45 lines.emplace_back("Entries = 1");
46
47 if (mask & kShowMean)
48 lines.emplace_back("Mean = 2");
49
50 if (mask & kShowDev)
51 lines.emplace_back("Std dev = 3");
52
53 if (mask & kShowRange) {
54 lines.emplace_back("X min = "s + std::to_string(ranges.GetMin(0)));
55 lines.emplace_back("X max = "s + std::to_string(ranges.GetMax(0)));
56 }
57}
58
59
60void RHist2StatBox::FillStatistic(unsigned mask, const RFrame::RUserRanges &ranges, std::vector<std::string> &lines) const
61{
62 // TODO: need to implement statistic fill for RHist2
63
64 if (mask & kShowEntries)
65 lines.emplace_back("Entries = 1");
66
67 if (mask & kShowMean) {
68 lines.emplace_back("Mean x = 2");
69 lines.emplace_back("Mean y = 3");
70 }
71
72 if (mask & kShowDev) {
73 lines.emplace_back("Std dev x = 5");
74 lines.emplace_back("Std dev y = 6");
75 }
76
77 if (mask & kShowRange) {
78 lines.emplace_back("X min = "s + std::to_string(ranges.GetMin(0)));
79 lines.emplace_back("X max = "s + std::to_string(ranges.GetMax(0)));
80 lines.emplace_back("Y min = "s + std::to_string(ranges.GetMin(1)));
81 lines.emplace_back("Y max = "s + std::to_string(ranges.GetMax(1)));
82 }
83}
84
85void RHist3StatBox::FillStatistic(unsigned mask, const RFrame::RUserRanges &ranges, std::vector<std::string> &lines) const
86{
87 // TODO: need to implement statistic fill for RHist3
88
89 if (mask & kShowEntries)
90 lines.emplace_back("Entries = 1");
91
92 if (mask & kShowMean) {
93 lines.emplace_back("Mean x = 2");
94 lines.emplace_back("Mean y = 3");
95 lines.emplace_back("Mean z = 4");
96 }
97
98 if (mask & kShowDev) {
99 lines.emplace_back("Std dev x = 5");
100 lines.emplace_back("Std dev y = 6");
101 lines.emplace_back("Std dev z = 7");
102 }
103
104 if (mask & kShowRange) {
105 lines.emplace_back("X min = "s + std::to_string(ranges.GetMin(0)));
106 lines.emplace_back("X max = "s + std::to_string(ranges.GetMax(0)));
107 lines.emplace_back("Y min = "s + std::to_string(ranges.GetMin(1)));
108 lines.emplace_back("Y max = "s + std::to_string(ranges.GetMax(1)));
109 lines.emplace_back("Z min = "s + std::to_string(ranges.GetMin(2)));
110 lines.emplace_back("Z max = "s + std::to_string(ranges.GetMax(2)));
111 }
112}
double GetMax(unsigned ndim) const
Definition: RFrame.hxx:92
double GetMin(unsigned ndim) const
Definition: RFrame.hxx:79
void FillStatistic(unsigned, const RFrame::RUserRanges &, std::vector< std::string > &) const override
void FillStatistic(unsigned, const RFrame::RUserRanges &, std::vector< std::string > &) const override
void FillStatistic(unsigned, const RFrame::RUserRanges &, std::vector< std::string > &) const override
virtual const std::vector< std::string > & GetEntriesNames() const
virtual void FillStatistic(unsigned, const RFrame::RUserRanges &, std::vector< std::string > &) const
std::unique_ptr< RDisplayItem > Display(const RDisplayContext &) override
Creates display item for drawable By default item contains drawable data itself.
unsigned fShowMask
show stat box lines
const std::string & GetTitle() const
std::shared_ptr< RFrame > GetFrame()
Get a frame object if exists.
Definition: RPadBase.cxx:229
static constexpr double s