SetBins

Hello

Is is possible to set my own bins after creating histograms with empty constructor?

I’m trying to do something like this:

TH2D histo=new TH2D(); //create histo with empty constructor
double xbins[10];
double ybins[10];
void myfunc()
{
//my bins
for(int i=0; i<(11); i++){
double xmin=0.003; double xmax=1; xbins[i]=xmin
pow(10,ilog10(xmax/xmin)/10);}
for(int i=0; i<(11); i++){
double xmin=1; double xmax=10; ybins[i]=xmin
pow(10,i*log10(xmax/xmin)/10);}

histo->SetBins(10,xbins,10,ybins); // THIS IS MY PROBLEM
histo->Draw();
}

The problem exist because function SetBins(…) need to have xlow, and xup instead xbins.
So how can I use my own bins in this situation?

regards
jimmij

call TAxis::SetBins with your array of bin edges.
See example in teh TH1 constructors.

Rene

HI

Thanks for replay, but I can’t see function SetBins() in the class TAxis.
This function exsist in class TH1 but it can’t use my array of low bins edges.

For example in TH1D there are two kind of constructors(with and without array):
TH1D(const char* name, const char* title, Int_t nbinsx, Axis_t xlow, Axis_t xup)
TH1D(const char* name, const char* title, Int_t nbinsx, const Double_t* xbins)

But there is only one kind of function SetBins:
void SetBins(Int_t nx, Axis_t xmin, Axis_t xmax)
I can’t find:
void SetBins(Int_t nx, const Double_t* xbins)
Does it exist? where?
I use root 4.00.08

best regards
jimmij

ahh, do you mean “TAxis::Set” not “SetBins” ?

In this way it is very simply:
histo->GetXaxis()->Set(nbins,xbins);

thanks
jimmij

Yes, sorry for the typo, I meant TAxis::Set

Rene