Histogram with [x,y) bin and store in tree

Yes, the “TEXT” option are centred.
Okay, let me try again.
But, I think GetBinCenter(i) on “he” after SetBinContent( ) doesn’t seems to work.
It shows an error "use of undeclared identifier ‘i’.

Thank you very much.

Try with:

unsigned long n_stats_error = sizeof(stats_error) / sizeof(double);
std::cout << "Number of errors data points :" << n_stats_error << std::endl;

if (n_stats_error != (n_pz_bins * n_pT_bins)) {
  std::cout << "Error: incorrect number of data points." << std::endl;
  return;
}

for (int k = 1; k <= n_pz_bins; k++)
  for (int l = 1; l <= n_pT_bins; l++)
    he->SetBinContent(k, l, stats_error[((k - 1) * n_pT_bins + (l - 1))]);

he->SetStats(kFALSE);
Double_t xmin = he->GetXaxis()->GetXmin();
Double_t xmax = he->GetXaxis()->GetXmax();
Double_t ymin = he->GetYaxis()->GetXmin();
Double_t ymax = he->GetYaxis()->GetXmax();

#if 0 /* 0 or 1 */
xmin = 0.30, xmax = 0.999999 * 68.00;
xmin = he->GetXaxis()->GetBinLowEdge(he->GetXaxis()->FindFixBin(xmin));
xmax = he->GetXaxis()->GetBinUpEdge(he->GetXaxis()->FindFixBin(xmax));
he->GetXaxis()->SetRangeUser(xmin, xmax);
ymin = 0.00, ymax = 0.999999 * 0.50;
ymin = he->GetYaxis()->GetBinLowEdge(he->GetYaxis()->FindFixBin(ymin));
ymax = he->GetYaxis()->GetBinUpEdge(he->GetYaxis()->FindFixBin(ymax));
he->GetYaxis()->SetRangeUser(ymin, ymax);
#endif /* 0 or 1 */

c2->cd();
gStyle->SetPalette(70);
he->Draw("COLZ");

for (int k = 1; k <= n_pz_bins; k++)
  for (int l = 1; l <= n_pT_bins; l++) {
    Double_t v = he->GetBinContent(k, l);
    if (!(v > 0.0)) continue; // skip "empty" bins
    Double_t x = he->GetXaxis()->GetBinCenter(k);
    Double_t y = he->GetYaxis()->GetBinCenter(l);
    if ((x < xmin) || (x > xmax) || (y < ymin) || (y > ymax)) continue;
    Int_t marker = kFullCircle;
    Double_t size = 0.7;
    if (v >= 5.0) {
      marker = kPlus; size = 0.6;
    } else if (v >= 2.5) {
      marker = kCircle; size = 0.6;
    }
    TMarker *m = new TMarker(x, y, marker);
    m->SetMarkerSize(size);
    m->Draw();
  }

c2->Modified(); c2->Update();
2 Likes

I’m really grateful for you help.

Thank you very much.
Appreciate it.