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

**URL:** <https://root-forum.cern.ch/t/root-snapshot-function-seems-to-be-blocked-when-using-vector-vector-float/53696>\
**Category:** Newbie\
**Tags:** tree, rdataframe, root\
**Created:** [February 20, 2023, 2:07pm UTC](https://root-forum.cern.ch/t/root-snapshot-function-seems-to-be-blocked-when-using-vector-vector-float/53696 "2023-02-20T14:07:14Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![mchiusi](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/8dc957/32.png) [@mchiusi](https://root-forum.cern.ch/u/mchiusi)\
**Post date:** [February 20, 2023, 2:07pm UTC](https://root-forum.cern.ch/t/root-snapshot-function-seems-to-be-blocked-when-using-vector-vector-float/53696/1 "2023-02-20T14:07:14Z")

</div>

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,  
Marco

[root\_file\_input](https://cernbox.cern.ch/s/bmwPVmAzMTDXrWR)  
[config.yaml](https://cernbox.cern.ch/s/KyVCsAdoxHURyIM)  
[produce.cc](https://root-forum.cern.ch/uploads/short-url/uRKImeCKzrn83p2ZuoNmRCnAkVq.cc) (1.5 KB)  
[skim.cc](https://root-forum.cern.ch/uploads/short-url/pjdlTUxAnDIlXMrNmq1EpLHqCaq.cc) (7.3 KB)  
[skim.h](https://root-forum.cern.ch/uploads/short-url/193xGVcCJOZ2Dvc6BWtJh0Wlv0n.h) (1010 Bytes)

_ROOT Version:_ 6.26/10  
_Compiler:_ g++ 10.4.0

* * *

---

<div class="post-metadata">

**Author:** ![eguiraud](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/eguiraud/32/32217_2.png) [@eguiraud](https://root-forum.cern.ch/u/eguiraud)\
**Post date:** [February 21, 2023, 2:47pm UTC](https://root-forum.cern.ch/t/root-snapshot-function-seems-to-be-blocked-when-using-vector-vector-float/53696/2 "2023-02-21T14:47:49Z")

</div>

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 `skim.cc` and `produce.cc` 😃

Cheers,  
Enrico

---

<div class="post-metadata">

**Author:** ![mchiusi](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/8dc957/32.png) [@mchiusi](https://root-forum.cern.ch/u/mchiusi)\
**Post date:** [February 22, 2023, 10:11am UTC](https://root-forum.cern.ch/t/root-snapshot-function-seems-to-be-blocked-when-using-vector-vector-float/53696/3 "2023-02-22T10:11:56Z")

</div>

Hello Enrico!,

thanks a lot for your answer.

I attach the main file ([main.cc](https://root-forum.cern.ch/uploads/short-url/ooXXB3Au49oisVBMeKpuMiqULUs.cc) (2.6 KB)) that can be now used together with root\_file\_input to reproduce the error.

Cheers,  
Marco

---

<div class="post-metadata">

**Author:** ![eguiraud](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/eguiraud/32/32217_2.png) [@eguiraud](https://root-forum.cern.ch/u/eguiraud)\
**Post date:** [February 23, 2023, 11:01am UTC](https://root-forum.cern.ch/t/root-snapshot-function-seems-to-be-blocked-when-using-vector-vector-float/53696/4 "2023-02-23T11:01:53Z")

</div>

Thank you @mchiusi !

Running `main.cc` I see

```auto
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…

---

<div class="post-metadata">

**Author:** ![eguiraud](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/eguiraud/32/32217_2.png) [@eguiraud](https://root-forum.cern.ch/u/eguiraud)\
**Post date:** [March 1, 2023, 4:01pm UTC](https://root-forum.cern.ch/t/root-snapshot-function-seems-to-be-blocked-when-using-vector-vector-float/53696/5 "2023-03-01T16:01:13Z")

</div>

Hi @mchiusi ,

that was quite tricky, but I think [Fix RVec masking by eguiraud · Pull Request #12400 · root-project/root · GitHub](https://github.com/root-project/root/pull/12400) 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.

Cheers,  
Enrico

---

<div class="post-metadata">

**Author:** ![mchiusi](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/8dc957/32.png) [@mchiusi](https://root-forum.cern.ch/u/mchiusi)\
**Post date:** [March 2, 2023, 1:39pm UTC](https://root-forum.cern.ch/t/root-snapshot-function-seems-to-be-blocked-when-using-vector-vector-float/53696/6 "2023-03-02T13:39:25Z")

</div>

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](https://root.cern/install/build_from_source/)?

Cheers,  
Marco

---

<div class="post-metadata">

**Author:** ![eguiraud](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/eguiraud/32/32217_2.png) [@eguiraud](https://root-forum.cern.ch/u/eguiraud)\
**Post date:** [March 2, 2023, 3:41pm UTC](https://root-forum.cern.ch/t/root-snapshot-function-seems-to-be-blocked-when-using-vector-vector-float/53696/7 "2023-03-02T15:41:55Z")

</div>

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](https://root.cern/install/nightlies/#pre-compiled-binaries) (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).

Cheers,  
Enrico
