Customized histogram binning

Hi Rooters, I need one help. I want to give customized binning to histogram using this function
TH1F * definevar1dHistogram(TString hname, int xbinnum_5, Float_t xbins_5[], TString xtitle, int color = kGreen+3){
TH1F *h1 = new TH1F(hname, hname, xbinnum_5, xbins_5 );
h1->GetXaxis()->SetTitle(xtitle);
h1->GetXaxis()->SetTitleOffset(1.20);
h1->SetLineColor(color);
h1->SetLineWidth(2.);
return h1;

}

like the binning I am using float xbin[9] = {-1.8,-1.6,-1.4,-1.0,0,1.0,1.4,1.6,1.8} ;

how can I do this ? Because this histogram stops at -1.0 bin and rest of the bins don’t appear on the histogram.

ROOT Version: no idea
Platform: lxplus6
Compiler: no idea


float xbin[] = {-1.8, -1.6, -1.4, -1., 0., 1., 1.4, 1.6, 1.8};
TH1F *h1 = new TH1F(hname, hname, (sizeof(xbin) / sizeof(xbin[0]) - 1), xbin);

Thanks for providing the idea. I changed the initial low bin edge to the exact binned histogram.
like

float xbin[] = {2.0, -1.8, -1.6, -1.4, -1., 0., 1., 1.4, 1.6, 1.8};
TH1F *h1 = new TH1F(hname, hname, (sizeof(xbin) / sizeof(xbin[0]) - 1), xbin);

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.