Vectors in 5.28.00

Hi there,

I have recently updated my Root version to 5.28, and my compiled code, which ran fine in 5.26, now throws some mysterious errors. The problem seems to be that Root no longer recognises stl vectors as valid TBranches. So something like this:

// HEADER
vector* b_jetHad_pt;

// IMPLEMENTATION
b_jetHad_pt = new vector;
oxsusy->Branch(“jetHad_pt”,&b_jetHad_pt); // oxsusy is the name of my TTree

Used to be valid, but now I get errors at runtime:

Error in TTree::Branch: The pointer specified for jetHad_pt is not of a class known to ROOT

I am doing #include at the top of my header file. As I say, this worked fine in the old release (I can’t keep using 5.26 for unrelated reasons). As a check I just went back and ran my code under 5.26 (without changing anything) and it worked beautifully. Any ideas?

Thanks,

Alex

Hi again,

Has anyone had a chance to look into this? Is it a problem with my local build (in which case I’m hoping someone can suggest what the problem might be)? A feature? Otherwise, it would appear to be a pretty major bug.

Thanks,

Alex

Hi,

can you re-rty with the tip of the branch v5-28-00-patches? If that fails, too (or if you are unable to test with that version of ROOT): can you send a little standalone test case that reproduces the error?

Cheers, Axel.

Hi Axel,

Thanks very much for getting back!

I am unable to get a more recent patch of Root, either on lxplus or locally, so I made a little program that reproduces the problem. Use the following makefile to make the attached source file:

“”"

ROOTLIBS = (shell (ROOTSYS)/bin/root-config --libs)
INCLUDES = -I $(ROOTSYS)/include

CC = g++
CCFLAGS = -fpic -g -Wall -O3

default:
(CC) (CCFLAGS) Root528Test.C (INCLUDES) (ROOTLIBS) -o Root528Test

“”"

Interestingly, it seems only vectors of floats are affected. The first time I tried this test program, I had a vector of integers instead, and it worked fine.

Thanks again,

Alex
Root528Test.C (497 Bytes)

Quick update to the above.

Annoyingly, this example also breaks under Root 5.26.00, whereas my original code (which is obviously much more complex) works fine under 5.26 and fails under 5.28. So the example kind of undermines the problem I was trying to highlight!

Anyway, my colleague has just suggested using vectors of doubles instead of floats. Tried that - works fine! Go figure.

Alex

Hi Alex and others,

I installed root version 5.28 on my new laptop and I also get problems with vectors of vectors, which I don’t have when running on lxplus (version 5.26).

Try the following macro:

[quote]{

gSystem->Load(“libCintex.so”);
Cintex::Cintex::Enable();

#include “Rtypes.h”
#include

vector<vector> i;

}
[/quote]
The last command gives me an error message with version 5.28:

[quote]Warning in : Failed to generate the dependency file for /home/phil/MyCode/SYNTcode/testana/macros/AutoDict_vector_vector_int_allocator_int______cxx.so
In file included from /home/phil/MyCode/SYNTcode/testana/macros/AutoDict_vector_vector_int_allocator_int______cxx_ACLiC_dict.h:34,
from /home/phil/MyCode/SYNTcode/testana/macros/AutoDict_vector_vector_int_allocator_int______cxx_ACLiC_dict.cxx:17:
/home/phil/MyCode/SYNTcode/testana/macros/AutoDict_vector_vector_int_allocator_int_____.cxx:2: fatal error: prec_stl/vector: No such file or directory
compilation terminated.
g++: /home/phil/MyCode/SYNTcode/testana/macros/AutoDict_vector_vector_int_allocator_int______cxx_ACLiC_dict.o: No such file or directory
Error in : Compilation failed!
Warning in : Failed to generate the dependency file for /home/phil/MyCode/SYNTcode/testana/macros/AutoDict_random_access_iterator_vector_int_allocator_int____long__cxx.so
In file included from /home/phil/MyCode/SYNTcode/testana/macros/AutoDict_random_access_iterator_vector_int_allocator_int____long__cxx_ACLiC_dict.h:34,
from /home/phil/MyCode/SYNTcode/testana/macros/AutoDict_random_access_iterator_vector_int_allocator_int____long__cxx_ACLiC_dict.cxx:17:
/home/phil/MyCode/SYNTcode/testana/macros/AutoDict_random_access_iterator_vector_int_allocator_int____long_.cxx:2: fatal error: prec_stl/vector: No such file or directory
compilation terminated.
g++: /home/phil/MyCode/SYNTcode/testana/macros/AutoDict_random_access_iterator_vector_int_allocator_int____long__cxx_ACLiC_dict.o: No such file or directory
Error in : Compilation failed!
[/quote]

