Compiling script that reads vector of vector

Hello Everyone,

I’m attempting to access an ntuple that has some of its data organized in vectors of vectors. To be specific the .h file that is generated upon executing MakeClass has a lines like

vector<vector > *pixel_clus_row;
.
.
fChain->SetBranchAddress(“pixel_clus_row”,&pixel_clus_row);

where the last line seems to be the problem when I uncomment things one line at a time. Everything works fine for ints, doubles and vectors of ints and vectors of doubles.

If anyone has a way to fix this, please let me know.

Thanks,
Max

In the cxx file generated by MakeClass, add the following lines

#ifdef __CINT__ #pragma link C++ class std::vector<vector<int> >+; #endif

This way you will get the dictionary for this stl class.

Rene

Hello Rene,

The 1st lines of my .C file are now precisely:


#include
#include

#ifdef CINT
#pragma link C++ class std::vector<vector >+;
#endif

At run time I now get
root [2] x.Loop()
5 318 //these are just values from the first event that I am printing
*** glibc detected *** free(): invalid pointer: 0x0a9f6948 ***

Does this make any sense?

Thanks again,
Max

Most likely you need to remove the line
fChain->SetMakeClass(1);
from the header file generated by MakeClass.

Cheers,
Philippe

Hello Everyone,

Both these suggestions taken together still did not work; I get a similar message as the one I listed above during runtime after compliling.

I also get the following while just trying to interpret


Error in TTree::SetBranchAddress: The class requested (vector<vector<float,allocator > >) for the branch “trk_PixPullEtaPix_Up” refer to an stl collection and do not have a compiled CollectionProxy. Please generate the dictionary for this class (vector<vector<float,allocator > >)

I get that, as near as I can tell, for any branch that is a vector<vector >

-Max

You also need to compile your MakeClass result (aka load it via ACLiC by using .L MyClass.C+).

Cheers,
Philippe

Hi Philipe,

Not sure what you mean;

when I do

.L MyClass.C+
MyClass m
m.Loop()

the I get
*** glibc detected *** free(): invalid pointer: 0x0a9f6948 ***

or, when I leave out the ‘+’, i.e.,
.L MyClass.C
MyClass m
m.Loop()

then I get the error in my previous post

Hi,

Can you send me your code and root file?

Philippe

Thanks Philippe, I’ve emailed them to your fnal account that I found on the cern directory

Hi Max,

Your unchanged code runs fine for me (even with valgrind) with ROOT 5.17/04. I suggest that you upgrade to a newer version of root (or if
you already have, try to run with valgrind to give us more information).

Cheers,
Philippe