Dear ROOT experts,
I have a function that loops over TTree and draws variables, doing some stuff so it’s getting slow if the tree has large number of events. So I would like to speed it up by creating threads.
So let’s say in case of 2 variables I have something like this:
[color=#4000BF] std::thread t[2];
t[0] = std::thread(draw,string(argv[1]), string(argv[2]), variables[0]);
t[1] = std::thread(draw,string(argv[1]), string(argv[2]), variables[1]);
t[0].join();
t[1].join();[/color]
If compile it like this :
g++ -o draw draw.cpp --std=c++11 root-config --cflags --libs
-O2 -I./ -lASImage
I get segmentation violation:
*** Break *** segmentation violation
Fatal in TClass::Init: gInterpreter not initialized
aborting
When adding -pthread compilation actually fails… I have looked through ROOT forums and seems like that one has to add
[color=#4000BF]ROOT::EnableThreadSafety();[/color]
but I don’t know where this function is defined:
error: ‘EnableThreadSafety’ is not a member of ‘ROOT’
I would appreciate any help and advice since I don’t have any experience with threads.
Regards,
Ivan.