Problem in printing stats box in 2D histogram

Dear Experts,

I have saved reconstruction efficiency in 2D histogram. I want to print the efficiency in the histogram. I have put “h2_rec.SetStats(1);” , but it is not printing anything on the histogram. I am pasting the part of code where I am saving the efficiency. Could you please tell me how to print the efficiency(number) in the 2D histogram? Thanks in advance.

 TH2F h2_rec("h2_rec","",nLBins,-1,1,nKBins,-1,1);
  h2_rec.SetMinimum(0.);//Y axis minimum                                                                                                        
  h2_rec.SetTitleOffset(2,"XY");
  h2_rec.SetXTitle("CosThetaL");
  h2_rec.SetYTitle("CosThetaK");
  for (int i = 1; i <= nLBins; i++) {
    for (int j = 1; j <= nKBins; j++) {
      //  for (int i = 1; i <= 6; i++) {                                                                                                        
      //for (int j = 1; j <= 5; j++) {                                                                                                          
      // Build from MC samples                                                                                                                  
      if (h2_nacc.GetBinContent(i,j) == 0 || h2_nreco.GetBinContent(i,j) == 0) {
        printf("WARNING: Efficiency(%d,%d)=0, set error to be 1.\n",i,j);
        h2_rec.SetBinContent(i,j,0.);
        h2_rec.SetBinError(i,j,1.);
      }else{
        h2_rec.SetBinContent(i,j,h2_nreco.GetBinContent(i,j)/h2_nacc.GetBinContent(i,j));//reco efficiency= h2_nreco/h2_nacc                    
        h2_rec.SetBinError(i,j,sqrt(h2_rec.GetBinContent(i,j)*(1-h2_rec.GetBinContent(i,j))/h2_nacc.GetBinContent(i,j)));
        printf("INFO: Efficiency(%d,%d)=%f +- %f.\n",i,j,h2_rec.GetBinContent(i,j),h2_rec.GetBinError(i,j));
      }

    }
  }

h2_rec.SetStats(1);
h2_rec.Draw("LEGO2 TEXT");

Regards,
Deepak

gStyle->SetOptStat("nemr");

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.