Deepak Kar wrote:
> Hi,
>
> I dont know if I am missing something obvious, but this is what I have.
>
> hist1.root with just one histogram in it, named hist1
> hist2.root with just one histogram in it, named hist2
> Neither have any directory structure.
>
The result of hadd will be a file containing both hist1 and hist2. of
course hadd should not add/merge (or whatever) hist1 and hist2.
> I somehow want hist1 and hist2 merged. Now when I try the usual
> hadd.C, it just gives me back whichever I put in first, hist1 or
> hist2, not the combined one.
> And I cant certainly do hist1->Add(hist2); since that does not care
> for the relative weights, which are much different - otherwise I could
> have just did that and divided by 2.
>
If what you want to do is the average of hist1 and hist2, see the doc of
TH1::Add (version >=5.18)
SPECIAL CASE (Average/Efficiency histograms) For histograms representing averages or efficiencies, one should compute the average of the two histograms and not the sum. One can mark a histogram to be an average histogram by setting its bit kIsAverage <http://root.cern.ch/root/html/TH1.html#TH1:kIsAverage> with
myhist.SetBit <http://root.cern.ch/root/html/TObject.html#TObject:SetBit>(TH1 <http://root.cern.ch/root/html/TH1.html>::kIsAverage <http://root.cern.ch/root/html/TH1.html#TH1:kIsAverage>); Note that the two histograms must have their kIsAverage <http://root.cern.ch/root/html/TH1.html#TH1:kIsAverage> bit set
IMPORTANT NOTE1: If you intend to use the errors of this histogram later you should call Sumw2 <http://root.cern.ch/root/html/TH1.html#TH1:Sumw2> before making this operation. This is particularly important if you fit the histogram after TH1 <http://root.cern.ch/root/html/TH1.html>::Add <http://root.cern.ch/root/html/TH1.html#TH1:Add>
IMPORTANT NOTE2: if h1 has a normalisation factor, the normalisation factor is used , ie this = this + c1*factor*h1 Use the other TH1 <http://root.cern.ch/root/html/TH1.html>::Add <http://root.cern.ch/root/html/TH1.html#TH1:Add> function if you do not want this feature
Rene Brun
> Can it be done?
>
> Thanks a lot,
> Deepak
>
>
>
>
Received on Wed Apr 02 2008 - 12:34:16 CEST
This archive was generated by hypermail 2.2.0 : Wed Apr 02 2008 - 17:50:01 CEST