Hi,Rooters:
On the Page 211 of “Root Users Guide5.21”,there is an function tree4r() for reading a Tree:
[color=green]void tree4r() {
// check if the event class is in the dictionary
// if it is not load the definition in libEvent.so
if (!TClassTable::GetDict(“Event”)) {
gSystem->Load("$ROOTSYS/test/libEvent.so");
}
// read the tree generated with tree4w
// note that we use “new” to create the TFile and TTree objects, because we
// want to keep these objects alive when we leave this function.
TFile *f = new TFile(“tree4.root”);
TTree t4 = (TTree)f->Get(“t4”);
// create a pointer to an event object for reading the branch values.
Event *event = new Event();
// get two branches and set the branch address
TBranch *bntrack = t4->GetBranch(“fNtrack”);
TBranch *branch = t4->GetBranch(“event_split”); [/color]
[color=red]branch->SetAddress(&event); [/color]//line 70 in my eventree.C file
…
When i execute the code ,there is errors infomation:
[color=red]Error: illegal pointer to class object branch 0x0 721 eventtree.C:70:[/color]
So ,what’s the problem in the code?
I did nothing modification on the function tree4r() and tree4w().
Any guidance will be appreciated.