37 DemoFloat16() =
default;
38 void Set(
float ref) { fF32 = fF16 = fI16 = fI14 = fI10 = fI8 = fI6 = fI4 = fR8 = fR6 = fR4 = fR2 = ref; }
43 const auto nEntries = 200000;
50 DemoFloat16 demoInstance;
51 auto demoInstanceBranch =
tree.Branch(
"d",
"DemoFloat16", &demoInstance, 4000);
62 auto branches = demoInstanceBranch->GetListOfBranches();
63 const auto nb = branches->GetEntries();
64 auto br =
static_cast<TBranch *
>(branches->At(0));
67 auto h =
new TH1F(
"h",
"Float16_t compression and precision", nb, 0, nb);
74 gcx->SetMarkerColor(
kBlue);
76 auto gdrange =
new TGraph();
77 gdrange->SetName(
"gdrange");
79 gdrange->SetMarkerColor(
kRed);
82 gdval->SetName(
"gdval");
84 gdval->SetMarkerColor(
kBlack);
88 br =
static_cast<TBranch *
>(branches->At(i));
89 const auto brName = br->
GetName();
90 h->GetXaxis()->SetBinLabel(i + 1, brName);
91 auto const cx =
double(zip64) / br->GetZipBytes();
92 gcx->SetPoint(i, i + 0.5, cx);
98 gdrange->SetPoint(i - 1, i + 0.5, drange);
100 tree.Draw(
Form(
"(fF32-%s)/fF32 >> hdval_%s", brName, brName),
"",
"goff");
103 gdval->SetPoint(i - 1, i + 0.5, dval);
105 tree.Draw(
Form(
"(fF32-%s) >> hdvalabs_%s", brName, brName),
"",
"goff");
108 auto c =
new TCanvas(brName, brName, 800, 600);
114 auto c1 =
new TCanvas(
"c1",
"c1", 800, 600);
118 h->GetXaxis()->LabelsOption(
"v");
124 auto legend =
new TLegend(0.3, 0.6, 0.9, 0.9);
125 legend->SetHeader(
Form(
"%d entries within the [-#pi, #pi] range", nEntries));
126 legend->AddEntry(gcx,
"Compression factor",
"lp");
127 legend->AddEntry(gdrange,
"Log of precision wrt range: p = -Log_{10}( RMS( #frac{Ref - x}{range} ) ) ",
"lp");
128 legend->AddEntry(gdval,
"Log of precision wrt value: p = -Log_{10}( RMS( #frac{Ref - x}{Ref} ) ) ",
"lp");
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
A TTree is a list of TBranches.
Long64_t GetZipBytes(Option_t *option="") const
Return total number of zip bytes in the branch if option ="*" includes all sub-branches of this branc...
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
Create / open a file.
A TGraph is an object made of two arrays X and Y with npoints each.
1-D histogram with a float per channel (see TH1 documentation)}
This class displays a legend box (TPaveText) containing several legend entries.
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
const char * GetName() const override
Returns name of object.
Random number generator class based on M.
A TTree represents a columnar dataset.
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Double_t RMS(Long64_t n, const T *a, const Double_t *w=0)
Returns the Standard Deviation of an array a with length n.
Double_t Log10(Double_t x)
Returns the common (base-10) logarithm of x.