Home | News | Documentation | Download

Saving complex numbers on a TBranch

What is the fastest way to write a complex variable to a branch in ROOT? I have real and complex variables, and custom structs containing arrays of real and complex variables, as follows (simplified version):

template<typename T, std::size_t N>
struct MyVector{
	T element[N];
};

double var;
std::complex<double> cvar;
MyVector<double, 3> vec;
MyVector<std::complex<double>, 3> cvec; 

To save var and vec is apparently straightforward:

tree->Branch("real_var", &var, "D");
tree->Branch("real_vec", &vec, "element[3]/D");

But how can I efficiently save a branch containing elements of the type std::complex<double> or MyVector<std::complex<double>, 3>? Speed of writing the file is important (reading speed matters too, but much less) so I don’t want to split the structs into TLeaves for each component.

Apologies for the very elementary question, but any help would be greatly appreciated.


ROOT Version: 6.22
Platform: Linux
Compiler: g++