Get branch with myobject from tree

Hello everyone!

I’m newbie with ROOT, I hope this question is not too obvious.

I have a macro which analyses a binary file whose content is the waveform of a pulse from a scope. There’s a created class there called ‘event’ which has as members, for instance, a vector of pulses (another class, pulses in the file), the pedestal, noise, etc. A tree is created with a branch containing the object ‘event’ on splitmode=0 (tree->Branch(“ev”, “event”, &ev, 32000, 0);). There’s one event instance per data file.

Now, I’d like to know whether the notion I have is right (and if wrong, please correct me and suggest the right way to do things):
To get the ‘ev’ branch from the tree I must:

-Create a TFile instance to load the output.root file with the tree.
-Create a TTree instance to load the tree.
-Somehow load the .h file with the ‘event’ class definition to be able to create an instance of ‘event’, let’s say event *ev; (?)
This would mean that I always need the original macro to get the branch with a created class not by default on ROOT.

  • Then,
    TBranch *branch = tree->Branch(“ev”, “event”, &ev, 32000, 0);
    -Is it necessary to SetBranchAddress()? What is it for?
    -Get entries, loop over the branch, get at each cycle the object ‘ev’ and from it the members (data) I want.

I’d really appreciate any suggestions/lessons/corrections!!
Thanks in advance!

Daniel

ROOT User’s Guide - Chapter 12. Trees
ROOT Tutorials: Trees I/O, Queries, Graphics
ROOT HowTo’s - Trees