Hi there,
I’d like to store objects into a branch, and also split them. Let’s create an example:
TTree tree;
TObject *in_ptr = 0;
tree.Branch("TheBranch", "TObject", &in_ptr, 3200, 99);
new (in_ptr) TObject();
in_ptr->SetUniqueID(1000);
tree.Fill();
tree.Print();
So we’ll get the following tree’s description:
******************************************************************************
*Tree : : *
*Entries : 1 : Total = 2263 bytes File Size = 0 *
* : : Tree compression factor = 1.00 *
******************************************************************************
*Branch :TheBranch *
*Entries : 1 : BranchElement (see below) *
*............................................................................*
*Br 0 :fUniqueID : UInt_t *
*Entries : 1 : Total Size= 669 bytes One basket in memory *
*Baskets : 0 : Basket Size= 3200 bytes Compression= 1.00 *
*............................................................................*
*Br 1 :fBits : UInt_t *
*Entries : 1 : Total Size= 653 bytes One basket in memory *
*Baskets : 0 : Basket Size= 3200 bytes Compression= 1.00 *
*............................................................................*
So there is ‘fUniqueID’ branch. Now, I’d like to extract a value only from ‘fUniqueID’ branch, without extracting an entire TObject’s instance. Trying to allocate storage for it:
UInt_t *out_ptr = 0;
tree.SetBranchAddress("fUniqueID", &out_ptr);
cout << "out_ptr = " << out_ptr << endl;
Here, out_ptr doesn’t change, i.e preserves a null value. But when I tried the following code instead,
TObject *out_ptr = 0;
tree.SetBranchAddress("TheBranch", &out_ptr);
cout << "out_ptr = " << out_ptr << endl;
– this worked: it did allocate allocate memory for the top ‘TheBranch’.
So where I am wrong? And, how should I get values directly from the ‘fUniqueID’ branch?
Thanks!
ROOT Version: 6.18.04
Platform: Linux, macOS
Compiler: g++ 7.4.0 on Linux, clang-1001.0.46.4 on macOS