GetMaximumBin

HI,
I declare a histogram in the following way:

Double_t e_nu[7]={5,7,10,14,18,22,30};
Double_t x_nu[14]={0.0001,0.03,0.06,0.1,0.15,0.20,0.25,0.30,0.40,0.50,0.60,0.70,0.80,0.90};
Double_t y_nu[9]={0.05,0.20,0.30,0.40,0.50,0.60,0.70,0.80,0.95};

TH3F *nu_reco_total = new TH3F(“nu_reco_total”,“total nu’s(reco)”,6,e_nu,13,x_nu,8,y_nu);

after filling the histogram, I try doing :
cout<<nu_reco_total->GetMinimumBin()<<" "<<nu_reco_total->GetMaximumBin()<<endl;

and I get the answer:
133 and 1030

I dont quite understand the answer, how are these numbers related to the Minimum or MaximumBin ?
Also what should I do if I want to get the minbin and maxbin in each of the x,y and z axes?
-thanks debdatta.

There are two functions that you can use to return the bin number having
the max or min content

Int_t TH1::GetMaximumBin() const Int_t TH1::GetMaximumBin(Int_t &locmaxx, Int_t &locmaxy, Int_t &locmaxz) const
In case of a 3-d histogram, it is better to use the second form that returns
(locmaxx, locmaxy, locmaxz).
The first form returns one single number that contains the compact information of locmaxx,locmaxy,locmaxz

Rene

Hi Rene,
thanks for your reply. I am still a little confused.

Int_t TH1::GetMaximumBin(Int_t &locmaxx, Int_t &locmaxy, Int_t &locmaxz) const

with this command, how do I get the locmaxx etc. initialised ? I apologise if I am missing something obvious.

                        -regards Debdatta.

locmaxx,locmaxy,locmaxz are 3 output parameters. Do

Int_t locmaxx,locmaxy,locmaxz; hist.GetMaximumBin(locmaxx,locmaxy,locmaxz); //and now use locmaxx, etc
Rene

Double_t e_nu[7]={5,7,10,14,18,22,30};
Double_t x_nu[14]={0.0001,0.03,0.06,0.1,0.15,0.20,0.25,0.30,0.40,0.50,0.60,0.70,0.80,0.90};
Double_t y_nu[9]={0.05,0.20,0.30,0.40,0.50,0.60,0.70,0.80,0.95};

TH3F *nu_reco_total = new TH3F(“nu_reco_total”,"",6,e_nu,13,x_nu,8,y_nu);

I tried:

Int_t locminx,locminy,locminz,locmaxx,locmaxy,locmaxz;

nu_reco_total->GetMinimumBin(locminx,locminy,locminz);
nu_reco_total->GetMaximumBin(locmaxx,locmaxy,locmaxz);

cout<<"min “<<locminx<<” “<<locminy<<” "<<locminz<<endl;
cout<<"max “<<locmaxx<<” “<<locmaxy<<” "<<locmaxz<<endl;

I see:
min 1 1 1
max 1 1 1

I tried getting the bins before “filling” the histogram, but I think it shouldn’t matter. I think I am doing something wrong.

                           -thanks debdatta.

I am totally confused by your question.
Do you want the bin with the minimum or maximum content?
or the minimum , maximum of the x,y axis ?

My previous answer was assuming the first case. If you meant the second case use e_nu[0], x_nu[0], etc

If none of these cases, please rephrase your question.

Rene

HI Rene,
I got a little confused too. I thought by calling MaximumBin I will get the “last” bin in the x-axis and not the bin having the “maximum” number of entries. It took me a while to figure that out. Thank you for your patience.

                                 -regards Debdatta.