Hello ROOTers,
I have 6 .root file named Data_x.root and I want to merge them in order to generate one Data.root file and see it with TBrowser, it is possible? How can i do that?
Thanks in Advance.
Hello ROOTers,
I have 6 .root file named Data_x.root and I want to merge them in order to generate one Data.root file and see it with TBrowser, it is possible? How can i do that?
Thanks in Advance.
Try: hadd Data.root Data_*.root
I tried:
add RUN4_2.root RUN4_1.root
^
root [1] hadd RUN4_2.root RUN4_1.root
ROOT_prompt_1:1:5: error: expected â;â after expression
hadd RUN4_2.root RUN4_1.root
^
;
Doesnât work.
hadd
is not a root command it is a standalone application based on root. You should execute it at the shell prompt.
$ hadd Data.root Data_*.root
Ok, I understand. By the way:
hadd RUN4_1.root RUN4.root;
output:
hadd Target file: RUN4_1.root
hadd compression setting for all output: 1
Error in <TFile::TFile>: file ~/Scrivania/RUN4_1.root already exists
Error in <TFileMerger::OutputFile>: cannot open the MERGER output file
hadd error opening target file (does RUN4_1.root exist?).
Pass "-f" argument to force re-creation of output file.
Maybe I understand⌠I need to merge a file with another file that already exist like:
hadd RUN4_2.root RUN4_1.root;
then:
hadd RUN4_3.root RUN4_1.root;
untilâŚ
hadd RUN4_6.root RUN4_1.root;
So the file RUN4_1.root
will be the merged file?
EDIT: I did this for several times:
hadd -f RUN4.root RUN4_6.root;
with output:
hadd Target file: RUN4.root
hadd compression setting for all output: 1
hadd Source file 1: RUN4_6.root
hadd Target path: RUN4.root:/
seems to workâŚ
This mean the file you chose for output already exists. Remove it or use option -f
LIke i said, EDIT: I did this for RUN4_1 to RUN4_6, creating for zero a the RUN4 file:
hadd -f RUN4.root RUN4_1.root;
with output:
hadd Target file: RUN4.root
hadd compression setting for all output: 1
hadd Source file 1: RUN4_6.root
hadd Target path: RUN4.root:/
It is correct?
I open the merged file and the number of entries is < then the singol RUN4_X.root filesâŚ
I also tried the advice of @Wile_E_Coyote :
hadd -f RUN4.root RUN4_*.root;
hadd Target file: RUN4.root
hadd compression setting for all output: 1
hadd Source file 1: RUN4_1.root
hadd Source file 2: RUN4_2.root
hadd Source file 3: RUN4_3.root
hadd Source file 4: RUN4_4.root
hadd Source file 5: RUN4_5.root
hadd Source file 6: RUN4_6.root
hadd Target path: RUN4.root:/
and works. Last question:
Now i see all the entries
Iâm interested to save the number of entries for a particolar condition âmult==4â.
I tried with the comand:
tree_arduino->Draw("mult==4")
but with this i visualize only th graph with this particular condition. How command i need to execute in order to visualize the number of entries with this condition?
hadd
usage is:
usage: hadd [-a A] [-k K] [-T T] [-O O] [-v V] [-j J] [-dbg DBG] [-d D] [-n N] [-cachesize CACHESIZE] [-experimental-io-features EXPERIMENTAL_IO_FEATURES] [-f F]
[-fk FK] [-ff FF] [-f0 F0] [-f6 F6]
TARGET SOURCES
So you need to specify first the target file and then the list of files you want to merge:
hadd target.root source1.root source2.root source3.root
tha will merge the 3 file source*.root
in target .root
you can also do:
hadd target.root source*.root
That will merge all the files matching the regular expression source*.root
in target.root
tree_arduino->Draw("mult","mult==4")
double n = htemp->GetEntries()
cout << n << endl;
Long64_t n = tree_arduino->Draw("mult", "mult==4", "goff");
This command give me the total number of entries (maybe it is my fault, i dont know)
This command works (in my specific case). What mean the goff option?
graphics off
Actually, one can do it in a more simple way:
Long64_t n = tree_arduino->Draw("", "mult==4");
Thanks for all the reply
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.