uproot_custom package¶
Subpackages¶
- uproot_custom.cpp package
- Module contents
AnyClassReaderAnyPointerReaderCStyleArrayReaderDoubleReaderEmptyReaderFloatReaderGroupReaderIReaderInt16ReaderInt32ReaderInt64ReaderInt8ReaderSTLMapReaderSTLSeqReaderSTLStringReaderTArrayCReaderTArrayDReaderTArrayFReaderTArrayIReaderTArrayLReaderTArraySReaderTObjectReaderTStringReaderUInt16ReaderUInt32ReaderUInt64ReaderUInt8Readerread_data()
- Module contents
- uproot_custom.detree package
- Subpackages
- uproot_custom.detree.compiler package
- Submodules
- uproot_custom.detree.compiler.frontend module
- uproot_custom.detree.compiler.ir_builder module
IRFunctionBuilderIRFunctionBuilder.assert_cursor_eq()IRFunctionBuilder.assert_str_eq()IRFunctionBuilder.block()IRFunctionBuilder.buf_append()IRFunctionBuilder.buf_append_const()IRFunctionBuilder.buf_append_len()IRFunctionBuilder.buf_append_offset()IRFunctionBuilder.buf_last()IRFunctionBuilder.buf_len()IRFunctionBuilder.call()IRFunctionBuilder.const()IRFunctionBuilder.const_into()IRFunctionBuilder.cursor()IRFunctionBuilder.data_size()IRFunctionBuilder.emit()IRFunctionBuilder.emit_op()IRFunctionBuilder.entries()IRFunctionBuilder.finish()IRFunctionBuilder.for_range()IRFunctionBuilder.if_()IRFunctionBuilder.init_offset()IRFunctionBuilder.local()IRFunctionBuilder.mov()IRFunctionBuilder.offset_seek()IRFunctionBuilder.read_append()IRFunctionBuilder.read_bulk()IRFunctionBuilder.read_cstr()IRFunctionBuilder.read_fields()IRFunctionBuilder.read_fnb()IRFunctionBuilder.read_scalar()IRFunctionBuilder.read_strided()IRFunctionBuilder.read_tstring()IRFunctionBuilder.read_version()IRFunctionBuilder.ref_count()IRFunctionBuilder.ref_get_class()IRFunctionBuilder.ref_get_obj()IRFunctionBuilder.ref_has()IRFunctionBuilder.ref_set_class()IRFunctionBuilder.ref_set_obj()IRFunctionBuilder.reg()IRFunctionBuilder.ret()IRFunctionBuilder.set_cursor()IRFunctionBuilder.skip()IRFunctionBuilder.skip_cstr()IRFunctionBuilder.skip_fnb()IRFunctionBuilder.skip_objhdr()IRFunctionBuilder.skip_reg()IRFunctionBuilder.skip_tobject()IRFunctionBuilder.skip_tstring()IRFunctionBuilder.skip_version()IRFunctionBuilder.state_get()IRFunctionBuilder.state_iadd()IRFunctionBuilder.state_set()IRFunctionBuilder.str_const()IRFunctionBuilder.str_load()IRFunctionBuilder.str_store()IRFunctionBuilder.temp()IRFunctionBuilder.throw()IRFunctionBuilder.while_()
- Module contents
- uproot_custom.detree.compiler package
- Submodules
- uproot_custom.detree.bufferproxy module
- uproot_custom.detree.builtin module
- uproot_custom.detree.cache module
- uproot_custom.detree.decl module
- uproot_custom.detree.interp module
- uproot_custom.detree.run module
- uproot_custom.detree.stream module
COUNTED_CONTEXTStreamStream.check_class_name()Stream.check_nbytes()Stream.check_nbytes_end()Stream.check_nbytes_start()Stream.entriesStream.has_ref()Stream.next_offset_after()Stream.open_framesStream.read_TString()Stream.read_bool()Stream.read_bulk()Stream.read_double()Stream.read_fNBytes()Stream.read_fVersion()Stream.read_float()Stream.read_int16()Stream.read_int32()Stream.read_int64()Stream.read_int8()Stream.read_into()Stream.read_null_terminated_string()Stream.read_uint16()Stream.read_uint32()Stream.read_uint64()Stream.read_uint8()Stream.ref_class_name()Stream.ref_count()Stream.ref_object_index()Stream.refsStream.set_class_ref()Stream.set_object_ref()Stream.skip()Stream.skip_TObject()Stream.skip_TString()Stream.skip_fNBytes()Stream.skip_fVersion()Stream.skip_null_terminated_string()Stream.skip_obj_header()
- Module contents
BufferBufferProxyChildChildListConstReaderStateStreamStream.check_class_name()Stream.check_nbytes()Stream.check_nbytes_end()Stream.check_nbytes_start()Stream.entriesStream.has_ref()Stream.next_offset_after()Stream.open_framesStream.read_TString()Stream.read_bool()Stream.read_bulk()Stream.read_double()Stream.read_fNBytes()Stream.read_fVersion()Stream.read_float()Stream.read_int16()Stream.read_int32()Stream.read_int64()Stream.read_int8()Stream.read_into()Stream.read_null_terminated_string()Stream.read_uint16()Stream.read_uint32()Stream.read_uint64()Stream.read_uint8()Stream.ref_class_name()Stream.ref_count()Stream.ref_object_index()Stream.refsStream.set_class_ref()Stream.set_object_ref()Stream.skip()Stream.skip_TObject()Stream.skip_TString()Stream.skip_fNBytes()Stream.skip_fVersion()Stream.skip_null_terminated_string()Stream.skip_obj_header()
reader()
- Subpackages
Submodules¶
uproot_custom.backend module¶
- uproot_custom.backend.get_backend() Literal['cpp', 'python', 'forth', 'detree'][source]¶
Return the current reader backend.
The backend is resolved in the following order of priority: explicitly set value via
set_backend()> UPROOT_CUSTOM_READER_BACKEND environment variable > default “cpp”.- Returns:
The current reader backend (“cpp”, “python”, “forth”, or “detree”).
- Raises:
ValueError – If the UPROOT_CUSTOM_READER_BACKEND environment variable is set to an unrecognized value.
- uproot_custom.backend.set_backend(backend: Literal['cpp', 'python', 'forth', 'detree']) None[source]¶
Set the current reader backend.
This overrides the UPROOT_CUSTOM_READER_BACKEND environment variable and the default “cpp”.
- Parameters:
backend – The reader backend to use. Must be one of “cpp”, “python”, “forth”, or “detree”.
- Raises:
ValueError – If backend is not a recognized reader backend.
- uproot_custom.backend.use_backend(backend: Literal['cpp', 'python', 'forth', 'detree'])[source]¶
Context manager to temporarily switch the reader backend.
The original backend is restored when exiting the with block.
Example:
import uproot_custom as uc with uc.use_backend("python"): branch.array()
- Parameters:
backend – The reader backend to use within the context. Must be one of “cpp”, “python”, “forth”, or “detree”.
- Raises:
ValueError – If backend is not a recognized reader backend.
uproot_custom.consts module¶
- uproot_custom.consts.DTYPE_TO_TYPECODE = {'bool': 'B', 'float32': 'f', 'float64': 'd', 'int16': 'h', 'int32': 'i', 'int64': 'q', 'int8': 'b', 'uint16': 'H', 'uint32': 'I', 'uint64': 'Q', 'uint8': 'B'}¶
numpy dtype name -> fixed-width
structtypecode. The platform-dependentl/Lare deliberately absent:array.arraymakes them 8 bytes on Linux, and the machine has no coercer for them.
uproot_custom.factories module¶
- class uproot_custom.factories.AnyClassFactory(name: str, sub_factories: list[Factory])[source]¶
Bases:
GroupFactoryThis class tries to read any class object that is not handled by other factories.
- build_cpp_reader()[source]¶
Build concrete C++ reader.
- Returns:
An instance of uproot_custom.cpp.IReader.
- build_detree_reader()[source]¶
Build the declarative reader the detree backend compiles.
There is deliberately no default: the detree backend needs a detree reader, and the other backends (cpp, python, forth) do not use this method. A factory that does not implement it cannot be read with UPROOT_CUSTOM_READER_BACKEND=detree.
- Returns:
An instance of uproot_custom.detree.builtin.Reader.
- classmethod build_factory(top_type_name, cur_streamer_info, all_streamer_info, item_path, **kwargs)[source]¶
Never match items. If one needs to use this factory, instatiate it directly.
- build_forth_reader(buffer_holder: BufferHolder)[source]¶
Build concrete Forth reader.
- Parameters:
buffer_holder – An instance of BufferHolder to register buffers.
- Returns:
An instance of uproot_custom._forth.IReader.
- class uproot_custom.factories.AnyPointerFactory(name: str, element_factory: Factory)[source]¶
Bases:
FactoryHandles pointer-to-object members serialized via ROOT’s read_object_any protocol.
Matches: - fType in {63, 64, 68, 69} - fTypeName ending with “*”
- build_cpp_reader()[source]¶
Build concrete C++ reader.
- Returns:
An instance of uproot_custom.cpp.IReader.
- build_detree_reader()[source]¶
Build the declarative reader the detree backend compiles.
There is deliberately no default: the detree backend needs a detree reader, and the other backends (cpp, python, forth) do not use this method. A factory that does not implement it cannot be read with UPROOT_CUSTOM_READER_BACKEND=detree.
- Returns:
An instance of uproot_custom.detree.builtin.Reader.
- classmethod build_factory(top_type_name, cur_streamer_info, all_streamer_info, item_path, **kwargs)[source]¶
Return an instance of this factory when current item matches this factory, otherwise return None.
- Parameters:
top_type_name – name of the top-level class of the current item. For example, vector<int> -> vector.
cur_streamer_info – streamer information of the current item.
all_streamer_info – streamer information of all types, keyed by class name; each value is a dictionary like cur_streamer_info.
item_path – path of the item being matched, for specific behavior.
- Returns:
A factory instance when this class matches the item, otherwise None.
- build_python_reader()[source]¶
Build concrete Python reader.
- Returns:
An instance of uproot_custom.python.IReader.
- make_awkward_content(raw_data)[source]¶
Reconstruct awkward contents with raw data returned by the reader backend.
- Parameters:
raw_data – Data returned by the reader backend.
- Returns:
The awkward content that builds the corresponding array.
- class uproot_custom.factories.BaseObjectFactory(name: str, sub_factories: list[Factory])[source]¶
Bases:
GroupFactoryThis class reads the base-class part of an object.
A BASE member is the base class’s members concatenated; it carries no fNBytes/fVersion header of its own (docs/reference/binary-format.md).
- build_cpp_reader()[source]¶
Build concrete C++ reader.
- Returns:
An instance of uproot_custom.cpp.IReader.
- build_detree_reader()[source]¶
Build the declarative reader the detree backend compiles.
There is deliberately no default: the detree backend needs a detree reader, and the other backends (cpp, python, forth) do not use this method. A factory that does not implement it cannot be read with UPROOT_CUSTOM_READER_BACKEND=detree.
- Returns:
An instance of uproot_custom.detree.builtin.Reader.
- classmethod build_factory(top_type_name, cls_streamer_info, all_streamer_info, item_path, **kwargs)[source]¶
Never match items. If one needs to use this factory, instatiate it directly.
- class uproot_custom.factories.CStyleArrayFactory(name: str, element_factory: Factory, flat_size: int, fMaxIndex: int, fArrayDim: ndarray)[source]¶
Bases:
FactoryThis class reads a C-style fixed/flexible array and std::array from a binary parser.
- build_cpp_reader()[source]¶
Build concrete C++ reader.
- Returns:
An instance of uproot_custom.cpp.IReader.
- build_detree_reader()[source]¶
Build the declarative reader the detree backend compiles.
There is deliberately no default: the detree backend needs a detree reader, and the other backends (cpp, python, forth) do not use this method. A factory that does not implement it cannot be read with UPROOT_CUSTOM_READER_BACKEND=detree.
- Returns:
An instance of uproot_custom.detree.builtin.Reader.
- classmethod build_factory(top_type_name, cur_streamer_info, all_streamer_info, item_path, **kwargs)[source]¶
Return an instance of this factory when current item matches this factory, otherwise return None.
- Parameters:
top_type_name – name of the top-level class of the current item. For example, vector<int> -> vector.
cur_streamer_info – streamer information of the current item.
all_streamer_info – streamer information of all types, keyed by class name; each value is a dictionary like cur_streamer_info.
item_path – path of the item being matched, for specific behavior.
- Returns:
A factory instance when this class matches the item, otherwise None.
- build_forth_reader(buffer_holder: BufferHolder)[source]¶
Build concrete Forth reader.
- Parameters:
buffer_holder – An instance of BufferHolder to register buffers.
- Returns:
An instance of uproot_custom._forth.IReader.
- build_python_reader()[source]¶
Build concrete Python reader.
- Returns:
An instance of uproot_custom.python.IReader.
- make_awkward_content(raw_data)[source]¶
Reconstruct awkward contents with raw data returned by the reader backend.
- Parameters:
raw_data – Data returned by the reader backend.
- Returns:
The awkward content that builds the corresponding array.
- class uproot_custom.factories.EmptyFactory(name: str)[source]¶
Bases:
FactoryThis factory does nothing. It’s just a place holder.
- build_cpp_reader()[source]¶
Build concrete C++ reader.
- Returns:
An instance of uproot_custom.cpp.IReader.
- build_detree_reader()[source]¶
Build the declarative reader the detree backend compiles.
There is deliberately no default: the detree backend needs a detree reader, and the other backends (cpp, python, forth) do not use this method. A factory that does not implement it cannot be read with UPROOT_CUSTOM_READER_BACKEND=detree.
- Returns:
An instance of uproot_custom.detree.builtin.Reader.
- classmethod build_factory(top_type_name, cur_streamer_info, all_streamer_info, item_path, **kwargs)[source]¶
This factory will never match items. If one needs to use this factory, instatiate it directly.
- build_forth_reader(buffer_holder: BufferHolder)[source]¶
Build concrete Forth reader.
- Parameters:
buffer_holder – An instance of BufferHolder to register buffers.
- Returns:
An instance of uproot_custom._forth.IReader.
- build_python_reader()[source]¶
Build concrete Python reader.
- Returns:
An instance of uproot_custom.python.IReader.
- class uproot_custom.factories.Factory(name: str)[source]¶
Bases:
objectBase class of reader factories.
A factory builds the reader tree for a branch and reconstructs the raw arrays returned by the selected reader backend into an awkward array.
- build_cpp_reader() IReader[source]¶
Build concrete C++ reader.
- Returns:
An instance of uproot_custom.cpp.IReader.
- build_detree_reader() Reader[source]¶
Build the declarative reader the detree backend compiles.
There is deliberately no default: the detree backend needs a detree reader, and the other backends (cpp, python, forth) do not use this method. A factory that does not implement it cannot be read with UPROOT_CUSTOM_READER_BACKEND=detree.
- Returns:
An instance of uproot_custom.detree.builtin.Reader.
- classmethod build_factory(top_type_name: str, cur_streamer_info: dict, all_streamer_info: dict, item_path: str, **kwargs) Factory | None[source]¶
Return an instance of this factory when current item matches this factory, otherwise return None.
- Parameters:
top_type_name – name of the top-level class of the current item. For example, vector<int> -> vector.
cur_streamer_info – streamer information of the current item.
all_streamer_info – streamer information of all types, keyed by class name; each value is a dictionary like cur_streamer_info.
item_path – path of the item being matched, for specific behavior.
- Returns:
A factory instance when this class matches the item, otherwise None.
- build_forth_reader(buffer_holder: BufferHolder) IReader[source]¶
Build concrete Forth reader.
- Parameters:
buffer_holder – An instance of BufferHolder to register buffers.
- Returns:
An instance of uproot_custom._forth.IReader.
- build_python_reader() IReader[source]¶
Build concrete Python reader.
- Returns:
An instance of uproot_custom.python.IReader.
- make_awkward_content(raw_data: Any) Content[source]¶
Reconstruct awkward contents with raw data returned by the reader backend.
- Parameters:
raw_data – Data returned by the reader backend.
- Returns:
The awkward content that builds the corresponding array.
- class uproot_custom.factories.GroupFactory(name: str, sub_factories: list[Factory])[source]¶
Bases:
FactoryThis factory groups differernt factory together. You can use this factory to read specific format of data as you like.
- build_cpp_reader()[source]¶
Build concrete C++ reader.
- Returns:
An instance of uproot_custom.cpp.IReader.
- build_detree_reader()[source]¶
Build the declarative reader the detree backend compiles.
There is deliberately no default: the detree backend needs a detree reader, and the other backends (cpp, python, forth) do not use this method. A factory that does not implement it cannot be read with UPROOT_CUSTOM_READER_BACKEND=detree.
- Returns:
An instance of uproot_custom.detree.builtin.Reader.
- classmethod build_factory(top_type_name, cur_streamer_info, all_streamer_info, item_path, **kwargs)[source]¶
Never match items. If one needs to use this factory, instatiate it directly.
- build_forth_reader(buffer_holder: BufferHolder)[source]¶
Build concrete Forth reader.
- Parameters:
buffer_holder – An instance of BufferHolder to register buffers.
- Returns:
An instance of uproot_custom._forth.IReader.
- build_python_reader()[source]¶
Build concrete Python reader.
- Returns:
An instance of uproot_custom.python.IReader.
- class uproot_custom.factories.PrimitiveFactory(name: str, dtype: str)[source]¶
Bases:
Factory- build_cpp_reader()[source]¶
Build concrete C++ reader.
- Returns:
An instance of uproot_custom.cpp.IReader.
- build_detree_reader()[source]¶
Build the declarative reader the detree backend compiles.
There is deliberately no default: the detree backend needs a detree reader, and the other backends (cpp, python, forth) do not use this method. A factory that does not implement it cannot be read with UPROOT_CUSTOM_READER_BACKEND=detree.
- Returns:
An instance of uproot_custom.detree.builtin.Reader.
- classmethod build_factory(top_type_name, cur_streamer_info, all_streamer_info, item_path, **kwargs)[source]¶
Return when top_type_name is a primitive type.
- build_forth_reader(buffer_holder: BufferHolder)[source]¶
Build concrete Forth reader.
- Parameters:
buffer_holder – An instance of BufferHolder to register buffers.
- Returns:
An instance of uproot_custom._forth.IReader.
- build_python_reader()[source]¶
Build concrete Python reader.
- Returns:
An instance of uproot_custom.python.IReader.
- cpp_reader_map: ClassVar[dict[str, type]] = {'bool': <class 'uproot_custom.cpp.kernel.UInt8Reader'>, 'float32': <class 'uproot_custom.cpp.kernel.FloatReader'>, 'float64': <class 'uproot_custom.cpp.kernel.DoubleReader'>, 'int16': <class 'uproot_custom.cpp.kernel.Int16Reader'>, 'int32': <class 'uproot_custom.cpp.kernel.Int32Reader'>, 'int64': <class 'uproot_custom.cpp.kernel.Int64Reader'>, 'int8': <class 'uproot_custom.cpp.kernel.Int8Reader'>, 'uint16': <class 'uproot_custom.cpp.kernel.UInt16Reader'>, 'uint32': <class 'uproot_custom.cpp.kernel.UInt32Reader'>, 'uint64': <class 'uproot_custom.cpp.kernel.UInt64Reader'>, 'uint8': <class 'uproot_custom.cpp.kernel.UInt8Reader'>}¶
- ftype2dtype: ClassVar[dict[int, str]] = {1: 'int8', 2: 'int16', 3: 'int32', 4: 'int64', 5: 'float32', 8: 'float64', 11: 'uint8', 12: 'uint16', 13: 'uint32', 14: 'uint64', 16: 'int64', 17: 'uint64', 18: 'bool'}¶
- make_awkward_content(raw_data: ndarray)[source]¶
Reconstruct awkward contents with raw data returned by the reader backend.
- Parameters:
raw_data – Data returned by the reader backend.
- Returns:
The awkward content that builds the corresponding array.
- make_awkward_form()[source]¶
Generate awkward form with tree configuration.
- Returns:
The awkward form of the current item.
- typename2dtype: ClassVar[dict[str, str]] = {'Bool_t': 'bool', 'Char_t': 'int8', 'Double_t': 'float64', 'Float_t': 'float32', 'Int_t': 'int32', 'Long_t': 'int64', 'Short_t': 'int16', 'UChar_t': 'uint8', 'UInt_t': 'uint32', 'ULong_t': 'uint64', 'UShort_t': 'uint16', 'bool': 'bool', 'char': 'int8', 'double': 'float64', 'float': 'float32', 'int': 'int32', 'int16_t': 'int16', 'int32_t': 'int32', 'int64_t': 'int64', 'int8_t': 'int8', 'long': 'int64', 'long long': 'int64', 'short': 'int16', 'signed char': 'int8', 'signed int': 'int32', 'signed long': 'int64', 'signed long long': 'int64', 'signed short': 'int16', 'uint16_t': 'uint16', 'uint32_t': 'uint32', 'uint64_t': 'uint64', 'uint8_t': 'uint8', 'unsigned char': 'uint8', 'unsigned int': 'uint32', 'unsigned long': 'uint64', 'unsigned long long': 'uint64', 'unsigned short': 'uint16'}¶
- class uproot_custom.factories.STLMapFactory(name: str, with_header: bool, objwise_or_memberwise: Literal[-1, 0, 1], key_factory: Factory, val_factory: Factory)[source]¶
Bases:
FactoryThis class reads mapping-like STL containers.
- build_cpp_reader()[source]¶
Build concrete C++ reader.
- Returns:
An instance of uproot_custom.cpp.IReader.
- build_detree_reader()[source]¶
Build the declarative reader the detree backend compiles.
There is deliberately no default: the detree backend needs a detree reader, and the other backends (cpp, python, forth) do not use this method. A factory that does not implement it cannot be read with UPROOT_CUSTOM_READER_BACKEND=detree.
- Returns:
An instance of uproot_custom.detree.builtin.Reader.
- classmethod build_factory(top_type_name, cur_streamer_info, all_streamer_info, item_path, in_std_array=False, **kwargs)[source]¶
Return when top_type_name is in cls.target_types.
- build_forth_reader(buffer_holder: BufferHolder)[source]¶
Build concrete Forth reader.
- Parameters:
buffer_holder – An instance of BufferHolder to register buffers.
- Returns:
An instance of uproot_custom._forth.IReader.
- build_python_reader()[source]¶
Build concrete Python reader.
- Returns:
An instance of uproot_custom.python.IReader.
- make_awkward_content(raw_data)[source]¶
Reconstruct awkward contents with raw data returned by the reader backend.
- Parameters:
raw_data – Data returned by the reader backend.
- Returns:
The awkward content that builds the corresponding array.
- make_awkward_form()[source]¶
Generate awkward form with tree configuration.
- Returns:
The awkward form of the current item.
- target_types: ClassVar[list[str]] = ['map', 'unordered_map', 'multimap', 'unordered_multimap']¶
- class uproot_custom.factories.STLSeqFactory(name: str, with_header: bool, objwise_or_memberwise: Literal[-1, 0, 1], element_factory: Factory)[source]¶
Bases:
FactoryThis factory reads sequence-like STL containers.
- build_cpp_reader()[source]¶
Build concrete C++ reader.
- Returns:
An instance of uproot_custom.cpp.IReader.
- build_detree_reader()[source]¶
Build the declarative reader the detree backend compiles.
There is deliberately no default: the detree backend needs a detree reader, and the other backends (cpp, python, forth) do not use this method. A factory that does not implement it cannot be read with UPROOT_CUSTOM_READER_BACKEND=detree.
- Returns:
An instance of uproot_custom.detree.builtin.Reader.
- classmethod build_factory(top_type_name, cur_streamer_info, all_streamer_info, item_path, in_std_array=False, **kwargs)[source]¶
Return when top_type_name is in cls.target_types.
- build_forth_reader(buffer_holder: BufferHolder)[source]¶
Build concrete Forth reader.
- Parameters:
buffer_holder – An instance of BufferHolder to register buffers.
- Returns:
An instance of uproot_custom._forth.IReader.
- build_python_reader()[source]¶
Build concrete Python reader.
- Returns:
An instance of uproot_custom.python.IReader.
- make_awkward_content(raw_data)[source]¶
Reconstruct awkward contents with raw data returned by the reader backend.
- Parameters:
raw_data – Data returned by the reader backend.
- Returns:
The awkward content that builds the corresponding array.
- make_awkward_form()[source]¶
Generate awkward form with tree configuration.
- Returns:
The awkward form of the current item.
- target_types: ClassVar[list[str]] = ['vector', 'array', 'list', 'set', 'multiset', 'unordered_set', 'unordered_multiset']¶
- class uproot_custom.factories.STLStringFactory(name: str, with_header: bool)[source]¶
Bases:
FactoryThis class reads std::string.
- build_cpp_reader()[source]¶
Build concrete C++ reader.
- Returns:
An instance of uproot_custom.cpp.IReader.
- build_detree_reader()[source]¶
Build the declarative reader the detree backend compiles.
There is deliberately no default: the detree backend needs a detree reader, and the other backends (cpp, python, forth) do not use this method. A factory that does not implement it cannot be read with UPROOT_CUSTOM_READER_BACKEND=detree.
- Returns:
An instance of uproot_custom.detree.builtin.Reader.
- classmethod build_factory(top_type_name, cur_streamer_info, all_streamer_info, item_path, in_std_array=False, **kwargs)[source]¶
Return an instance of this factory when current item matches this factory, otherwise return None.
- Parameters:
top_type_name – name of the top-level class of the current item. For example, vector<int> -> vector.
cur_streamer_info – streamer information of the current item.
all_streamer_info – streamer information of all types, keyed by class name; each value is a dictionary like cur_streamer_info.
item_path – path of the item being matched, for specific behavior.
- Returns:
A factory instance when this class matches the item, otherwise None.
- build_forth_reader(buffer_holder: BufferHolder)[source]¶
Build concrete Forth reader.
- Parameters:
buffer_holder – An instance of BufferHolder to register buffers.
- Returns:
An instance of uproot_custom._forth.IReader.
- build_python_reader()[source]¶
Build concrete Python reader.
- Returns:
An instance of uproot_custom.python.IReader.
- class uproot_custom.factories.TArrayFactory(name: str, dtype: str)[source]¶
Bases:
FactoryThis class reads TArray from a binary paerser.
TArray includes TArrayC, TArrayS, TArrayI, TArrayL, TArrayL64, TArrayF, and TArrayD. Corresponding dtype is int8, int16, int32, int64, int64, float32, and float64 respectively.
- build_cpp_reader()[source]¶
Build concrete C++ reader.
- Returns:
An instance of uproot_custom.cpp.IReader.
- build_detree_reader()[source]¶
Build the declarative reader the detree backend compiles.
There is deliberately no default: the detree backend needs a detree reader, and the other backends (cpp, python, forth) do not use this method. A factory that does not implement it cannot be read with UPROOT_CUSTOM_READER_BACKEND=detree.
- Returns:
An instance of uproot_custom.detree.builtin.Reader.
- classmethod build_factory(top_type_name, cur_streamer_info, all_streamer_info, item_path, **kwargs)[source]¶
Return when top_type_name is in cls.typenames.
- build_forth_reader(buffer_holder: BufferHolder)[source]¶
Build concrete Forth reader.
- Parameters:
buffer_holder – An instance of BufferHolder to register buffers.
- Returns:
An instance of uproot_custom._forth.IReader.
- build_python_reader()[source]¶
Build concrete Python reader.
- Returns:
An instance of uproot_custom.python.IReader.
- make_awkward_content(raw_data)[source]¶
Reconstruct awkward contents with raw data returned by the reader backend.
- Parameters:
raw_data – Data returned by the reader backend.
- Returns:
The awkward content that builds the corresponding array.
- make_awkward_form()[source]¶
Generate awkward form with tree configuration.
- Returns:
The awkward form of the current item.
- typename2dtype: ClassVar[dict[str, str]] = {'TArrayC': 'int8', 'TArrayD': 'float64', 'TArrayF': 'float32', 'TArrayI': 'int32', 'TArrayL': 'int64', 'TArrayL64': 'int64', 'TArrayS': 'int16'}¶
- class uproot_custom.factories.TObjectFactory(name: str, keep_data: bool)[source]¶
Bases:
FactoryThis class reads base TObject from a binary parser. You should skip reconstructing array when this factory keeps no data, since the method reconstruct_array will always return None.
- build_cpp_reader()[source]¶
Build concrete C++ reader.
- Returns:
An instance of uproot_custom.cpp.IReader.
- build_detree_reader()[source]¶
Build the declarative reader the detree backend compiles.
There is deliberately no default: the detree backend needs a detree reader, and the other backends (cpp, python, forth) do not use this method. A factory that does not implement it cannot be read with UPROOT_CUSTOM_READER_BACKEND=detree.
- Returns:
An instance of uproot_custom.detree.builtin.Reader.
- classmethod build_factory(top_type_name, cur_streamer_info, all_streamer_info, item_path, **kwargs)[source]¶
Match the TObject base record.
The configuration contains:
factory: cls
name: fName
keep_data: whether to keep data from TObject.
- build_forth_reader(buffer_holder: BufferHolder)[source]¶
Build concrete Forth reader.
- Parameters:
buffer_holder – An instance of BufferHolder to register buffers.
- Returns:
An instance of uproot_custom._forth.IReader.
- build_python_reader()[source]¶
Build concrete Python reader.
- Returns:
An instance of uproot_custom.python.IReader.
- keep_data_itempaths: ClassVar[set[str]] = {}¶
- class uproot_custom.factories.TStringFactory(name: str, with_header: bool)[source]¶
Bases:
FactoryThis class reads TString from a binary parser.
- build_cpp_reader()[source]¶
Build concrete C++ reader.
- Returns:
An instance of uproot_custom.cpp.IReader.
- build_detree_reader()[source]¶
Build the declarative reader the detree backend compiles.
There is deliberately no default: the detree backend needs a detree reader, and the other backends (cpp, python, forth) do not use this method. A factory that does not implement it cannot be read with UPROOT_CUSTOM_READER_BACKEND=detree.
- Returns:
An instance of uproot_custom.detree.builtin.Reader.
- classmethod build_factory(top_type_name, cur_streamer_info, all_streamer_info, item_path, **kwargs)[source]¶
Return an instance of this factory when current item matches this factory, otherwise return None.
- Parameters:
top_type_name – name of the top-level class of the current item. For example, vector<int> -> vector.
cur_streamer_info – streamer information of the current item.
all_streamer_info – streamer information of all types, keyed by class name; each value is a dictionary like cur_streamer_info.
item_path – path of the item being matched, for specific behavior.
- Returns:
A factory instance when this class matches the item, otherwise None.
- build_forth_reader(buffer_holder: BufferHolder)[source]¶
Build concrete Forth reader.
- Parameters:
buffer_holder – An instance of BufferHolder to register buffers.
- Returns:
An instance of uproot_custom._forth.IReader.
- build_python_reader()[source]¶
Build concrete Python reader.
- Returns:
An instance of uproot_custom.python.IReader.
- uproot_custom.factories.build_factory(cur_streamer_info: dict, all_streamer_info: dict, item_path: str = '', **kwargs) Factory[source]¶
Generate a factory with the given streamer information.
- Parameters:
cur_streamer_info – streamer information of the current item.
all_streamer_info – streamer information of all types.
item_path – path to the item.
- Returns:
An instance of Factory.
- uproot_custom.factories.read_branch(branch: TBranch, data: ndarray[uint8], offsets: ndarray, cursor_offset: int, cur_streamer_info: dict, all_streamer_info: dict[str, list[dict]], item_path: str = '')[source]¶
uproot_custom.interpretation module¶
The uproot plumbing the AsCustom interpretation needs, and nothing else.
An uproot Interpretation has to answer five questions: does this branch match (match_branch), what is its C++ type name, how is it cached, how are the per-basket arrays joined, and what awkward form does it produce. Answering them means reading the branch’s streamer info and building a factory – none of which depends on how the bytes are then decoded.
AsCustom keeps that plumbing and delegates the byte-level read to the reader backend selected by uproot_custom.backend:
cpp – the pybind11 readers in uproot_custom.cpp (the default);
python – the pure-Python readers in uproot_custom.python;
forth – the experimental Forth readers in uproot_custom._forth;
detree – declarative readers in uproot_custom.detree, compiled to a detree-vm module and executed on a Detree machine.
A factory is the same on every backend: it decides which reader to build and how the raw data becomes an awkward array. Only the byte-level reader differs, so a branch must produce the same array whichever backend runs it.
- class uproot_custom.interpretation.AsCustom(branch: TBranch, context: dict, simplify: bool)[source]¶
Bases:
CustomInterpretationThe branch, its streamer info, and the factory built from them.
A subclass supplies its own basket_array; everything else is here.
- awkward_form(file, context=None, index_format='i64', header=False, tobject_header=False, breadcrumbs=())[source]¶
- Parameters:
file (uproot.reading.ReadOnlyFile) – File to use to generate uproot.model.Model classes from its uproot.reading.ReadOnlyFile.streamers and
file_pathfor error messages.context (dict) – Context for the Form-generation; defaults are the remaining arguments below.
index_format (str) – Format to use for indexes of the
awkward.forms.Form; may be"i32","u32", or"i64".header (bool) – If True, include header fields of each C++ class.
tobject_header (bool) – If True, include header fields of each
TObjectbase class.breadcrumbs (tuple of class objects) – Used to check for recursion. Types that contain themselves cannot be Awkward Arrays because the depth of instances is unknown.
The
awkward.forms.Formto use to put objects of type type in an Awkward Array.
- basket_array(data: ndarray, byte_offsets: ndarray, basket, branch, context, cursor_offset, library, interp_options)[source]¶
- Parameters:
data (array of
numpy.uint8) – Raw but uncompressed data from theTBasket. If theTBaskethas offsets and navigational metadata, it is not included in this array.byte_offsets (array of
numpy.int32) – Index where each entry of theTBasketstarts and stops. The header is not included (i.e. the first offset is0), and the length of this array is one greater than the number of entries in theTBasket.basket (uproot.models.TBasket.Model_TBasket) – The
TBasketobject.context (dict) – Auxiliary data used in deserialization.
cursor_offset (int) – Correction to the integer keys used in uproot.source.cursor.Cursor.refs for objects deserialized by reference (uproot.deserialization.read_object_any).
library (uproot.interpretation.library.Library) – The requested library for output.
interp_options (dict) – Flags and other options passed through the interpretation process.
Performs the first step of interpretation, from uncompressed
TBasketdata to a temporary array.
- property cache_key: str¶
The cache key of the interpretation.
- final_array(basket_arrays, entry_start, entry_stop, entry_offsets, library, branch, options)[source]¶
Concatenate the arrays from the baskets and return the final array.
- classmethod match_branch(branch: TBranch, context: dict, simplify: bool) bool[source]¶
Return whether this interpretation applies to branch.
The arguments come from uproot.interpretation.identify.interpretation_of.
- Parameters:
branch – the TBranch to interpret as an array.
context – auxiliary data used in deserialization.
simplify – if True, call uproot.interpretation.objects.AsObjects.simplify on any uproot.interpretation.objects.AsObjects to try to get a more efficient interpretation.
- Returns:
True when the branch’s regularized object path is registered for this interpretation.
- target_branches: ClassVar[set[str]] = {}¶
Branches this interpretation claims, as regularized object paths. This set is the storage behind uproot_custom.claim; claim branches through that function rather than by writing here, so the cycle number is regularized and the argument type is checked.
- property typename: str¶
The name of the type of the interpretation.
uproot_custom.python module¶
- class uproot_custom.python.AnyClassReader(name: str, element_readers: list[IReader])[source]¶
Bases:
IReader- read(stream: BinaryStream)[source]¶
- class uproot_custom.python.AnyPointerReader(name: str, element_reader: IReader)[source]¶
Bases:
IReaderReads objects stored via ROOT’s read_object_any protocol.
This handles both: - True pointers (kObjectP=64, kAnyP=69): full read_object_any with null/reference support - Object headers (kNewClassTag + classname before object data)
- Binary format (read_object_any):
- bcnt (uint32) — if kByteCountMask set: versioned, then read tag (uint32)
otherwise: unversioned, tag = bcnt
tag: - tag == 0: null pointer - tag & kClassMask == 0 (nonzero): reference to previously-read object (skip bytes) - tag == kNewClassTag: null-terminated classname + object data - tag & kClassMask != 0: reference to known class, new object data
- uproot_custom.python.BinaryBuffer¶
alias of
BinaryStream
- class uproot_custom.python.BinaryStream(data: NDArray[uint8], offsets: NDArray[uint32], initial_cursor_position: int, repr_nbytes: int = 50)[source]¶
Bases:
object- check_nbytes_end(expected: int | None = None) None[source]¶
Fail unless the cursor is at the end of the counted region.
- Parameters:
expected – the end position, for a region whose size the caller computed instead of reading; the innermost frame is then left open, so the two forms do not pair with each other.
- check_nbytes_start() None[source]¶
Read a masked fNBytes and remember where the counted region ends.
The call opens a frame and check_nbytes_end closes it. Frames nest, so a sub-reader that is framed itself does not disturb its caller.
- property entries¶
- property open_frames: int¶
The number of counted regions still waiting for their end.
- property remaining_data¶
- class uproot_custom.python.CStyleArrayReader(name: str, flat_size: int, element_reader: IReader)[source]¶
Bases:
IReader
- class uproot_custom.python.GroupReader(name: str, element_readers: list[IReader])[source]¶
Bases:
IReader
- class uproot_custom.python.IReader(name: str)[source]¶
Bases:
object- read(stream: BinaryStream) None[source]¶
- read_many(stream: BinaryStream, count: int) int[source]¶
- read_many_memberwise(stream: BinaryStream, count: int) int[source]¶
- read_until(stream: BinaryStream, end_pos: int) int[source]¶
- class uproot_custom.python.PrimitiveReader(name: str, dtype: Literal['bool', 'uint8', 'uint16', 'uint32', 'uint64', 'int8', 'int16', 'int32', 'int64', 'float32', 'float64'])[source]¶
Bases:
IReader
- class uproot_custom.python.STLMapReader(name: str, with_header: bool, key_reader: IReader, value_reader: IReader)[source]¶
Bases:
IReader- read_body(stream: BinaryStream, is_memberwise: bool)[source]¶
- read_element_version(stream: BinaryStream)[source]¶
- class uproot_custom.python.STLSeqReader(name: str, with_header: bool, element_reader: IReader)[source]¶
Bases:
IReader- read_body(stream: BinaryStream, is_memberwise: bool)[source]¶
- read_element_version(stream: BinaryStream)[source]¶
- class uproot_custom.python.STLStringReader(name: str, with_header: bool)[source]¶
Bases:
IReader- read_body(stream: BinaryStream)[source]¶
- class uproot_custom.python.TArrayReader(name: str, dtype: Literal['int8', 'int16', 'int32', 'int64', 'float32', 'float64'])[source]¶
Bases:
IReader
- class uproot_custom.python.TObjectReader(name: str, keep_data: bool = False)[source]¶
Bases:
IReader
uproot_custom.utils module¶
- uproot_custom.utils.get_map_key_val_typenames(type_name: str) tuple[str, str][source]¶
Get the key and value type names of a map type.
e.g. map<int, vector<int>> -> (int, vector<int>)
Module contents¶
- class uproot_custom.AnyClassFactory(name: str, sub_factories: list[Factory])[source]¶
Bases:
GroupFactoryThis class tries to read any class object that is not handled by other factories.
- build_cpp_reader()[source]¶
Build concrete C++ reader.
- Returns:
An instance of uproot_custom.cpp.IReader.
- build_detree_reader()[source]¶
Build the declarative reader the detree backend compiles.
There is deliberately no default: the detree backend needs a detree reader, and the other backends (cpp, python, forth) do not use this method. A factory that does not implement it cannot be read with UPROOT_CUSTOM_READER_BACKEND=detree.
- Returns:
An instance of uproot_custom.detree.builtin.Reader.
- classmethod build_factory(top_type_name, cur_streamer_info, all_streamer_info, item_path, **kwargs)[source]¶
Never match items. If one needs to use this factory, instatiate it directly.
- build_forth_reader(buffer_holder: BufferHolder)[source]¶
Build concrete Forth reader.
- Parameters:
buffer_holder – An instance of BufferHolder to register buffers.
- Returns:
An instance of uproot_custom._forth.IReader.
- class uproot_custom.AnyPointerFactory(name: str, element_factory: Factory)[source]¶
Bases:
FactoryHandles pointer-to-object members serialized via ROOT’s read_object_any protocol.
Matches: - fType in {63, 64, 68, 69} - fTypeName ending with “*”
- build_cpp_reader()[source]¶
Build concrete C++ reader.
- Returns:
An instance of uproot_custom.cpp.IReader.
- build_detree_reader()[source]¶
Build the declarative reader the detree backend compiles.
There is deliberately no default: the detree backend needs a detree reader, and the other backends (cpp, python, forth) do not use this method. A factory that does not implement it cannot be read with UPROOT_CUSTOM_READER_BACKEND=detree.
- Returns:
An instance of uproot_custom.detree.builtin.Reader.
- classmethod build_factory(top_type_name, cur_streamer_info, all_streamer_info, item_path, **kwargs)[source]¶
Return an instance of this factory when current item matches this factory, otherwise return None.
- Parameters:
top_type_name – name of the top-level class of the current item. For example, vector<int> -> vector.
cur_streamer_info – streamer information of the current item.
all_streamer_info – streamer information of all types, keyed by class name; each value is a dictionary like cur_streamer_info.
item_path – path of the item being matched, for specific behavior.
- Returns:
A factory instance when this class matches the item, otherwise None.
- build_python_reader()[source]¶
Build concrete Python reader.
- Returns:
An instance of uproot_custom.python.IReader.
- make_awkward_content(raw_data)[source]¶
Reconstruct awkward contents with raw data returned by the reader backend.
- Parameters:
raw_data – Data returned by the reader backend.
- Returns:
The awkward content that builds the corresponding array.
- class uproot_custom.AsCustom(branch: TBranch, context: dict, simplify: bool)[source]¶
Bases:
CustomInterpretationThe branch, its streamer info, and the factory built from them.
A subclass supplies its own basket_array; everything else is here.
- all_streamer_info: dict[str, list[dict]]¶
- awkward_form(file, context=None, index_format='i64', header=False, tobject_header=False, breadcrumbs=())[source]¶
- Parameters:
file (uproot.reading.ReadOnlyFile) – File to use to generate uproot.model.Model classes from its uproot.reading.ReadOnlyFile.streamers and
file_pathfor error messages.context (dict) – Context for the Form-generation; defaults are the remaining arguments below.
index_format (str) – Format to use for indexes of the
awkward.forms.Form; may be"i32","u32", or"i64".header (bool) – If True, include header fields of each C++ class.
tobject_header (bool) – If True, include header fields of each
TObjectbase class.breadcrumbs (tuple of class objects) – Used to check for recursion. Types that contain themselves cannot be Awkward Arrays because the depth of instances is unknown.
The
awkward.forms.Formto use to put objects of type type in an Awkward Array.
- basket_array(data: ndarray, byte_offsets: ndarray, basket, branch, context, cursor_offset, library, interp_options)[source]¶
- Parameters:
data (array of
numpy.uint8) – Raw but uncompressed data from theTBasket. If theTBaskethas offsets and navigational metadata, it is not included in this array.byte_offsets (array of
numpy.int32) – Index where each entry of theTBasketstarts and stops. The header is not included (i.e. the first offset is0), and the length of this array is one greater than the number of entries in theTBasket.basket (uproot.models.TBasket.Model_TBasket) – The
TBasketobject.context (dict) – Auxiliary data used in deserialization.
cursor_offset (int) – Correction to the integer keys used in uproot.source.cursor.Cursor.refs for objects deserialized by reference (uproot.deserialization.read_object_any).
library (uproot.interpretation.library.Library) – The requested library for output.
interp_options (dict) – Flags and other options passed through the interpretation process.
Performs the first step of interpretation, from uncompressed
TBasketdata to a temporary array.
- property cache_key: str¶
The cache key of the interpretation.
- cls_streamer_info: dict¶
- final_array(basket_arrays, entry_start, entry_stop, entry_offsets, library, branch, options)[source]¶
Concatenate the arrays from the baskets and return the final array.
- classmethod match_branch(branch: TBranch, context: dict, simplify: bool) bool[source]¶
Return whether this interpretation applies to branch.
The arguments come from uproot.interpretation.identify.interpretation_of.
- Parameters:
branch – the TBranch to interpret as an array.
context – auxiliary data used in deserialization.
simplify – if True, call uproot.interpretation.objects.AsObjects.simplify on any uproot.interpretation.objects.AsObjects to try to get a more efficient interpretation.
- Returns:
True when the branch’s regularized object path is registered for this interpretation.
- target_branches: ClassVar[set[str]] = {}¶
Branches this interpretation claims, as regularized object paths. This set is the storage behind uproot_custom.claim; claim branches through that function rather than by writing here, so the cycle number is regularized and the argument type is checked.
- property typename: str¶
The name of the type of the interpretation.
- class uproot_custom.BaseObjectFactory(name: str, sub_factories: list[Factory])[source]¶
Bases:
GroupFactoryThis class reads the base-class part of an object.
A BASE member is the base class’s members concatenated; it carries no fNBytes/fVersion header of its own (docs/reference/binary-format.md).
- build_cpp_reader()[source]¶
Build concrete C++ reader.
- Returns:
An instance of uproot_custom.cpp.IReader.
- build_detree_reader()[source]¶
Build the declarative reader the detree backend compiles.
There is deliberately no default: the detree backend needs a detree reader, and the other backends (cpp, python, forth) do not use this method. A factory that does not implement it cannot be read with UPROOT_CUSTOM_READER_BACKEND=detree.
- Returns:
An instance of uproot_custom.detree.builtin.Reader.
- classmethod build_factory(top_type_name, cls_streamer_info, all_streamer_info, item_path, **kwargs)[source]¶
Never match items. If one needs to use this factory, instatiate it directly.
- class uproot_custom.CStyleArrayFactory(name: str, element_factory: Factory, flat_size: int, fMaxIndex: int, fArrayDim: ndarray)[source]¶
Bases:
FactoryThis class reads a C-style fixed/flexible array and std::array from a binary parser.
- build_cpp_reader()[source]¶
Build concrete C++ reader.
- Returns:
An instance of uproot_custom.cpp.IReader.
- build_detree_reader()[source]¶
Build the declarative reader the detree backend compiles.
There is deliberately no default: the detree backend needs a detree reader, and the other backends (cpp, python, forth) do not use this method. A factory that does not implement it cannot be read with UPROOT_CUSTOM_READER_BACKEND=detree.
- Returns:
An instance of uproot_custom.detree.builtin.Reader.
- classmethod build_factory(top_type_name, cur_streamer_info, all_streamer_info, item_path, **kwargs)[source]¶
Return an instance of this factory when current item matches this factory, otherwise return None.
- Parameters:
top_type_name – name of the top-level class of the current item. For example, vector<int> -> vector.
cur_streamer_info – streamer information of the current item.
all_streamer_info – streamer information of all types, keyed by class name; each value is a dictionary like cur_streamer_info.
item_path – path of the item being matched, for specific behavior.
- Returns:
A factory instance when this class matches the item, otherwise None.
- build_forth_reader(buffer_holder: BufferHolder)[source]¶
Build concrete Forth reader.
- Parameters:
buffer_holder – An instance of BufferHolder to register buffers.
- Returns:
An instance of uproot_custom._forth.IReader.
- build_python_reader()[source]¶
Build concrete Python reader.
- Returns:
An instance of uproot_custom.python.IReader.
- make_awkward_content(raw_data)[source]¶
Reconstruct awkward contents with raw data returned by the reader backend.
- Parameters:
raw_data – Data returned by the reader backend.
- Returns:
The awkward content that builds the corresponding array.
- class uproot_custom.EmptyFactory(name: str)[source]¶
Bases:
FactoryThis factory does nothing. It’s just a place holder.
- build_cpp_reader()[source]¶
Build concrete C++ reader.
- Returns:
An instance of uproot_custom.cpp.IReader.
- build_detree_reader()[source]¶
Build the declarative reader the detree backend compiles.
There is deliberately no default: the detree backend needs a detree reader, and the other backends (cpp, python, forth) do not use this method. A factory that does not implement it cannot be read with UPROOT_CUSTOM_READER_BACKEND=detree.
- Returns:
An instance of uproot_custom.detree.builtin.Reader.
- classmethod build_factory(top_type_name, cur_streamer_info, all_streamer_info, item_path, **kwargs)[source]¶
This factory will never match items. If one needs to use this factory, instatiate it directly.
- build_forth_reader(buffer_holder: BufferHolder)[source]¶
Build concrete Forth reader.
- Parameters:
buffer_holder – An instance of BufferHolder to register buffers.
- Returns:
An instance of uproot_custom._forth.IReader.
- build_python_reader()[source]¶
Build concrete Python reader.
- Returns:
An instance of uproot_custom.python.IReader.
- class uproot_custom.Factory(name: str)[source]¶
Bases:
objectBase class of reader factories.
A factory builds the reader tree for a branch and reconstructs the raw arrays returned by the selected reader backend into an awkward array.
- build_cpp_reader() IReader[source]¶
Build concrete C++ reader.
- Returns:
An instance of uproot_custom.cpp.IReader.
- build_detree_reader() Reader[source]¶
Build the declarative reader the detree backend compiles.
There is deliberately no default: the detree backend needs a detree reader, and the other backends (cpp, python, forth) do not use this method. A factory that does not implement it cannot be read with UPROOT_CUSTOM_READER_BACKEND=detree.
- Returns:
An instance of uproot_custom.detree.builtin.Reader.
- classmethod build_factory(top_type_name: str, cur_streamer_info: dict, all_streamer_info: dict, item_path: str, **kwargs) Factory | None[source]¶
Return an instance of this factory when current item matches this factory, otherwise return None.
- Parameters:
top_type_name – name of the top-level class of the current item. For example, vector<int> -> vector.
cur_streamer_info – streamer information of the current item.
all_streamer_info – streamer information of all types, keyed by class name; each value is a dictionary like cur_streamer_info.
item_path – path of the item being matched, for specific behavior.
- Returns:
A factory instance when this class matches the item, otherwise None.
- build_forth_reader(buffer_holder: BufferHolder) IReader[source]¶
Build concrete Forth reader.
- Parameters:
buffer_holder – An instance of BufferHolder to register buffers.
- Returns:
An instance of uproot_custom._forth.IReader.
- build_python_reader() IReader[source]¶
Build concrete Python reader.
- Returns:
An instance of uproot_custom.python.IReader.
- make_awkward_content(raw_data: Any) Content[source]¶
Reconstruct awkward contents with raw data returned by the reader backend.
- Parameters:
raw_data – Data returned by the reader backend.
- Returns:
The awkward content that builds the corresponding array.
- class uproot_custom.GroupFactory(name: str, sub_factories: list[Factory])[source]¶
Bases:
FactoryThis factory groups differernt factory together. You can use this factory to read specific format of data as you like.
- build_cpp_reader()[source]¶
Build concrete C++ reader.
- Returns:
An instance of uproot_custom.cpp.IReader.
- build_detree_reader()[source]¶
Build the declarative reader the detree backend compiles.
There is deliberately no default: the detree backend needs a detree reader, and the other backends (cpp, python, forth) do not use this method. A factory that does not implement it cannot be read with UPROOT_CUSTOM_READER_BACKEND=detree.
- Returns:
An instance of uproot_custom.detree.builtin.Reader.
- classmethod build_factory(top_type_name, cur_streamer_info, all_streamer_info, item_path, **kwargs)[source]¶
Never match items. If one needs to use this factory, instatiate it directly.
- build_forth_reader(buffer_holder: BufferHolder)[source]¶
Build concrete Forth reader.
- Parameters:
buffer_holder – An instance of BufferHolder to register buffers.
- Returns:
An instance of uproot_custom._forth.IReader.
- build_python_reader()[source]¶
Build concrete Python reader.
- Returns:
An instance of uproot_custom.python.IReader.
- class uproot_custom.PrimitiveFactory(name: str, dtype: str)[source]¶
Bases:
Factory- build_cpp_reader()[source]¶
Build concrete C++ reader.
- Returns:
An instance of uproot_custom.cpp.IReader.
- build_detree_reader()[source]¶
Build the declarative reader the detree backend compiles.
There is deliberately no default: the detree backend needs a detree reader, and the other backends (cpp, python, forth) do not use this method. A factory that does not implement it cannot be read with UPROOT_CUSTOM_READER_BACKEND=detree.
- Returns:
An instance of uproot_custom.detree.builtin.Reader.
- classmethod build_factory(top_type_name, cur_streamer_info, all_streamer_info, item_path, **kwargs)[source]¶
Return when top_type_name is a primitive type.
- build_forth_reader(buffer_holder: BufferHolder)[source]¶
Build concrete Forth reader.
- Parameters:
buffer_holder – An instance of BufferHolder to register buffers.
- Returns:
An instance of uproot_custom._forth.IReader.
- build_python_reader()[source]¶
Build concrete Python reader.
- Returns:
An instance of uproot_custom.python.IReader.
- cpp_reader_map: ClassVar[dict[str, type]] = {'bool': <class 'uproot_custom.cpp.kernel.UInt8Reader'>, 'float32': <class 'uproot_custom.cpp.kernel.FloatReader'>, 'float64': <class 'uproot_custom.cpp.kernel.DoubleReader'>, 'int16': <class 'uproot_custom.cpp.kernel.Int16Reader'>, 'int32': <class 'uproot_custom.cpp.kernel.Int32Reader'>, 'int64': <class 'uproot_custom.cpp.kernel.Int64Reader'>, 'int8': <class 'uproot_custom.cpp.kernel.Int8Reader'>, 'uint16': <class 'uproot_custom.cpp.kernel.UInt16Reader'>, 'uint32': <class 'uproot_custom.cpp.kernel.UInt32Reader'>, 'uint64': <class 'uproot_custom.cpp.kernel.UInt64Reader'>, 'uint8': <class 'uproot_custom.cpp.kernel.UInt8Reader'>}¶
- ftype2dtype: ClassVar[dict[int, str]] = {1: 'int8', 2: 'int16', 3: 'int32', 4: 'int64', 5: 'float32', 8: 'float64', 11: 'uint8', 12: 'uint16', 13: 'uint32', 14: 'uint64', 16: 'int64', 17: 'uint64', 18: 'bool'}¶
- make_awkward_content(raw_data: ndarray)[source]¶
Reconstruct awkward contents with raw data returned by the reader backend.
- Parameters:
raw_data – Data returned by the reader backend.
- Returns:
The awkward content that builds the corresponding array.
- make_awkward_form()[source]¶
Generate awkward form with tree configuration.
- Returns:
The awkward form of the current item.
- typename2dtype: ClassVar[dict[str, str]] = {'Bool_t': 'bool', 'Char_t': 'int8', 'Double_t': 'float64', 'Float_t': 'float32', 'Int_t': 'int32', 'Long_t': 'int64', 'Short_t': 'int16', 'UChar_t': 'uint8', 'UInt_t': 'uint32', 'ULong_t': 'uint64', 'UShort_t': 'uint16', 'bool': 'bool', 'char': 'int8', 'double': 'float64', 'float': 'float32', 'int': 'int32', 'int16_t': 'int16', 'int32_t': 'int32', 'int64_t': 'int64', 'int8_t': 'int8', 'long': 'int64', 'long long': 'int64', 'short': 'int16', 'signed char': 'int8', 'signed int': 'int32', 'signed long': 'int64', 'signed long long': 'int64', 'signed short': 'int16', 'uint16_t': 'uint16', 'uint32_t': 'uint32', 'uint64_t': 'uint64', 'uint8_t': 'uint8', 'unsigned char': 'uint8', 'unsigned int': 'uint32', 'unsigned long': 'uint64', 'unsigned long long': 'uint64', 'unsigned short': 'uint16'}¶
- class uproot_custom.STLMapFactory(name: str, with_header: bool, objwise_or_memberwise: Literal[-1, 0, 1], key_factory: Factory, val_factory: Factory)[source]¶
Bases:
FactoryThis class reads mapping-like STL containers.
- build_cpp_reader()[source]¶
Build concrete C++ reader.
- Returns:
An instance of uproot_custom.cpp.IReader.
- build_detree_reader()[source]¶
Build the declarative reader the detree backend compiles.
There is deliberately no default: the detree backend needs a detree reader, and the other backends (cpp, python, forth) do not use this method. A factory that does not implement it cannot be read with UPROOT_CUSTOM_READER_BACKEND=detree.
- Returns:
An instance of uproot_custom.detree.builtin.Reader.
- classmethod build_factory(top_type_name, cur_streamer_info, all_streamer_info, item_path, in_std_array=False, **kwargs)[source]¶
Return when top_type_name is in cls.target_types.
- build_forth_reader(buffer_holder: BufferHolder)[source]¶
Build concrete Forth reader.
- Parameters:
buffer_holder – An instance of BufferHolder to register buffers.
- Returns:
An instance of uproot_custom._forth.IReader.
- build_python_reader()[source]¶
Build concrete Python reader.
- Returns:
An instance of uproot_custom.python.IReader.
- make_awkward_content(raw_data)[source]¶
Reconstruct awkward contents with raw data returned by the reader backend.
- Parameters:
raw_data – Data returned by the reader backend.
- Returns:
The awkward content that builds the corresponding array.
- make_awkward_form()[source]¶
Generate awkward form with tree configuration.
- Returns:
The awkward form of the current item.
- target_types: ClassVar[list[str]] = ['map', 'unordered_map', 'multimap', 'unordered_multimap']¶
- class uproot_custom.STLSeqFactory(name: str, with_header: bool, objwise_or_memberwise: Literal[-1, 0, 1], element_factory: Factory)[source]¶
Bases:
FactoryThis factory reads sequence-like STL containers.
- build_cpp_reader()[source]¶
Build concrete C++ reader.
- Returns:
An instance of uproot_custom.cpp.IReader.
- build_detree_reader()[source]¶
Build the declarative reader the detree backend compiles.
There is deliberately no default: the detree backend needs a detree reader, and the other backends (cpp, python, forth) do not use this method. A factory that does not implement it cannot be read with UPROOT_CUSTOM_READER_BACKEND=detree.
- Returns:
An instance of uproot_custom.detree.builtin.Reader.
- classmethod build_factory(top_type_name, cur_streamer_info, all_streamer_info, item_path, in_std_array=False, **kwargs)[source]¶
Return when top_type_name is in cls.target_types.
- build_forth_reader(buffer_holder: BufferHolder)[source]¶
Build concrete Forth reader.
- Parameters:
buffer_holder – An instance of BufferHolder to register buffers.
- Returns:
An instance of uproot_custom._forth.IReader.
- build_python_reader()[source]¶
Build concrete Python reader.
- Returns:
An instance of uproot_custom.python.IReader.
- make_awkward_content(raw_data)[source]¶
Reconstruct awkward contents with raw data returned by the reader backend.
- Parameters:
raw_data – Data returned by the reader backend.
- Returns:
The awkward content that builds the corresponding array.
- make_awkward_form()[source]¶
Generate awkward form with tree configuration.
- Returns:
The awkward form of the current item.
- target_types: ClassVar[list[str]] = ['vector', 'array', 'list', 'set', 'multiset', 'unordered_set', 'unordered_multiset']¶
- class uproot_custom.STLStringFactory(name: str, with_header: bool)[source]¶
Bases:
FactoryThis class reads std::string.
- build_cpp_reader()[source]¶
Build concrete C++ reader.
- Returns:
An instance of uproot_custom.cpp.IReader.
- build_detree_reader()[source]¶
Build the declarative reader the detree backend compiles.
There is deliberately no default: the detree backend needs a detree reader, and the other backends (cpp, python, forth) do not use this method. A factory that does not implement it cannot be read with UPROOT_CUSTOM_READER_BACKEND=detree.
- Returns:
An instance of uproot_custom.detree.builtin.Reader.
- classmethod build_factory(top_type_name, cur_streamer_info, all_streamer_info, item_path, in_std_array=False, **kwargs)[source]¶
Return an instance of this factory when current item matches this factory, otherwise return None.
- Parameters:
top_type_name – name of the top-level class of the current item. For example, vector<int> -> vector.
cur_streamer_info – streamer information of the current item.
all_streamer_info – streamer information of all types, keyed by class name; each value is a dictionary like cur_streamer_info.
item_path – path of the item being matched, for specific behavior.
- Returns:
A factory instance when this class matches the item, otherwise None.
- build_forth_reader(buffer_holder: BufferHolder)[source]¶
Build concrete Forth reader.
- Parameters:
buffer_holder – An instance of BufferHolder to register buffers.
- Returns:
An instance of uproot_custom._forth.IReader.
- build_python_reader()[source]¶
Build concrete Python reader.
- Returns:
An instance of uproot_custom.python.IReader.
- class uproot_custom.TArrayFactory(name: str, dtype: str)[source]¶
Bases:
FactoryThis class reads TArray from a binary paerser.
TArray includes TArrayC, TArrayS, TArrayI, TArrayL, TArrayL64, TArrayF, and TArrayD. Corresponding dtype is int8, int16, int32, int64, int64, float32, and float64 respectively.
- build_cpp_reader()[source]¶
Build concrete C++ reader.
- Returns:
An instance of uproot_custom.cpp.IReader.
- build_detree_reader()[source]¶
Build the declarative reader the detree backend compiles.
There is deliberately no default: the detree backend needs a detree reader, and the other backends (cpp, python, forth) do not use this method. A factory that does not implement it cannot be read with UPROOT_CUSTOM_READER_BACKEND=detree.
- Returns:
An instance of uproot_custom.detree.builtin.Reader.
- classmethod build_factory(top_type_name, cur_streamer_info, all_streamer_info, item_path, **kwargs)[source]¶
Return when top_type_name is in cls.typenames.
- build_forth_reader(buffer_holder: BufferHolder)[source]¶
Build concrete Forth reader.
- Parameters:
buffer_holder – An instance of BufferHolder to register buffers.
- Returns:
An instance of uproot_custom._forth.IReader.
- build_python_reader()[source]¶
Build concrete Python reader.
- Returns:
An instance of uproot_custom.python.IReader.
- make_awkward_content(raw_data)[source]¶
Reconstruct awkward contents with raw data returned by the reader backend.
- Parameters:
raw_data – Data returned by the reader backend.
- Returns:
The awkward content that builds the corresponding array.
- make_awkward_form()[source]¶
Generate awkward form with tree configuration.
- Returns:
The awkward form of the current item.
- typename2dtype: ClassVar[dict[str, str]] = {'TArrayC': 'int8', 'TArrayD': 'float64', 'TArrayF': 'float32', 'TArrayI': 'int32', 'TArrayL': 'int64', 'TArrayL64': 'int64', 'TArrayS': 'int16'}¶
- class uproot_custom.TObjectFactory(name: str, keep_data: bool)[source]¶
Bases:
FactoryThis class reads base TObject from a binary parser. You should skip reconstructing array when this factory keeps no data, since the method reconstruct_array will always return None.
- build_cpp_reader()[source]¶
Build concrete C++ reader.
- Returns:
An instance of uproot_custom.cpp.IReader.
- build_detree_reader()[source]¶
Build the declarative reader the detree backend compiles.
There is deliberately no default: the detree backend needs a detree reader, and the other backends (cpp, python, forth) do not use this method. A factory that does not implement it cannot be read with UPROOT_CUSTOM_READER_BACKEND=detree.
- Returns:
An instance of uproot_custom.detree.builtin.Reader.
- classmethod build_factory(top_type_name, cur_streamer_info, all_streamer_info, item_path, **kwargs)[source]¶
Match the TObject base record.
The configuration contains:
factory: cls
name: fName
keep_data: whether to keep data from TObject.
- build_forth_reader(buffer_holder: BufferHolder)[source]¶
Build concrete Forth reader.
- Parameters:
buffer_holder – An instance of BufferHolder to register buffers.
- Returns:
An instance of uproot_custom._forth.IReader.
- build_python_reader()[source]¶
Build concrete Python reader.
- Returns:
An instance of uproot_custom.python.IReader.
- keep_data_itempaths: ClassVar[set[str]] = {}¶
- class uproot_custom.TStringFactory(name: str, with_header: bool)[source]¶
Bases:
FactoryThis class reads TString from a binary parser.
- build_cpp_reader()[source]¶
Build concrete C++ reader.
- Returns:
An instance of uproot_custom.cpp.IReader.
- build_detree_reader()[source]¶
Build the declarative reader the detree backend compiles.
There is deliberately no default: the detree backend needs a detree reader, and the other backends (cpp, python, forth) do not use this method. A factory that does not implement it cannot be read with UPROOT_CUSTOM_READER_BACKEND=detree.
- Returns:
An instance of uproot_custom.detree.builtin.Reader.
- classmethod build_factory(top_type_name, cur_streamer_info, all_streamer_info, item_path, **kwargs)[source]¶
Return an instance of this factory when current item matches this factory, otherwise return None.
- Parameters:
top_type_name – name of the top-level class of the current item. For example, vector<int> -> vector.
cur_streamer_info – streamer information of the current item.
all_streamer_info – streamer information of all types, keyed by class name; each value is a dictionary like cur_streamer_info.
item_path – path of the item being matched, for specific behavior.
- Returns:
A factory instance when this class matches the item, otherwise None.
- build_forth_reader(buffer_holder: BufferHolder)[source]¶
Build concrete Forth reader.
- Parameters:
buffer_holder – An instance of BufferHolder to register buffers.
- Returns:
An instance of uproot_custom._forth.IReader.
- build_python_reader()[source]¶
Build concrete Python reader.
- Returns:
An instance of uproot_custom.python.IReader.
- uproot_custom.build_factory(cur_streamer_info: dict, all_streamer_info: dict, item_path: str = '', **kwargs) Factory[source]¶
Generate a factory with the given streamer information.
- Parameters:
cur_streamer_info – streamer information of the current item.
all_streamer_info – streamer information of all types.
item_path – path to the item.
- Returns:
An instance of Factory.
- uproot_custom.claim(path: str | Iterable[str]) None[source]¶
Claim branches for Uproot-custom to interpret.
A claimed branch is read by AsCustom instead of by Uproot’s own interpretations. Each path is an object-path in the form branch.object_path reports it; the paths are regularized here, so the trailing ;N cycle number may be kept or dropped.
Claim every branch before its interpretation is first computed. Uproot caches that per branch object, so a claim made after branch.array(), tree.arrays() or tree.show() has no effect on that file object.
- Parameters:
path – one object-path, or an iterable of them.
- uproot_custom.get_backend() Literal['cpp', 'python', 'forth', 'detree'][source]¶
Return the current reader backend.
The backend is resolved in the following order of priority: explicitly set value via
set_backend()> UPROOT_CUSTOM_READER_BACKEND environment variable > default “cpp”.- Returns:
The current reader backend (“cpp”, “python”, “forth”, or “detree”).
- Raises:
ValueError – If the UPROOT_CUSTOM_READER_BACKEND environment variable is set to an unrecognized value.
- uproot_custom.release(path: str | Iterable[str]) None[source]¶
Withdraw branches claimed with claim.
Releasing a path that was never claimed does nothing.
- Parameters:
path – one object-path, or an iterable of them.
- uproot_custom.set_backend(backend: Literal['cpp', 'python', 'forth', 'detree']) None[source]¶
Set the current reader backend.
This overrides the UPROOT_CUSTOM_READER_BACKEND environment variable and the default “cpp”.
- Parameters:
backend – The reader backend to use. Must be one of “cpp”, “python”, “forth”, or “detree”.
- Raises:
ValueError – If backend is not a recognized reader backend.
- uproot_custom.use_backend(backend: Literal['cpp', 'python', 'forth', 'detree'])[source]¶
Context manager to temporarily switch the reader backend.
The original backend is restored when exiting the with block.
Example:
import uproot_custom as uc with uc.use_backend("python"): branch.array()
- Parameters:
backend – The reader backend to use within the context. Must be one of “cpp”, “python”, “forth”, or “detree”.
- Raises:
ValueError – If backend is not a recognized reader backend.