Re: Problem with ROOT

From: Stan Seibert (volsung@physics.utexas.edu)
Date: Tue Jan 24 2006 - 18:43:07 CST


On Jan 24, 2006, at 6:00 PM, Dan Wright wrote:

> I've been having some problems with ROOT, and I was hoping to use a
> little of the collective knowledge on this list to troubleshoot. I
> want
> to loop through all the events in a tree, and analyze a certain
> variable each time. It seemed simple to begin with, but I can't
> seem to
> make it work. Here's what I have currently:
>
> double en = 0;
> T->SetBranchAddress("mc.totScintEdep", &en);
> T->GetEntry(0);
> cout << en << endl;
> 0

I have great difficulty understanding the mysterious subtleties of
TTrees and TBranches, so RAT includes a little class to simplify
reading events out of a ROOT tree:

RATDSReader r("testIBDgen.root");
RAT_DS *ds;

while (ds = r.NextEvent()) {
   cout << "mc.totScintEdep: " << ds->mc.totScintEdep << endl;
}

RATDSReader::NextEvent() just returns the events in the file one
after the other until it hits the end, and then it returns 0. The 0
is what terminates the while loop.

---
Stan Seibert


This archive was generated by hypermail 2.1.6 : Sun Feb 12 2006 - 00:01:01 CST