Store data from tree to vector

Dears rooters,

I’m would like to store the data from a Tree into a vector. I tried with this but doesn’t work.

std::vector xVals=(t->GetV1());

Someone can help me?

Thanks in advance :slight_smile:

std::vector<Double_t> xVals(t->GetV1(), t->GetV1() + t->GetSelectedRows());

thanks for the reply.
I tried your solution but i got this error:
Error in TRint::HandleTermInput(): std::bad_alloc caught: std::bad_alloc

what means?
thanks in advance

I guess you get also an Error in TTreeFormula::Compile: Bad numerical expression : “y_values”.

Try with:

std::vector<double> xVals(t->GetV1(),
                          t->GetV1() + (t->GetSelectedRows() < 0 ? 0 : t->GetSelectedRows()));

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.