How to retrieve objects from ROOT

I’m looking to use ROOT to store a time-series set of like-structured data objects into one or more ROOT files. The object retrieval patterns would be to return all objects in a file…or one or more specific subset of objects in a file. I have some questions about the latter…that I’m hoping I can get some responses to. I’m working my way through documentation, but just have some questions as I’ve read the documentation…

  • by default is the key name in the ROOT file the same as the object name?
    if not…what is the relationship between an object name in a ROOT file and the associated key name?

  • the same-named object can appear in different ROOT files?

  • in looking at an example of a Tfile map() output…with the list of keys…what is the “title” used for?

  • do most people using ROOT use the ROOT viewer to peruse files and objects within files…
    or do people write their own UIs to do this also?

  • the ROOT viewer can be used to actually retrieve objects?
    can it retrieve one or more objects and deliver them to another file system location outside of ROOT usage?

  • is there any way to locate a specific object without knowing the ROOT file it is in?

  • is it possible to store user-defined metadata in a ROOT file at the object-level…(.meaning metadata about each object)…that is visible and can be retrieved or used to help locate a specific/desired object in a file? Otherwise would use an associated database to contain metadata on each object. Does anyone do that?

  • is there a way to get a count of the number of objects in any identified ROOT file?

Appreciate any responses.

[quote]I’m looking to use ROOT to store a time-series set of like-structured data objects into one or more ROOT files. The object retrieval patterns would be to return all objects in a file…or one or more specific subset of objects in a file. I have some questions about the latter…that I’m hoping I can get some responses to. I’m working my way through documentation, but just have some questions as I’ve read the documentation…
[/quote]ROOT files can be used to store two types of objects:
-serialized objects with a key name/title identifier (say a few hundred, thousands per file)

  • a special object (class TTree) used to store a big number (millions, billions) of objects of the same type (with polymorphisme).

In High Energy Physics, typically people store histograms as keyed objects and events in a TTree.

[quote] - by default is the key name in the ROOT file the same as the object name?
if not…what is the relationship between an object name in a ROOT file and the associated key name?
[/quote] When you write an object to a file via object->Write(), the name of the key is the object name. You can specify an alternative name for objects with no name.

[quote]- the same-named object can appear in different ROOT files?
[/quote]Yes

[quote]- in looking at an example of a TFile map() output…with the list of keys…what is the “title” used for?
[/quote]The key name is typically a short name (that you can associate to a C++ variable name in your code).
The title may be much longer and carry additional information to be used in possible selections without reading the object from the file.

[quote]- do most people using ROOT use the ROOT viewer to peruse files and objects within files…
or do people write their own UIs to do this also?
[/quote]For simple things, people use the standard ROOT TBrowser. For more advanced viewing (for example event viewers) more sophisticated viewers have been developed (eg the ROOT TEveBrowser, Viewer)

[quote]- the ROOT viewer can be used to actually retrieve objects?
can it retrieve one or more objects and deliver them to another file system location outside of ROOT usage?
[/quote]You can read and send an object or collections of objects through a messaging system (sockets, etc).
On the other side you can use ROOT to read these objects or implement your own deserialisation system if you are courageous enough to develop one ::slight_smile:
You can also access remotely any ROOT file via the http service of your web server.

[quote]- is there any way to locate a specific object without knowing the ROOT file it is in?
[/quote]You can create a central ROOT file with a hierarchy of directories for your bookkeeping information.
You can also use a relational data base or any other system depending on the scale.

[quote]- is it possible to store user-defined metadata in a ROOT file at the object-level…(.meaning metadata about each object)…that is visible and can be retrieved or used to help locate a specific/desired object in a file? Otherwise would use an associated database to contain metadata on each object. Does anyone do that?
[/quote]ROOT files are self describing. All data types stored in a ROOT file have a summary information (list of TStreamerInfos) used to read later any type (including support for schema evolution)

[quote]- is there a way to get a count of the number of objects in any identified ROOT file?
[/quote]If you have one single directory level, this is simply the number of keys. If you have a directory tree
you have to scan the directories tree to sum up the number of keys in each directory.

Rene