Array of vectors in existing root file

Hi,

I have an existing ntuple which I want to read in. With the MakeClass() method I created some standard code for this.

The problem is that some of the branches seem to contain arrays of std::vectors which I am not able to access with the code from MakeClass. Other variables and plain arrays (which are also in the ntuple) work.

Here some lines from the MakeClass code to illustrate my problem:

class CollectionTree {
public :

const Int_t kMaxm_genVertices = 10000;

std::vector m_genVertices_m_particlesIn[kMaxm_genVertices];

TBranch *b_m_genVertices_m_particlesIn; //!

void CollectionTree::Init(TTree *tree)
{

fChain->SetBranchAddress(“m_genVertices.m_particlesIn”, m_genVertices_m_particlesIn, &b_m_genVertices_m_particlesIn);

}

}

In the analysis loop the following command always returns 0

m_genVertices_m_particlesIn[i].size()

despite that I see when inspecting with TBrowser that the array of vectors must have some contents. Is there anyone who can help me? I can provide more code and the ntuple if necessary.

Hi,

The skeleton generated by MakeClass can not handle objects. In order to allow for the decomposition of the object in ints, floats, etc, the skeleton calls (SetMakeClass(1)).

I recommend that you try using MakeProxy instead (which allow both the access to object and efficient access to the individual (spit) members.

Cheers,
Philippe.

Sorry to resurrect an old thread, but I am running into the exact same issue - except that I used MakeSelector() rather than MakeClass().

Is there really no way to alter the skeleton to allow access to the array of vectors? It seems odd that MakeSelector() knows enough to recognize the array-of-vector structure, but then has no way of working with it.

Hi,

You can alter it by removing the SetMakeClass(1) but then you have to use object for all the branches.

With v5.28, you could also try to call SetMakeClass(0) on the branch holding your std::vectors.

Cheers,
Philippe.