How to create more than one output event in FairTask Exec()-function? [message #23774] |
Tue, 26 March 2019 12:41 ![Go to next message Go to next message](/theme/gsi/images/down.png) |
C. A. Douma
Messages: 88 Registered: September 2015 Location: Groningen
|
continuous participant |
From: *kvi-cart.rug.nl
|
|
Dear all,
I would like to design an R3BRoot FairTask that merges several .root-files.
So suppose that I create a TClonesArray* fOutput;
that I write its content with FairRootManaber::Register to an output-file,
and that I expand the fOutput-array with one object at a time
using the new-operator (inside the Exec()-function),
is there a way to manually call a command for writing fOutput
to the file and emptying it halfway inside the Exec()-function?
So that I essentially generate multiple events in the output-tree
for a single Exec()-call?
Many thanks in advance!
Christiaan Douma.
|
|
|
|
Re: How to create more than one output event in FairTask Exec()-function? [message #23793 is a reply to message #23789] |
Wed, 27 March 2019 12:32 ![Go to previous message Go to previous message](/theme/gsi/images/up.png) ![Go to next message Go to next message](/theme/gsi/images/down.png) |
C. A. Douma
Messages: 88 Registered: September 2015 Location: Groningen
|
continuous participant |
From: *kvi-cart.rug.nl
|
|
Dear Jan,
The ultimate goal of this exercise is to do my simulations in multi-thread mode.
To avoid the complicated C++ multithread programming, my thoughts went to using
a bash-script for running, say, 4 copies of r3b_sim.C in parallel (in different shells).
Then, I can run your digitizer afterwards (also 4x in different shells).
However, this will then produce 4 distinct .root-files, all with their own
digitizer output tree. Hence, I wanted to write another FairTask that does
nothing more then merging these 4 files into one. But since FairTask
runs Exec() ones per event and reads & writes one event at a time,
taking event 1 from 4 different files & writing them as event 1,2,3,4
does not seem possible withing Exec(). Hence my question: can I manually
call a write & reset function for the output TClonesArray?
In that Case, I can use AddFriend() on the 4 digitizer files, read one
event from each file during one Exec()-call and then call the write & reset
function 4 times to produce 4 output events within that same Exec()-call.
Christiaan.
|
|
|
Re: How to create more than one output event in FairTask Exec()-function? [message #23799 is a reply to message #23793] |
Wed, 27 March 2019 13:16 ![Go to previous message Go to previous message](/theme/gsi/images/up.png) ![Go to next message Go to next message](/theme/gsi/images/down.png) |
Jan Mayer
Messages: 20 Registered: August 2015
|
occasional visitor |
From: *ikp.uni-koeln.de
|
|
Quote:This will then produce 4 distinct .root-files, all with their own digitizer output tree. Hence, I wanted to write another FairTask that does nothing more then merging these 4 files into one.
Aha! Now we're talking.
Quote: Hence my question: can I manually call a write & reset function for the output TClonesArray?
You don't need to do that. At all.
I mean, if you think about it, this must be such a common problem! Everyone would face that at some point, right? Even the experimental data is split into multiple files automatically. Since decades, people would have to work with that, right? Having their code run over terabytes of data in hundreds of root files!
There are two main solutions: Add the file contents together to form a new large file with "hadd" (not recommended), or simply tell ROOT that the input is split over multiple files - in ROOT terms, that is called a "TChain".
The FairRoot equivalent / abstraction is in "FairFileSource", which has a function "AddFile", which does what it says.
/**Add ROOT file to input, the file will be chained to already added files*/
void AddFile(TString FileName);
[Updated on: Wed, 27 March 2019 13:18] Report message to a moderator
|
|
|
|
|
|