Efficient way to load a 3D matrix and access randomly its vectorial field elements

Hi there,

I am just wondering if there inside ROOT a dedicated class to load a 3-dimensional matrix that defines 3-dimensional vectors. Thats it an object dedicated to host fieldmap-like data.

I am using the following approach

std::vector<std::vector<std::vector<TVector3>>> field;

but my matrix is of the order of 5M elements in total, So I have 5M TVector3 elements, and when I want to get those elements it starts to be a bit slow.

I though, perhaps using a TH3F for each of the field components would be more efficient?

Do you have any advice to improve performance here?

There is any 3-dimensional fieldmap-like class at ROOT that cares about the performance under the table?

@moneta can perhaps give some advice on this? Thanks!

Do you need to have the TVector3 functionality or just using the 3 coordinates ?
If you don’t need it, I would then use the RTensor class with 4 dimensions.
See https://root.cern.ch/doc/master/classTMVA_1_1Experimental_1_1RTensor.html


Ok, thanks, that’s probably what we need.

We need to use certain TVector3 operations, but we could hardcode those if the gain in performance is worth.

You can probably store in memory the data in a RTensor or something similar (like a big std::vector ) and then re-fill a TVector3 when needed using for example
TVector3::SetXYZ( v1,v2,v3);


1 Like

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