HADD histograms in ONE file issues

Dear experts,
I would like to merge root files containing a canvas with two histograms into ONE file
In the target file I would like to have JUST ONE canvas with two histograms which
are the sum of the input files

I’ve tried with:
hadd target.root input1.root input2.root input3.root input4.root

But in the target.root file I see:
root [2] _file0->ls()
TFile** AllToys/toyMC_FLAFB_2_FL_NLL.root
TFile* AllToys/toyMC_FLAFB_2_FL_NLL.root
KEY: TCanvas cNLL1;4 cNLL1
KEY: TCanvas cNLL1;3 cNLL1
KEY: TCanvas cNLL1;2 cNLL1
KEY: TCanvas cNLL1;1 cNLL1

There are 4 TCanvas !
I instead would like JUST ONE canvas with two histograms which are the sum of the input files


  • Mauro.

hadd add file not canvases. See the help:

Usage: hadd [-f[0-9]] [-k] [-T] [-O] [-n maxopenedfiles] [-v verbosity] targetfile source1 [source2 source3 ...]
This program will add histograms from a list of root files and write them
to a target root file. The target file is newly created and must not 
exist, or if -f ("force") is given, must not be one of the source files.
Supply at least two source files for this to make sense... ;-)
If the option -k is used, hadd will not exit on corrupt or non-existant input files but skip the offending files instead.
If the option -T is used, Trees are not merged
If the option -O is used, when merging TTree, the basket size is re-optimized
If the option -v is used, explicitly set the verbosity level; 0 request no output, 99 is the default
If the option -n is used, hadd will open at most 'maxopenedfiles' at once, use 0 to request to use the system maximum.
When -the -f option is specified, one can also specify the compression
level of the target file. By default the compression level is 1, but
if "-f0" is specified, the target file will not be compressed.
if "-f6" is specified, the compression level 6 will be used.
if Target and source files have different compression levels
 a slower method is used