Hi, I just want to fill a tree with numerical data, but also I need to record one string of two characters per entry. Here is my example code with two numerical entries, which compiles. Recording the string is in line 11 which is commented. When I uncomment compilation fails.
#include<iostream>
#include<TFile.h>
#include<TTree.h>
void example(){
int Z;
int A;
string element;
TTree* tree = new TTree("DATA", "all stuff");
tree->Branch("Z", &Z);
tree->Branch("A", &A);
//tree->Branch("element", &element);
Z = 1;
A = 2;
element = "AA";
tree->Fill();
Z = 10;
A = 20;
element = "BB";
tree->Fill();
tree->Print();
tree->Show(0);
tree->Show(1);
tree->Scan();
tree->GetEntry(0);
cout << Z << endl;
cout << A << endl;
cout << element << endl;
tree->GetEntry(1);
cout << Z << endl;
cout << A << endl;
cout << element << endl;
TFile* f = new TFile("mu.root", "recreate");
tree->Write("tree");
f->Close();}
P.S. For historical reasons I am using root 5.28/00 for windows, and it has to stay that way.
Many thanks in advance!