Dear experts,
I am trying to create a TTree with a TBranch defined from an object of the class MyEventClass, inheriting from TObject. MyEventClass has a TString member called test_string.
I create the TTree with the following code:
[code]#include “CreateSimpleEventTree.hh”
using namespace std;
int main()
{
TString name = “MyEventTree”;
TString title = “MyEventTree”;
TTree *tree = new TTree(name, title);
MyEventClass event;
MyEventClass::Class()->IgnoreTObjectStreamer(); //this is to remove the TObject branch with fUniqueID and fBits leaves.
TBranch *branch = tree->Branch(“event”, &event,32000,2);
for (int i=0;i<10;i++) {
event.test_var_01 = i;
event.test_var_02 = i*10;
event.test_string.Form("%d",i);
tree->Fill();
}
TFile OutputFile(“outputs/MyEventTree.root”,“RECREATE”);
tree->Write();
return 0;
}
[/code]
Class definition and dictionary files in attachment.
When I try to open the TTree with a TBrowser the TString member is in a separate branch with lot of leaves containing members like IsLong() GetShortSize() etc…
Also, method TTree::Show() does not print any value for the variable test_string.
What am I doing wrong?
Thank you.
gianluca
MyEventClass.hh.txt (355 Bytes)
MyEventClass.cc.txt (61 Bytes)
MyDict.h.txt (2.08 KB)
MyDict.cc.txt (25.9 KB)