ROOT Snapshot function seems to be blocked when using vector<vector<float>>

Good morning,

I’m trying to create a new TTree containing some selected branches from a more general TTree. I’m having some issues with the following branches: genpart_posx, genpart_posy and genpart_posz.
In the original file these branches are ROOT::VecOps::RVec<vector<float>> type. To read them in the next steps with uproot I’d like to transform them in a vector<vector<float> > type.

The program performs a for cycle over the three branches for each event remaining after a skimming. For some of them, which they can be called good events, the three branches are analysed correctly. Unfortunately for some events (which in principle have exactly the same structure as good events) the program is blocked.

I get the same result if I define a dummy vector inside or outside the for cycle, or if I change the definition order of the three branches.

Can anyone give me some suggestions about how to fix this behaviour?
Thanks a lot for your help,

config.yaml (1.5 KB) (7.3 KB)
skim.h (1010 Bytes)

ROOT Version: 6.26/10
Compiler: g++ 10.4.0

1 Like

Hello @mchiusi ,

and welcome to the ROOT forum!

Note that in the input file you shared columns such as cl3d_layer_pt are already a vector<vector<T>> (no RVecs). RDataFrame reads the outer collection as an RVec, but that’s not what’s stored in the file (you can check e.g. with HGCalTriggerNtuple->Print().

Does that information help at all? Otherwise do you think you could reduce the reproducer to a single main function that reproduces the problem? There seems to be a lot going on between and :smiley:


Hello Enrico!,

thanks a lot for your answer.

I attach the main file ( (2.6 KB)) that can be now used together with root_file_input to reproduce the error.


Thank you @mchiusi !

Running I see

Error in <TTree::Branch>: The class requested (vector<vector<float> >) for the branch "good_genpart_posx" is an instance of an stl collection and does not have a compiled CollectionProxy. Please generate the dictionary for this collection (vector<vector<float> >) to avoid to write corrupted data.

which makes sense: we need dictionaries to read vector<vector<float>>.

Adding gInterpreter->GenerateDictionary("vector<vector<float>>", "vector"); at the beginning of the program fixes that error and then I get a crash during the event loop. Investigating…

Hi @mchiusi ,

that was quite tricky, but I think Fix RVec masking by eguiraud · Pull Request #12400 · root-project/root · GitHub fixes the issue (or at least part of the issue). It’s a real, nasty bug in RVec.

It would be great if you could try out a ROOT build that includes the patch and let me know whether you see any further issue.


Hello @eguiraud,

Thank a lot for your help.
Could you give me some more details / instructions to get the patch which includes your modifications?
Should I follow something like this?


Hi @mchiusi ,

yes, exactly. You would have to build ROOT’s master branch from source (as the patch has been merged in master today). You can also use the pre-compiled nightly builds or the LCG nightly builds (as of tomorrow), as per the instructions here (the conda nightlies are lagging behind at the moment).

The patch will be included in ROOT v6.28.02 (which should be out soon-ish) and v6.30 (further in the future).