I have to read a TBranch which every entry is vector of floats (*Br 3 :timing_par : timing_par[3]/F ), and ‘a priori’, I don’t know the size of this vector (this should be parameterized in the code).
I’m doing it like this:
It works fine, but it is very slow. I think it is because I have to store this values in a std::vector<std::vector>, and to do so, I have to go entry by entry converting the doubles into float, and this is very slow.
I cannot do the SetBranchAdress to an usual float array, because I get this error:
error: ISO C++ forbids variable length array ‘test’ [-Werror=vla]
Float_t test[NPAR];
Any idea is welcome!
J
ROOT Version (e.g. 6.12/04):
Platform, compiler (e.g. CentOS 7.3, gcc6.2):
trying to clarify your case here.
You have a dataset a column of which stores vector instances. You would like to “extract” this column as a data structure in memory. Is this correct?
Hi dpiparo,
Thanks for you answer. Yes, this is basically what I do with the code above, but I don’t know which is the more efficient-fast way.
The Branch is defined as “timing_par[3]/F”, a vector of floats, but I could change this definition if there is a better way.
The only requirement is that the size of the vector should be parametrised…
ROOT::Experimental::TDataFrame d("mytree", "file.root");
// auto c = d.Take<std::vector<float>>("v"); // a bit slower, reallocations possible
auto v = d.Take<std::vector<float>, std::deque<std::vector<float>>>("v");