Problem with std::vectors within a root macro

Hello everybody.
The attached root macro works fine.
I read in rms and mean from histos in a root file after selecting the histos according to their name. The textfile generated in the macro contains all the info I need. You can look at it (attached).

The problem arises when I try to push_back the values that I got from the histo into std::vectors, i.e. when line 58 in the script is uncommented. The values that I need to store in a std::vect are those in column 3 in the txt output file.

I looked more carefully into std::vects properties but still…It crashes somwhere around entry 287 (total entries 441). I don’t undst why it stops pushing back stuff into the vector even if it gets all the numbers correctly…

I cannot attach the root file, cause it’s huge.

If someone can help with this, it’d be great.
thanks a lot
Martino
likeProfiles_NAMES_STRING.txt (13.7 KB)
loop_over_Keys_STRING_rootForum.cxx (1.76 KB)

the push_back problem described above seems to disappear if using version 5.18 of root. It crashes under 5.10. Why is it like this?

Hi,

it’s probably because we fixed it between 5.10 and 5.18 :wink: In general CINT is not very good at interpreting STL; you should run your script in compiled mode: “.x loop_over_Keys_STRING_rootForum.cxx+” (note the trailing +). Does it work then?

Cheers, Axel.

hi!
thanks a lot for your answer.
Could you tell me how to launch the macro? I mean, the sintax… I have never done it before and I have two integers as input…

Hi,

Either.x loop_over_Keys_STRING_rootForum.cxx+(2,3)or.L loop_over_Keys_STRING_rootForum.cxx+ loop_over_Keys_STRING_rootForum.cxx(2,3);

Cheers,
Philippe

hello everybody.
thanks a lot. It’s ok now.