void write_rntuple_to_rfile(const char *fileName)
{
auto pInt = model->MakeField<int>("intField");
for (int i = 0; i < 10; ++i) {
*pInt = i;
}
}
void read_rntuple_from_rfile(const char *fileName)
{
auto pInt = reader->GetModel().GetDefaultEntry().GetPtr<int>("intField");
for (auto i : reader->GetEntryRange()) {
reader->LoadEntry(i);
std::cout << "value[" << i << "] = " << *pInt << "\n";
}
}
void rfile002_rntuple()
{
const char *const fileName = "rfile_rntuple.root";
write_rntuple_to_rfile(fileName);
read_rntuple_from_rfile(fileName);
}
#define R__ASSERT(e)
Checks condition e and reports a fatal error if it's false.
R__EXTERN TSystem * gSystem
static std::unique_ptr< RFile > Open(std::string_view path, const ROpenOptions &opts=ROpenOptions())
Opens the file for reading.
static std::unique_ptr< RFile > Recreate(std::string_view path, const RRecreateOptions &opts=RRecreateOptions())
Opens the file for reading/writing, overwriting it if it already exists.
static std::unique_ptr< RNTupleModel > Create()
static std::unique_ptr< RNTupleReader > Open(std::string_view ntupleName, std::string_view storage, const ROOT::RNTupleReadOptions &options=ROOT::RNTupleReadOptions())
Open an RNTuple for reading.
Representation of an RNTuple data set in a ROOT file.
virtual int Unlink(const char *name)
Unlink, i.e.
std::unique_ptr< RNTupleWriter > RNTupleWriter_Append(std::unique_ptr< ROOT::RNTupleModel > model, std::string_view ntuplePath, ROOT::Experimental::RFile &file, const ROOT::RNTupleWriteOptions &options=ROOT::RNTupleWriteOptions())
Creates an RNTupleWriter that writes into the given file, appending to it.