How to save RVectors of LorentzVectors in ROOT files?

Please read tips for efficient and successful posting and posting code

ROOT Version: 6.24.06
Platform: /
Compiler: gcc/9.3.0

I need to save RVectors of LorentzVectors to a new root file. Currently we are running a RDataFrame script in pyroot which uses pre-compiled C++ functions (see cernbox link at the bottom of post). When running the python function, it gives the following error log:

Error in TTree::Branch: The class requested (vector<ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D > >) for the branch “jets_LV” is an instance of an stl collection and does not have a compiled CollectionProxy. Please generate the dictionary for this collection (vector<ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D > >) to avoid to write corrupted data.

We also tried to pass a vector of vector (std::vector<std::vector>) from C++ to Python, but it gives a similar error. What can I do in this case? Any help would be appreciated.



@pcanal should know but he’s absent atm, @moneta do you know have experience saving vectors of lorentzvectors ?


You can save easy a std::vector because we have the dictionary in ROOT. For the other types you need to generate the dictionary in order to save in a file.
See I/O of custom classes - ROOT


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