|Message: Re: Saving data on .root File using ParGeant4 (Geant4 4.9.6p01 + TOP-C)||Not Logged In (login)|
Click on the Forum title, e.g. on the "Forums by Category" page, to read a sequence of postings to the Forum and its threads all in one page. If you are only interested in one thread or the thread following a specific posting, click the thread or the posting, which takes you to a smaller page, which contains only the part you are interested in and may be easier to navigate.
Messages are "chained" if there are only replies at the first level, i.e. 1/1.html, 1/1/1.html etc. In case of "chained" messages the message number is replaced by the icon and there is no indentation.
Inline: Display the subject line only or also the text of the posting(s); for the choice "All" the "Outline" choices are switched off.
|1||0||1||no text / full text of posting|
|2||1||All||text for level 1 only / text for All postings|
Outline: Choose the depth of the posting thread, successive toggle controls provide increasing detail.
|1||2||1||2 levels / 1 level (original posting)|
|2||3||2||3 levels / 2 levels|
|3||3||All||3 levels / all levels (all postings)|
as you guessed the simplest way of handling this situation is to have each thread to have its own file.
You can always merge them later in the analysis step (creating a TChain http://root.cern.ch/root/html534/TChain.html for ttrees and summing up together histograms: http://root.cern.ch/drupal/content/how-merge-histogram-files).
Note that every file must have a unique name. There is a relatively simple way to do this. In your application you can add the unique thread ID to the ROOT file name. These are some lines of code I use myself in my application:
#include <TFile.h> #include <G4MTGetTid.hh> #include <iostream>//... Where you create the TFile ...// std::ostringstream filename; filename << "file_" << gettid() << ".root"; TFile * file = TFile::Open( filename.str().c_str() , "recreate" );
The output file name will be: file_nnnn.root where nnnn is a unique number identifying your thread.
Please note that unfortunately this is not enough: many classes of ROOT are not thread safe, it means that you need to create mutexes and lock them around the relevant parts of the code. If you need more information on how to create mutexes and use them, please let me know and I will add more instructions to this thread.
Hope this helps, Andrea
On Mon, 04 Feb 2013 20:45:55 GMT, Cristian Acu�a wrote:
> Hello everybody! > > I'm a newbie (in programming and Geant4 as well), and I'm having > problems with a certain simulation using Geant4 with TOP-C. I'm > simulating a very simple geometry of a LYSO scintillator crystal with > two sensors. I'm shooting gammas to it, and saving the Energy deposited > on the sensors on an TNtuple and storing the data on a root file. > > The problem is that when I use the multi threaded version of the code, I > have several errors with the storing of the data, because every slave > process writes the data on the same file (the exact error is "Error in > <TROOT::WriteTObject>: The current directory (root) is not associated > with a file. The object (Tuple) has not been written.") > > If somebody knows a way to store data using ROOT (or g4tools) in an > efficient way, I would appreciate the help very much. > > I think the solution may be to create a file for every slave and then > store the data generated by every slave on this files and merge them, > but I currently don't know how to do this. > > Thanks in advance. > > P.D: Sorry for the bad English. >
|Inline Depth:||Outline Depth:||Add message:|