You are here

How to Understand a Class Structure?

The class structure and Object-Orientation make possible more modular programming. However, programs consisting of several hundred classes and several hundred thousand lines of code may be difficult to understand, in particular for novice users. ROOT provides a set of tools to help understanding an existing class structure, a data structure in memory or files.

  • TFile::ls can be used to list objects in a file or directory.
    • list->ls() lists objects in a collection pointed by list.
    • list->Dump() dumps all objects in a collection pointed by list.
  • TFile::Map dumps the structure of a file. One line is printed for every record written to the file with the following information:
    • Date/Time when the object was written.
    • Position of the object (starting byte number).
    • Number of bytes occupied by the object.
    • Object class name.
    • Compression factor (if file is compressed).
  • TClass::Draw can be used to draw the inheritance tree for a given object. All ROOT classes are documented with their associated inheritance tree (see for example TPaveText). This tree can be generated interactively via the command: object->DrawClass() or by selecting the DrawClass item when pointing with the right moose button to an object in a canvas. The tree is automatically generated when a given class is processed through the documentation tool (class THtml).
  • TObject::Inspect can be used to view the contents of a given object. A table is shown where, for each data member, its name, current value and its title are given. If a data member is a pointer to another object, one can click on the pointer and, in turn, inspect the pointed object,etc.
  • TObject::Dump is the same as TObject::Inspect, except that the output is on stdout. An object dump can be written to a file.
  • The ROOT general object browser (see TBrowser) can be used to browse collections such as the list of classes, geometries, files and TTrees. A browser can be started from the Start Browser item in the canvas View menu or by creating a browser object. Example: TBrowser b. More than one browser can be active at any time.