class DemoFloat16 {
private:
float fF32;
public:
DemoFloat16() = default;
void Set(float ref) { fF32 = fF16 = fI16 = fI14 = fI10 = fI8 = fI6 = fI4 = fR8 = fR6 = fR4 = fR2 = ref; }
};
void float16()
{
const auto nEntries = 200000;
DemoFloat16 demoInstance;
auto demoInstanceBranch =
tree.Branch(
"d",
"DemoFloat16", &demoInstance, 4000);
}
auto branches = demoInstanceBranch->GetListOfBranches();
const auto nb = branches->GetEntries();
auto br =
static_cast<TBranch *
>(branches->At(0));
auto h =
new TH1F(
"h",
"Float16_t compression and precision", nb, 0, nb);
gcx->SetName("gcx");
gcx->SetMarkerColor(
kBlue);
gdrange->SetName("gdrange");
gdrange->SetMarkerColor(
kRed);
gdval->SetName("gdval");
gdval->SetMarkerColor(
kBlack);
br =
static_cast<TBranch *
>(branches->At(i));
h->GetXaxis()->SetBinLabel(i + 1, brName);
auto const cx =
double(zip64) / br->GetZipBytes();
gcx->SetPoint(i, i + 0.5, cx);
if (i == 0) continue;
gdrange->SetPoint(i - 1, i + 0.5, drange);
tree.Draw(
Form(
"(fF32-%s)/fF32 >> hdval_%s", brName, brName),
"",
"goff");
gdval->SetPoint(i - 1, i + 0.5, dval);
tree.Draw(
Form(
"(fF32-%s) >> hdvalabs_%s", brName, brName),
"",
"goff");
auto c =
new TCanvas(brName, brName, 800, 600);
hdval->DrawClone();
}
h->GetXaxis()->LabelsOption(
"v");
gcx->Draw("lp");
gdrange->Draw("lp");
gdval->Draw("lp");
auto legend =
new TLegend(0.3, 0.6, 0.9, 0.9);
legend->SetHeader(
Form(
"%d entries within the [-#pi, #pi] range", nEntries));
legend->AddEntry(gcx, "Compression factor", "lp");
legend->AddEntry(gdrange, "Log of precision wrt range: p = -Log_{10}( RMS( #frac{Ref - x}{range} ) ) ", "lp");
legend->AddEntry(gdval, "Log of precision wrt value: p = -Log_{10}( RMS( #frac{Ref - x}{Ref} ) ) ", "lp");
legend->Draw();
}
char * Form(const char *fmt,...)
A pseudo container class which is a generator of indices.
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)}
TAxis * GetXaxis()
Get the behaviour adopted by the object about the statoverflows. See EStatOverflows for more informat...
This class displays a legend box (TPaveText) containing several legend entries.
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
virtual const char * GetName() const
Returns name of object.
Random number generator class based on M.
A TTree represents a columnar dataset.
Short_t Max(Short_t a, Short_t b)
Double_t RMS(Long64_t n, const T *a, const Double_t *w=0)
Return the Standard Deviation of an array a with length n.
Double_t Log10(Double_t x)