Hello!
Could you help me?
I want to read tree and add TMultiGraph in the TObjArray.
But TMultiGraph don’t have copy constructor.
How to overcome this promlem?
void ReadTree()
{
TObjArray Hlist(0);
Hlist.SetOwner(kTRUE);
TFile f("D:\\Data_work\\tree.root");
TTree* t;
f.GetObject("t1", t);
TMultiGraph* graph = new TMultiGraph();
t->SetBranchAddress("gr", &graph);
for (int i = 0; i < t->GetEntries(); ++i)
{
t->GetEntry(i);
Hlist.Add(new TMultiGraph(*graph)); // error
}
TFile ofile_Hlist("D:\\Data_work\\graphs.root", "RECREATE");
Hlist.Write();
ofile_Hlist.Close();
}
And also: is this code to write TMultiGraph in the tree correct?
[code]void CreateTree()
{
TTree tree(“t1”, “Parser tree”);
TMultiGraph *gr = new TMultiGraph();
TGraphErrors *gr_1 = new TGraphErrors();
TGraphErrors *gr_2 = new TGraphErrors();
tree.Branch("gr", "TMultiGraph", &gr, 128000, 0);
//loop to create 5 TMultiGraph
for (int j = 0; j < 5; j++)
{
//fill graphs
for (int i = 0; i < 10; ++i)
{
gr_1->SetPoint(i, i + gRandom->Uniform(-.5, .5), gRandom->Uniform(-.5, .5));
gr_2->SetPoint(i, i + gRandom->Uniform(-.1, .1), gRandom->Uniform(-.1, .1));
}
gr->Add(gr_1);
gr->Add(gr_2);
tree.Fill();
gr->Clear();
gr_1->Clear();
gr_2->Clear();
}
TFile f("D:\\Data_work\\tree.root", "recreate");
tree.Write();
}[/code]
I have read here root.cern.ch/root/htmldoc/guide … ding-trees , but have not found the similiar examples.
Thank you in advance.