22#include <ROOT/RNTuple.hxx>
42constexpr char const* kNTupleFileName =
"ntpl005_introspection.root";
52 double x()
const {
return fX; }
53 double y()
const {
return fY; }
54 double z()
const {
return fZ; }
56 void SetXYZ(
double x,
double y,
double z) {
66 auto model = RNTupleModel::Create();
67 auto fldVector3 = model->MakeField<
Vector3>(
"v3");
70 RNTupleWriteOptions options;
73 auto ntuple = RNTupleWriter::Recreate(std::move(model),
"Vector3", kNTupleFileName, options);
75 for (
unsigned int i = 0; i < 500000; ++i) {
76 fldVector3->SetXYZ(
r.Gaus(0,1),
r.Landau(0,1),
r.Gaus(100,10));
82void ntpl005_introspection() {
85 auto ntuple = RNTupleReader::Open(
"Vector3", kNTupleFileName);
91 ntuple->PrintInfo(ENTupleInfo::kStorageDetails);
94 ntuple->Show(0, ENTupleShowFormat::kCompleteJSON);
98 ntuple->EnableMetrics();
104 TH1F h1(
"x",
"x component of Vector3", 100, -3, 3);
108 auto viewX = ntuple->GetView<
double>(
"v3.fX");
109 for (
auto i : ntuple->GetEntryRange()) {
116 TH1F h2(
"y",
"y component of Vector3", 100, -5, 20);
117 auto viewY = ntuple->GetView<
double>(
"v3.fY");
118 for (
auto i : ntuple->GetEntryRange()) {
124 ntuple->PrintInfo(ENTupleInfo::kMetrics);
130 float fileSize =
static_cast<float>(fileStat.
fSize);
131 float nbytesRead = ntuple->GetMetrics().GetCounter(
"RNTupleReader.RPageSourceFile.szReadPayload")->GetValueAsInt() +
132 ntuple->GetMetrics().GetCounter(
"RNTupleReader.RPageSourceFile.szReadOverhead")->GetValueAsInt();
134 std::cout <<
"File size: " << fileSize / 1024. / 1024. <<
" MiB" << std::endl;
135 std::cout <<
"Read from file: " << nbytesRead / 1024. / 1024. <<
" MiB" << std::endl;
136 std::cout <<
"Ratio: " << nbytesRead / fileSize << std::endl;
#define R__LOAD_LIBRARY(LIBRARY)
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.
void SetXYZ(Double_t x, Double_t y, Double_t z)
ENTupleInfo
Listing of the different options that can be printed by RNTupleReader::GetInfo()
ENTupleShowFormat
Listing of the different entry output formats of RNTupleReader::Show()
@ kUseGeneralPurpose
Use the new recommended general-purpose setting; it is a best trade-off between compression ratio/dec...