Adding two histograms with different X ranges (c++)

_ROOT Version: 6.10.06
Hello rooters,
I have two histograms with different X ranges, one is from 0-3 MeV (1000 bins) and the other one is from 0 to 10 MeV (also 1000 bins). I need to add the first one to the second one.
I am a C++ and root beginner, is there a way to do this??
Thank you!

So you want to ignore the axis ranges ?
You want to do a bin by bin addition ?
What should be the new range of the resulting histogram ?

The resulting histogram should have range from 0 to 10 MeV.
In both cases it is a gamma ray spectrum and i need to merge them together.

May be the example shown in TH1::Merge can help you:

Thank you for your response!
At the end it was solved by this loop. Maybe someone will find it useful.

     do {pole[i]+=h_sum->GetBinContent(j);
         cout<<i<<" pole"<<pole[i]<<endl;
     } while(h6->GetBinLowEdge(j)<h_sum->GetBinLowEdge(i+1));


This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.