although my code actually runs fine despite of it:

[quote]root [1] i
(class vector<vector >)151828176
[/quote]

Try also the following macro:

[quote]{

gSystem->Load(“libCintex.so”);
Cintex::Cintex::Enable();

#include “Rtypes.h”
#include

vector<vector> f;
vector ff;
ff.push_back(1);
f.push_back(ff);

vector<vector> d;
vector dd;
dd.push_back(2);
d.push_back(dd);

}[/quote]

There the operation with floats works very fine, while the last command (with double) does not work:

[quote]Error: Can’t call vector<vector<double,allocator >,allocator<vector<double,allocator > > >::push_back(dd) in current scope (tmpfile):1:
Possible candidates are…
(in vector<vector<double,allocator >,allocator<vector<double,allocator > > >)
*** Interpreter error recovered ***
[/quote]

Now my immediate problem is that I need to use vectors of vectors of double in my analysis code and there is no way I can run it on my laptop. Any idea?

Cheers
Phil

Hi,

Does anyone know if there is a solution other than playing tricks with variable types or reinstalling root in an older version?

Cheers
Phil

I believe you’ve found a real bug in cint. And I believe Alex will take care of it … just needs time.
I also get problems (reported by you) when I do:

root [0] #include
root [1] vector< vector > i

and/or when I do:

root [0] #include
root [1] vector<vector> d;
root [2] vector dd;
root [3] dd.push_back(2);
root [4] d.push_back(dd);

A similar issue involving “vector< pair<> >” has been reported here: [url]Vector< pair<> >

(ROOT 5.28/00a - v5-28-00-patches, checked out revision 38187 on 2011.02.21 at about 18:03 UTC, Ubuntu 10.04.2 LTS i686, gcc 4.4.3)

Hi,

Sorry - I just saw this now! I will look into it tomorrow.

Axel.

Hi,

vector<vector > and vector<vector > are now fixed in the trunk and v5-28-00-patches (will become part of v5.28b); thanks for your reports! FYI, these two bugs were caused by completely different problems, which explains why they were behaving so differently.

Cheers, Axel.

[Note: It will show up in 5.28b, in my original version I unfortunately misspelled that as 5.28a.]

Hi!

I get the problem with vector<vector> again in 5.30.00:

Error: Invalid type ‘vector<vector’ in declaration of ‘>’

having a tree with that type while compiling (.L) the class generated with MakeSelector.

Could you please check?

Thanks,

Sebastian

Hi,

The problem described in the earlier part of this thread are still working in v5.30. You are likely to have a different problem. I recommend that you open a new thread and given more information about the issue you are encountering.

Cheers,
Philippe.

Hi,

Thanks. I opened a new thread: [url]MakeSelector TTree gives: Invalid type vector<vector<int>

Best regards,

Sebastian

[quote=“SebastianSchmitt”]Hi,

Thanks. I opened a new thread: [url]MakeSelector TTree gives: Invalid type vector<vector<int>

Best regards,

Sebastian[/quote]

Thanks Seb, the code to resolve this is:

Code: Select all
gInterpreter->GenerateDictionary(“vector<pair<double, double> >”,“vector”);

First, thanks for the solution to this problem. When I implement this, ROOT creates three files (.cxx, .d, .so) in the directory where I started ROOT. Is there an elegant way to avoid this clutter? I suppose one way to do it would be in rootlogoff.C but I’m looking for a better way 8)

The files in my particular case are:

AutoDict_vector_pair_double__double___.cxx
AutoDict_vector_pair_double__double___.so
AutoDict_vector_pair_double__double___.d

Thanks in advance!

(Will cling in ROOT 6 fix this issue altogether?)

Hi,

yes, ROOT 6 fixes the issue (with no temporary files).

All the files produced in this scheme will start with AutoDict_ (So AutoDict_*.[cxx|so|d])

Cheers,
Philippe.