For the SOACollection part, you can simply call .pack() / .unpack(). For the rest, you either need to write the packer manually or convert your structure to SOACollection to be able to leverage the automatic packer.
Hi Arthur, I cannot refuse that offer :-) The PV tracks are not very small. However, they are currently already ordered by vertex. (Every vertex has an indices point to the first and last+1 track in the track list.) There are a few things to worry about:
The format of the PVTracks is currently tight to the PV fnding algorithm. So, we need to be careful to change the data layout.
There is a reason that the existing Vertex object derives from LHCb::VertexBase: there is a lot of old code with particles pointing to vertices which still works exactly because of the inheritance. So, we need to be careful that that remains working (or adapt all the downstream code, which is probably a lot of work).
Every VertexBase object also has a 'key' which comes from KeyedObject. We need the key as well (because it is used elsewhere), but this can just the index in the container (e.g. 'offset()').
Note that we store both the cov matrix and its inverse. It's convenient to have both, but we need to persist only the inverse. The 'load(Buffer)' function will then need to fill the cov matrix. (In PVTrack there are some fields that are only cached for speed, I think: These objects can also be created from the original Velo container.)
If I were to implement the persistence, I would actually not change to SoA, but rather add the save(Buffer) and load(Buffer, version) functions to PrimaryVertexContainer.
@ahennequ if you do this can you please take care of making the Allen converters put out the same format, anticipating eventual discussions about which algorithms to use in HLT2 next year?