19def write_rntuple_to_rfile(fileName):
24 model.MakeField[
"int"](
"intField")
27 entry = writer.CreateEntry()
38def read_rntuple_from_rfile(fileName):
42 rntuple = file.Get(
"ntuple")
46 entry = reader.CreateEntry()
47 for i
in reader.GetEntryRange():
48 reader.LoadEntry(i, entry)
49 print(f
"value[{i}] = {entry['intField']}")
52fileName =
"rfile_rntuple_py.root"
54 write_rntuple_to_rfile(fileName)
55 read_rntuple_from_rfile(fileName)
57except FileNotFoundError:
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.
static std::unique_ptr< RNTupleWriter > Append(std::unique_ptr< ROOT::RNTupleModel > model, std::string_view ntupleName, TDirectory &fileOrDirectory, const ROOT::RNTupleWriteOptions &options=ROOT::RNTupleWriteOptions())
Creates an RNTupleWriter that writes into an existing TFile or TDirectory, without overwriting its co...