Commonly used
UnROOT.LazyBranch — Type
LazyBranch(f::ROOTFile, branch)Construct an accessor for a given branch such that BA[idx] and or BA[1:20] is type-stable. And memory footprint is a single basket (<1MB usually). You can also iterate or map over it. If you want a concrete Vector, simply collect() the LazyBranch.
Example
julia> rf = ROOTFile("./test/samples/tree_with_large_array.root");
julia> b = rf["t1/int32_array"];
julia> ab = UnROOT.LazyBranch(rf, b);
julia> for entry in ab
@show entry
break
end
entry = 0
julia> ab[begin:end]
0
1
...UnROOT.LazyTree — Method
LazyTree(f::ROOTFile, s::AbstractString, branch::Union{AbstractString, Regex})
LazyTree(f::ROOTFile, s::AbstractString, branch::Vector{Union{AbstractString, Regex}})Constructor for LazyTree, which is close to an DataFrame (interface wise), and a lazy Table (speed wise). Looping over a LazyTree is fast and type stable. Internally, LazyTree contains a typed table whose branch are LazyBranch. This means that at any given time only N baskets are cached, where N is the number of branches.
Split branches are re-named, and the exact renaming may change. See Issue 156 for context.
Example
julia> mytree = LazyTree(f, "Events", ["Electron_dxy", "nMuon", r"Muon_(pt|eta)$"])
Row │ Electron_dxy nMuon Muon_eta Muon_pt
│ Vector{Float32} UInt32 Vector{Float32} Vector{Float32}
─────┼───────────────────────────────────────────────────────────
1 │ [0.000371] 0 [] []
2 │ [-0.00982] 2 [0.53, 0.229] [19.9, 15.3]
3 │ [] 0 [] []
4 │ [-0.00157] 0 [] []
⋮ │ ⋮ ⋮ ⋮ ⋮UnROOT.LazyTree — Method
function LazyTree(f::ROOTFile, tree::TTree, treepath, branches; sink = LazyTree)Creates a lazy tree object of the selected branches only. branches is vector of String, Regex or Pair{Regex, SubstitutionString}, where the first item is the regex selector and the second item the rename pattern. An alternative container can be used by providing a sink function. The sink function must take as argument an table with a Tables.jl interface. The table columns are filled with LazyBranch objects.
UnROOT.LazyTreeView — Type
LazyTreeView{T<:NamedTuple, I} <: AbstractVector{LazyEvent{T}}A lazy, non-copying view into a subset of rows of a LazyTree, returned by view(tree, idx) / @view tree[idx]. It stores the parent tree's columns together with the selected row indices, so indexing yields the exact same LazyEvent{T} as the parent tree. In particular eltype(@view tree[r]) === eltype(tree), which means a method written for a concrete LazyEvent{T} accepts events from both a tree and a view of it.
More Internal
UnROOT.AbstractRooAbsBinning — Type
AbstractRooAbsBinningAbstract supertype for RooFit binning objects attached to a RooRealVar.
UnROOT.ClusterInfo — Type
ClusterInfoWraps one cluster's page locations (the outer list, one item per column) together with the cluster's entry range. The entry range is needed to handle deferred (extension) columns: clusters written before a column was added omit it from the page list entirely, and clusters overlapping the column's first_ele_idx need leading zero elements.
UnROOT.Cursor — Type
The Cursor type is embedded into Branches of a TTree such that when we need to read the content of a Branch, we don't need to go through the Directory and find the TKey and then seek to where the Branch is.
UnROOT.LeafField — Type
struct LeafField{T}
content_col_idx::Int
columnrecord::ColumnRecord
alt_col_idx::Vector{Int}
alt_columnrecords::Vector{ColumnRecord}
endBase case of field nesting, this links to a column in the RNTuple by 1-based index (content_col_idx). T is the eltype of this field which mostly uses Julia native types except for Switch.
A field may have several column representations (e.g. a float field stored as Real32 in some clusters and Real16 in others). content_col_idx/columnrecord describe the primary representation; alt_col_idx/alt_columnrecords the secondary ones. In every cluster exactly one representation is active, the others are suppressed (they have no pages), see _active_pages.
UnROOT.OffsetBuffer — Type
OffsetBufferWorks with seek, position of the original file. Think of it as a view of IOStream that can be indexed with original positions.
UnROOT.Preamble — Method
Reads the preamble of an object.
The cursor will be put into the right place depending on the data.
UnROOT.RNTuple — Type
RNTupleThis is the struct for holding all metadata (schema) needed to completely describe and RNTuple from ROOT, just like TTree, to obtain a table-like data object, you need to use LazyTree explicitly:
Example
julia> f = ROOTFile("./test/samples/RNTuple/test_ntuple_stl_containers.root");
julia> f["ntuple"]
UnROOT.RNTuple:
header:
name: "ntuple"
ntuple_description: ""
writer_identifier: "ROOT v6.29/01"
schema:
RNTupleSchema with 13 top fields
├─ :lorentz_vector ⇒ Struct
├─ :vector_tuple_int32_string ⇒ Vector
├─ :string ⇒ String
├─ :vector_string ⇒ Vector
...
..
.
julia> LazyTree(f, "ntuple")
Row │ string vector_int32 array_float vector_vector_i vector_string vector_vector_s variant_int32_s vector_variant_ ⋯
│ String Vector{Int32} StaticArraysCor Vector{Vector{I Vector{String} Vector{Vector{S Union{Int32, St Vector{Union{In ⋯
─────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
1 │ one [1] [1.0, 1.0, 1.0] Vector{Int32}[Int3 ["one"] [["one"]] 1 Union{Int64, Strin ⋯
2 │ two [1, 2] [2.0, 2.0, 2.0] Vector{Int32}[Int3 ["one", "two"] [["one"], ["two"]] two Union{Int64, Strin ⋯
3 │ three [1, 2, 3] [3.0, 3.0, 3.0] Vector{Int32}[Int3 ["one", "two", "th [["one"], ["two"], three Union{Int64, Strin ⋯
4 │ four [1, 2, 3, 4] [4.0, 4.0, 4.0] Vector{Int32}[Int3 ["one", "two", "th [["one"], ["two"], 4 Union{Int64, Strin ⋯
5 │ five [1, 2, 3, 4, 5] [5.0, 5.0, 5.0] Vector{Int32}[Int3 ["one", "two", "th [["one"], ["two"], 5 Union{Int64, Strin ⋯
5 columns omittedUnROOT.RNTupleCardinality — Type
struct RNTupleCardinality{T}
content_col_idx::Int
nbits::Int
endSpecial field. The cardinality is basically a counter, but the data column is a leaf column of Index32 or Index64. To get a number from Cardinality, one needs to compute ary[i] - ary[i-1].
UnROOT.RNTupleField — Type
mutable struct RNTupleField{R, F, O, E} <: AbstractVector{E}Not a counterpart of RNTuple field in ROOT. This is a user-facing Julia-only construct like LazyBranch that is meant to act like a lazy AbstractVector backed with file IO source and a schema field from RNTuple.schema.
Ris the type of parentRNTupleFis the type of the field in the schema- 'O' is the type of output when you read a cluster-worth of data
- 'E' is the element type of
O(i.e. what you get for each event (row) in iteration)
UnROOT.RNTupleSchema — Type
struct RNTupleSchemaA wrapper struct for print_tree implementation of the schema display.
Example
julia> f = ROOTFile("./test/samples/RNTuple/test_ntuple_stl_containers.root");
julia> f["ntuple"].schema
RNTupleSchema with 13 top fields
├─ :lorentz_vector ⇒ Struct
│ ├─ :pt ⇒ Leaf{Float32}(col=26)
│ ├─ :eta ⇒ Leaf{Float32}(col=27)
│ ├─ :phi ⇒ Leaf{Float32}(col=28)
│ └─ :mass ⇒ Leaf{Float32}(col=29)
├─ :vector_tuple_int32_string ⇒ Vector
│ ├─ :offset ⇒ Leaf{Int32}(col=9)
│ └─ :content ⇒ Struct
│ ├─ :_1 ⇒ String
│ │ ├─ :offset ⇒ Leaf{Int32}(col=37)
│ │ └─ :content ⇒ Leaf{Char}(col=38)
│ └─ :_0 ⇒ Leaf{Int32}(col=36)
├─ :string ⇒ String
│ ├─ :offset ⇒ Leaf{Int32}(col=1)
│ └─ :content ⇒ Leaf{Char}(col=2)
├─ :vector_string ⇒ Vector
│ ├─ :offset ⇒ Leaf{Int32}(col=5)
│ └─ :content ⇒ String
│ ├─ :offset ⇒ Leaf{Int32}(col=13)
│ └─ :content ⇒ Leaf{Char}(col=14)
...
..
.UnROOT.ROOTFile — Method
ROOTFile(filename::AbstractString; customstructs = Dict("TLorentzVector" => LorentzVector{Float64}))ROOTFile's constructor from a file. The customstructs dictionary can be used to pass user-defined struct as value and its corresponding fClassName (in Branch) as key such that UnROOT will know to interpret them, see interped_data.
See also: LazyTree, LazyBranch
Example
julia> f = ROOTFile("test/samples/NanoAODv5_sample.root")
ROOTFile with 2 entries and 21 streamers.
test/samples/NanoAODv5_sample.root
└─ Events
├─ "run"
├─ "luminosityBlock"
├─ "event"
├─ "HTXS_Higgs_pt"
├─ "HTXS_Higgs_y"
└─ "⋮"UnROOT.RooArgList — Type
RooArgListJulia representation of a persisted RooFit RooArgList.
The contained arguments can be indexed by position or, when the elements carry names, via list["parameter_name"].
UnROOT.RooFitResult — Type
RooFitResultJulia representation of a top-level persisted RooFit RooFitResult.
This provides access to the core fit summary, parameter lists, covariance and correlation matrices when stored, and the global correlation coefficients.
UnROOT.RooRealVar — Type
RooRealVarJulia representation of a persisted RooFit RooRealVar.
This exposes the parameter name, current value, symmetric/asymmetric errors, plotting metadata, and the attached binning object when available.
UnROOT.RooUniformBinning — Type
RooUniformBinningRepresentation of a persisted RooUniformBinning. The current RooFitResult reader keeps this type for API completeness, but may leave the binning field of a RooRealVar as missing when the serialized binning object is not needed by the current fixtures.
UnROOT.StdArrayField — Type
StdArrayField<N, T>Special base-case field for a leaf field representing std::array<T, N>. This is because RNTuple would serialize it as a leaf field but with flags == 0x0001 in the field description. In total, there are two field descriptions associlated with array<>, one for meta-data (the N), the other one for the actual data.
UnROOT.Streamers — Method
function Streamers(io)Reads all the streamers from the ROOT source.
UnROOT.StringField — Type
StringFieldSpecial base-case field for String leaf field. This is because RNTuple splits a leaf String field into two columns (instead of split in field records). So we need an offset column and a content column (that contains Chars).
UnROOT.UnionVector — Type
UnionVector{T, N} <: AbstractVector{T}Lazy view of a std::variant field. tag[i] selects the alternative (1-based) holding entry i and kindex[i] its 1-based index within that alternative's content vector. A tag of 0 marks a variant without value (valueless_by_exception), which is returned as missing.
UnROOT.WritableRNTuple — Type
WritableRNTupleHandle to an RNTuple inside a WritableROOTFile, obtained with f[name] or mkrntuple. Data is added with append!(rnt, table); length(rnt) is the number of entries written so far.
UnROOT.WritableROOTFile — Type
WritableROOTFileA ROOT file opened for writing by create, recreate or update. Behaves like a dictionary of the objects in the file's top directory: keys(f), haskey(f, name), f[name] (a WritableRNTuple) and f[name] = table (create a new RNTuple holding table). Close it with close(f); the file on disk is valid after every operation, so closing only flushes and releases the handle.
UnROOT.WritableROOTFile — Method
WritableROOTFile(io::IO, file_name; compression, path="", owns_io=false)Write a fresh ROOT file container (magic, file header, TFile and top directory records) into the empty, seekable io and return the handle. file_name is the name recorded inside the file. Used by write_rntuple to write into any IO; prefer recreate for files on disk.
UnROOT._BufferSlot — Type
_BufferSlot{B}One thread's cache of a lazy branch/field: the decoded data of one basket (or RNTuple cluster) together with the entry range it covers. Slots are immutable and published through an atomic field of _SlotBox, so the hot read path (getindex of an entry that is already cached) takes no lock: a reader either sees a complete slot or the previous one, never a half-updated pair of buffer and range.
UnROOT._SlotBox — Type
_SlotBox{B}Mutable holder of one thread's _BufferSlot (or nothing before the first read). The slot is an atomic field: refills store it with release semantics and readers load it with acquire semantics.
Base.append! — Method
append!(rnt::WritableRNTuple, table) -> rntAppend the rows of table (any Tables.jl table) to rnt as one new cluster. The table must have exactly the RNTuple's top-level fields (in any order) with matching element types. Since every call writes a cluster of its own, prefer few large appends over many small ones.
Base.getindex — Method
Base.getindex(ba::LazyBranch{T, J}, idx::Integer) where {T, J}Get the idx-th element of a LazyBranch, starting at 1. If idx is within the range of the calling thread's cached basket, it is returned from that buffer without taking a lock. Otherwise the correct basket is fetched by calling basketarray and becomes the thread's cached basket.
UnROOT._active_pages — Method
_active_pages(field::LeafField, page_list) -> (pages, columnrecord)The pages of field in this cluster together with the column record they belong to. A field may have several column representations; in every cluster exactly one of them is active while the others are suppressed (no pages), so the first representation that has pages is the active one.
UnROOT._basket_boundaries — Method
_basket_boundaries(b) -> Vector{Int64}Entry boundaries of the baskets of branch b: basket i holds the (1-based) entries boundaries[i]+1:boundaries[i+1]. Baskets 1:numbaskets(b) are on disk; a trailing basket beyond that is the embedded one.
UnROOT._column_storage_type — Method
_column_storage_type(cr::ColumnRecord) -> TypeThe Julia element type whose bytes make up a page of column cr (before any split/zigzag/delta transformation): index columns are stored as plain Int32 or Int64, everything else as the table's jltype.
UnROOT._field_output_type — Method
_field_output_type(::Type{F}) where FThis is function is used in two ways:
- provide a output type prediction for each "field" in RNTuple so we can
achieve type stability
- it's also used to enforce the type stability in
read_field:
# this is basically a type assertion for `res`
return res::_field_output_type(field)UnROOT._parse_field — Method
_parse_field(field_id, ..., ::Val{rntuple_role_struct})Parse a record (struct) field. The members of base classes (ROOT stores every base class as a sub-field named :_N) are flattened into the record, as ROOT and uproot do. When the same member name is inherited through more than one base class (or clashes with an own member), the inherited ones are disambiguated as BaseClass::member. Members that carry no data at all (recursively empty structs) are dropped.
UnROOT._read_page_list — Function
_read_page_list(rn, nth=1)The (cached) page list of the nth cluster group of rn.
UnROOT._rntuple_clusterrange — Method
The event number range a given cluster covers, in Julia's index
UnROOT._root_compress — Method
_root_compress(payload, fCompress) -> Vector{UInt8}Compress payload using ROOT's block framing for the fCompress setting (algorithm*100 + level; 0 means no compression). Returns the on-disk bytes. As ROOT does, if compression does not shrink the data the original payload is returned unchanged, so a reader detects the absence of compression by comparing the on-disk size to the uncompressed size.
UnROOT._root_datime — Function
_root_datime([t]) -> UInt32Encode a wall-clock time as ROOT's TDatime (the fDatime field of every TKey): a 32-bit packed (year-1995):month:day:hour:min:sec. Defaults to the current local time, so written files carry a real timestamp instead of a frozen one.
UnROOT._search_col_type — Method
_search_col_type(field_id, column_records, alias_columns)Find the column(s) attached to the (0-based) field_id and wrap them into a LeafField or StringField. Alias columns (projected fields) redirect to the physical columns of another field. Returns nothing when no column is attached to the field (e.g. the std::atomic<T> wrapper field, whose payload lives in a sub-field).
UnROOT._unpack_bits! — Method
_unpack_bits!(out::AbstractVector{UInt32}, packed::AbstractVector{UInt8}, nbits)Unpack a little-endian bit stream of nbits-wide unsigned values (the on-disk layout of Real32Trunc/Real32Quant pages) into out.
UnROOT._write_rblob — Method
_write_rblob(file::IO, payload::AbstractVector{UInt8}, fdatime; compression=0) -> (pos, nbytes)Write an RBlob TKey followed by payload with correctly computed key sizes, optionally compressing the payload with ROOT's block framing for the given compression (fCompress) code. The key's fObjLen records the uncompressed size and fNbytes the on-disk size, so a reader can tell whether the blob is compressed. Returns the file position where the (possibly compressed) payload starts and its on-disk byte count (for locators).
UnROOT.array — Method
array(f::ROOTFile, path; raw=false)Reads an array from a branch. Set raw=true to return raw data and correct offsets.
UnROOT.arrays — Method
arrays(f::ROOTFile, treename)Reads all branches from a tree.
UnROOT.auto_T_JaggT — Method
auto_T_JaggT(f::ROOTFile, branch; customstructs::Dict{String, Type})Given a file and branch, automatically return (eltype, JaggType). This function is aware of custom structs carried with the parent ROOTFile.
See also: ROOTFile, interped_data
UnROOT.basketarray — Method
basketarray(f::ROOTFile, path::AbstractString, ith)
basketarray(f::ROOTFile, branch::Union{TBranch, TBranchElement}, ith)
basketarray(lb::LazyBranch, ith)Reads actual data from ith basket of a branch. This function first calls readbasket to obtain raw bytes and offsets of a basket, then calls auto_T_JaggT followed by interped_data to translate raw bytes into actual data.
UnROOT.basketarray_iter — Method
basketarray_iter(f::ROOTFile, branch::Union{TBranch, TBranchElement})
basketarray_iter(lb::LazyBranch)Returns a Base.Generator yielding the output of basketarray() for all baskets.
UnROOT.chaintrees — Method
chaintrees(ts)Chain a collection of LazyTrees together to form a larger tree, every tree should have identical branch names and types, we're not trying to re-implement SQL here.
Example
julia> typeof(tree)
LazyTree with 1 branches:
a
julia> tree2 = UnROOT.chaintrees([tree,tree]);
julia> eltype(tree.a) == eltype(tree2.a)
true
julia> length(tree)
100
julia> length(tree2)
200
julia> eltype(tree)
UnROOT.LazyEvent{NamedTuple{(:a,), Tuple{LazyBranch{Int32, UnROOT.Nojagg, Vector{Int32}}}}}
julia> eltype(tree2)
UnROOT.LazyEvent{NamedTuple{(:a,), Tuple{SentinelArrays.ChainedVector{Int32, LazyBranch{Int32, UnROOT.Nojagg, Vector{Int32}}}}}}UnROOT.compressed_datastream — Method
compressed_datastream(io, tkey)Extract all [compressionheader][rawbytes] from a TKey. This is an isolated function because we want to compartmentalize disk I/O as much as possible.
See also: decompress_datastreambytes
UnROOT.create — Method
create(path; compression=404) -> WritableROOTFile
create(f::Function, path; compression)Create a new ROOT file at path for writing RNTuples; errors if the file already exists (like ROOT's "CREATE" option). compression is the ROOT fCompress code (algorithm*100 + level, 0 for none) used for the data. The do-block form closes the file when f returns.
UnROOT.decompress_datastreambytes — Method
decompress_datastreambytes(compbytes, tkey)Process the compressed bytes compbytes which was read out by compressed_datastream and pointed to from tkey. This function simply return uncompressed bytes according to the compression algorithm detected (or the lack of).
UnROOT.endcheck — Method
function endcheck(io, preamble::Preamble)Checks if everything went well after parsing a TObject. Used in conjunction with Preamble.
UnROOT.generate_page_links — Function
generate_page_links(page_locators, compression, element_offsets=zeros(...)) -> RNTuplePageTopListBuild the nested page-location list for a single cluster. page_locators is a vector of (num_elements, nbytes, offset) for each column's single page; compression is the fCompress code recorded per column and element_offsets the number of elements each column already holds in earlier clusters (the column's global index of the first element in this cluster).
UnROOT.httpstreamer — Method
Placeholder function which is extended with HTTP is loaded.
UnROOT.interped_data — Method
interped_data(rawdata, rawoffsets, ::Type{T}, ::Type{J}) where {T, J<:JaggType}The function thats interpret raw bytes (from a basket) into corresponding Julia data, based on type T and jagg type J.
In order to retrieve data from custom branches, user should defined more speialized method of this function with specific T and J. See TLorentzVector example.
UnROOT.interped_data — Method
interped_data(rawdata, rawoffsets, ::Type{Vector{LorentzVector{Float64}}}, ::Type{Offsetjagg})The interped_data method specialized for LorentzVector. This method will get called by basketarray instead of the default method for TLorentzVector branch.
UnROOT.isvoid — Method
isvoid(::Type{T})Internal function to determine (by only looking at the type) if a RNTuple field is recursively empty. A field is empty is there's no more data column attached to it from this point forward.
For example, the :_0 field is empty here:
├─ Symbol("AntiKt4TruthDressedWZJetsAux:") ⇒ Struct
│ ├─ :m ⇒ Vector
│ │ ├─ :offset ⇒ Leaf{UnROOT.Index64}(col=23)
│ │ └─ :content ⇒ Leaf{Float32}(col=24)
│ ├─ Symbol(":_0") ⇒ Struct
│ │ ├─ Symbol(":_2") ⇒ Struct
│ │ ├─ Symbol(":_1") ⇒ Struct
│ │ ├─ Symbol(":_0") ⇒ Struct
│ │ │ └─ Symbol(":_0") ⇒ Struct
│ │ └─ Symbol(":_3") ⇒ StructWhen we parse the schema, we discard anything that cannot possibly produce redable data.
UnROOT.mkrntuple — Method
mkrntuple(f::WritableROOTFile, name, spec) -> WritableRNTupleAdd an RNTuple called name to f. spec is either a Tables.jl table, whose contents become the first cluster (this is what f[name] = table does), or a type specification for an initially empty RNTuple: a Tables.Schema or a NamedTuple of element types such as (x = Float64, v = Vector{Int32}). Fill it afterwards with append!.
Supported element types: Bool, Int8–Int64, UInt8–UInt64, Float16/Float32/Float64, String, and (nested) Vectors of these.
UnROOT.numbaskets — Method
numbaskets(b) -> IntNumber of baskets of branch b that are stored as separate TKeys on disk. A branch may additionally hold one "embedded" basket (a TBasket streamed together with the branch itself, e.g. in recovered or CloneTreed files); that basket holds the entries from fBasketEntry[numbaskets + 1] to fEntries, see _basket_boundaries.
UnROOT.parseTH — Method
parseTH(th::Dict{Symbol, Any}; raw=true) -> (counts, edges, sumw2, nentries)
parseTH(th::Dict{Symbol, Any}; raw=false) -> Union{FHist.Hist1D, FHist.Hist2D, FHist.Hist3D}When raw=true, parse the output of TH into a tuple of counts, edges, sumw2, and nentries. When raw=false, parse the output of TH into FHist.jl histograms.
Example
julia> UnROOT.parseTH(UnROOT.samplefile("histograms1d2d.root")["myTH1D"])
([40.0, 2.0], (-2.0:2.0:2.0,), [800.0, 2.0], 4.0)
julia> UnROOT.parseTH(UnROOT.samplefile("histograms1d2d.root")["myTH1D"]; raw=false)
edges: -2.0:2.0:2.0
bin counts: [40.0, 2.0]
total count: 42.0!!! note
TH1, TH2, and TH3 histograms are supported.UnROOT.parsetobject — Method
Direct parsing of streamed objects which are not sitting on branches. This function needs to be rewritten, so that it can create proper types of TObject inherited data (like TVectorT<*>).
UnROOT.read_field — Method
read_field(io, field::F, page_list) where FRead a field from the io stream. The page_list is a list of PageLinks for the current cluster group. The type stability is achieved by type asserting based on type F via _field_output_type function.
UnROOT.read_field — Method
read_field(io, field::StructField{N, T}, page_list) where {N, T}Since each field of the struct is stored in a separate field of the RNTuple, this function returns a StructArray to maximize efficiency.
UnROOT.read_pagedesc — Method
read_pagedesc(io, pagedescs::AbstractVector{PageDescription}, cr::ColumnRecord)
read_pagedesc!(dst::AbstractVector{UInt8}, io, pagedescs, cr)Read the decompressed raw bytes given a list of Page Descriptions, either into a freshly allocated vector or into dst (which must hold exactly ceil(num_elements * nbits / 8) bytes, or 4 * num_elements bytes for the variable-width float encodings). The nbits comes from the column record since pagedesc only contains num_elements information.
UnROOT.read_tvectort_double — Method
read_tvectort_double(io)Read the payload of a streamed TVectorT<double> once the outer TObject header has already been consumed by the caller.
UnROOT.readbasket — Method
readbasket(f::ROOTFile, branch, ith)
readbasketseek(f::ROOTFile, branch::Union{TBranch, TBranchElement}, seek_pos::Int, nbytes)The fundamental building block of reading read data from a .root file. Read one basket's raw bytes and offsets at a time. These raw bytes and offsets then (potentially) get processed by interped_data.
See also: auto_T_JaggT, basketarray
UnROOT.readobjany! — Method
function readobjany!(io, tkey::TKey, refs)The main entrypoint where streamers are parsed and cached for later use. The refs dictionary holds the streamers or parsed data which are reused when already available.
UnROOT.recreate — Method
recreate(path; compression=404) -> WritableROOTFile
recreate(f::Function, path; compression)Create a new ROOT file at path, overwriting any existing file (like ROOT's "RECREATE" option). See create for the arguments.
Example
UnROOT.recreate("out.root") do f
f["events"] = (x = [1.0, 2.0], s = ["a", "b"]) # first cluster
append!(f["events"], (x = [3.0], s = ["c"])) # second cluster
endUnROOT.rnt_ary_to_page — Method
rnt_ary_to_page(ary::AbstractVector, cr::ColumnRecord) endTurns an AbstractVector into a page of an RNTuple. The element type must be primitive for this to work.
UnROOT.rnt_col_to_ary — Method
rnt_col_to_ary(col) -> Vector{Vector}Normalize each user-facing "column" into a collection of Vector{<:Real} ready to be written to a page. After calling this on all user-facing "column", we should have as many arys as our ColumnRecords and in the same order.
UnROOT.rnt_write — Method
@SimpleStruct struct ClusterGroupRecord minimumentrynumber::Int64 entryspan::Int64 numclusters::Int32 pagelistlink::EnvLink end
UnROOT.skiptobj — Method
function skiptobj(io)Skips a TObject.
UnROOT.splitup — Method
splitup(data::Vector{UInt8}, offsets, T::Type; skipbytes=0)Given the offsets and data return by array(...; raw = true), reconstructed the actual array (with custom struct, can be jagged as well).
UnROOT.topological_sort — Method
function topological_sort(streamer_infos)Sort the streamers with respect to their dependencies and keep only those which are not defined already.
The implementation is based on https://stackoverflow.com/a/11564769/1623645
UnROOT.unpack — Method
unpack(x::CompressionHeader)Return the following information:
- Name of compression algorithm
- Level of the compression
- compressedbytes and uncompressedbytes according to uproot3
UnROOT.update — Method
update(path; compression=nothing) -> WritableROOTFile
update(f::Function, path; compression)Open the existing ROOT file at path so RNTuples can be added to it and existing RNTuples extended (like ROOT's "UPDATE" option). New data uses the file's own compression setting unless compression is given.
Only files with the 32-bit layout (smaller than 2 GiB) are supported. An RNTuple written by another program can be extended when UnROOT can reproduce its schema exactly: fields of the supported types (numbers, Bool, strings and nested vectors of these), one column representation per field, and a footer UnROOT's writer serializes byte for byte.
Example
UnROOT.update("out.root") do f
append!(f["events"], (x = [4.0, 5.0], s = ["d", "e"]))
endUnROOT.write_rntuple — Method
write_rntuple(file::IO, table; file_name="test_ntuple_minimal.root",
rntuple_name="myntuple", compression=404)Write table (any Tables.jl-compatible table, e.g. a NamedTuple of vectors) into file as an RNTuple inside a freshly created ROOT file structure. The output is readable by UnROOT itself, uproot, and ROOT (≥ 6.34).
Supported column element types: Bool (bit column), Int8–Int64, UInt8–UInt64, Float16/Float32/Float64, String, and (nested) Vectors of these.
compression is a ROOT fCompress code (algorithm*100 + level); pass 0 for no compression. Supported algorithms: 4 LZ4 (default, level 4), 1 ZLIB, 5 ZSTD. Each page and the header/footer/page-list envelopes are compressed independently, and any block that fails to shrink is stored uncompressed.
The data is written as a single cluster with one page per column; struct/union columns are not supported. To write several RNTuples into one file, or to append clusters to an RNTuple (also in an existing file), use recreate / update and append!.
Example
julia> open("out.root", "w") do io
UnROOT.write_rntuple(io, (x=[1.0, 2.0], s=["a", "b"]); rntuple_name="t")
end
julia> LazyTree("out.root", "t")UnROOT.xrootdstreamer — Method
Placeholder function which is extended with XRootD is loaded.
UnROOT.@SimpleStruct — Macro
macro SimpleStructDefine reading method on the fly for _rntuple_read
Example
julia> @SimpleStruct struct Locator
num_bytes::Int32
offset::UInt64
endwould automatically define the following reading method:
function _rntuple_read(io, ::Type{Locator})
num_bytes = _rntuple_read(io, Int32)
offset = _rntuple_read(io, UInt64)
Locator(num_bytes, offset)
endNotice _rntuple_read falls back to read for all types that are not defined by us.
UnROOT.@stack — Macro
macro stack(into, structs...)Stack the fields of multiple structs and create a new one. The first argument is the name of the new struct followed by the ones to be stacked. Parametric types are not supported and the fieldnames needs to be unique.
Example:
@stack Baz Foo BarCreates Baz with the concatenated fields of Foo and Bar