Extracting some data from the root file via TSelector

Hi,

I try to extract some data from the root file via TSelector.

if(fReader.GetEntries(entry)>0)

{

cout<< *U<<endl;

cout<<T[entry]<<endl;

}

It works fine for U, but not T

Where.

  1. TTreeReaderArrayT
  2. TTreeReaderValue<Float_t>U

Any help I appreciated

Thanks

NA

See examples in the TTreeReader class reference and the related tutorials: ${ROOTSYS}/tutorials/tree/*Reader*

Thanks for your response, but there is no clear example here
${ROOTSYS}/tutorials/tree/*Reader*

I want an example for
TTreeReaderArray<float T

I know how I can deal with

  1. TTreeReaderValue<Float_t>U

Thanks In Advance
NA

See the second “more complete example” in the TTreeReader class reference.

Thanks for your response, This works for TTreeReaderValue<float
but not for TTreeReaderArray<float

Thanks In Advance

NA

Hi @nora !

Can you

  • post the code that you use and enclose it in ```, please, so we can read it? I’m not sure how you declare the TTreeReaderArray and how you try to access a value from it.
  • share the error message you see?

Thanks for your response,
Here you are

TTreeReaderArray<floa T = {fReader, "T"};
TTreeReaderValue<Float_t> U = {fReader, "U"};


fReader.SetLocalEntry(entry);
if(fReader.GetEntries(entry)>0)
{
  nn->Fill(*T);
  nn->Fill(*U);

}

U works fine, but not for T.
This is the error message, I got.

error: indirection requires pointer operand (‘TTreeReaderArray’ invalid)
nn->Fill(*T);
Error in TSelector::GetSelector: The file Energy.C does not define a class named Energy.

Thanks In Advance
NA

Hi,

I suppose

actually reads

?

Which overload of nn->Fill() is nn->Fill(*T); supposed to call? T “points” to an array; you can access the elements, e.g. T[0] etc; there is no operator* for TTreeReaderArray. We could add it, what would you expect it to return?

Thanks