You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: manual/root_files/index.md
+27-9Lines changed: 27 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,30 +7,33 @@ toc: true
7
7
toc_sticky: true
8
8
---
9
9
10
-
ROOT files contain C++ objects that are stored to disk.
11
-
You can open files when starting ROOT
10
+
ROOT files contain data, for example in the form of objects that are instances of C++ classes, and executable code, for example through `TExec`, `TMacro`, and `TFormula` instances.
11
+
12
+
> As for *all* files, do not open ROOT files from an unknown origin!
13
+
14
+
You can open files when starting ROOT, specifying those as commandline arguments
In ROOT you can save objects in ROOT files, making these objects "persistent".
33
+
Objects can be written in ROOT files, making these objects "persistent".
31
34
Later on, you can read these objects back: the object is reconstructed in memory.
32
35
33
-
ROOT files often contain columnar data, used for instance by all LHC (Large Hadron Collider) experiments.
36
+
Not only individual objects can be written, in a so-called "row-wise fashion". ROOT files can contain also columnar data, used for instance by many High Energy Physics Experiments, at LHC and elsewhere. At the end of LHC Run 3, *Exabytes* of data were written in ROOT's columnar format!
34
37
35
38
## Storing an object in a ROOT file and reading it back
36
39
@@ -57,7 +60,7 @@ For the second argument, the following options are available:
57
60
### Storing an object in a ROOT file
58
61
59
62
You can save any object, for instance canvases or histograms, into a ROOT file.
60
-
You can even store your own types.
63
+
You can even store your own types, provided that you expose to ROOT the information necessary for their serialization.
61
64
62
65
<!-- For more information, see the → [I/O]({{ '/manual/io' | relative_url }}) section of the manual. -->
ROOT will automatically save and close any ROOT files still open when the session ends.
81
-
The ROOT file is also saved and closed when deleting / destructing the `TFile` object.
84
+
The ROOT file is also saved and closed when deleting, or more in general destructing, the `TFile` object.
82
85
83
86
{% highlight C++ %}
84
87
void closeAtDestruct(TH1 *hist) {
@@ -102,10 +105,13 @@ def closeAtDestruct(hist):
102
105
103
106
### Opening and inspecting a ROOT file
104
107
108
+
ROOT is not needed to inspect ROOT files! For example, those can be opened in your web browser with [JSRoot](https://root.cern/js/latest/){:target="_blank"}: no single C++ line is executed, pure JavaScript code provides all the functionality needed.
109
+
110
+
Of course, ROOT files can be opened and inspected with ROOT's C++ and Python APIs.
105
111
Use [TFile::Open()](https://root.cern/doc/master/classTFile.html#ad8870806a04da2c2f4aa02bee4ec6833){:target="_blank"} to open a ROOT file.
106
112
While this operation might return a valid pointer to a `TFile` object,
107
113
this object might not be able to access data, for instance because ROOT was unable to open the file in the filesystem.
108
-
Use[TObject::IsZombie()](https://root.cern/doc/master/classTObject.html#aaa8418b9b6692a12d8d0e500c51911bf){:target="_blank"} to check whether the ROOT file was successfully opened.
114
+
You can use[TObject::IsZombie()](https://root.cern/doc/master/classTObject.html#aaa8418b9b6692a12d8d0e500c51911bf){:target="_blank"} to check whether the ROOT file was successfully opened.
@@ -137,6 +143,14 @@ See also → [Object ownership]({{ '/manual/object_ownership' | relative_url }})
137
143
138
144
For the particular case of TTree, cycles only store metadata, see [Baskets, clusters and the tree header]({{ '/manual/trees/#baskets-clusters-and-the-tree-header' | relative_url }}).
139
145
146
+
Something a bit advanced now. The information ROOT relies on for serializing objects is stored in `TStreamerInfo` instances, which are stored themselves in the ROOT file. This feature offers several advantages, for example it can make the ROOT file and its content self descriptive.
147
+
If you want to have a look to the list of `TStreamerInfo` instances in a file, you can use the following API:
In C++, use the `Get<T>()` method to retrieve the objects from a ROOT file.<br>
@@ -280,6 +294,10 @@ Double-click the ROOT file to inspect its content.
280
294
Double-clicking graphical objects displays them in a canvas tab.
281
295
Double-clicking files that end with `.C` displays them in an editor tab.
282
296
297
+
> Clicking on objects in a `TBrowser` (or `RBrowser`) instance can lead to the execution of code.
298
+
> For example, a `TCanvas` instance may rely on `TExec` instances to obtain certain effects, a histogram or a graph may do the same with the `TExec` instances stored in their *list of functions*. The `TFormula` powering function classes such as `TF1` or its multidimensional counterparts, also executes jitted C++ code to obtain maximum runtime performance.
299
+
> As explained above, as for *all* files, do not open ROOT files from an unknown origin!
300
+
283
301
## Accessing a remote ROOT file
284
302
285
303
You can read and write a remote ROOT file by specifying its URL to [TFile::Open()](https://root.cern/doc/master/classTFile.html#aec5f3fae0774aabfc615ebb4b00fe5e0){:target="_blank"}.
0 commit comments