Hi,
I am facing a problem with multiple trees and threads. I need two separate files to be created.
I have three threads, one which writes to one TreeA and second to another TreeB while the third thread plots the data from either TreeA and TreeB. My program runs for a while and crashes after sometime. This does not happen if I do not plot the data from the Tree.
Here is a short glimpse of my code
In the main function I create my two trees:
F1 = new TFile(“Rawdata.root”,“RECREATE”); // the first file for the event data
T1 = new TTree(“EVE”,“INEVENTS”);
F2 = new TFile(“THREEDTEMP.root”,“RECREATE”); // the second file for the mon data
T2 = new TTree(“THREED”,“INTHREED”);
I am afraid that we need more information from your side; Are you using TThread of your threads system? Are you thread-locking critical operations like drawing?
When calling Ttree::Draw, for example, X11 is called and X11 is not thread safe.
You can see examples of TThread in $ROOTSYS/tutorials/thread.
I am using Qts QThread Class for my threads. The Tree draw operation and the Tree fill operations are “mutexed” and this was working when I have only one file. The problem come when the second File/Tree comes into picture. I will look into the examples and see what I can get out of it.
Thanks.
What about ROOT ? Roughly saying, ROOT is a single (hierarchical) container of the various ROOT objects.
Very often the objects are added to the container and removed from it behind the scene. (see for example root.cern.ch/phpBB2/viewtopic.ph … tdirectory. Search RootForum for “SetDirectory(0)” )
See the topic 8558 mentioned above again.
As “container of the objects” ROOT is a critical resource. Its access should be protected with “mutex”.
This means, there is no common “one–size-fit-all” advice. One needs to see your application to spot the critical sections.
Thanks a lot,
I read the links you had given and now it works wonderful. As the Qt-Root users are increasing, It would be of great help to many if the next documentation comes up with an updated section for Qt-Root that includes the features available to the users and examples.
[quote=“dsmcc”] I read the links you had given and now it works wonderful.[/quote] [quote=“dsmcc”]As the Qt-Root users are increasing, It would be of great help to many if the next documentation comes up with an updated section for Qt-Root that includes the features available to the users and examples.[/quote] I agree the documentation is needed . The GUI related documentation and Qt-layer were handled by Ilka for several years . Alas, she lost her CERN appointment.
However, I think your original question is not GUI (and Qt) related.
I think you were correct asking [quote=“dsmcc”]Could you please post a short code which implements managing Trees in a multiple thread scenario. [/quote] I think one may have faced the same trouble if he did not use QtRoot. It is the multithreaded issue indeed.