I would like to write a class object to tree.
I find the following method TTree::Branch() appropriate.
Should classname
match the output of TObject::ClassName() and why at all is it necessary to indicated classname as this information is available to ROOT via TObject::ClassName()
.
Please read tips for efficient and successful posting and posting code
ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided
pcanal
December 8, 2021, 8:16pm
2
You should not need it. This should work/be-sufficient:
MyClass *ptr = ....
...
tree->Branch("nameofbranch.", &ptr);
1 Like
Why do you put &
before the pointer? I conclude that you refer to TBranch * TTree::Branch (const char * name, T * obj, Int_t bufsize = 32000, Int_t splitlevel = 99 ) and there obj
is not a double pointer.
pcanal
December 8, 2021, 8:43pm
4
I was actually using: template TBranch * TTree::Branch ( const char * name, T ** addobj, Int_t bufsize = 32000, Int_t splitlevel = 99 )
But indeed you can also use the other alternative;
MyClass ptr{....};
...
tree->Branch("nameofbranch.", &ptr);
Cheers,
Philippe.
PS. Of course, there is other possible variation on how to use those functions
system
Closed
December 22, 2021, 8:44pm
5
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.