1. Some words on classes
Code in ROOT / AliROOT / AliPhysics has the form of classes, generally one class per file
- Our analysis task will also be a c++ class
- A class contains both variables and functions (called `methods') as members
- Often the member variables must be accessed through the methods
- A bit abstract, but not so difficult when you see it
class Rectangle
{
private :
int width , height ;
public :
Rectangle (int , int );
int GetArea () { return height * width ;}
}
Classes are nice, because they can be derived from one-another:
INSERT PICTURE slide 7
- CRectangle is derived from base class CPolyogon, and inherits its members
This avoids having to repeat common code for all classes, but can sometimes make understanding the code a bit tricky. Have a look at the following code snippets:
class Polygon
{
private :
int width , height ;
}
class Rectangle : public Polygon
{
public :
Rectangle (int , int );
int GetArea () { return height * width ;}
}
class Triangle : public Polygon
{
public :
Triangle (int , int );
int GetArea () { return ( height * width ) /2;}
}
many of the functions we'll use, are inherited from an analysis base class!