Cint Dictionaries for vector<vector<unsigned long long>>

Hi,

I’m compiling a macro which is supposed to read a Tree containing 64bit int vectors:

vector<vector > *trk_Pixel_hit_id;

I added in the LinkDef.h file all these pragma (that work for int and float):

#pragma link C++ class vector<vector >+;
#pragma link C++ class vector<vector<ULong64_t> >+;
#pragma link C++ class vector<vector >+;
#pragma link C++ class vector<vector >+;
#pragma link C++ class vector<vector<Long64_t> >+;

And I see the dictionaries in the Dict.h file:
/* STUB derived class for protected member access */
typedef vector<vector<int,allocator >,allocator<vector<int,allocator > > > G__vectorlEvectorlEintcOallocatorlEintgRsPgRcOallocatorlEvectorlEintcOallocatorlEintgRsPgRsPgRsPgR;
typedef vector<vector<unsigned long long,allocator >,allocator<vector<unsigned long long,allocator > > > G__vectorlEvectorlEunsignedsPlongsPlongcOallocatorlEunsignedsPlongsPlonggRsPgRcOallocatorlEvectorlEunsignedsPlongsPlongcOallocatorlEunsignedsPlongsPlonggRsPgRsPgRsPgR;
typedef vector<vector<float,allocator >,allocator<vector<float,allocator > > > G__vectorlEvectorlEfloatcOallocatorlEfloatgRsPgRcOallocatorlEvectorlEfloatcOallocatorlEfloatgRsPgRsPgRsPgR;
typedef vector<vector<long long,allocator >,allocator<vector<long long,allocator > > > G__vectorlEvectorlElongsPlongcOallocatorlElongsPlonggRsPgRcOallocatorlEvectorlElongsPlongcOallocatorlElongsPlonggRsPgRsPgRsPgR;

But any time I try to get the Tree entry, I receive this message:
Error in TBufferFile::CheckByteCount: object of class vector<vector<ULong64_t> > read too few bytes: 6 instead of 670

…and reads always 6 bytes. Can you help me?

My compilation setup is:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

uname -a
Darwin pb-d-128-141-141-192.cern.ch 12.4.0 Darwin Kernel Version 12.4.0: Wed May 1 17:57:12 PDT 2013; root:xnu-2050.24.15~1/RELEASE_X86_64 x86_64

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

g++ -v
Using built-in specs.
Target: i686-apple-darwin11
Configured with: /private/var/tmp/llvmgcc42/llvmgcc42-2336.11~182/src/configure --disable-checking --enable-werror --prefix=/Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2 --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-prefix=llvm- --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin11 --enable-llvm=/private/var/tmp/llvmgcc42/llvmgcc42-2336.11~182/dst-llvmCore/Developer/usr/local --program-prefix=i686-apple-darwin11- --host=x86_64-apple-darwin11 --target=i686-apple-darwin11 --with-gxx-include-dir=/usr/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ROOT 5.34/01 (tags/v5-34-01@45048, Jul 13 2012, 15:31:31 on macosx)
CINT/ROOT C/C++ Interpreter version 5.18.00, July 2, 2010

Thanks you, cheers
francesca

Apparently CINT has some problems with “(unsigned) long long” related types.

A brutal fix …

#pragma link C++ class vector+;
#pragma link C++ class vector<vector >+;
#pragma link C++ class vector<ULong64_t>+;
#pragma link C++ class vector<vector<ULong64_t> >+;
#pragma link C++ class vector+;
#pragma link C++ class vector<vector >+;
#pragma link C++ class vector<Long64_t>+;
#pragma link C++ class vector<vector<Long64_t> >+;

… ignore messages in form “Note: Link requested for already precompiled class …”.

Thanks Wile,
I added the pragma commands you suggested me,… but it’s not working! I have still the same errors:

Error in TBufferFile::CheckByteCount: object of class vector<vector<ULong64_t> > read too few bytes: 6 instead of 670
Error in TBufferFile::CheckByteCount: object of class vector<vector<ULong64_t> > read too few bytes: 6 instead of 670
Error in TBufferFile::CheckByteCount: object of class vector<vector<ULong64_t> > read too few bytes: 6 instead of 1382
Error in TBufferFile::CheckByteCount: object of class vector<vector<ULong64_t> > read too few bytes: 6 instead of 1382
Error in TBufferFile::CheckByteCount: object of class vector<vector<ULong64_t> > read too few bytes: 6 instead of 254
Error in TBufferFile::CheckByteCount: object of class vector<vector<ULong64_t> > read too few bytes: 6 instead of 254
Error in TBufferFile::CheckByteCount: object of class vector<vector<ULong64_t> > read too few bytes: 6 instead of 446
Error in TBufferFile::CheckByteCount: object of class vector<vector<ULong64_t> > read too few bytes: 6 instead of 446
Error in TBufferFile::CheckByteCount: object of class vector<vector<ULong64_t> > read too few bytes: 6 instead of 110
Error in TBufferFile::CheckByteCount: object of class vector<vector<ULong64_t> > read too few bytes: 6 instead of 110
Error in TBufferFile::CheckByteCount: object of class vector<vector<ULong64_t> > read too few bytes: 6 instead of 118
Error in TBufferFile::CheckByteCount: object of class vector<vector<ULong64_t> > read too few bytes: 6 instead of 118
Error in TBufferFile::CheckByteCount: object of class vector<vector<ULong64_t> > read too few bytes: 6 instead of 42
Error in TBufferFile::CheckByteCount: object of class vector<vector<ULong64_t> > read too few bytes: 6 instead of 42

I’m adding in the attachments the Dictionary files.
Cheers, francesca
L1TTpatternBase_Dict.h (5.75 KB)
L1TTpatternBase_Dict.C (137 KB)

