Re: New binning method in ROOT v5.14

From: Rene Brun <Rene.Brun_at_cern.ch>
Date: Mon, 29 Jan 2007 23:10:55 +0100


Sebastien,

Your script c1.C contains strange values for heDp (created with 80 bins, but only the first 20 are filled.
Taking these 20 bins, I call TH1::Rebin. See script in attachment.

Rene Brun

Sebastien GADRAT wrote:
> Hi rooters,
>
> I recently compiled the new ROOT production release v5.14 and tried
> the new re-binning method which allows to rebin in variable bins an
> existing histogram.
> I have got a histogram with a constant bining of 0.1 named heDp. In
> order to compensate large error bars especially for large value of the
> x axis, I tried the new method.
> After getting the heDp histogram which I would like to rebin, I define
> my x1 vector for the new desired binning. Then I can try to rebin
> using the Rebin() method.
> On figure c1.gif, one can see in black the heDp histogram, and in red
> the new histogran obtained after the rebin() method. When looking
> carefully to the new histogram, one can notice that a bin content of
> the new histogram correspond to the same bin content of the first
> histogram. As an example I show below some example : the bin content
> of the first bin of the rebin plot is strictly the same as the first
> bin of the heDp histogram... I also join to the mail a ROOT generated
> macro with part of the points showed in the c1.gif figure.
> What did I do wrong when using the new rebin method ??
> Best regards,
>
> Sebastien
>
> PS : here is one try using the new bin() method. This is how I got the
> red histogram on the gif file.
>
> root [248] heDp->Draw()
> root [249] Double_t
> x1[18]={0,0.2,0.4,0.6,0.8,1.0,1.2,1.6,2.0,2.4,2.8,3.2,4.0,4.8,5.6,6.4,7.2,8.0}
>
> root [250] heDp->Rebin(17,"MyBinnedPlot",x1);
> root [252] MyBinnedPlot->SetLineColor(2)
> root [254] MyBinnedPlot->Draw("same")
> root [255] heDp->GetBinContent(1)
> (const Double_t)2.63617876917123795e-02
> root [256] MyBinnedPlot->GetBinContent(1)
> (const Double_t)2.63617876917123795e-02
> root [257] heDp->GetBinContent(2)
> (const Double_t)3.03412843495607376e-02
> root [258] MyBinnedPlot->GetBinContent(2)
> (const Double_t)3.03412843495607376e-02
> root [259] heDp->GetBinContent(3)
> (const Double_t)3.32100354135036469e-02
> root [260] MyBinnedPlot->GetBinContent(3)
> (const Double_t)3.32100354135036469e-02
>
> ------------------------------------------------------------------------
>
> ------------------------------------------------------------------------
>
> {
> //=========Macro generated from canvas: c1/c1
> //========= (Mon Jan 29 18:07:28 2007) by ROOT version5.14/00
> TCanvas *c1 = new TCanvas("c1", "c1",480,308,700,500);
> gStyle->SetOptFit(1);
> gStyle->SetOptStat(0);
> c1->SetHighLightColor(10);
> c1->Range(-1.2,-0.0127123,8.8,0.0673027);
> c1->SetFillColor(0);
> c1->SetBorderMode(0);
> c1->SetBorderSize(2);
> c1->SetTickx();
> c1->SetTicky();
> c1->SetLeftMargin(0.12);
> c1->SetRightMargin(0.08);
> c1->SetTopMargin(0.08);
> c1->SetBottomMargin(0.12);
> c1->SetFrameBorderMode(0);
> c1->SetFrameBorderMode(0);
>
> TH1 *heDp = new TH1F("heDp","",80,0,8);
> heDp->SetBinContent(1,0.0263618);
> heDp->SetBinContent(2,0.0303413);
> heDp->SetBinContent(3,0.03321);
> heDp->SetBinContent(4,0.0345854);
> heDp->SetBinContent(5,0.0351559);
> heDp->SetBinContent(6,0.0349591);
> heDp->SetBinContent(7,0.0343107);
> heDp->SetBinContent(8,0.0340966);
> heDp->SetBinContent(9,0.0310726);
> heDp->SetBinContent(10,0.0324048);
> heDp->SetBinContent(11,0.029634);
> heDp->SetBinContent(12,0.0289748);
> heDp->SetBinContent(13,0.0271789);
> heDp->SetBinContent(14,0.0249413);
> heDp->SetBinContent(15,0.0269446);
> heDp->SetBinContent(16,0.0265154);
> heDp->SetBinContent(17,0.0218799);
> heDp->SetBinContent(18,0.0239263);
> heDp->SetBinContent(19,0.0202026);
> heDp->SetBinContent(20,0.0158329);
> heDp->SetBinError(1,0.000734346);
> heDp->SetBinError(2,0.000480592);
> heDp->SetBinError(3,0.000474477);
> heDp->SetBinError(4,0.000515063);
> heDp->SetBinError(5,0.000579597);
> heDp->SetBinError(6,0.000659407);
> heDp->SetBinError(7,0.000759282);
> heDp->SetBinError(8,0.000886014);
> heDp->SetBinError(9,0.00097349);
> heDp->SetBinError(10,0.00118025);
> heDp->SetBinError(11,0.00129625);
> heDp->SetBinError(12,0.00150644);
> heDp->SetBinError(13,0.00171331);
> heDp->SetBinError(14,0.00183931);
> heDp->SetBinError(15,0.00225261);
> heDp->SetBinError(16,0.00250632);
> heDp->SetBinError(17,0.00252429);
> heDp->SetBinError(18,0.00310484);
> heDp->SetBinError(19,0.00324808);
> heDp->SetBinError(20,0.00248394);
> heDp->SetEntries(388990);
> heDp->Draw("");
> Double_t xAxis[18] = {0, 0.2, 0.4, 0.6, 0.8, 1, 1.2, 1.6, 2, 2.4, 2.8, 3.2, 4, 4.8, 5.6, 6.4, 7.2, 8};
>
> TH1 *MyBinnedPlot = new TH1F("MyBinnedPlot","",17, xAxis);
> MyBinnedPlot->SetBinContent(1,0.0263618);
> MyBinnedPlot->SetBinContent(2,0.0303413);
> MyBinnedPlot->SetBinContent(3,0.03321);
> MyBinnedPlot->SetBinContent(4,0.0345854);
> MyBinnedPlot->SetBinContent(5,0.0351559);
> MyBinnedPlot->SetBinContent(6,0.0349591);
> MyBinnedPlot->SetBinContent(7,0.0343107);
> MyBinnedPlot->SetBinContent(8,0.0340966);
> MyBinnedPlot->SetBinContent(9,0.0310726);
> MyBinnedPlot->SetBinContent(10,0.0324048);
> MyBinnedPlot->SetBinContent(11,0.029634);
> MyBinnedPlot->SetBinContent(12,0.0289748);
> MyBinnedPlot->SetBinContent(13,0.0271789);
> MyBinnedPlot->SetBinContent(14,0.0249413);
> MyBinnedPlot->SetBinContent(15,0.0269446);
> MyBinnedPlot->SetBinContent(16,0.0265154);
> MyBinnedPlot->SetBinContent(17,0.0218799);
> MyBinnedPlot->SetBinContent(18,0.0121076);
> MyBinnedPlot->SetBinError(1,0.000734346);
> MyBinnedPlot->SetBinError(2,0.000480592);
> MyBinnedPlot->SetBinError(3,0.000474477);
> MyBinnedPlot->SetBinError(4,0.000515063);
> MyBinnedPlot->SetBinError(5,0.000579597);
> MyBinnedPlot->SetBinError(6,0.000659407);
> MyBinnedPlot->SetBinError(7,0.000759282);
> MyBinnedPlot->SetBinError(8,0.000886014);
> MyBinnedPlot->SetBinError(9,0.00097349);
> MyBinnedPlot->SetBinError(10,0.00118025);
> MyBinnedPlot->SetBinError(11,0.00129625);
> MyBinnedPlot->SetBinError(12,0.00150644);
> MyBinnedPlot->SetBinError(13,0.00171331);
> MyBinnedPlot->SetBinError(14,0.00183931);
> MyBinnedPlot->SetBinError(15,0.00225261);
> MyBinnedPlot->SetBinError(16,0.00250632);
> MyBinnedPlot->SetBinError(17,0.00252429);
> MyBinnedPlot->SetBinError(18,0.00310484);
> MyBinnedPlot->SetEntries(388990);
> MyBinnedPlot->SetLineColor(2);
> MyBinnedPlot->Draw("same");
>
> c1->Modified();
> c1->cd();
> c1->SetSelected(c1);
> }
>

{
//=========Macro generated from canvas: c1/c1 //========= (Mon Jan 29 18:07:28 2007) by ROOT version5.14/00

   TCanvas *c1 = new TCanvas("c1", "c1",480,308,700,500);    gStyle->SetOptFit(1);
   gStyle->SetOptStat(0);

   c1->SetHighLightColor(10);
   c1->Range(-1.2,-0.0127123,8.8,0.0673027);
   c1->SetFillColor(0);
   c1->SetBorderMode(0);
   c1->SetBorderSize(2);
   c1->SetTickx();
   c1->SetTicky();
   c1->SetLeftMargin(0.12);
   c1->SetRightMargin(0.08);
   c1->SetTopMargin(0.08);
   c1->SetBottomMargin(0.12);
   c1->SetFrameBorderMode(0);
   c1->SetFrameBorderMode(0);
   

   TH1 *heDp = new TH1F("heDp","",20,0,8);

   heDp->SetBinContent(1,0.0263618);
   heDp->SetBinContent(2,0.0303413);
   heDp->SetBinContent(3,0.03321);
   heDp->SetBinContent(4,0.0345854);
   heDp->SetBinContent(5,0.0351559);
   heDp->SetBinContent(6,0.0349591);
   heDp->SetBinContent(7,0.0343107);
   heDp->SetBinContent(8,0.0340966);
   heDp->SetBinContent(9,0.0310726);
   heDp->SetBinContent(10,0.0324048);
   heDp->SetBinContent(11,0.029634);
   heDp->SetBinContent(12,0.0289748);
   heDp->SetBinContent(13,0.0271789);
   heDp->SetBinContent(14,0.0249413);
   heDp->SetBinContent(15,0.0269446);
   heDp->SetBinContent(16,0.0265154);
   heDp->SetBinContent(17,0.0218799);
   heDp->SetBinContent(18,0.0239263);
   heDp->SetBinContent(19,0.0202026);
   heDp->SetBinContent(20,0.0158329);
   heDp->SetBinError(1,0.000734346);
   heDp->SetBinError(2,0.000480592);
   heDp->SetBinError(3,0.000474477);
   heDp->SetBinError(4,0.000515063);
   heDp->SetBinError(5,0.000579597);
   heDp->SetBinError(6,0.000659407);
   heDp->SetBinError(7,0.000759282);
   heDp->SetBinError(8,0.000886014);
   heDp->SetBinError(9,0.00097349);
   heDp->SetBinError(10,0.00118025);
   heDp->SetBinError(11,0.00129625);
   heDp->SetBinError(12,0.00150644);
   heDp->SetBinError(13,0.00171331);
   heDp->SetBinError(14,0.00183931);
   heDp->SetBinError(15,0.00225261);
   heDp->SetBinError(16,0.00250632);
   heDp->SetBinError(17,0.00252429);
   heDp->SetBinError(18,0.00310484);
   heDp->SetBinError(19,0.00324808);
   heDp->SetBinError(20,0.00248394);
   heDp->SetEntries(388990);
   heDp->Draw("");
   

   Double_t xAxis[18] = {0, 0.2, 0.4, 0.6, 0.8, 1, 1.2, 1.6, 2, 2.4, 2.8, 3.2, 4, 4.8, 5.6, 6.4, 7.2, 8};

   TH1F *hr2 = heDp->Rebin(17,"hr2",xAxis);    hr2->SetLineColor(2);
   hr2->Draw("same");
} Received on Mon Jan 29 2007 - 23:11:19 CET

This archive was generated by hypermail 2.2.0 : Wed Jan 31 2007 - 11:50:01 CET