How to define a log10 binning

Hi Rooters,

I would like to bin my Ntuple in the log10 scale and then fill a histo with this changed ntuple.

My code at the moment looks like this:


TString Inputfile1 = “/data/mwright/DminTool/OUTPUT/AlpgenJimmyttbarlnqqNp0.root”;
TString n1 = “AntKtDminNoCal_dmin_01_”;

TFile g = new TFile(Inputfile1);
TTree
b = (TTree*)gDirectory->Get(“D3PD”);

TH1F AntKtDminNoCal_dmin_01_norm1_np0 = new TH1F(“AntKtDminNoCal_dmin_01_norm1_np0”,"Jet 0-1 Dmin Value Norm to 1/LumiBinWidth Np0",10000,0,1000000);



b->Draw(“AntKtDminNoCal_dmin_01_>> AntKtDminNoCal_dmin_01_norm1_np0”);


I would need to take the Log10 of each bin in the AntKtDminNoCal_dmin_01_ Ntuple. Does anyone know how I would go about this?

Then stick this into the AntKtDminNoCal_dmin_01_norm1_np0 histogram

Cheers,

Mike

Hi,

to create an histogram in log10 binning between xmin and xmax with nbins do :

         Double_t *xbins    = new Double_t[nbins+1];
         Double_t xlogmin = TMath::Log10(xmin);
         Double_t xlogmax = TMath::Log10(xmax);
         Double_t dlogx   = (xlogmax-xlogmin)/((Double_t)nbins);
         for (i=0;i<=nbins;i++) { 
            Double_t xlog = xlogmin+ i*dlogx;
            xbins[i] = TMath::Exp( TMath::Log(10) * xlog ); 
         }
         h1 = new TH1D("h1","h1 (log scale)",nbins,xbins);

Lorenzo

1 Like