Art, Sorry for the delay to answer your question. I am just back from the joint ALICE/STAR meeting at BNL. The behaviour of TProfile::Scale is correct in PAW and Root. It does not make sense for a TProfile to scale along the Y coordinates since this object is supposed to contain for a given X value the mean/rms along Y. A profile histogram is not a 1-d histogram. It includes for each bin - number of entries - sum of weights - sum of squares of weights Scaling a profile implies scaling also the number of entries. TProfile::SetBinContent modifies only the sum of weights. The value plotted along Y is (sum of weights)/(number of entries). You can obtain/set the number of entries in one bin via GetBinEntries/SetBinEntries If what you want to do is to scale along Y (even if I do not understand the meaning of this operation), you have to write some lines of code as shown below: { TAxis *xaxis = hprof->GetXaxis(); Int_t nbins = xaxis->GetNbins(); Float_t xmin = xaxis->GetXmin(); Float_t xmax = xaxis->GetXmax(); TH1F *hp = new TH1F("hp","???",nbins,xmin,xmax); for (Int_t bin=0;bin<=nbins;bin++) { hp->SetBinContent(bin,hprof->GetBinContent(bin)); hp->SetBinError(bin,hprof->GetBinError(bin)); } hp->SetEntries(hprof->GetEntries()); hp->Scale(2); hp->Draw(); } Rene Brun Art Poskanzer wrote: > > I got no response to the mail below. But I have since learned that > profile histograms have always behaved this way, even in PAW. I am now > trying to scale my profile histogram by looping over all the bins, > doing GetBinContent, scaling it, and then doing SetBinContent. (I > would do the same for the errors.) However, this procedure gives > nonsense (very low) results when I do a GetBinContent again. Although > GetBinContent is a member function of TProfile, SetBinContent is > inherited from TH1D. > > Someone, please tell me how to correctly scale a profile histogram. > > My code at the moment is: > double content; > for (int n = 0; n < nBins+1 ; n++) { > content = hp>GetBinContent(n); > content *= scaleFactor; > hp>SetBinContent(n, content); > } > > Art Poskanzer > > Art Poskanzer wrote: > > > When ROOT scales a profile histogram it keeps the contents fixed > > and reduces the error by the square root of the scale factor. > > This is because it scales the sum of the weights, the sum of the > > weights squared, and also the number of entries. Is this behavior > > correct? > > > > I want to scale the histogram, that is, the contents and the > > errors, like one would scale a 1D histogram. Do I have to convert > > it to a 1D and then scale it? > > > > Is the only way to convert it to loop over the bins getting each > > content and error and putting them into the 1D? > > > > I am using root 2.23/12 in root4star. > > > > Art Poskanzer and Glenn Cooper > > ------------------------------------------------------------------------ > > Art Poskanzer <AMPoskanzer@lbl.gov> > Lawrence Berkeley National Laboratory > > Art Poskanzer > Lawrence Berkeley National Laboratory <AMPoskanzer@lbl.gov> > HTML Mail > Fax: 510-486-7105 > Home: 510-841-4710 > Work: 510-486-5618 > Netscape Conference Address > Specific DLS Server > Additional Information: > Last Name Poskanzer > First Name Art > Version 2.1
This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:23 MET