Pointer to a 2D vector of integers

I am trying to access information from a pointer to a 2D vector that is declared in the header as:
vector<vector > *v0_trk_index;

I access the integers on my local machine running root version 5.18/00b by using this code:

for(int i=0;i<v0_n;i++){
std::cout<<"Kshort mass is: "<<v0_ksMass->at(i)<<std::endl;
for(int j=0;j<v0_trk_n->at(i);j++){
std::cout<<((*v0_trk_index)[i]).at(j)<<std::endl;
}
}

However, when I run on the GRID or a remote machine such as lxplus (root version 5.22/00f and later versions), I receive this error when I run my code:

Error: Can’t call vector<vector >::operator in current scope woo.C:45:
Possible candidates are…
(in vector<vector >)
Error: non class,struct,union object $((*v0_trk_index)[i]) used with . or -> woo.C:45:
(class G__CINT_ENDL)1

Is this a problem with an installed library?

Either way, I am confused. Can someone help me?

Thanks!

Sam

Hi,

did you generate a dictionary for vector<vector >? See e.g. Vector of vector in a tree - filling clone tree on how to do that.

Cheers, Axel.

I just tried what you suggested. I created a file called loader.C containing:

#include <vector>
#ifdef __MAKECINT__
#pragma link C++ class vector<vector<int> >+;
#endif

When I used the command .L loader.C+, I received this message:
root [0] .L loader.C+
Info in TUnixSystem::ACLiC: creating shared library /cluster/tufts/physicshe/shamil01/Fatras15.6.9/./loader_C.so
Note: Link requested for undefined class vector<vector > (ignore this message) :0:
Error: A dictionary has been requested for vector<vector > but there is no declaration!

I then tried to run my code and received the same message regarding the 2D vector as before.

Am I doing something blatantly wrong?

Hi,

Do you have a file named ‘vector’ in the same directory?

Philippe.

No, I do not.

Hi,

Can you send me the result of touch linkdef.h # linkdef.h should be an empty file rootcint -f /var/tmp/dict.cxx -c loader.C linkdef.h

Cheers,
Philippe.

There is no output when I issue the commands. A file named dict.cxx and dict.h are created in the folder var/tmp/ though.

Is this what you expected to happen?

Hi,

No it is not what I expected in your case. rootcint seems to be running fine by itself so the problem must come from extra information provided by ACLiC ; let me try a couple of things to reproduce your problem.

Cheers,
Philippe.

Hi,

I still can not reproduce your problem :frowning:.

Can you send the file build.log and rootcint.log resulting from executing the following command on the root prompt:gDebug = 7; .L loader.C++ >& build.log .! eval `grep rootcint build.log | grep -v Info | sed -e "s/-c/-c -t -T/"` >& rootcint.log

Thanks,
Philippe.

Hi,

Looking at your log reminded me you are using v5.22 and indeed I am able to reproduce your symptom with v5.22 but not with v5.27/04. The way I reproduce your problem is by having a rootmap file for vector<vector > that point to a library that either actually does not contain a dictionary for vector<vector > or contain a reflex dictionary for it.

I am guessing that your case in the later (i.e. there is a reflex dictionary for vector<vector > in one of the library on your LD_LIBRARY_PATH and a corresponding rootmap file). If this is the case you ought to be able to work around the issue by doing:root [] gSystem->Load("libCintex"); Cintex::Enable();(and you probably do not need the loader.C).

Cheers,
Philippe.

It worked!!! (without the loader.C file) Thank you so much!

Cheers,

Sam