I do not want to set the number of bins automatically, because it might be a user error. Simply clone one of the operands before dividing, instead of calling the default constructor. Rene Brun Thomas Bretz wrote: > > Rene, > > yes, itmust. So why is the binning not automatically taken over? > > Thomas. > > Rene Brun wrote: > > Thomas, > > > > The resulting histogram must have the same number of bins than the > > operand histograms. > > > > Rene Brun > > > > On Thu, 18 Mar 2004, Thomas Bretz wrote: > > > > > >>Hi Rene, > >> > >>why does h4 need the same number of bins? It is enough if h4 'takes' the > >>binning from either h3 or h2, isn't it? > >> > >>Thomas. > >> > >>Rene Brun wrote: > >> > >>>Your two projections h2 and h3 have the same number of bins, > >>>eg you can do h3->Divide(h2); > >>>However, you call the default constructor for h4. h4 does not have the > >>>same number of bins as h2 and h3. > >>>Instead of > >>> TH2D *h4 = new TH2D; > >>> h4->Divide(h3, h2); > >>>do > >>> TH2D *h4 = (TH2D*)h2->Clone(); > >>> h4->Divide(h3, h2); > >>> > >>>Rene Brun > >>> > >>>Thomas Bretz wrote: > >>> > >>> > >>>>Hi, > >>>> > >>>>I have a > >>>>Double_t x[5] = { 0, 1, 2, 3, 4 }; > >>>>TH3D fHist("", "", 4, x, 4, x, 4, x); > >>>>and do: > >>>>fHist.GetZaxis()->SetRange(3, 4); > >>>>TH1 *h2 = fHist.Project3D("xy_off"); //, -1, 9999, "E"); > >>>> > >>>>fHist.GetZaxis()->SetRange(1,2); > >>>>TH1 *h3 = fHist.Project3D("xy_on"); //, -1, 9999, "E"); > >>>> > >>>>TH2D *h4 = new TH2D; > >>>>h4->Divide(h3, h2); > >>>> > >>>>And I get > >>>>Attempt to divide histograms with different number of bins... > >>>> > >>>>What am I doing wrong? I would expect to have two projections to have > >>>>the same binning... > >>>> > >>>>Thomas. > >>> > >>> > > > >
This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:06 MET