Adapted from tv3.C Illustrates various RNTuple introspection methods.
#include <cassert>
constexpr char const* kNTupleFileName = "ntpl005_introspection.root";
class Vector3 {
private:
double fX = 0;
double fY = 0;
double fZ = 0;
public:
double x()
const {
return fX; }
double y()
const {
return fY; }
double z() const { return fZ; }
void SetXYZ(
double x,
double y,
double z) {
fZ = z;
}
};
void Generate()
{
auto model = RNTupleModel::Create();
auto fldVector3 = model->MakeField<Vector3>("v3");
RNTupleWriteOptions options;
auto ntuple = RNTupleWriter::Recreate(std::move(model), "Vector3", kNTupleFileName, options);
for (unsigned int i = 0; i < 500000; ++i) {
fldVector3->SetXYZ(
r.Gaus(0,1),
r.Landau(0,1),
r.Gaus(100,10));
ntuple->Fill();
}
}
void ntpl005_introspection() {
Generate();
auto ntuple = RNTupleReader::Open("Vector3", kNTupleFileName);
ntuple->PrintInfo();
ntuple->PrintInfo(ENTupleInfo::kStorageDetails);
ntuple->Show(0);
ntuple->EnableMetrics();
TH1F h1(
"x",
"x component of Vector3", 100, -3, 3);
{
auto viewX = ntuple->GetView<double>("v3.fX");
for (auto i : ntuple->GetEntryRange()) {
}
}
TH1F h2(
"y",
"y component of Vector3", 100, -5, 20);
auto viewY = ntuple->GetView<double>("v3.fY");
for (auto i : ntuple->GetEntryRange()) {
}
ntuple->PrintInfo(ENTupleInfo::kMetrics);
assert(retval == 0);
float fileSize =
static_cast<float>(fileStat.
fSize);
float nbytesRead = ntuple->GetMetrics().GetCounter("RNTupleReader.RPageSourceFile.szReadPayload")->GetValueAsInt() +
ntuple->GetMetrics().GetCounter("RNTupleReader.RPageSourceFile.szReadOverhead")->GetValueAsInt();
std::cout << "File size: " << fileSize / 1024. / 1024. << " MiB" << std::endl;
std::cout << "Read from file: " << nbytesRead / 1024. / 1024. << " MiB" << std::endl;
std::cout << "Ratio: " << nbytesRead / fileSize << std::endl;
}
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
R__EXTERN TSystem * gSystem
The RNTupleModel encapulates the schema of an ntuple.
An RNTuple that is used to read data from storage.
Common user-tunable settings for storing ntuples.
An RNTuple that gets filled with entries (data) and writes them to storage.
1-D histogram with a float per channel (see TH1 documentation)
virtual Int_t Fill(Double_t x)
Increment bin with abscissa X by 1.
virtual TH1 * DrawCopy(Option_t *option="", const char *name_postfix="_copy") const
Copy this histogram and Draw in the current pad.
This is the base class for the ROOT Random number generators.
int GetPathInfo(const char *path, Long_t *id, Long_t *size, Long_t *flags, Long_t *modtime)
Get info about a file: id, size, flags, modification time.
ENTupleInfo
Listing of the different options that can be printed by RNTupleReader::GetInfo()
@ kUseGeneralPurpose
Use the new recommended general-purpose setting; it is a best trade-off between compression ratio/dec...