I want to see if I am thinking about this correctly:
Let’s consider the following example:
We have a tree with a branch named Events
that stores events of class MyEvent.
In this class, there are member functions RunId()
, EventId()
, etc.
When the data is written to the branch Events
, a split-level is performed so that mRunId
, mEventId
, etc, are all stored in sub-branches.
Now we have a tree MyTree
with a branch named Events
and within the branch Events
, we have sub-branches . One sub-branch has all the mRunId
values, another sub-branch has all the mEventId
value, etc.
Would this be the right way to process a branch from MyTree
?
TChain* eventChain = new Chain("MyTree")
eventChain -> Add(eventFile.root) // Assuming that other files will be chained too.
MyEvent* event = 0;
eventChain->SetBranchAddress("Events", &event)
eventChain->GetEvent(1)
event->RunId() // Where RunId() is a member function of the class MyEvent and it returns the value `mRunId`
event->EventId() // Where EventId() is a member function of the class MyEvent and it returns the value `mEventId`
I am providing this example in an attempt to see if:
a) I need to assign a pointer to each sub-branch,
b) or if I can still have one pointer of class MyEvent
and all the information from the sub-branches can be accessed using one pointer, in this case the pointer would be event
, since one entry of the sub-branches corresponds to all the data members of class MyEvent
and the pointer event
is of type MyEvent
.
Can you please let me know if I am thinking about reading the tree correctly, and if either my interpretation in a or b is correct? If not, what is the correct way to go about it?