Reading values from leaf

Greetings all,

I am trying to read individual entry values from a leaf into a series of variables. The values represent the net counts in a series of gamma peak and an associated peak error.

The first pair of values is read correctly - subsequent pairs are not. I suspect that I am failing to initialize a pointer correctly but I can not seem to figure out how to correct the problem.

I have attached a short script which demonstrates the problem and an ASCII file which is read in by the script to illustrate the issue. I have also attached an example of output from a root session.

Any guidance you can give on what I am doing wrong here will be greatly appreciated.

Regards
ExampleSession.txt (1.13 KB)
parameters_ru98RIV0309_R1.txt (183 Bytes)
Example.C (785 Bytes)

Hi,

[quote] I suspect that I am failing to initialize a pointer correctly but I can not seem to figure out how to correct the problem[/quote].You simply mis-read the documentation for TLeaf::GetValue. The parameter is the requested index within the current entry/event (thus, of course, this value should always be 0 if the leaf does not point to an array). So the pattern you want to use is:

TREE->GetEntry(2); Double_t P3A1 = TREE->GetLeaf("PeakArea")->GetValue(0); Double_t P3eA1 = TREE->GetLeaf("PeakError")->GetValue(0);

Cheers,
Philippe.

Thank you Philippe, that works perfectly

Regards