Is there a function in root which returns the bin number that has the first entry, or the x axis position which has the first entry?
I’ve tried browsing the TH1F and TF1 classes on the ref guide, but can’t seem to find it …
Thanks
Is there a function in root which returns the bin number that has the first entry, or the x axis position which has the first entry?
I’ve tried browsing the TH1F and TF1 classes on the ref guide, but can’t seem to find it …
Thanks
I’m not an expert and surely you have solved but I try anyway.
I do not understand what “bin containing first entry” means.
If you mean “the bin containing the first value used to fill the histo” I don’t
think it can be retrieved.
Regards, Germano
It means “the first bin with a non-null entry”
Rene
Hi, thanks for the response, but yeah you guessed i’ve figured it out.
Rene was right its the first non null bin entry.
I couldn’t find such a function in Root, so I just wrote a little function to include in my program.
int GetFirstNon0Entry(TH1F *h)
{
int nbins = h->GetXbins();
int binconent = 0;
int x=0;
for (int i=0; i<nbins; i++)
{
bincontent = h -> GetBinContent(i+1);
if (bincontent !=0)
{
x= h -> GetBinCenter(i+1);
return (x);
}
}
then where i needed the x co-ordinate of the first non-null entry i called the function:
int first_time = GetFirstNon0Entry( histogram );
Thanks anyway Germano
[quote=“no1else”]Hi, thanks for the response, but yeah you guessed i’ve figured it out.
Rene was right its the first non null bin entry.
Thanks anyway Germano [/quote]
Not at all.
I wonder only if it could be guessed by your post that you was referring
to the first non null bin entry, or I missed some other information.
But I’m happy you solved
Cheers, Germano