You can extend ROOT with your own classes. When defining a class, it inherits from TObject .
Defining a class
The definition of a class requires the following steps:
Inheriting from TObject .
Integrating the class to ROOT.
Providing a constructor.
Inheriting from TObject
The TObject class provides the default behaviour and protocols for the objects in the ROOT system. The TObject class is the primary interface to classes providing object I/O (writing the class into a ROOT file), error handling, inspection, introspection, and drawing.
Therefore, your class should inherit from TObject .
Integrating the class to ROOT
Add the following line to your class header file, to integrate your class to ROOT:
ClassVersionID is used by the ROOT I/O system. It is written on the output stream and during reading. You can check this
ClassVersionID during reading and take appropriate action depending on the value of
Every time you change the data members of a class, increase its
ClassVersionID by 1.
ClassVersionID >= 1.
ClassVersionID = 0 in case you do not need object I/O.
Calling the ClassImp macro
ClassImp macro to give your class run time type identification (RTTI) and full I/O capabilities. In addition, you can generate properly documentation for your class using THtml
Add the following line to your class header file:
ROOT requires for every class to have one of the following constructors:
A constructor with zero parameters or with one or more parameters all with default values.
A constructor with exactly one parameter which type is a pointer to one of the types marked as an
The default constructor or I/O constructor is called whenever an object is being read from a ROOT database.
Example for a class