Hi All,
I’d like to use TTree::Draw on the same TTree inside of multiple TThreads. The idea is to make a TEventList in each thread by making a different selection…run numbers in this case. And then process those events inside the thread. The problem is that TTree::Draw results in a seg fault when it is called concurrently from multiple threads even though the “>>objectToWriteTo” argument is different in each thread.
I have attached the source code I’m using as well as the ROOT file with the tree that I’m accessing. To run the code and reproduce the results do the following in a ROOT session
.L drawFromThreads.C+
drawFromThreads()
After reproducing the error try moving the line
inTree->Draw(Form(">>elist_%d",threadIndex),Form("RunNum==%d",rNum));
which exists in void *threadFunction() to inside the TThread lock/Unlock block above to see that the code works when TTree::Draw is called sequentially from each thread.
Of course, moving the TTree::Draw call to inside the lock/unlock block is not a permanent solution because it is the operation which takes the longest and is the primary reason for doing multiple threads.
I’m using the following system configuration:
ROOT v5.34.04
Ubuntu 12.10
gcc version 4.7.2
Many thanks in advance for your time and suggestions. Or, If you know of an easier way of accomplishing what I want to do I’m all ears…
-Chris
RunAndEventTree.root (535 KB)
drawFromThreads.C (2.53 KB)