Re: [ROOT] Error tabulating Ntuple variable value vs No of entries

From: Rene Brun (Rene.Brun@cern.ch)
Date: Tue May 07 2002 - 21:03:20 MEST


Hi

I suppose you want to do this:

    for(int i =0; i<numBins;i++) {
       binContent[i]=hist->GetBinContent(i+1);
       printf(" %d \t %f\n "i,binContent[i]);
    }

Note that GetBinContent(0) returns the number of underflows
          GetBinContent(1) return the content of first bin
 TAxis::FindBin(Double_t x) returns the bin mumber corresponding to axis
value x.

Rene Brun


On Tue, 7 May 2002, Aron, Navneet wrote:

> 
> 
> 
> Hi Root users,
> In my attempt to tabulate the number of entries versus Ntuple variable  value, i wrote the following code, which is err.
> could any one suggest, what  is wrong with this code.
> Sincerely,
> Navneet 
> 
> 
> {
>    gROOT->Reset();
>    filename ="gamma_5.000_3.5_0_20_5_90_10000_ntp.root";
>    TFile *r = new TFile(filename);
>    TTree *Tree = (TTree*)r->Get("t1");
>    Tree.Draw("Trig_Bits>>hist");
> 
>    Int_t numBins =hist->GetNbinsX();
> 
>    Double_t binContent[100];
>    Int_t bin[100];
> 
>    printf("%s\n\n",filename);
>    printf("Bin:  Trig_Bits:  Events\n");
> 
>    for(int i =0; i<numBins;i++) 
>    {
>      bin[i] =hist->GetXaxis()->FindBin(i);
>      binContent[i]=hist->GetBinContent(bin[i]);
>      printf(" %d \t %f\n "bin[i],binContent[i]);
>    }
> 
> }
> 



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:52 MET