Before you open any ROOT file, try to execute (it helped on several occasions):
gROOT->ProcessLine("#include ");

It is also possible that CINT has some real problems with “ULong64_t” and “Long64_t” typedefs.
Can you try to re-create all your files so that they explicitly use “unsigned long long” and “long long” instead?

Hi,
no different results. I’m sorry.
I’m sending you the (skimmed) root file, so you can have a look directly: the Tree is InDetTrackTree.
Cheers, francesca
small.root (420 KB)

There something screwy in your “skimmed” ROOT file (I guess Philippe should have a look at it).
Could you try to run the attached macro on your “original” ROOT file …
… either as “interpreted” …
root [0] .x read_tree.cxx(“original_file_name.root”)
… or as “compiled” …
root [0] .x read_tree.cxx++(“original_file_name.root”)
read_tree.cxx (2.52 KB)

Hi,
well, if I include in my ReadClass:

if (!(gInterpreter->IsLoaded(“vector”)))
gInterpreter->ProcessLine("#include ");
gSystem->Exec(“rm -f AutoDictvectorlonglong”);
gSystem->Exec(“rm -f AutoDictvectorLong64*”);
// gInterpreter->GenerateDictionary(“vector”, “vector”);
// gInterpreter->GenerateDictionary(“vector<vector >”, “vector”);
// gInterpreter->GenerateDictionary(“vector<Long64_t>”, “vector”);
gInterpreter->GenerateDictionary(“vector<vector<Long64_t> >”, “vector”);
// gInterpreter->GenerateDictionary(“vector”, “vector”);
// gInterpreter->GenerateDictionary(“vector<vector >”, “vector”);
// gInterpreter->GenerateDictionary(“vector<ULong64_t>”, “vector”);
gInterpreter->GenerateDictionary(“vector<vector<ULong64_t> >”, “vector”);

before opening the tree, then it works! This does not require the LinkDef.h file but it auto-generates the dictionaries. I see the new dictionaries contain more pragma commands than those I’ve written in my LinkDef.h.
Thanks a lot, it’s close from my side.
Cheers, francesca

But you do see that many of these lines are commented out, don’t you.

BTW. In your original post I can see:
vector<vector > *trk_Pixel_hit_id;
while it should be either:
vector<vector > *trk_Pixel_hit_id = 0;
or:
vector<vector > *trk_Pixel_hit_id = new vector<vector >;

No, I’m saying that now in my directory there are few new dictionary files, generated at runtime:

AutoDict_vector_vector_Long64_t___.cxx
AutoDict_vector_vector_Long64_t____cxx.d
AutoDict_vector_vector_Long64_t____cxx.so*
AutoDict_vector_vector_ULong64_t___.cxx
AutoDict_vector_vector_ULong64_t____cxx.d
AutoDict_vector_vector_ULong64_t____cxx.so*

which for example contain lines like:

#pragma link C++ class vector<vector<ULong64_t> >+;
#pragma link C++ class vector<vector<ULong64_t> >::*;
#ifdef G__VECTOR_HAS_CLASS_ITERATOR
#pragma link C++ operators vector<vector<ULong64_t> >::iterator;
#pragma link C++ operators vector<vector<ULong64_t> >::const_iterator;
#pragma link C++ operators vector<vector<ULong64_t> >::reverse_iterator;
#endif

more pragma commands than those I originally wrote in my LinkDef.h file. I tried to add those lines in the LinkDef.h file, but it doesn’t work. So I’m guessing that more commands must be added (in the LinkDef.h?) if one does not want to have new files auto-generated at run-time. I hope this is not a problem when running on the grid.

BTW, I’m doing the reset of the pointer. I’m using the MakeClass() method to generate the code.
Cheers, francesca

The “LinkDef.h” files are used by the “rootcint”. Afterwards you need to compile and link the generated dictionary source code into a shared library. Finally, you need to manually load that library into your ROOT session (or you can link your standalone executable with that library, if you are building one).
There is NO auto-loading in this case.

Yes, you are right. I usually prefer to have shared libraries into which linking my Dictionaries, so they are generated only once. In this case instead I regenerate the dictionaries at any run (with consequent overhead loss of time if I have multiple jobs). But anyway, I’ll keep this solution.
Thanks again, francesca

If you have a shared library with all dictionaries … try:

if (!(gInterpreter->IsLoaded(“vector”))) gInterpreter->ProcessLine("#include ");
gSystem->Load(“SharedLibraryWithDictionaries.so”);

Hi,
I compile the classes in a library and add the dictionaries in that library via Makefile:

$(LIBDIR)L1TTpatternBase_Dict.o: L1TTpatternBase_Dict.C
$(CC) $(CFLAGS) -Iinc -o $@ $< root-config --cflags $(INCLUDES)

L1TTpatternBase_Dict.C: $(WORKDIR)L1TTpattern/L1TTpatternBase.h $(WORKDIR)L1TTpattern/LinkDef.h
$(DICTEXEC) -f $@ -c -p $(INCLUDES) $^

$(LIBDIR)%.o: $(SRCDIR)%.C
$(CC) $(CFLAGS) -Iinc -o $@ $< root-config --cflags $(INCLUDES)

It works for vector<vector>. The library is correctly linked:

otool -L i686-slc4-gcc34-opt/libStudy.a
Archive : i686-slc4-gcc34-opt/libStudy.a
i686-slc4-gcc34-opt/libStudy.a(L1TTpatternBase.o):
i686-slc4-gcc34-opt/libStudy.a(L1TTpatternBase_Dict.o):
i686-slc4-gcc34-opt/libStudy.a(L1TTpatternStudy.o):

You need a shared library “.so” in order to be able to “gSystem->Load” it, not a static library “.a”.