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,
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
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…
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).