The name of file is TTree.C. File containing the next code:
#include “TFile.h”
#include “TMath.h”
#include “TTree.h”
#include “TH1.h”
#include “iostream”
using namespace std;
void TTree()
{
TFile f(“SimpleTree.root”,“RECREATE”); // Create file first. The TTree will be associated to it
TTree data(“tree”,“Example TTree”); // No need to specify column names
double x, y, z, t;
data.Branch(“x”,&x,“x/D”); // Associate variable pointer to column and specify its type, double
data.Branch(“y”,&y,“y/D”);
data.Branch(“z”,&z,“z/D”);
data.Branch(“t”,&t,“t/D”);
for (int i = 0; i<128; ++i) {
x = gRandom->Uniform(-10,10);
y = gRandom->Gaus(0,5);
z = gRandom->Exp(10);
t = gRandom->Landau(0,2);
data.Fill(); // Make sure the values of the variables are recorded
}
data.Write(); // Dump on the file
f.Close();
}
When I launch it via “.x TTree.C” there are shown error that “must use ‘class’ tag to refer to type ‘TTree’ in this scope TTree tree(“T”,“An example of ROOT tree with a few branches”);”
What is the problem ?