Nick van Eijndhoven wrote: > > Dear friends, > I have two TH1F* objects h1 and h2 and would like to get the ratio > of the two histos into a third one with the correct error calculation > (i.e. Sumw2() option). > > If I do : > > TH1F h3=(*h1); > h3.Sumw2(); > h3.Divide(h1,h2,1,1); > h3.Draw(); > > I get the correct result (i.e. h3 drawn with correct error bars). > > However, now I would like to use the convenient 'histo operators' and do : > > TH1F h3=(*h1)/(*h2); > h3.Draw(); > > But now h3 is drawn as a histo without error bars, giving me the impression > that the Sumw2() option was not used. > When I do h3.Draw("e1p") I see that indeed the errors are incorrect. > > Q : How can I achieve correct error calculation using the 'histo operators' ? > > Note : A default won't work, since sometimes in h3=(*h1)+(*h2) one would like > to add without Sumw2() and sometimes with Sumw2() set. > I suggest the following sequence: TH1F h3 = (*h1) h3.Sumw2() h3 = h3/(*h2) and you will get the correct error bars. Unless I have objections, I will systematically activate the creation/storage of error bars in case of multiplication and divisions. > Another point is the following : > > I would like to have h3 also defined as TH1F*, but clearly > > TH1F* h3=(*h1)/(*h2) will fail. > > How to achieve this ? Do not use operators, but TH1::Divide directly TH1F *h3 = new TH1F("h3",....) //same params as h1 h3->Divide(...) Rene Brun
This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:26:18 MET