Skip to content

Commit 1fbac62

Browse files
committed
[io][doc] Some touches to TFile and RFile documentation
1 parent de992f1 commit 1fbac62

2 files changed

Lines changed: 43 additions & 18 deletions

File tree

io/io/inc/ROOT/RFile.hxx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/// \ingroup Base ROOT7
33
/// \author Giacomo Parolini <giacomo.parolini@cern.ch>
44
/// \date 2025-03-19
5-
/// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback
5+
/// \warning This is part of the ROOT 7 prototype! It will change without notice. Feedback
66
/// is welcome!
77

88
#ifndef ROOT7_RFile
@@ -189,6 +189,9 @@ public:
189189
\ingroup RFile
190190
\brief An interface to read from, or write to, a ROOT file, as well as performing other common operations.
191191
192+
Please refer to the documentation of TFile for the details related to how data and executable code can be stored
193+
in ROOT files.
194+
192195
## When and why should you use RFile
193196
194197
RFile is a modern and minimalistic interface to ROOT files, both local and remote, that can be used instead of TFile

io/io/src/TFile.cxx

Lines changed: 39 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,35 @@
1313
\file TFile.cxx
1414
\class TFile
1515
\ingroup IO
16-
\brief A ROOT file is an on-disk file, usually with extension .root, that stores objects in a file-system-like logical structure, possibly including subdirectory hierarchies.
16+
\brief A file, usually with extension .root, that stores data and code in the form of serialized objects in a
17+
file-system-like logical structure, possibly including subdirectory hierarchies.
18+
\note ROOT files contain data, and executable code, for example through TExec, TMacro, and TFormula instances. As for all files, **do not open ROOT files from an unknown origin!**
1719
\note See also \ref IO
1820
\note See also \ref rootio (or `io/doc/TFile` folder in your codebase)
1921
22+
ROOT files a are an efficient mean to store C++ class instances, e.g. data,
23+
both as individual objects, in a so called *row-wise fashion*, and in a
24+
*so-called columnar fashion*. Also executable code can be stored in ROOT files,
25+
for example in the form of TMacro, TExec or TFormula instances, and the
26+
related federation of classes.
27+
28+
For example, a TCanvas or TPad instance may rely on TExec instances stored in
29+
their *list of executables* to obtain certain graphics effects: in this case,
30+
code will be executed upon drawing. A TH1 or a TGraph instance, as well as
31+
their multidimensional counterparts and derived classes, may also execute code
32+
upon drawing through TExec instances stored in their *list of functions*.
33+
Another example of code which is executable is represented by TFormula
34+
instances, that are the "computational workhorse" of function classes such as
35+
TF1, its multidimensional counterparts, and related classes. There, jitted C++
36+
code is executed for example upon evaluation, for example during fits or
37+
drawing operations, to obtain maximum runtime performance.
38+
39+
2040
<details>
2141
<summary>ROOT file data format specification</summary>
2242
2343
A ROOT file is composed of a header, followed by consecutive data records
24-
(`TKey` instances) with a well defined format.
44+
(TKey instances) with a well defined format.
2545
2646
The first data record starts at byte fBEGIN (currently set to kBEGIN).
2747
Bytes 1->kBEGIN contain the file description, when fVersion >= 1000000
@@ -225,18 +245,18 @@ TFile::TFile() : TDirectoryFile(), fCompress(ROOT::RCompressionSetting::EAlgorit
225245
///
226246
/// Option | Description
227247
/// -------|------------
228-
/// NEW or CREATE | Create a new file and open it for writing, if the file already exists the file is not opened.
229-
/// RECREATE | Create a new file, if the file already exists it will be overwritten.
230-
/// UPDATE | Open an existing file for writing. If no file exists, it is created.
231-
/// READ | Open an existing file for reading (default).
232-
/// NET | Used by derived remote file access classes, not a user callable option.
233-
/// WEB | Used by derived remote http access class, not a user callable option.
234-
/// READ_WITHOUT_GLOBALREGISTRATION | Used by TTreeProcessorMT, not a user callable option.
248+
/// NEW or CREATE | Create a new file and open it for writing, if the file already exists the file
249+
/// is not opened. RECREATE | Create a new file, if the file already exists it will be
250+
/// overwritten. UPDATE | Open an existing file for writing. If no file exists, it is
251+
/// created. READ | Open an existing file for reading (default). NET | Used by derived
252+
/// remote file access classes, not a user callable option. WEB | Used by derived remote
253+
/// http access class, not a user callable option. READ_WITHOUT_GLOBALREGISTRATION | Used by TTreeProcessorMT, not a
254+
/// user callable option.
235255
///
236256
/// If option = "" (default), READ is assumed.
237-
/// \note Even in READ mode, if the file is the current directory `cd()`, and you create e.g. a new histogram in your code,
238-
/// the histogram will be appended (but not written) to this directory, and automatically deleted when closing the file.
239-
/// To avoid this behavior, call hist->SetDirectory(nullptr); after creating it.
257+
/// \note Even in READ mode, if the file is the current directory `cd()`, and you create e.g. a new histogram in your
258+
/// code, the histogram will be appended (but not written) to this directory, and automatically deleted when closing the
259+
/// file. To avoid this behavior, call hist->SetDirectory(nullptr); after creating it.
240260
///
241261
/// The file can be specified as a URL of the form:
242262
///
@@ -255,12 +275,12 @@ TFile::TFile() : TDirectoryFile(), fCompress(ROOT::RCompressionSetting::EAlgorit
255275
///
256276
/// file.tar?filetype=raw
257277
///
258-
/// This is convenient because the many remote file access plugins allow
259-
/// easy access to/from the many different mass storage systems.
278+
/// This can be convenient because the many file access plugins allow
279+
/// easy access to remote endpoints, e.g. mass storage pools.
260280
/// The title of the file (ftitle) will be shown by the ROOT browsers.
261281
/// A ROOT file (like a Unix file system) may contain objects and
262-
/// directories. There are no restrictions for the number of levels
263-
/// of directories.
282+
/// directories, as well as executable code. There are no restrictions
283+
/// for the number of levels of directories.
264284
/// A ROOT file is designed such that one can write in the file in pure
265285
/// sequential mode (case of BATCH jobs). In this case, the file may be
266286
/// read sequentially again without using the file index written
@@ -288,7 +308,9 @@ TFile::TFile() : TDirectoryFile(), fCompress(ROOT::RCompressionSetting::EAlgorit
288308
/// The enumeration ROOT::RCompressionSetting::EAlgorithm associates each
289309
/// algorithm with a number. There is a utility function to help
290310
/// to set the value of compress. For example,
311+
///
291312
/// ROOT::CompressionSettings(ROOT::kLZMA, 1)
313+
///
292314
/// will build an integer which will set the compression to use
293315
/// the LZMA algorithm and compression level 1. These are defined
294316
/// in the header file <em>Compression.h</em>.
@@ -315,7 +337,7 @@ TFile::TFile() : TDirectoryFile(), fCompress(ROOT::RCompressionSetting::EAlgorit
315337
/// }
316338
/// ~~~
317339
/// When opening the file, the system checks the validity of this directory.
318-
/// If something wrong is detected, an automatic Recovery is performed. In
340+
/// If something wrong is detected, an automatic recovery is performed. In
319341
/// this case, the file is scanned sequentially reading all logical blocks
320342
/// and attempting to rebuild a correct directory (see TFile::Recover).
321343
/// One can disable the automatic recovery procedure when reading one

0 commit comments

Comments
 (0)