Vector<vector<float>> error in lxplus

Hi,

I have logged into lxplus from putty and trying to run a root macro which i generated using MakeClass. I am trying to access a vector<vector <>>. I am getting this error

Error: Can't call vector<vector<float> >::operator[](el1) in current scope elec_geo20.C:271: Possible candidates are... (in vector<vector<float,allocator<float> >,allocator<vector<float,allocator<float> > > >) /afs/cern.ch/user/h/hari/testarea/17.2.6.2/Tutorial/MyDPDMaker/run/AutoDict_vector_vector_float____cxx.so -1:-1 0 public: vector<vector<float,allocator<float> >,all$ /afs/cern.ch/user/h/hari/testarea/17.2.6.2/Tutorial/MyDPDMaker/run/AutoDict_vector_vector_float____cxx.so -1:-1 0 public: vector<vector<float,allocator<float> >,all$ Error: Incorrect use of operator[] elec_geo20.C:271: *** Interpreter error recovered ***

I browsed through the forum and try adding this within the macro, but still getting the same error

if (!(gInterpreter->IsLoaded("vector"))) gInterpreter->ProcessLine("#include <vector>"); gSystem->Exec("rm -f AutoDict*vector*vector*float*"); gInterpreter->GenerateDictionary("vector<vector<float> >", "vector");

I am looking for some suggestions. Thanks

Try to make sure that you have a “clean” situation:
[bash/csh]: rm -f ./AutoDict_* /afs/cern.ch/user/h/hari/testarea/17.2.6.2/Tutorial/MyDPDMaker/run/AutoDict_*
and then try your ROOT macro again.

If this doesn’t help, we need to see your “elec_geo20.C” file.

Hi

Still i am getting the error.

Error: Can't call vector<vector<float> >::operator[](el1) in current scope elec_geo20.C:215: Possible candidates are... (in vector<vector<float,allocator<float> >,allocator<vector<float,allocator<float> > > >) /afs/cern.ch/user/h/hari/testarea/17.2.6.2/Tutorial/MyDPDMaker/run/AutoDict_vector_vector_float____cxx.so -1:-1 0 public: vector<vector<float,alloc$ /afs/cern.ch/user/h/hari/testarea/17.2.6.2/Tutorial/MyDPDMaker/run/AutoDict_vector_vector_float____cxx.so -1:-1 0 public: vector<vector<float,alloc$ Error: Incorrect use of operator[] elec_geo20.C:215: *** Interpreter error recovered ***

I have attached my elec_geo20.C file.
elec_geo20.C (9.4 KB)

Create a small “loader.cxx” macro with these 4 “magic” lines (that generate the “AutoDict_*”).
Remove these 4 lines from your “void elec_geo20::Loop(string num)” method.
Then, in a ROOT session, first execute “.x loader.cxx” and then load/execute your “elec_geo20”.

Hi Wile,

I tried it. Now i am getting

Error: Can't call vector<vector<int> >::operator[](el1) in current scope elec_geo20.C:213: Possible candidates are... (in vector<vector<int> >) Error: Incorrect use of operator[] elec_geo20.C:213: *** Interpreter error recovered ***

I think one needs to see your “elec_geo20.h” file (in particular one needs to check some pointers with names “el_refittedTrack_*” -> can it be that some of them are related to “vector<vector >”?).

Try a “loader.cxx” in form: { if (!(gInterpreter->IsLoaded("vector"))) gInterpreter->ProcessLine("#include <vector>"); gSystem->Exec("rm -f AutoDict*vector*vector*int*"); gInterpreter->GenerateDictionary("vector<vector<int> >", "vector"); gSystem->Exec("rm -f AutoDict*vector*vector*float*"); gInterpreter->GenerateDictionary("vector<vector<float> >", "vector"); }

Indeed, that was the problem. It works now… :slight_smile:

Thanks a lot.