Map<string,int> in Nutple -- access CINT works, gmake

Dear all!

I have produced the attached ntuple (containing 2 events, with several vector and map branches).

When developing my ntupling code, I tested it using a CINT macro, using
ROOT 5.24/00 (trunk@29257, Jun 30 2009, 09:23:51 on linux)
CINT/ROOT C/C++ Interpreter version 5.17.00

works fine.

Accessing the information worked fine, also:
.L Ntuple.C++
works fine

Printing out information in CINT works fine.

However if I use a standalone gmake-compiled code outside root, it does NOT work and gives a segfault.

I attach all relevant code.

WHAT Works:

root -l
root [0] .L Ntuple2.C
root [1] Ntuple2 t
root [2] t.Loop()

What does not work:
mv Makefile.txt Makefile
gmake MainAnalysis_v3
./MainAnalysis_v3 input.txt te
(programm works with input text file and then output string)

Any suggestions?
I know that sometimes there are segfault problems, if in the .h file, a vector branch is mixed inbetween normal integers. I have tried reordering, but have not succeeded so far.

I am very puzzled, especially since CINT works and gmake NOT… :frowning:

Makefile.txt (1.9 KB)
Ntuple_output.root (12.9 KB)
Ntuple2.h (5.06 KB)
Ntuple2.C (1.72 KB)
MainAnalysis_v3.C (1.15 KB)
input.txt (19 Bytes)

You must generate a compiled dictionary for your classes ibn Ntuple2.h.
The simplest solution is simply to do:

root > .L Ntuple2.C+ root > Ntuple2 t root > t.Loop()

Sorry, i think my description of the problem was not too accurate in the first few lines…

Compiling and running in CINT works! (i.e. your solution)

However, I would like to use g++ compiled code, using

this compiles but gives a segfault – the Ntuple is not read in correctly and I do not understand, how and why it works in CINT and not in standalone-compiled ROOT.

Thanks & CHeers

My solution uses gcc compiled code via ACLIC and it is far much simpler than creating Makefiles. If you insist with makefiles, create your dictionary for all classes defined in Ntuple2.h and compile/link it with your application.
The simple line “.L Ntuple2.C+” is doing all that automatically for you.
see the Users Guide.