GSI Forum
GSI Helmholtzzentrum für Schwerionenforschung

Home » R3BRoot » Data Analysis » How to create more than one output event in FairTask Exec()-function? (How to create more than one output event in FairTask Exec()-function?)
How to create more than one output event in FairTask Exec()-function? [message #23774] Tue, 26 March 2019 12:41 Go to next message
C. A. Douma is currently offline  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 #23789 is a reply to message #23774] Wed, 27 March 2019 10:34 Go to previous messageGo to next message
Jan Mayer is currently offline  Jan Mayer
Messages: 20
Registered: August 2015
occasional visitor
From: *ikp.uni-koeln.de
Hello,

what is it you actually want to accomplish? What should be "merged" and why?

Quote:
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?

I do not think it is a good Idea to work against one of the main principles of the data processing system. In- and Output files should have a 1:1 relationship - so one can use data from several root files together and be sure its the correct event each time (see 14.16.2 https://root.cern.ch/root/htmldoc/guides/users-guide/Trees.html#example- 3-adding-friends-to-trees).


I suspect your problem is somewhere else, and can be solved differently.


Jan
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 messageGo to next message
C. A. Douma is currently offline  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 messageGo to next message
Jan Mayer is currently offline  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

Re: How to create more than one output event in FairTask Exec()-function? [message #23803 is a reply to message #23799] Wed, 27 March 2019 14:16 Go to previous messageGo to next message
C. A. Douma is currently offline  C. A. Douma
Messages: 88
Registered: September 2015
Location: Groningen
continuous participant
From: *kvi-cart.rug.nl
FairFileSource::AddFile() looks promising. How can I use it?

In a steering macro, I do

FairRunAna* run = new FairRunAna();
run->SetInputFile("<path to>/DigiFile.root");

Can I then just do
run->AddFile("<path to>/DigiFile_2.root");
and do run->Run(0,twice as many events as in a single file);

Christiaan.
Re: How to create more than one output event in FairTask Exec()-function? [message #23809 is a reply to message #23803] Wed, 27 March 2019 14:27 Go to previous messageGo to next message
Jan Mayer is currently offline  Jan Mayer
Messages: 20
Registered: August 2015
occasional visitor
From: *ikp.uni-koeln.de
auto source = new FairFileSource("<path to>/DigiFile.root");
source->AddFile("<path to>/DigiFile_2.root");

auto run = new FairRunAna();
run->SetSource(source);


"SetInputFile" is deprecated anyway.

Also, with
run->Run(0, 0);
all available events will be processed. No need to specifying the exact number.

[Updated on: Wed, 27 March 2019 14:35]

Report message to a moderator

Re: How to create more than one output event in FairTask Exec()-function? [message #23815 is a reply to message #23809] Wed, 27 March 2019 15:35 Go to previous message
C. A. Douma is currently offline  C. A. Douma
Messages: 88
Registered: September 2015
Location: Groningen
continuous participant
From: *kvi-cart.rug.nl
Thank you. I will try it.

Christiaan.
Previous Topic: reading container parameter
Next Topic: Some UCESB zero-suppressed multi hit documentation
Goto Forum:
  


Current Time: Thu Dec 12 15:11:24 CET 2024

Total time taken to generate the page: 0.00772 seconds