Adding std::array<double,2> to a TTree branch

I have been working on a simulation and reconstruction script for collider events.
This is the final project of my university class in Numerical Analysis and Simulation.
The simulation is run and written onto a TTree via TClonesArray and everything works as expected.
To benchmark the program, I have also tried to use stl classes as std::vector and std::array. The hits are saved by their cylindrical coordinates (angle and z, since radius is fixed), so I have a vector of arrays of two doubles (std::vector<std::array<double,2>>).

Since this type needs a dictionary to be saved in a TTree, I have added

#ifdef __MAKECINT__
#pragma link C++ class std::array<double,2> +;
#pragma link C++ class std::vector<std::array<double, 2> > +;

but when I try to compile the macro, I get

Info in <TUnixSystem::ACLiC>: creating shared library /home/albertoperro/unito/TANS/finalProj/bin_std/
Error: It is not necessary to explicitly select class array<double,2>. I/O is supported for it transparently.
Error in <ACLiC>: Dictionary generation failed!

I have seen that this question was posted in a somehow similar example here. I have tried to build ROOT from source since the pull request was merged, but it did not solve the issue.

You can find all of my code here.

ROOT Version: 6.19.0 built from master GitHub
Platform: Ubuntu Linux 18.04.2 LTS
Compiler: C++14


@pcanal can probably help here. To me it looks like you should just remove the pragma link statements for all “std::” containers.

Indeed the statement:

#pragma link C++ class std::array<double,2> +;

is not needed.
However, if I recall correctly, an STL collection containing (directly) and std::array is not yet supported. To work around it, use a wrapper/struct class whose sole member is an std::array. (you will need to generate the dictionary for the struct and the vector containing the struct.

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