Get Mean and RMS of all branches in a tree

There are many posts about people having trouble with vector<vector> branches in TTrees in the forum. A quick search reveals for example:

Unfortunately I don’t remember how to make this work myself.

Jean-François