I would like to store in the TTree nested structures, something like:
struct a
{
struct *b;
int something;
}
struct b
{
struct *c;
}
Where b and c will point to an arrays of structures. The dimensions of the arrays are not know at the time of writing of the code and will be dynamically allocated.
In general I understand that due to non-continuity writing this kind of structure to TTree (even if I have arrays with known size instead of pointers) is very inconvenient. So I decided to create classes for each structure. However, if I have
class a
{
public:
int val;
a(){val=0;}
}
class b
{
public:
a *obj;
b(){obj = new a[2]; obj[0].val=1;}
}
And initialize TTree branch with
a *obj1 = new a();
t->Branch("test_branch", "a", &obj1, 32000, 99);
Than after writing to the TTree I have inside a branch with “obj” of type “*b”. This does not behave like an array - printing both values of obj[0] and obj[1] .val gives 1. Is there a way to add this kind of nested structures with dynamically allocated arrays of structures to a TTree?